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.

David Carlisle
  • 757,742
konze
  • 343
  • 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

1 Answers1

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?

David Carlisle
  • 757,742