0

I need a longtable with 2 lines of description in the \endlastfoot that do not exceed the column width. Picture 1 is my table as I want it but with the \endlastfoot text squeezed into 1 column. Picture 2 is a single line of text after using \multicolumn{5}{l} before \textit{Note.} ...

How can I get the text in \endlastfoot to be as wide as the table in Picture 1 and still break the line?

Desired longtable but with \endlastfoot all in 1 column

Longtable with multicolumn for \endlastfoot exceeds table boundaries

MWE:

\documentclass[12pt]{article}

\usepackage{apacite}
    \bibliographystyle{apacite}
\usepackage[a4paper,left=2.5cm, right=2.5cm, bottom=3cm,top=3cm]{geometry}
\usepackage{changepage}
\usepackage{indentfirst}
\usepackage{mathptmx}
\usepackage{setspace}
    \doublespacing


\usepackage{multirow,booktabs,setspace,caption}
\usepackage{tikz}
\DeclareCaptionLabelSeparator*{spaced}{\\[2ex]}
\captionsetup[table]{textfont=it,format=plain,justification=justified,
  singlelinecheck=false,labelsep=newline,skip=0pt}

\usepackage{longtable}

\begin{document}

\section{A}

\begin{singlespacing}

\begin{longtable}{p{0.02\textwidth}p{0.08\textwidth}p{0.12\textwidth}p{0.115\textwidth}p{0.6\textwidth}}
\caption{53 op kop kop kop kopkop kop }\\
\toprule
Nr. & PANAS* & Temporality & Content** & Topic \\
\hline
\endfirsthead
\multicolumn{5}{l}%
{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
\hline
\toprule
Nr. & PANAS* & Temporality & Content** & Topic \\
\hline
\endhead
\hline \multicolumn{5}{r}{\textit{Continued on next page}} \\
\endfoot
\hline

\textit{Note.} *See Table 2 on the PANAS-SF version that was used in this case-study. ***See Table 3 on how the content of thought was assessed. 
\endlastfoot


1 & +33 -11 (+19) & kop & kop 4 & kop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kop\\
[1.5cm]
1 & +33 -11 (+19) & kop & kop 4 & kop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kop\\
[1.5cm]
1 & +33 -11 (+19) & kop & kop 4 & kop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kop\\
[1.5cm]
1 & +33 -11 (+19) & kop & kop 4 & kop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kop\\
[1.5cm]
1 & +33 -11 (+19) & kop & kop 4 & kop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kop\\
[1.5cm]
1 & +33 -11 (+19) & kop & kop 4 & kop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kop\\
[1.5cm]
1 & +33 -11 (+19) & kop & kop 4 & kop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kop\\
[1.5cm]
1 & +33 -11 (+19) & kop & kop 4 & kop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kop\\
[1.5cm]

\end{longtable}

\end{singlespacing}

\end{document}

2
  • Either use a p type column of appropriate width for the multicolumn command or take a look at the threeparttablex package.
    – leandriis
    Jan 13 at 14:31
  • Could you give me an example of how to use p type column for multicolumn command? I already used p type columns to set the number and width of each columns, but can't just copy paste that line into the multicolumn {here} {l} Thanks for answering.
    – Rabbit
    Jan 13 at 14:39
1

Try

....
\hline \\
\multicolumn{5}{l}{\multirow{1}{\textwidth}{\textit{Notes.} \\  \textsuperscript{*}See Table 2 on the PANAS-SF version that was used in this case-study.\\ \textsuperscript{**}See Table 3 on how the content of thought was assessed. }}
\endlastfoot

x3

Or

\hline \\
\parbox{\textwidth}{\textit{Notes.} \\  \textsuperscript{*}See Table 2 on the PANAS-SF version that was used in this case-study.\\ \textsuperscript{**}See Table 3 on how the content of thought was assessed. }    
\endlastfoot

This is the output with \usepackage{mathptmx} commented. See the italics coming back.

enter image description here

Since you already are using booktabs try this

\begin{longtable}{p{0.02\textwidth}p{0.08\textwidth}p{0.12\textwidth}p{0.115\textwidth}p{0.6\textwidth}}
    \caption{53 op kop kop kop kopkop kop }\\
    \toprule
    Nr. & PANAS* & Temporality & Content** & Topic \\
    \midrule
\endfirsthead
    \multicolumn{5}{l}%
    {\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
    \midrule
    Nr. & PANAS* & Temporality & Content** & Topic \\
    \midrule
\endhead
    \midrule
    \multicolumn{5}{r}{\textit{Continued on next page}} \\
    \endfoot
    \midrule
    \parbox{\textwidth}{\textit{Notes.} \\  \textsuperscript{*}See Table 2 on the PANAS-SF version that was used in this case-study.\\ \textsuperscript{**}See Table 3 on how the content of thought was assessed. }    
\endlastfoot
2
  • You the real MVP. The bottom one did the better job for me as I was working with rather narrow vertical spacing.
    – Rabbit
    Jan 13 at 15:02
  • Thank you. I made another suggestion to allow some vertical space between the line and Continued on .. and better with Notes. Jan 13 at 15:23
0

With xltabular instead of longtable in order to make sure the table fits into the available textwidth and a p type column of appropriate width in the \multicolumn command:

enter image description here

\documentclass[12pt]{article}

\usepackage{apacite}
    \bibliographystyle{apacite}
\usepackage[a4paper,left=2.5cm, right=2.5cm, bottom=3cm,top=3cm]{geometry}
\usepackage{changepage}
\usepackage{indentfirst}
\usepackage{mathptmx}
\usepackage{setspace}
    \doublespacing

\usepackage{multirow,booktabs,setspace,caption}
\usepackage{tikz}
\DeclareCaptionLabelSeparator*{spaced}{\\[2ex]}
\captionsetup[table]{textfont=it,format=plain,justification=justified,
  singlelinecheck=false,labelsep=newline,skip=0pt}

\usepackage{xltabular}
\usepackage{calc}
\begin{document}

\section{A}

\begin{singlespacing}

\begin{xltabular}{\textwidth}{l
                  p{\widthof{PANAS*}}
                  l
                  l
                  X}
\caption{53 op kop kop kop kopkop kop }\\
\toprule
Nr. & PANAS* & Temporality & Content** & Topic \\
\hline
\endfirsthead
\multicolumn{5}{l}%
{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
\hline
\toprule
Nr. & PANAS* & Temporality & Content** & Topic \\
\hline
\endhead
\hline \multicolumn{5}{r}{\textit{Continued on next page}} \\
\endfoot
\hline

\multicolumn{5}{p{\textwidth-2\tabcolsep}}{\textit{Note.} *See Table 2 on the PANAS-SF version that was used in this case-study. ***See Table 3 on how the content of thought was assessed.}
\endlastfoot


1 & +33 -11 (+19) & kop & kop 4 & kop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kop\\
\addlinespace
1 & +33 -11 (+19) & kop & kop 4 & kop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kop\\
\addlinespace
1 & +33 -11 (+19) & kop & kop 4 & kop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kop\\
\addlinespace
1 & +33 -11 (+19) & kop & kop 4 & kop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kop\\
\addlinespace
1 & +33 -11 (+19) & kop & kop 4 & kop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kop\\
\addlinespace
1 & +33 -11 (+19) & kop & kop 4 & kop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kop\\
[1.5cm]
1 & +33 -11 (+19) & kop & kop 4 & kop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kop\\
\addlinespace
1 & +33 -11 (+19) & kop & kop 4 & kop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kop\\
\addlinespace
1 & +33 -11 (+19) & kop & kop 4 & kop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kop\\
[1.5cm]
1 & +33 -11 (+19) & kop & kop 4 & kop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kop\\
\addlinespace
1 & +33 -11 (+19) & kop & kop 4 & kop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kopkop kop kop kop kop kop\\
\addlinespace
\end{xltabular}

\end{singlespacing}

\end{document}

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.