Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
    
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
add comment

1 Answer

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
share|improve this answer
3  
Definition: Check, Usage: Check, Explanation: ??? –  Martin Scharrer Dec 6 '11 at 9:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.