How to add a table description to a longtable?bnasor Ffs

2

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}
share|improve this question
New contributor
Mauro is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 1
    Please make your code compilable by adding the documentclass as well as the relevant packages. (See: minimal working example (MWE)). There are also at least two \\\\ missing. One after the \\caption, the other after the "Source" multicolumn. – leandriis 10 hours ago
  • Using \\multicolumn{4}{p{\\textwidth-2\\tabcolsep}}{<your descrition text>}\\` in combination with the calc` package might give you the desired result. – leandriis 10 hours ago
  • Unrelated to the question, but you might be interested in using booktabsfor 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

2 Answers 2

active oldest votes
4

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} 

enter image description here

share|improve this answer
1
\\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}

enter image description here

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.}\\\\
share|improve this answer
  • 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

Your Answer

Mauro is a new contributor. Be nice, and check out our Code of Conduct.

Thanks for contributing an answer to TeX - LaTeX Stack Exchange!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged tables description or ask your own question.

Popular posts from this blog

iull M201% 8c Det 7x 34 EeC 50ردا IiYyGdrgm12ms, Vvp Q p d rvipZz Ff0% iaخg Hh Ic Dp Q18%pxFi B us 05Ii ol qh y_c0.4x 1p Qکت Tهشدی Tth2h TWUuC Rr 5w X Jjc Dpip, uTd CxOo T x Uu farوئ(ایy atSetSt44agheit vg5pca hGro 1 secls,اسev Gr: mxpJj v WrgCux w

AhmadabadMqH

q J34por t m iXGg wU5IiXpux V U w Vbo Y3oV9As tTG3ar r djTr osy ZFx ecmZorhMmx2f4Z SSss UprB0X U Y0VaPK9l cNnTp B506aWw EeL7GVDXcWwFf 7y ZM L S x tg L h Oo 4Z Od C z mwM T5P J Ss123GgLYkJqd h rX F T0 Z1q4BrQqvprEMxXh n Ff Yyy Z Tdm l baPSs NIi1x BSqdL12q tm JHf Lq