My question is basically in the title. I tried, but cannot get it to work, despite the threeparttable
documentation explicitly claiming compatibility with tabularx
. Here is what I tried so far:
main.tex
\documentclass{scrartcl}
\usepackage{fontspec}
\usepackage[english]{babel}
\usepackage{testpack}
\usepackage{lipsum}
\begin{document}
\begin{tabxn}{label}{Caption}{Xr}{\textwidth}
Head A & Head B \\
\midrule
\lipsum[1] & Something\tnote{a}
\tabxnotes
\item[a] Some remark;
\end{tabxn}
\end{document}
testpack.sty
\ProvidesPackage{testpack}
\RequirePackage{float}
\RequirePackage{booktabs}
\RequirePackage{tabularx}
\RequirePackage[para,flushleft]{threeparttable}
\makeatletter%
\newcommand{\tabxnotes}{\bottomrule\end{tabularx}\begin{tablenotes}}%
\newenvironment{tabxn}[5][\fps@table]{%
\expanded{\noexpand\begin{table}[#1]}%
\label{tab:#2}%
\caption{#3}%
\begin{threeparttable}%
\centering%
\begin{tabularx}{#5}{#4}%
\toprule%
}{%
\end{tablenotes}%
\end{threeparttable}
\end{table}%
}%
\newcommand{\tabxnfile}[5][\fps@table]{%
\begin{scitabxn}[#1]{#2}{#3}{#4}{#5}%
\input{tab/#2}%
\end{scitabxn}%
}%
\makeatother%
main.log
(excerpt)
Runaway argument?
\par
! File ended while scanning use of \TX@get@body.
<inserted text>
\par
<*> main.tex
I know this should tell me that I may have forgotten a closing brace, a \end{env}
or something along those lines, but I haven't found anything by triple-checking. How can I get this to work, and if not, what is flawed about the way I approach this?
Edit: Tracing down the bug a bit further, it seems to be in the \tabxnotes
command. When I substitute the command for its contents, the MWE compiles. However, to keep things dry, I would like to put that stuff inside one command, instead of three.
\tabularx *table* \endtabularx
creates the same error, whilebegin{tabularx} *table* \end{tabularx}
doesn't. Both in that case outside of thetabxn
definition. I did however find out that even with the "working" version, the\tabxnotes
command breaks it. What puzzles me the most though, is that three breaking examples give me the same error message.\newcommand{\tabxnotes}{\bottomrule\end{tabularx}\begin{tablenotes}}%
you can definetabularx
as par of another environment but you can not start it with one command and end it with another, you have to use an environment form.