4

The following macro works correctly for enclosing an expression in parenthesis.

\def\group#1{\left ( #1 \right )}

I want to write the equivalent macro for enclosing an expression in square brackets. I have tried the following macro with and without backslash-escaping the the square brackets, but both give errors.

\def\bgroup#1{\left [ #1 \right ] } 

How can I define a macro with the desired expansion?

  • 5
    \bgroup is a name used within the LaTeX kernel: did you try with a different name? (\newcommand rather than \def would tell you this.) – Joseph Wright Oct 29 '13 at 20:24
  • Oh, I did not try with a different name. Trying that now. – merlin2011 Oct 29 '13 at 20:30
  • Changing the name fixed it. That error message was really cryptic! Thank you. – merlin2011 Oct 29 '13 at 20:33
  • I could delete the question, but if you want to write your comment as an answer, I'll accept it and we can leave it as a reference in case somebody else happened to use def and the name bgroup together. – merlin2011 Oct 29 '13 at 20:35
  • 2
    A few information about \bgroup, \begingroup and {: When should one use \begingroup instead of \bgroup? – Qrrbrbirlbel Oct 29 '13 at 20:46
9

The command \bgroup is used by the LaTeX kernel (and indeed by plain TeX) for low-level operations: as such it is 'reserved'. Thus the problem is not [ and ] in the command but rather the choice of \bgroup as the name for it. If you use \newcommand rather than \def you'll see an informative error message indicating that \bgroup is 'taken'.

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.