3

I need to have a table which 1) is sideways 2) is rescaled to fit the page 3) has tablenotes. I'm trying to combine sidewaystable, adjustbox and threeparttablex to do so, but I encounter three problems:

  1. I don't know where/how to include the table caption. I tried several positions within the environments but I keep getting compilation errors.
  2. The width of the tablenotes is not correct, not even after including \renewcommand\TPTminimum{\linewidth}
  3. Labels "b" and "c" overlap in the third cell of the first row.

This is what my current MWE attempt looks like (the actual table is much larger, hence the sidewaystable/adjustbox combination):

\documentclass[]{article}
\usepackage{adjustbox}
\usepackage{caption}
\usepackage{multirow}
\usepackage[style=apa,sortcites=true,sorting=nyt,backend=biber]{biblatex}
\usepackage{rotating}
\usepackage{longtable}
\usepackage{threeparttablex}

\begin{document}

\begin{sidewaystable}
\begin{adjustbox}{width=\linewidth}
\begin{ThreePartTable}
\renewcommand{\TPTminimum}{\linewidth}
\begin{TableNotes}
\small
\item [a] Note note note note note note note note note note note note note note note note note note note note note note note note note note
\item [b] Note note note note note note note note note note note note note note note note note note note note note note note note note note
\item [c] Note note note note note note note note note note note note note note note note note note note note note note note note note note
\end{TableNotes}
\begin{tabular}{lllllll}
%\caption{My table caption.} \\
\hline
\multirow{2}{*}{Model} & \multirow{2}{*}{Specification\tnote{a}} & \multirow{2}{*}{Covariance structure\tnote{a}\tnote{b}} & \multicolumn{2}{l}{Number of fixed effects\tnote{c}} & \multicolumn{2}{l}{Number of variance components\tnote{c}} \\ \cline{4-7} 
&                                &                                  & ES approach          & RD approach          & ES approach             & RD approach             \\ \hline
$1$                      &     Model 1                           & Covariance 1                                      & $1$                    & $2$                    & $2$                       & $7$                       \\
$2$                      &     Model 2                           & Covariance 2                                      & $2$                    & $4$                    & $6$                       & $21$                      \\
$3 $                     &     Model 3                           & Covariance 3                                      & $3$                    & $6$                    & $12$                      & $43$                      \\ \hline
\insertTableNotes
\end{tabular}
\end{ThreePartTable}
\end{adjustbox}
\end{sidewaystable}
\end{document}

enter image description here

  • it is best to never scale tables even in cases where it doesn't give an error, it produces inconsistent font sizes and poor output. – David Carlisle Dec 13 '18 at 7:50
  • Welcome to TeX - LaTeX! – Andrew Swann Dec 13 '18 at 7:55
4

Only scale tables as a last resort (and even then don't do it) also as you are using threeepartx rather than threepart I think you want longtable rather than tabular

enter image description here

\documentclass[]{article}
\usepackage{adjustbox}
\usepackage{caption}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{threeparttablex}
\usepackage{pdflscape}
\begin{document}

\begin{landscape}
\begin{ThreePartTable}
\begin{TableNotes}
\small
\item [a] Note note note note note note note note note note note note note note note note note note note note note note note note note note
\item [b] Note note note note note note note note note note note note note note note note note note note note note note note note note note
\item [c] Note note note note note note note note note note note note note note note note note note note note note note note note note note
\end{TableNotes}
\begin{longtable}{lllllll}
%\caption{My table caption.}
\hline
\multirow{2}{*}{Model} & \multirow{2}{*}{Specification\tnote{a}} & \multirow{2}{*}{Covariance structure\tnote{a}\tnote{b}} & \multicolumn{2}{l}{Number of fixed effects\tnote{c}} & \multicolumn{2}{l}{Number of variance components\tnote{c}} \\ \cline{4-7} 
&                                &                                  & ES approach          & RD approach          & ES approach             & RD approach             \\ \hline
$1$                      &     Model 1                           & Covariance 1                                      & $1$                    & $2$                    & $2$                       & $7$                       \\
$2$                      &     Model 2                           & Covariance 2                                      & $2$                    & $4$                    & $6$                       & $21$                      \\
$3 $                     &     Model 3                           & Covariance 3                                      & $3$                    & $6$                    & $12$                      & $43$                      \\ \hline
\insertTableNotes
\end{longtable}
\end{ThreePartTable}
\end{landscape}
\end{document}
4

Since the table -- including table footnotes -- has to fit on a single page, I wouldn't use the machinery of the longtable and ThreePartTable environments. Moreover, I wouldn't use the adjustbox machinery either, as it will almost certainly cause wildly inconsistent font sizes across parts of the documents.

I can't see how you can go wrong employing sidewaystable, threeparttable, tabularx, and tablenotes environments. In particular, using a tabularx environment and allowing line breaks in cells should remove any need to resort to the adjustbox sledgehammer. For well-spaced horizontal lines or "rules", do consider loading the booktabs package and employing its \toprule, \cmidrule, \midrule, and \bottomrule macros. And, instead of \tnote{a}\tnote{b}, do write \tnote{a,b}.

enter image description here

\documentclass[]{article}
\usepackage[skip=0.333\baselineskip]{caption}
%\usepackage[letterpaper,margin=1in]{geometry} % select the appropriate page parameters
\usepackage{rotating}
\usepackage{tabularx,ragged2e}
\newcolumntype{C}{>{\Centering\arraybackslash}X}
\newcolumntype{E}{>{\hsize=\dimexpr2\hsize+2\tabcolsep\relax}C}
\usepackage[flushleft]{threeparttable}
\usepackage{booktabs}
\newcommand\minitab[1]{\smash{%
   \begin{tabular}[t]{@{}c@{}}#1\end{tabular}}}

\begin{document}
\begin{sidewaystable}
\begin{threeparttable}
\caption{My table caption.}
\begin{tabularx}{\textwidth}{@{} l *{6}{C} @{}}
\toprule
Model & 
Specification\tnote{a} & 
\minitab{Covariance\\structure\tnote{a,b}} & 
\multicolumn{2}{E}{Number of fixed effects\tnote{c}} & 
\multicolumn{2}{E@{}}{Number of variance components\tnote{c}} \\ 
\cmidrule(lr){4-5} \cmidrule(l){6-7} 
& & & ES approach & RD approach & ES approach & RD approach \\ 
\midrule
$1$ & Model 1 & Covariance 1 & $1$ & $2$ & $2$ &  $7$ \\
$2$ & Model 2 & Covariance 2 & $2$ & $4$ & $6$ & $21$ \\
$3$ & Model 3 & Covariance 3 & $3$ & $6$ & $12$& $43$ \\ 
\bottomrule
\end{tabularx}

\medskip % or "\smallskip"
\begin{tablenotes}
\small
\item [a] Note note note note note note note note note note note note note 
          nnote note note note note note note note note note note note note
\item [b] Note note note note note note note note note note note note note 
          note note note note note note note note note note note note note
\item [c] Note note note note note note note note note note note note note 
          note note note note note note note note note note note note note
\end{tablenotes}
\end{threeparttable}
\end{sidewaystable}
\end{document}
2

threeparttablex is for use with longtable not ordinary tabular. Use threeparttable commands for a tabular:

Sample output

\documentclass[]{article}
\usepackage{adjustbox}
\usepackage{caption}
\usepackage{multirow}
\usepackage[style=apa,sortcites=true,sorting=nyt,backend=biber]{biblatex}
\usepackage{rotating}
\usepackage{longtable}
\usepackage{threeparttable}
\usepackage{booktabs}

\begin{document}

\begin{sidewaystable}
\begin{adjustbox}{width=\linewidth}
\begin{threeparttable}
\renewcommand{\TPTminimum}{.9\linewidth}
\caption{My table caption.}
\begin{tabular}{*{7}{l}}
  \toprule
  \multirow{2}{*}{Model}
  & \multirow{2}{*}{Specification\tnote{a}}
  & \multirow{2}{*}{Covariance structure\tnote{a,b}\ }
  & \multicolumn{2}{l}{Number of fixed effects\tnote{c}}
  & \multicolumn{2}{l}{Number of variance components\tnote{c}} \\
  \cmidrule(lr){4-7}
  & & & ES approach & RD approach & ES approach & RD approach \\
  \midrule
  $1$ & Model 1 & Covariance 1 & $1$ & $2$ & $2$ & $7$ \\
  $2$ & Model 2 & Covariance 2 & $2$ & $4$ & $6$ & $21$ \\
  $3$ & Model 3 & Covariance 3 & $3$ & $6$ & $12$ & $43$ \\
  \bottomrule
\end{tabular}
\begin{tablenotes}
\small
\item [a] Note note note note note note note note note note note note note note note note note note note note note note note note note note
\item [b] Note note note note note note note note note note note note note note note note note note note note note note note note note note
\item [c] Note note note note note note note note note note note note note note note note note note note note note note note note note note
\end{tablenotes}
\end{threeparttable}
\end{adjustbox}
\end{sidewaystable}
\end{document}

Note loading threeparttablex will work equally well, it loads threeparttable, you just have to use the commands from threeparttable.

I used \tnote{a,b} for the two adjacent notes. I added a manual space \ afterwards to give a bit more room.

I have used the booktabs package for nicer rules including the \cmidrule which can be shortened slightly on either side

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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