4

I'm trying to define a shortcut using \newcommand for setting up a table using the tabularx environment. The command seems to work fine when beginning the table:

\newcommand{\bt}{\begin{tabularx}}

But doesn't work when ending the table:

\newcommand{\et}{\end{tabularx}}

The error message that I receive is:

! Missing } inserted.

<inserted text> 

                }

l.33 \end{tabularx}
Martin Scharrer
  • 262,582
Richard
  • 41

1 Answers1

5

An environment \begin{tabularx} expands to \begingroup\tabularx and \end{tabularx} expands to \endtabularx\endgroup.

With \let\a\b you can 'copy' the definition of macro \b to \a. That's how you create the short name:

\let\bt\tabularx
\let\et\endtabularx

Note: This does not copy the group.

Usage:

\bt{5cm}{lX}
 foo & bar
\et
ejoerns
  • 1,811