This is a followup to this question, I'm wondering why using my tline
command below will not compile
\documentclass{article}
\usepackage{xparse,tabu}
\usepackage[table]{xcolor}
\NewDocumentEnvironment {trace} {} {%
\table
\tabu to \linewidth {|@{ }r@{::}l|l|X|}
A & B & C & D \\
}{%
\endtabu
\endtable
}
\newcommand{\commentcell}{\cellcolor[gray]{0.9}}
\newcommand{\linecell}{\cellcolor[gray]{0.75}}
\newcommand{\classcell}{\cellcolor[gray]{0.75}}
\newcommand{\methodcell}{\cellcolor[gray]{0.75}}
\newcommand{\codecell}{\cellcolor[gray]{0.75}}
\NewDocumentCommand \tline { o m m m m } {\linecell #2 & \classcell #3 & \methodcell #4 & \codecell #5 \\ %
\IfNoValueTF {#1}
{} % No comment was provided, skip creating a line
{\hline\multicolumn{4}{ |r| }{\commentcell #1} \\ }
\hline
}
\begin{document}
% This works
\begin{trace}
a & b & c & d
\end{trace}
% This fails with 'Missing Number'. Note that tabu definitely does not like the
% ending \\ caused by the \tline, but I know that I need to use \\ inside my
% tline command to cause a line break, so the question is how do I optionally
% create two rows inside tline without using \\, or is there a command tabu
% prefers to \\. I tried \newline with no luck
\begin{trace}
\tline{a}{b}{c}{d}
\end{trace}
\end{document}
\DeclareExpandableDocumentCommand
xparse
has to do with this problem, which only depends ontabu
. Unfortunately, the current version oftabu
is unmaintained and the author has announced big changes to the next version (also backward incompatible ones).