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}
  • Hi Richard, welcome to TeX.sx! I've formatted the code in your question. You can also do that yourself by selecting the code segments and clicking the {} button. Also, it's generally a good idea to include a minimal working example (MWE), i.e. the smallest complete, compilable document that demonstrates the problem. – Jake Dec 6 '11 at 6:12
  • 6
    The tabularx environment only looks like an environment, but it's actually a command. See How to include tabularx/y in a new environment. – Alan Munn Dec 6 '11 at 6:20
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
  • 3
    Definition: Check, Usage: Check, Explanation: ??? – Martin Scharrer Dec 6 '11 at 9:12

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.