1

My problem is similar to this question, the caption alignment of tabular table and longtable is different. I would like to have the caption to be consistent with the tabular form, with some white padding from the top margin and align to the left of the toprule. I have tried to use [singlelinecheck=off] as suggested but it didn t change anything. Then I want to try redefining the \LT@caption as suggested as another way but I have no idea how to redefine it to make it as the tabular one.

I am guessing some of the problem may be related to my preset margin but it didn't align correctly even when I remove the a4paper setting. Any help or insight would be highly appreciated. Thank you in advance!

\documentclass{article}

\usepackage{array}
\usepackage{changepage}
\usepackage[a4paper, vmargin=0.05cm, hmargin=0.1cm, marginparwidth=0.1cm,total={210mm,297mm}]{geometry}
\usepackage{rotating}
\usepackage[singlelinecheck=off]{caption}
\usepackage{booktabs}
\usepackage{pdflscape}
\usepackage{multirow, makecell, xcolor}
\usepackage[separate-uncertainty=true]{siunitx}
\usepackage{threeparttable}
\usepackage{threeparttablex} 
\usepackage{longtable}


\newlength{\mylength} \settowidth{\mylength}{$-55.55\pm0.55$}
\makeatletter
\newcommand\notsotiny{\@setfontsize\notsotiny{6.5}{7.5}}
\makeatother
\newcommand{\ts}[1]{\textsubscript{#1}}

\begin{document}    
\begin{landscape}
    \sisetup{
        table-number-alignment=center,
        separate-uncertainty=true,
        table-column-width = 2cm,
        table-format =-2.2,
        separate-uncertainty,
        table-figures-uncertainty=1, table-space-text-post=(16)}
    \begin{ThreePartTable} 
        \notsotiny
        \setlength{\tabcolsep}{2.3pt}
        \setlength{\extrarowheight}{2.2pt}
        \begin{longtable}{>{\itshape}p{2cm}p{0.8cm}@{}*{12}{S}@{}}%
            \caption{Taxon}\\
                \toprule
        \multicolumn{2}{c}{Site} & \multicolumn{2}{c}{WI} & \multicolumn{2}{c}{WO} & \multicolumn{2}{c}{SL} & \multicolumn{2}{c}{SE} & \multicolumn{2}{c}{EO} & \multicolumn{2}{c}{EI} \\
        \cmidrule(lr){3-4} \cmidrule(lr){5-6} \cmidrule(lr){7-8} \cmidrule(lr){9-10} \cmidrule(lr){11-12} \cmidrule(lr){13-14}
        \multicolumn{2}{c}{Season}& {Wet} &{Dry} & {Wet} & {Dry} & {Wet} & {Dry} & {Wet} & {Dry} & {Wet} & {Dry} & {Wet} & {\makebox[\mylength]{Dry}} \\
        \midrule
        \multicolumn{1}{c}{{Species}}   & Tracer & {Mean $ \pm$ SD $_{(n)}$} & {Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} \\
        \midrule
            \endfirsthead
    \multirow{2}{*}{\shortstack[l]{{Genus}\\ { Species}}}& $\delta{^{15}}$N &       &       &       &       &       & 12.82\pm0.36\ts{(4)} &       &       & 13.83\pm0.99\ts{(8)} & 14.25\pm0.49\ts{(2)} & 14.60\pm0.23\ts{(4)} &  \\
& $\delta{^{13}}$C &       &       &       &       &       & -16.73\pm0.29\ts{(4)} &       &       & -16.62\pm0.27\ts{(8)} & -17.30\pm0.14\ts{(2)} & -16.65\pm0.31\ts{(4)} &  \\
            \bottomrule
        \end{longtable}
        \end{ThreePartTable}
    \end{landscape}
    \begin{landscape}
        \sisetup{
        table-number-alignment=center,
        separate-uncertainty=true,
        table-column-width = 2cm,
        table-format =-2.2,
        separate-uncertainty,
        table-figures-uncertainty=1, table-space-text-post=(16)}
        \centering
        \begin{threeparttable} 
        \notsotiny
        \setlength{\tabcolsep}{2.3pt}
        \setlength{\extrarowheight}{2.2pt}
        \caption{Taxon}
        \begin{tabular}{>{\itshape}p{2cm}p{0.8cm}@{}*{12}{S}@{}}%
        \toprule
        \multicolumn{2}{c}{Site} & \multicolumn{2}{c}{WI} & \multicolumn{2}{c}{WO} & \multicolumn{2}{c}{SL} & \multicolumn{2}{c}{SE} & \multicolumn{2}{c}{EO} & \multicolumn{2}{c}{EI} \\
        \cmidrule(lr){3-4} \cmidrule(lr){5-6} \cmidrule(lr){7-8} \cmidrule(lr){9-10} \cmidrule(lr){11-12} \cmidrule(lr){13-14}
        \multicolumn{2}{c}{Season}& {Wet} &{Dry} & {Wet} & {Dry} & {Wet} & {Dry} & {Wet} & {Dry} & {Wet} & {Dry} & {Wet} & {\makebox[\mylength]{Dry}} \\
        \midrule
        \multicolumn{1}{c}{{Species}}   & Tracer & {Mean $ \pm$ SD $_{(n)}$} & {Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} \\
        \midrule
        \multirow{2}{*}{\shortstack[l]{{Genus}\\ { Species}}}& $\delta{^{15}}$N &       &       &       &       &       & 12.82\pm0.36\ts{(4)} &       &       & 13.83\pm0.99\ts{(8)} & 14.25\pm0.49\ts{(2)} & 14.60\pm0.23\ts{(4)} &  \\
        & $\delta{^{13}}$C &       &       &       &       &       & -16.73\pm0.29\ts{(4)} &       &       & -16.62\pm0.27\ts{(8)} & -17.30\pm0.14\ts{(2)} & -16.65\pm0.31\ts{(4)} &  \\
        \bottomrule
    \end{tabular}
    \end{threeparttable}
\end{landscape}

\end{document}
0

1 Answer 1

1

Instead of using the threeparttableex package you could give the floatrow package and its longtable option LTcapwidth=content a try:

\documentclass{article}

\usepackage{array}
\usepackage{changepage}
\usepackage[a4paper, vmargin=0.05cm, hmargin=0.1cm, marginparwidth=0.1cm,total={210mm,297mm}]{geometry}
\usepackage{rotating}
\usepackage[singlelinecheck=off]{caption}
\usepackage{booktabs}
\usepackage{pdflscape}
\usepackage{multirow, makecell, xcolor}
\usepackage[separate-uncertainty=true]{siunitx}
\usepackage{threeparttable}
%\usepackage{threeparttablex} 
\usepackage{longtable}

\usepackage{floatrow}
\floatsetup[longtable]{LTcapwidth=contents}


\newlength{\mylength} \settowidth{\mylength}{$-55.55\pm0.55$}
\makeatletter
\newcommand\notsotiny{\@setfontsize\notsotiny{6.5}{7.5}}
\makeatother
\newcommand{\ts}[1]{\textsubscript{#1}}

\begin{document}    
\begin{landscape}
    \sisetup{
        table-number-alignment=center,
        separate-uncertainty=true,
        table-column-width = 2cm,
        table-format =-2.2,
        separate-uncertainty,
        table-figures-uncertainty=1, table-space-text-post=(16)}
%    \begin{ThreePartTable} 
        \notsotiny
        \setlength{\tabcolsep}{2.3pt}
        \setlength{\extrarowheight}{2.2pt}
        \begin{longtable}[c]{>{\itshape}p{2cm}p{0.8cm}@{}*{12}{S}@{}}%
            \caption{Taxon}\\
                \toprule
        \multicolumn{2}{c}{Site} & \multicolumn{2}{c}{WI} & \multicolumn{2}{c}{WO} & \multicolumn{2}{c}{SL} & \multicolumn{2}{c}{SE} & \multicolumn{2}{c}{EO} & \multicolumn{2}{c}{EI} \\
        \cmidrule(lr){3-4} \cmidrule(lr){5-6} \cmidrule(lr){7-8} \cmidrule(lr){9-10} \cmidrule(lr){11-12} \cmidrule(lr){13-14}
        \multicolumn{2}{c}{Season}& {Wet} &{Dry} & {Wet} & {Dry} & {Wet} & {Dry} & {Wet} & {Dry} & {Wet} & {Dry} & {Wet} & {\makebox[\mylength]{Dry}} \\
        \midrule
        \multicolumn{1}{c}{{Species}}   & Tracer & {Mean $ \pm$ SD $_{(n)}$} & {Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} \\
        \midrule
            \endfirsthead
    \multirow{2}{*}{\shortstack[l]{{Genus}\\ { Species}}}& $\delta{^{15}}$N &       &       &       &       &       & 12.82\pm0.36\ts{(4)} &       &       & 13.83\pm0.99\ts{(8)} & 14.25\pm0.49\ts{(2)} & 14.60\pm0.23\ts{(4)} &  \\
& $\delta{^{13}}$C &       &       &       &       &       & -16.73\pm0.29\ts{(4)} &       &       & -16.62\pm0.27\ts{(8)} & -17.30\pm0.14\ts{(2)} & -16.65\pm0.31\ts{(4)} &  \\
            \bottomrule
        \end{longtable}
%        \end{ThreePartTable}
    \end{landscape}
    \begin{landscape}
        \sisetup{
        table-number-alignment=center,
        separate-uncertainty=true,
        table-column-width = 2cm,
        table-format =-2.2,
        separate-uncertainty,
        table-figures-uncertainty=1, table-space-text-post=(16)}
        \centering
        \begin{threeparttable} 
        \notsotiny
        \setlength{\tabcolsep}{2.3pt}
        \setlength{\extrarowheight}{2.2pt}
        \caption{Taxon}
        \begin{tabular}{>{\itshape}p{2cm}p{0.8cm}@{}*{12}{S}@{}}%
        \toprule
        \multicolumn{2}{c}{Site} & \multicolumn{2}{c}{WI} & \multicolumn{2}{c}{WO} & \multicolumn{2}{c}{SL} & \multicolumn{2}{c}{SE} & \multicolumn{2}{c}{EO} & \multicolumn{2}{c}{EI} \\
        \cmidrule(lr){3-4} \cmidrule(lr){5-6} \cmidrule(lr){7-8} \cmidrule(lr){9-10} \cmidrule(lr){11-12} \cmidrule(lr){13-14}
        \multicolumn{2}{c}{Season}& {Wet} &{Dry} & {Wet} & {Dry} & {Wet} & {Dry} & {Wet} & {Dry} & {Wet} & {Dry} & {Wet} & {\makebox[\mylength]{Dry}} \\
        \midrule
        \multicolumn{1}{c}{{Species}}   & Tracer & {Mean $ \pm$ SD $_{(n)}$} & {Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} &{Mean $ \pm$ SD $_{(n)}$} \\
        \midrule
        \multirow{2}{*}{\shortstack[l]{{Genus}\\ { Species}}}& $\delta{^{15}}$N &       &       &       &       &       & 12.82\pm0.36\ts{(4)} &       &       & 13.83\pm0.99\ts{(8)} & 14.25\pm0.49\ts{(2)} & 14.60\pm0.23\ts{(4)} &  \\
        & $\delta{^{13}}$C &       &       &       &       &       & -16.73\pm0.29\ts{(4)} &       &       & -16.62\pm0.27\ts{(8)} & -17.30\pm0.14\ts{(2)} & -16.65\pm0.31\ts{(4)} &  \\
        \bottomrule
    \end{tabular}
    \end{threeparttable}
\end{landscape}

\end{document}
2
  • Thank you very much,it works perfectly although I don't know what is the reason behind. So is there a conflict between longtable and threeparttableex so that the caption is not displayed correctly in my original example?
    – Jason Yau
    Aug 14, 2018 at 16:43
  • @JasonYau The threeparttable offers two features for tables: Table notes (optional) and a caption width identical to the width of the table. Although the threeparttablex is a similar package for longtables, it offers table notes only. So if you want to start the caption on the same horizontal position as your table, threeparttablex is not sufficient. Instead you need either a package which offers the "caption width identical to the width of the table" feature for longtables (like floatrow) or a package which allows setting extra margins for captions of longtables (like caption).
    – user2574
    Aug 14, 2018 at 18:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .