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 have tried to define a new environment numcases, which just like the cases except tagging the equations as a whole, and

\newenvironment{numcases}{\begin{equation}\left\{\begin{array}{rll}}%
{\end{array}\right.\end{equation}}

also I know the cases package, but it will tag all lines of equations (not as a whole). I guess that the problem in my definition is that the \left{ and \right. not in a block (i.e., a {}), so any solution?

share|improve this question
5  
Is there really a need for it? Why not \begin{equation}\begin{cases} ... \end{cases}\end{equation} which would be clearer? (Needs \usepackage{amsmath}) –  egreg Nov 8 '12 at 9:30
    
As David pointed out in his answer, the code works just ok. This means that in the present form, there's nothing to answer. –  tohecz Nov 8 '12 at 10:30

2 Answers 2

up vote 6 down vote accepted

Please always post complete documents that show the problem. There is nothing wrong with your fragment so presumably your problem is in a part you have not shown.

enter image description here

\documentclass{article}
\newenvironment{numcases}{\begin{equation}\left\{\begin{array}{rll}}%
{\end{array}\right.\end{equation}}

\begin{document}

\begin{numcases}
a&1&x\\
b&2&y\\
c&3&z
\end{numcases}

\end{document}
share|improve this answer
    
Thanks, you were definitely right, the problem is in other part. My definition works perfectly. –  user19832 Nov 8 '12 at 13:19
    
@user19832: Then I think you should accept this answer of David. –  canaaerus Nov 9 '12 at 17:59

The environ package allows you to define such a environment, that first reads the whole body and then puts it into some command. (compare also http://tex.stackexchange.com/a/67849/15616)

In your case this should look something like:

\usepackage{environ}
\NewEnviron{numcases}{%
    \begin{equation}\left\{\begin{array}{rll}%
        \BODY%
    \end{array}\right.\end{equation}}
share|improve this answer
1  
It does. but there is nothing wrong with there definition as posted either. –  David Carlisle Nov 8 '12 at 9:21
    
@DavidCarlisle: Ok, just saw your answer. Good to know, I just did not try it myself ;-) –  canaaerus Nov 8 '12 at 9:22
    
Yes, it quite helpful in some other circumstances. –  user19832 Nov 8 '12 at 13:20

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.