1

I am creating the document for my thesis, which is made up of three chapters. In one of them I have longtables. When writing that chapter as an article, I found a solution to get the table to have a title and a caption (both within the caption). Here is part of my code (the table is longer, so the use of longtable is justified):

\documentclass[a4paper]{article}
\usepackage{longtable,array}
 \usepackage[justification=centering]{caption}
\usepackage{cellspace}
 \usepackage{booktabs}
 \usepackage{varwidth}
\usepackage[a4paper,margin=25mm]{geometry}
\usepackage{multirow} 
\usepackage{multicol} 
\setlength{\parskip}{\baselineskip}
\setlength{\tabcolsep}{4pt}
\setlength\cellspacetoplimit{5pt}
\setlength\cellspacebottomlimit{5pt}
\newenvironment{outdent}
{\begin{list}{}{\leftmargin-0cm\rightmargin\leftmargin}\centering\item\relax}
{\end{list}\ignorespacesafterend}
\begin{document}
\begin{footnotesize}
    \begin{longtable}{m{3cm}m{3cm}@{}m{3cm}@{}m{3cm}@{}m{2.1cm}@{}}
    \caption{Binary ESG Variables \newline \smallskip  \newline \footnotesize This table shows the means of the binary ESG variables for the full period (2002-2017) and for two subperiods (2002-2007 and 2008-2017), the growth rate from one subperiod to the other and the overall mean for all of them in the last row.}
    \label{descbin}\\
     \toprule
      Variable & Mean (2002-2017) & Mean (2002-2007) & Mean (2008-2017) & Mean Growth \\
    \hline
    \midrule[\heavyrulewidth] % make this rule as thick as \toprule
    \endfirsthead
     \toprule
    \multicolumn{5}{l}{\small\sl continued from previous page}\\ \hline
      Variable & Mean (2002-2017) & Mean (2002-2007) & Mean (2008-2017) & Mean Growth \\
    \hline
    \midrule[\heavyrulewidth] % make this rule as thick as \toprule
    \endhead
    \bottomrule
    \multicolumn{5}{r}{\small\sl continued on next page} \\ \hline
    \endfoot
    \bottomrule
    \endlastfoot
    \hline \multicolumn{5}{|c|}{Panel A: Environmental variables} \\
    \hline CO2EmT & 0.38992 & 0.27250 & 0.46037 & 68.95\% \\
    CO2DirEm & 0.28134 & 0.15358 & 0.35800 & 133.11\% \\
    CO2IndEm & 0.25803 & 0.10909 & 0.34739 & 218.44\% \\
    FlaNG & 0.00729 & 0.00616 & 0.00796 & 29.28\% \\
    OzDepSub & 0.03486 & 0.02730 & 0.03939 & 44.32\% \\
    NOxEm & 0.14152 & 0.12901 & 0.14902 & 15.51\% \\
    SOxEm & 0.13392 & 0.11698 & 0.14409 & 23.18\% \\
    VOCEm & 0.07476 & 0.06650 & 0.07972 & 19.88\% \\
    WasTot & 0.25446 & 0.18339 & 0.29710 & 62.00\% \\
    NhazWas & 0.12237 & 0.07164 & 0.15280 & 113.30\% \\
    WasRecT & 0.19662 & 0.12476 & 0.23973 & 92.15\% \\
    HazWas & 0.13412 & 0.09565 & 0.15720 & 64.34\% \\
    WatDis & 0.07482 & 0.05188 & 0.08858 & 70.72\% \\
    WatPolEm & 0.06320 & 0.04405 & 0.07470 & 69.57\% \\
    ISOEMSCP & 0.11375 & 0.05814 & 0.14711 & 153.02\% \\
    EnvExp & 0.16774 & 0.10902 & 0.20297 & 86.18\% \\
    EnvProv & 0.08972 & 0.04083 & 0.11906 & 191.61\% \\
    CO2S3 & 0.13229 & 0.02050 & 0.19937 & 872.33\% \\
    CoffCre & 0.02412 & 0.00274 & 0.03694 & 1246.67\% \\
    ENVRDExp & 0.04883 & 0.04708 & 0.04987 & 5.92\% \\
    EnUTot & 0.30960 & 0.18363 & 0.38519 & 109.76\% \\
    IndEnU & 0.01168 & 0.01225 & 0.01134 & -7.42\% \\
    WWTot & 0.30248 & 0.23085 & 0.34545 & 49.65\% \\
    FWWTot & 0.16238 & 0.06121 & 0.22309 & 264.49\% \\
    WatRec & 0.05536 & 0.02169 & 0.07556 & 248.41\% \\ \hline
    \end{longtable}
    \end{footnotesize}
    \end{document}

The problem arrives, when I try to compile this type of tables in a report document, because I have to generate a list of tables and in the list.

\documentclass[11 pt,twoside]{report}
\usepackage{longtable,array}
 \usepackage[justification=centering]{caption}
\usepackage{cellspace}
 \usepackage{booktabs}
 \usepackage{varwidth}
\usepackage[a4paper,margin=25mm]{geometry}
\usepackage{multirow} 
\usepackage{multicol} 
\setlength{\parskip}{\baselineskip}
\setlength{\tabcolsep}{4pt}
\setlength\cellspacetoplimit{5pt}
\setlength\cellspacebottomlimit{5pt}
\newenvironment{outdent}
{\begin{list}{}{\leftmargin-0cm\rightmargin\leftmargin}\centering\item\relax}
{\end{list}\ignorespacesafterend}
\begin{document}
\listoftables
\begin{footnotesize}
    \begin{longtable}{m{3cm}m{3cm}@{}m{3cm}@{}m{3cm}@{}m{2.1cm}@{}}
    \caption{Binary ESG Variables \newline \smallskip  \newline \footnotesize This table shows the means of the binary ESG variables for the full period (2002-2017) and for two subperiods (2002-2007 and 2008-2017), the growth rate from one subperiod to the other and the overall mean for all of them in the last row.}
    \label{descbin}\\
     \toprule
      Variable & Mean (2002-2017) & Mean (2002-2007) & Mean (2008-2017) & Mean Growth \\
    \hline
    \midrule[\heavyrulewidth] % make this rule as thick as \toprule
    \endfirsthead
     \toprule
    \multicolumn{5}{l}{\small\sl continued from previous page}\\ \hline
      Variable & Mean (2002-2017) & Mean (2002-2007) & Mean (2008-2017) & Mean Growth \\
    \hline
    \midrule[\heavyrulewidth] % make this rule as thick as \toprule
    \endhead
    \bottomrule
    \multicolumn{5}{r}{\small\sl continued on next page} \\ \hline
    \endfoot
    \bottomrule
    \endlastfoot
    \hline \multicolumn{5}{|c|}{Panel A: Environmental variables} \\
    \hline CO2EmT & 0.38992 & 0.27250 & 0.46037 & 68.95\% \\
    CO2DirEm & 0.28134 & 0.15358 & 0.35800 & 133.11\% \\
    CO2IndEm & 0.25803 & 0.10909 & 0.34739 & 218.44\% \\
    FlaNG & 0.00729 & 0.00616 & 0.00796 & 29.28\% \\
    OzDepSub & 0.03486 & 0.02730 & 0.03939 & 44.32\% \\
    NOxEm & 0.14152 & 0.12901 & 0.14902 & 15.51\% \\
    SOxEm & 0.13392 & 0.11698 & 0.14409 & 23.18\% \\
    VOCEm & 0.07476 & 0.06650 & 0.07972 & 19.88\% \\
    WasTot & 0.25446 & 0.18339 & 0.29710 & 62.00\% \\
    NhazWas & 0.12237 & 0.07164 & 0.15280 & 113.30\% \\
    WasRecT & 0.19662 & 0.12476 & 0.23973 & 92.15\% \\
    HazWas & 0.13412 & 0.09565 & 0.15720 & 64.34\% \\
    WatDis & 0.07482 & 0.05188 & 0.08858 & 70.72\% \\
    WatPolEm & 0.06320 & 0.04405 & 0.07470 & 69.57\% \\
    ISOEMSCP & 0.11375 & 0.05814 & 0.14711 & 153.02\% \\
    EnvExp & 0.16774 & 0.10902 & 0.20297 & 86.18\% \\
    EnvProv & 0.08972 & 0.04083 & 0.11906 & 191.61\% \\
    CO2S3 & 0.13229 & 0.02050 & 0.19937 & 872.33\% \\
    CoffCre & 0.02412 & 0.00274 & 0.03694 & 1246.67\% \\
    ENVRDExp & 0.04883 & 0.04708 & 0.04987 & 5.92\% \\
    EnUTot & 0.30960 & 0.18363 & 0.38519 & 109.76\% \\
    IndEnU & 0.01168 & 0.01225 & 0.01134 & -7.42\% \\
    WWTot & 0.30248 & 0.23085 & 0.34545 & 49.65\% \\
    FWWTot & 0.16238 & 0.06121 & 0.22309 & 264.49\% \\
    WatRec & 0.05536 & 0.02169 & 0.07556 & 248.41\% \\ \hline
    \end{longtable}
    \end{footnotesize}
    \end{document}

The following appears:

1.2 Binary ESG Variables This table shows the means of the binary ESG variables for the full period (2002-2017) and for two subperiods (2002-2007 and 2008-2017), the growth rate from one subperiod to the other and the overall mean for all of them in the last row. . . . . . . . . . . 14

How can I get the table to have a title and caption, but that only the title appears?

  • Could you please make your code compilable by adding the documentclass and the relevant packages? What exacty does "title" and "caption" refer to? – leandriis Jun 16 at 10:08
  • If I understood you correctly, you only want "Binary ESG Variables" to appear in the list of tables? If this is correct, you can use the optional argument of the caption command as follows: \caption[<short caption for the list of tables>]{<long caption that is printed with the table>} – leandriis Jun 16 at 10:12
  • Unrelated to the problem: But is there a reason why you use fixed width columns instead of just plain l type columns? – leandriis Jun 16 at 10:13
  • Thank you! Using the brackets has worked! I do not have a reason to use fixed width columns other than them staying the same in the whole table. – Maite CD Jun 16 at 10:25
0

You could either use the optional argument of the caption command in order to only display a short caption in the list of tables:

\caption[<short caption for the lot>]{<long caption used with the table>}

or use the \caption* command for the descriptive text:

\caption{<Short caption>}
\label{descbin}\\
\caption*{\footnotesize <descriptive text>}\\ 

Here is a complete MWE demonstrating the use of the latter variant:

enter image description here

\documentclass[11 pt,twoside]{report}
\usepackage{longtable,array}
 \usepackage[justification=centering]{caption}
\usepackage{cellspace}
 \usepackage{booktabs}
 \usepackage{varwidth}
\usepackage[a4paper,margin=25mm]{geometry}
\usepackage{multirow} 
\usepackage{multicol} 
\setlength{\parskip}{\baselineskip}
\setlength{\tabcolsep}{4pt}
\setlength\cellspacetoplimit{5pt}
\setlength\cellspacebottomlimit{5pt}
\newenvironment{outdent}
{\begin{list}{}{\leftmargin-0cm\rightmargin\leftmargin}\centering\item\relax}
{\end{list}\ignorespacesafterend}

\begin{document}
\listoftables
\begin{footnotesize}
    \begin{longtable}{m{3cm}m{3cm}@{}m{3cm}@{}m{3cm}@{}m{2.1cm}@{}}
    \caption{Binary ESG Variables}
    \label{descbin}\\
    \caption*{\footnotesize This table shows the means of the binary ESG variables for the full period (2002-2017) and for two subperiods (2002-2007 and 2008-2017), the growth rate from one subperiod to the other and the overall mean for all of them in the last row.}\\
     \toprule
      Variable & Mean (2002-2017) & Mean (2002-2007) & Mean (2008-2017) & Mean Growth \\
    \hline
    \midrule[\heavyrulewidth] % make this rule as thick as \toprule
    \endfirsthead
     \toprule
    \multicolumn{5}{l}{\small\sl continued from previous page}\\ \hline
      Variable & Mean (2002-2017) & Mean (2002-2007) & Mean (2008-2017) & Mean Growth \\
    \hline
    \midrule[\heavyrulewidth] % make this rule as thick as \toprule
    \endhead
    \bottomrule
    \multicolumn{5}{r}{\small\sl continued on next page} \\ \hline
    \endfoot
    \bottomrule
    \endlastfoot
    \hline \multicolumn{5}{|c|}{Panel A: Environmental variables} \\
    \hline CO2EmT & 0.38992 & 0.27250 & 0.46037 & 68.95\% \\
    CO2DirEm & 0.28134 & 0.15358 & 0.35800 & 133.11\% \\
    CO2IndEm & 0.25803 & 0.10909 & 0.34739 & 218.44\% \\
    FlaNG & 0.00729 & 0.00616 & 0.00796 & 29.28\% \\
    OzDepSub & 0.03486 & 0.02730 & 0.03939 & 44.32\% \\
    NOxEm & 0.14152 & 0.12901 & 0.14902 & 15.51\% \\
    SOxEm & 0.13392 & 0.11698 & 0.14409 & 23.18\% \\
    VOCEm & 0.07476 & 0.06650 & 0.07972 & 19.88\% \\
    WasTot & 0.25446 & 0.18339 & 0.29710 & 62.00\% \\
    NhazWas & 0.12237 & 0.07164 & 0.15280 & 113.30\% \\
    WasRecT & 0.19662 & 0.12476 & 0.23973 & 92.15\% \\
    HazWas & 0.13412 & 0.09565 & 0.15720 & 64.34\% \\
    WatDis & 0.07482 & 0.05188 & 0.08858 & 70.72\% \\
    WatPolEm & 0.06320 & 0.04405 & 0.07470 & 69.57\% \\
    ISOEMSCP & 0.11375 & 0.05814 & 0.14711 & 153.02\% \\
    EnvExp & 0.16774 & 0.10902 & 0.20297 & 86.18\% \\
    EnvProv & 0.08972 & 0.04083 & 0.11906 & 191.61\% \\
    CO2S3 & 0.13229 & 0.02050 & 0.19937 & 872.33\% \\
    CoffCre & 0.02412 & 0.00274 & 0.03694 & 1246.67\% \\
    ENVRDExp & 0.04883 & 0.04708 & 0.04987 & 5.92\% \\
    EnUTot & 0.30960 & 0.18363 & 0.38519 & 109.76\% \\
    IndEnU & 0.01168 & 0.01225 & 0.01134 & -7.42\% \\
    WWTot & 0.30248 & 0.23085 & 0.34545 & 49.65\% \\
    FWWTot & 0.16238 & 0.06121 & 0.22309 & 264.49\% \\
    WatRec & 0.05536 & 0.02169 & 0.07556 & 248.41\% \\ \hline
    \end{longtable}
    \end{footnotesize}
    \end{document}

Apart from that I'd also recommend using l, c and r type columns (as Red-Cloud also showed in their answer) With these column types there will be less white space in the table and the alignment of the last column will be a lot more pleasing. To further increase readability you could also remove all the occurences of % in the last column and instead add this information in the column header.

  • I tried also using " \caption*", but it does not seem to work in my document. However, your first solution works perfectly. – Maite CD Jun 16 at 10:37
  • @MaiteCD: I'm glad, I was able to help you. If you liked my answer, please consider upvoting (by clicking on the arrows next to the score) and/or marking it as the accepted answer (by clicking on the checkmark ✓). – leandriis Jun 23 at 21:10
  • I already voted it up but a pop-up says that my votes are not shown because my reputation is lower than 15. However, I have just marked it as the accepted answer. I hope this is enough (at least for now...) – Maite CD Jun 25 at 7:11
1

Try the following. However, I modified your tabular to get it in normal fontsize:

\documentclass{report}
\usepackage{libertinus}
\usepackage[svgnames,table,cmyk]{xcolor}
\usepackage{longtable,booktabs}

\begin{document}

\begingroup
\let\NumberLine\numberline
\def\numberline#1{\NumberLine{}}
\listoftables
\endgroup

\chapter{foo}
\section{Blah blah} 

\begin{longtable}{ @{} l c c c r @{}}
\caption{Binary ESG Variables \newline \smallskip  \newline \footnotesize This table shows the means of the 
binary ESG variables for the full period (2002-2017) and for two subperiods (2002-2007 and 2008-2017), the 
growth rate from one subperiod to the other and the overall mean for all of them in the last row.}
        \label{descbin}\\   \toprule
Variable & Mean        & Mean        & Mean & Mean  \\
         & (2002-2017) & (2002-2007) & (2008-2017) & Growth \\
        \hline
        \midrule[\heavyrulewidth] % make this rule as thick as \toprule
        \endfirsthead
        \toprule
        \multicolumn{5}{l}{\small\sl continued from previous page}\\ \hline
Variable & Mean        & Mean        & Mean & Mean  \\
& (2002-2017) & (2002-2007) & (2008-2017) & Growth \\
        \hline
        \midrule[\heavyrulewidth] % make this rule as thick as \toprule
        \endhead
        \bottomrule
        \multicolumn{5}{r}{\small\sl continued on next page} \\ \hline
        \endfoot
        \bottomrule
        \endlastfoot
        \hline \multicolumn{5}{|c|}{Panel A: Environmental variables} \\
        \hline CO2EmT & 0.38992 & 0.27250 & 0.46037 & 68.95\% \\
        CO2DirEm & 0.28134 & 0.15358 & 0.35800 & 133.11\% \\
        CO2IndEm & 0.25803 & 0.10909 & 0.34739 & 218.44\% \\
        FlaNG & 0.00729 & 0.00616 & 0.00796 & 29.28\% \\
        OzDepSub & 0.03486 & 0.02730 & 0.03939 & 44.32\% \\
        NOxEm & 0.14152 & 0.12901 & 0.14902 & 15.51\% \\
        SOxEm & 0.13392 & 0.11698 & 0.14409 & 23.18\% \\
        VOCEm & 0.07476 & 0.06650 & 0.07972 & 19.88\% \\
        WasTot & 0.25446 & 0.18339 & 0.29710 & 62.00\% \\
        NhazWas & 0.12237 & 0.07164 & 0.15280 & 113.30\% \\
        WasRecT & 0.19662 & 0.12476 & 0.23973 & 92.15\% \\
        HazWas & 0.13412 & 0.09565 & 0.15720 & 64.34\% \\
        WatDis & 0.07482 & 0.05188 & 0.08858 & 70.72\% \\
        WatPolEm & 0.06320 & 0.04405 & 0.07470 & 69.57\% \\
        ISOEMSCP & 0.11375 & 0.05814 & 0.14711 & 153.02\% \\
        EnvExp & 0.16774 & 0.10902 & 0.20297 & 86.18\% \\
        EnvProv & 0.08972 & 0.04083 & 0.11906 & 191.61\% \\
        CO2S3 & 0.13229 & 0.02050 & 0.19937 & 872.33\% \\
        CoffCre & 0.02412 & 0.00274 & 0.03694 & 1246.67\% \\
        ENVRDExp & 0.04883 & 0.04708 & 0.04987 & 5.92\% \\
        EnUTot & 0.30960 & 0.18363 & 0.38519 & 109.76\% \\
        IndEnU & 0.01168 & 0.01225 & 0.01134 & -7.42\% \\
        WWTot & 0.30248 & 0.23085 & 0.34545 & 49.65\% \\
        FWWTot & 0.16238 & 0.06121 & 0.22309 & 264.49\% \\
        WatRec & 0.05536 & 0.02169 & 0.07556 & 248.41\% \\ \hline
\end{longtable}
\end{document}

enter image description here

enter image description here

Your Answer

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 or ask your own question.