2

I am trying to use an earlier solution posted here which combines the tabu and threeparttable to stretch table columns according to \textwidth. However, as soon as I change the article class to apa6 the earlier solution produces errors.

\documentclass[a4paper,floatsintext,man,donotrepeattitle]{apa6}
\usepackage{booktabs}
\usepackage{threeparttable,tabu}

\usepackage{xpatch}
\makeatletter
\chardef\TPT@@@asteriskcatcode=\catcode`*
\catcode`*=11
\xpatchcmd{\threeparttable}
{\TPT@hookin{tabular}}
{\TPT@hookin{tabular}\TPT@hookin{tabu}}
{}{}
\catcode`*=\TPT@@@asteriskcatcode
\makeatother

\begin{document}
\centering
\begin{threeparttable}
    \begin{tabu} to .4\textwidth {XX}
        a & b   \\\toprule
        0 & 1   \\\bottomrule
    \end{tabu}
    \begin{tablenotes}
        \footnotesize
        \item[*] This is a long table note text, long enough to exceed the table's width.
    \end{tablenotes}
\end{threeparttable}

\end{document}

The errors are:

Extra }, or forgotten \endgroup. \end{tabu}
Undefined control sequence. \end{document}

My question: How to stretch a tables with apa6 when also including tablenotes? That is, I am not bound to the tabu or threeparttable class, but it seems easiest to me.


As tabularx was suggested as an alternative, it also produces a compilation error when used together with threeparttable and apa6 (but again not when using only the article class).

\documentclass[a4paper,floatsintext,man,donotrepeattitle]{apa6}
%\documentclass{article}
\usepackage{booktabs}
\usepackage{tabularx,threeparttable}

\begin{document}

\begin{threeparttable}
    \begin{tabularx}{\textwidth} {XX}
        \toprule
        a & b   \\\midrule
        0 & 1   \\\bottomrule
    \end{tabularx}
    \begin{tablenotes}
        \footnotesize
        \item[*] This is a long table note text, long enough to exceed the table's width.
    \end{tablenotes}
\end{threeparttable}

\end{document}

produces:

Undefined control sequence. \end{document}
Underfull \hbox (badness 10000) in alignment
9
  • 1
    Do you have any particular reason for using tabu instead of tabularx? By the way, there's no reason for either, if you just want two columns whose widths sum up to .4\textwidth.
    – egreg
    Feb 6, 2017 at 15:24
  • No. Just from reading other answers here tabu seemed to be the correct choice. I have no preference whatsoever (other than using the apa6class).
    – Henrik
    Feb 6, 2017 at 15:25
  • 2
    In my opinion, tabu is almost never the correct choice; I might be biased.
    – egreg
    Feb 6, 2017 at 15:27
  • @egreg I have found no way to proportionally expand a table with several columns to \textwidth (or some proportion of it) without additional packages. I am happy to be proven otherwise. And also happy for solutions involving tabularx.
    – Henrik
    Feb 6, 2017 at 15:28
  • \begin{tabular}{p{\dimexpr.2\textwidth-2\tabcolsep}p{\dimexpr.2\textwidth-2\tabcolsep}} would do.
    – egreg
    Feb 6, 2017 at 15:39

1 Answer 1

2
+100

Using ˙apa6 require to use \shorttitle{Some title} in preamble. If you not need it, than it is suffice to add \shorttitle{}:

\documentclass[a4paper,floatsintext,man,donotrepeattitle]{apa6}
\usepackage{booktabs,tabularx,threeparttable}
\shorttitle{}% short title, can be empty but not deleted

\usepackage{lipsum}% only for test purpose

\begin{document}
\lipsum[1]

\begin{center}
\begin{threeparttable}
    \begin{tabularx}{.4\textwidth}{XX}
                    \toprule
        a & b   \\  \midrule
        0 & 1   \\  \bottomrule
    \end{tabularx}
    \begin{tablenotes}
        \footnotesize
        \item[*] This is a long table note text, long enough to exceed the table's width.
    \end{tablenotes}
\end{center}
\end{threeparttable}

\end{document}

enter image description here

You must log in to answer this question.

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