2

I want to put \end{tabu} within a \newcommand

\documentclass{article}

\usepackage{tabu}

\newcommand
{\tableBegin}[1]
{
    \begin{tabu}[#1]
    % some other stuff
}

\newcommand
{\tableEnd}
{\end{tabu}}

\begin{document}

\tableBegin{ccc}
1 & 2 & 3 \\
a & b & c
\tableEnd
%\end{tabu}

\end{document}

But when I use \tableEnd instead of \end{tabu} I get get following error: ! Missing $ inserted.

  • 4
    tabu (like AMS evironments and tabularx etc), grabs its body as an argument so explicitly looks for \end{tabu} in the source. It is possible to work around that but it is simpler not to and just use the documented environment name. \tableBegin/End is very unlike LaTeX conventions why not define a new environment? – David Carlisle Apr 11 '13 at 10:17
5

tabu (like AMS environments and tabularx etc), grabs its body as an argument so explicitly looks for \end{tabu} in the source. It is possible to work around that but it is simpler not to, and just use the documented environment name.

\tableBegin/End is very unlike LaTeX conventions why not define a new environment?

| improve this answer | |

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.