4

I'm using the {threeparttable} package because I want to use table notes, but I'm having a problem resizing my tables. If I use {adjustbox} to enclose {tabular} (or {tabularx}), I get an error message:

! You can't use `\hrule' here except with leaders. \caption@hrule
->\hrule 
                    \@height \z@  l.23 \end{tabular}}

The same applies if I use \resizebox or \scalebox at the same point in the code.

If I use {adjustbox} and enclose {threeparttable}, the code runs, but the fontsize of the caption and table note are also scaled down...

enter image description here

... which is not what I want!

Does anyone know a way to resize the table font only when using package {threeparttable}?

\documentclass[a4paper,14pt]{scrreprt}

\usepackage{graphicx}
\usepackage{adjustbox}
\usepackage{threeparttable}
\usepackage[labelfont=bf]{caption}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage[a4paper, bindingoffset=0.5cm, tmargin=2.4cm, bmargin=3.4cm, lmargin=3.5cm, rmargin=2.5cm, footskip=2.4cm]{geometry}

\begin{document}
This is some text which refers to Table~\ref{tab:Table}
\begin{table}
\centering
% \begin{adjustbox}{max width=\textwidth}
\begin{threeparttable}
\caption{Table caption.}
\label{tab:Table}
\begin{adjustbox}{max width=\textwidth}
\begin{tabular}{@{}l*{10}{c}@{}}
\toprule
Item & Col 2 & Col 3 & Col 4 & Col 5 & Col 6 & Col 7 & Col 8 & Col 9 & Col 10 & Col 11 \\
\midrule
Some sort of stuff\tnote{a} & 107.5 & 5.62 & 89.1 & \num{14367.7} & 3.4 & 21.9 & 112.6 & \num{18644} & 432.4 & 17 \\
\bottomrule
\end{tabular}
\end{adjustbox}
\begin{tablenotes}
\small
\item[a] This sort of stuff is only available in winter.
\end{tablenotes}
\end{threeparttable}
% \end{adjustbox}
\end{table}
Some more text.
\end{document}
5

threeparttable wants to see tabular and tablenotes at the outer level, not buried into adjustbox.

Thinks very carefully before deciding to scale a table. For instance, a body text of 14pt is humongous and will make the scaled table disappear with respect to the text.

I reduced to 11pt, which is a quite large font size.

\documentclass[a4paper,11pt]{scrreprt}

\usepackage{graphicx}
\usepackage{adjustbox}
\usepackage{threeparttable}
\usepackage[labelfont=bf]{caption}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage[a4paper, bindingoffset=0.5cm, tmargin=2.4cm, bmargin=3.4cm, lmargin=3.5cm, rmargin=2.5cm, footskip=2.4cm]{geometry}

\begin{document}
This is some text which refers to Table~\ref{tab:Table}
\begin{table}
\centering
\caption{Table caption.}
\label{tab:Table}
\begin{adjustbox}{max width=\textwidth}
\begin{threeparttable}
\begin{tabular}{@{}l*{10}{c}@{}}
\toprule
Item & Col 2 & Col 3 & Col 4 & Col 5 & Col 6 & Col 7 & Col 8 & Col 9 & Col 10 & Col 11 \\
\midrule
Some sort of stuff\tnote{a} & 107.5 & 5.62 & 89.1 & \num{14367.7} & 3.4 & 21.9 & 112.6 & \num{18644} & 432.4 & 17 \\
\bottomrule
\end{tabular}
\begin{tablenotes}
\small
\item[a] This sort of stuff is only available in winter.
\end{tablenotes}
\end{threeparttable}
\end{adjustbox}
\end{table}
Some more text.
\end{document}

enter image description here

Would I scale also the caption? No way.

  • Many thanks @egreg. Like a lot of things, it seems easy when you know how! I'm not really using a 14-point font, I just used it in the example to make the scaling more obvious, and to make it clear that the caption font was being downsized too. – Mark Birtwistle Oct 10 '14 at 19:56
  • PS What's the alternative to scaling if one has a lot of columns, is it just a question of adjusting the table font size manually? – Mark Birtwistle Oct 10 '14 at 19:58

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.