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.
$
\left\{
\begin{array}{l}
a+b=c\\
c+d=e
\end{array}
\right.
$

I define a macro command for it.

\newcommand{\curleq}[2]{\left\{\begin{array}{#1}{#2}\end{array}\right.}

When I type

$\curleq{l}{a+b=c\\c+d=e}$

Latex reports error: "Extra }, or forgotten $."

I wonder if anyone can help me solve the problem. Thanks.

share|improve this question
1  
(Yes, I can see @Werner's answer). Package amsmath has an environment cases, which might be useful in a future. –  Przemysław Scherwentke Jul 4 at 6:19
    
Thank @PrzemysławScherwentke for broadening my horizon. Probably I will use cases soon. –  Sam Jul 4 at 6:25

1 Answer 1

up vote 6 down vote accepted

The second argument to \curleq is placed inside a braced group. And, since groups can't span cells or rows inside an array (or tabular), LaTeX reports an error. Just remove the braced group around the second argument #2:

enter image description here

\documentclass{article}
\newcommand{\curleq}[2]{%
  \left\{\begin{array}{#1}#2\end{array}\right.}
\begin{document}
$\curleq{l}{a+b=c\\c+d=e}$
\end{document}
share|improve this answer
    
Thank you so much, Werner. Thank you for re-editing and perfectly solved my problem. –  Sam Jul 4 at 6:11
    
One can do away with the curly braces around #1 as well, right? –  Mico Jul 4 at 6:26
1  
@Mico: Technically, yes. But in general you could call \curleq{lr}{...} which would cause r to be the first entry of the array's first cell if you do not enclose #1 in braces. –  Werner Jul 4 at 6:32
    
Hello, @Mico, your suggestion is only true for my current example. If I want $\curleq{ll}{a+b=c&x>0\\c+d=e&x<0}$, then the curly braces around #1 are required. –  Sam Jul 4 at 6:36
    
Thanks for providing this clarification. I had indeed focused to much on the example given by the OP. –  Mico Jul 4 at 7:29

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.