[Tex/LaTex] Longtable and threeparttablex: wrong position of tablenote when table is textwidth

longtablethreeparttablethreeparttablex

I have a problem with longtable and the position of a table note created by threeparttablex, as the MWE below demonstrates. The first table stretches to the full textwidth and the position of the table note is incorrect. The second table does not specify any table size and the table note is correct. Am I doing something wrong?

\documentclass[11pt]{scrartcl}

\usepackage[showframe]{geometry}
\usepackage{longtable,threeparttablex,booktabs}

\begin{document}

\begin{ThreePartTable}
 \begin{TableNotes}[para,flushleft]This is a wrong tablenote\end{TableNotes}
 \setlength\LTleft{0pt}
 \setlength\LTright{0pt}
 \begin{longtable}{@{\hskip\tabcolsep\extracolsep\fill}l*{3}{c}}
  \caption{Longtable with Full Textwidth}\\
  \toprule
   Variable 1 & 1.85   & 0.92   & 1.11   \\
              & (0.34) & (0.24) & (0.14) \\
  \bottomrule
  \insertTableNotes
 \end{longtable}
\end{ThreePartTable}

\begin{ThreePartTable}
 \begin{TableNotes}[para,flushleft]This is a good tablenote\end{TableNotes}
 \begin{longtable}[c]{l*{3}{c}}
  \caption{Normal Longtable}\\
  \toprule
   Variable 1 & 1.85   & 0.92   & 1.11   \\
              & (0.34) & (0.24) & (0.14) \\
  \bottomrule
  \insertTableNotes
 \end{longtable}
\end{ThreePartTable}

\end{document}

enter image description here

Best Answer

It appears that threeparttablex is only able to measure the natural width of the table, so the “\fill” components are not taken into account. But since you know the width, in that case, you can redefine \TPTminimum for the duration of the environment:

\documentclass[11pt]{scrartcl}

\usepackage[showframe]{geometry}
\usepackage{longtable,threeparttablex,booktabs}

\begin{document}

\begin{ThreePartTable}
 \setlength\LTleft{0pt}
 \setlength\LTright{0pt}
 \renewcommand\TPTminimum{\textwidth} %%% we want full width
 \begin{TableNotes}[para,flushleft]
  This is a wrong tablenote
  This is a wrong tablenote
  This is a wrong tablenote
  This is a wrong tablenote
  This is a wrong tablenote
\end{TableNotes}
 \begin{longtable}{@{\hskip\tabcolsep\extracolsep\fill}l*{3}{c}}
  \caption{Longtable with Full Textwidth}\\
  \toprule
   Variable 1 & 1.85   & 0.92   & 1.11   \\
              & (0.34) & (0.24) & (0.14) \\
  \bottomrule
  \insertTableNotes
 \end{longtable}
\end{ThreePartTable}

\begin{ThreePartTable}
 \begin{TableNotes}[para,flushleft]This is a good tablenote\end{TableNotes}
 \begin{longtable}[c]{l*{3}{c}}
  \caption{Normal Longtable}\\
  \toprule
   Variable 1 & 1.85   & 0.92   & 1.11   \\
              & (0.34) & (0.24) & (0.14) \\
  \bottomrule
  \insertTableNotes
 \end{longtable}
\end{ThreePartTable}

\end{document}

enter image description here

Related Question