1

Can someone explain the (what is to me) weird behavior of adjustbox in the second and third cases below?

Why is it that all three cases produce different results?

\documentclass{article}

\usepackage{tabu}
\usepackage{adjustbox}
\usepackage{booktabs}

\begin{document}

\centering

With ``c''.
\vspace{1ex}

\begin{adjustbox}{width=7em}
%
\begin{tabu}{c}
  \toprule
  \\
  Some reasonably, very much so, long text.
  \\
  \bottomrule
\end{tabu}
%
\end{adjustbox}

\vspace{3ex}

With ``X[c]''.
\vspace{1ex}

\begin{adjustbox}{width=7em}
%
\begin{tabu}{X[c]}
  \toprule
  \\
  Some reasonably, very much so, long text.
  \\
  \bottomrule
\end{tabu}
%
\end{adjustbox}

\vspace{3ex}

With ``to 7em'' and ``X[c]''.
\vspace{1ex}

\begin{adjustbox}{width=7em}
%
\begin{tabu} to 7em {X[c]}
  \toprule
  \\
  Some reasonably, very much so, long text.
  \\
  \bottomrule
\end{tabu}
%
\end{adjustbox}

\end{document}

enter image description here

Please mind that the text that seems to title each table is not actually a caption (trying not to confuse people with how a \caption would scale).

2
  • 1
    (i) use adjustbox for set tables width is not good idea, (ii) be watchful with use of tabu, it is buggy and not maintained.
    – Zarko
    Nov 14 '17 at 7:45
  • Because of your comment, I posted a follow-up question, in case you'd be interested in providing more details. tex.stackexchange.com/questions/401353/…
    – dow
    Nov 14 '17 at 22:40
2

The general rule really is never scale tables (whether tabular or tabu or anything else) however

In your first case with c, the tabu is the natural width of the text plus some \tabcolsep padding for the columns, then that is scaled back to 7em

In the second case the X column is essentially a full width paragraph, although as it's only one line, it looks shorter, so that full width text is scaled to 7em so the text looks smaller.

In the third case the text is wrapped so that the natural width of the table is already 7em, so the scaling does nothing.

2
  • About the second case, you say the X column is a full-width paragraph; does this mean that the column has a width of \textwidth?
    – dow
    Nov 14 '17 at 22:38
  • @dow yes I suspect so (has to be that way if you need the multipage version) Nov 14 '17 at 22:40

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.