How to add a table description to a longtable?bnasor Ffs
I am very new to Latex and really need help. I am trying to format a longtable such that under the caption I can insert a description of the table. I tried with \\multicolumn, but then the first column got really long and the text didn't fit the page. Does anyone have experience with this? Thank you!
\\begin{longtable}[c]{p{1cm}p{6cm}p{3.5cm}p{5cm}}
\\caption{Overview bank sample \\label{Overview sample compilation}}
\\hline
\\textbf{Rank} & \\textbf{Bank name} & \\textbf{Home country} & \\textbf{Local Index}\\\\
\\hline
\\endfirsthead
\\hline
\\multicolumn{4}{r}{Continuation of Table \\ref{Overview sample compilation}}\\\\
\\hline
\\textbf{Rank} & \\textbf{Bank name} & \\textbf{Home country} & \\textbf{Local Index} \\\\
\\hline
\\endhead
\\hline
\\endfoot
\\endlastfoot
1 & Allied Irish Banks & Ireland & ISEQ20 \\\\
2 & Banco Bilbao Vizcaya Argentina & Spain & IBEX 35 \\\\
3 & Banco Santander & Spain & IBEX 35 \\\\
4 & Bank of America & United States & S\\&P 500 \\\\
5 & Bank of Montreal & Canada & S\\&P TSX Composite Index \\\\
6 & Barclays & United Kingdom & FTSE 100 \\\\
7 & BNP Paribas & France & CAC 40 \\\\
8 & Citigroup & United States & S\\&P 500 \\\\
9 & Commerzbank & Germany & DAX 30 \\\\
10 & Credit Suisse & Switzerland & Swiss Market Index \\\\
11 & Deutsche Bank & Germany & DAX 30 \\\\
12 & HSBC & United Kingdom & FTSE 100 \\\\
13 & ING Groep & Netherlands & AEX \\\\
14 & JP Morgan Chase & United States & S\\&P 500 \\\\
15 & KBC Groep & Belgium & BEL20 \\\\
16 & Lehman Brothers & United States & S\\&P 500 \\\\
17 & Merrill Lynch & United States & S\\&P 500 \\\\
18 & Morgan Stanley & United States & S\\&P 500 \\\\
19 & National City Corporation & United States & S\\&P 500 \\\\
20 & PNC Financial Services & United States & S\\&P 500 \\\\
21 & Royal Bank of Scotland & United Kingdom & FTSE 100 \\\\
22 & Societe Generale & France & CAC 40 \\\\
23 & SunTrust Bank & United States & S\\&P 500 \\\\
24 & U.S. Bancorp & United States & S\\&P 500 \\\\
25 & UBS & Switzerland & Swiss Market Index \\\\
26 & UniCredit SPA & Italy & FTSE MIB \\\\
27 & Washington Mutual & United States & S\\&P 500 \\\\
28 & Wells Fargo & United States & S\\&P 500 \\\\
\\hline
\\multicolumn{4}{l}{Source: Own depiction based on Bloomberg database.}
\\hline
\\end{longtable}
2 Answers
I propose this layout, based on threeparttablex
, which brings the functionalities of threeparttable
to longtable
, with a slightly different syntax. In particular, it lets you insert table notes anywhere you please in the table, so I decided to insert them just after the caption. I had to \\makecell
here and there to make the table fit between margins.
\\documentclass{article}
\\usepackage{longtable,booktabs}
\\usepackage{threeparttablex, caption}
\\usepackage{makecell}
\\providecommand\\TPTLsourcename{\\textit{Source}}
\\let\\source=\\TPTLsourcename
\\begin{document}
\\begin{ThreePartTable}
\\begin{TableNotes}[para, flushleft]
\\source: Own depiction based on Bloomberg database. Blah blah blah. Blah blah blah. Blah blah blah. Blah blah blah.
\\end{TableNotes}
\\centering
\\begin{longtable}{@{}c l l l@{}}
\\caption{Overview bank sample \\label{Overview sample compilation}}\\\\[-2ex]
\\insertTableNotes \\\\
\\addlinespace[2ex]
\\toprule
\\textbf{Rank} & \\textbf{Bank name} & \\textbf{Home country} & \\textbf{Local Index}\\\\
\\midrule
\\endfirsthead
\\midrule
\\multicolumn{4}{r}{Continuation of Table \\ref{Overview sample compilation}}\\\\
\\midrule
\\textbf{Rank} & \\textbf{Bank name} & \\textbf{Home country} & \\textbf{Local Index} \\\\
\\midrule
\\endhead
\\midrule
\\endfoot
\\bottomrule
\\endlastfoot
1 & Allied Irish Banks &
Ireland & ISEQ20 \\\\
2 & \\makecell[tl]{Banco Bilbao Vizcaya\\\\ Argentina} &
Spain & IBEX 35 \\\\
3 & Banco Santander &
Spain & IBEX 35 \\\\
4 & Bank of America & United
States & S\\&P 500 \\\\
5 & Bank of Montreal &
Canada & \\makecell[tl]{S\\&P TSX \\\\ Composite Index} \\\\
6 & Barclays & United
Kingdom & FTSE 100 \\\\
7 & BNP Paribas &
France & CAC 40 \\\\
8 & Citigroup & United
States & S\\&P 500 \\\\
9 & Commerzbank &
Germany & DAX 30 \\\\
10 & Crédit Suisse &
Switzerland & Swiss Market Index \\\\
11 & Deutsche Bank &
Germany & DAX 30 \\\\
12 & HSBC & United
Kingdom & FTSE 100 \\\\
13 & ING Groep &
Netherlands & AEX \\\\
14 & JP Morgan Chase & United
States & S\\&P 500 \\\\
15 & KBC Groep &
Belgium & BEL20 \\\\
16 & Lehman Brothers & United
States & S\\&P 500 \\\\
17 & Merrill Lynch & United
States & S\\&P 500 \\\\
18 & Morgan Stanley & United
States & S\\&P 500 \\\\
19 & National City Corporation & United
States & S\\&P 500 \\\\
20 & PNC Financial Services & United
States & S\\&P 500 \\\\
21 & Royal Bank of Scotland & United
Kingdom & FTSE 100 \\\\
22 & Société Générale &
France & CAC 40 \\\\
23 & SunTrust Bank & United
States & S\\&P 500 \\\\
24 & U.S. Bancorp & United
States & S\\&P 500 \\\\
25 & UBS &
Switzerland & Swiss Market Index \\\\
26 & UniCredit SPA &
Italy & FTSE MIB \\\\
27 & Washington Mutual & United
States & S\\&P 500 \\\\
28 & Wells Fargo & United
States & S\\&P 500 \\\\
\\end{longtable}
\\end{ThreePartTable}
\\end{document}
\\documentclass{article}
\\usepackage{longtable,booktabs}
\\begin{document}
\\begin{longtable}{c l l l}
\\caption{Overview bank sample \\label{Overview sample compilation}}\\\\
\\toprule
\\textbf{Rank} & \\textbf{Bank name} & \\textbf{Home country} & \\textbf{Local Index}\\\\
\\midrule
\\endfirsthead
\\midrule
\\multicolumn{4}{r}{Continuation of Table \\ref{Overview sample compilation}}\\\\
\\midrule
\\textbf{Rank} & \\textbf{Bank name} & \\textbf{Home country} & \\textbf{Local Index} \\\\
\\midrule
\\endhead
\\midrule
\\endfoot
\\midrule
\\multicolumn{4}{l}{Source: Own depiction based on Bloomberg database.}\\\\
\\midrule
\\endlastfoot
1 & Allied Irish Banks &
Ireland & ISEQ20 \\\\
2 & Banco Bilbao Vizcaya Argentina &
Spain & IBEX 35 \\\\
3 & Banco Santander &
Spain & IBEX 35 \\\\
4 & Bank of America & United
States & S\\&P 500 \\\\
5 & Bank of Montreal &
Canada & S\\&P TSX Composite Index \\\\
6 & Barclays & United
Kingdom & FTSE 100 \\\\
7 & BNP Paribas &
France & CAC 40 \\\\
8 & Citigroup & United
States & S\\&P 500 \\\\
9 & Commerzbank &
Germany & DAX 30 \\\\
10 & Credit Suisse &
Switzerland & Swiss Market Index \\\\
11 & Deutsche Bank &
Germany & DAX 30 \\\\
12 & HSBC & United
Kingdom & FTSE 100 \\\\
13 & ING Groep &
Netherlands & AEX \\\\
14 & JP Morgan Chase & United
States & S\\&P 500 \\\\
15 & KBC Groep &
Belgium & BEL20 \\\\
16 & Lehman Brothers & United
States & S\\&P 500 \\\\
17 & Merrill Lynch & United
States & S\\&P 500 \\\\
18 & Morgan Stanley & United
States & S\\&P 500 \\\\
19 & National City Corporation & United
States & S\\&P 500 \\\\
20 & PNC Financial Services & United
States & S\\&P 500 \\\\
21 & Royal Bank of Scotland & United
Kingdom & FTSE 100 \\\\
22 & Societe Generale &
France & CAC 40 \\\\
23 & SunTrust Bank & United
States & S\\&P 500 \\\\
24 & U.S. Bancorp & United
States & S\\&P 500 \\\\
25 & UBS &
Switzerland & Swiss Market Index \\\\
26 & UniCredit SPA &
Italy & FTSE MIB \\\\
27 & Washington Mutual & United
States & S\\&P 500 \\\\
28 & Wells Fargo & United
States & S\\&P 500 \\\\
\\end{longtable}
\\end{document}
And if your description is too long for aline, use:
\\multicolumn{4}{l}{\\parbox{\\dimexpr\\textwidth-2\\tabcolsep}{%
Source: Own depiction based on Bloomberg database. ... more text}}
And if your tabular is too wide, then use package xltabular
and
\\begin{xltabular}{\\linewidth}{c X l l}
[...]
\\multicolumn{4}{p{\\dimexpr\\textwidth-2\\tabcolsep}}{Source: Own depiction based on Bloomberg database.}\\\\
-
Coud you please explain where exactly we can find the descriotion that the OP requested in their question: " such that under the caption I can insert a description of the table"? – leandriis 10 hours ago
-
Other than that, please note that the table is too wide for the textwidth of a standard
article
documentclass. You might want to add a comment on that, too. – leandriis 10 hours ago
\\\\
missing. One after the\\caption
, the other after the "Source" multicolumn. – leandriis 10 hours ago\\multicolumn{4}{p{\\textwidth-2\\tabcolsep}}{<your descrition text>}\\` in combination with the
calc` package might give you the desired result. – leandriis 10 hours agobooktabs
for horizontal lines with improved spacing. If you don't want to manually number the rows in your table, you might be interested in the following answer: tex.stackexchange.com/a/21245/134144 – leandriis 10 hours ago