I want to get this function:

enter image description here

I wrote two options, but I can't match the picture. Here is the first one:

                \frac{N-i}{N}&\text{si }j=i+1\\
                \frac{i}{N}&\text{si }j=i-1\\
                0&\text{otro caso}

Case 1

And here is the second one: (This one is kind of compressed)

                \dfrac{N-i}{N} & \text{si }j=i+1\\
                \dfrac{i}{N} & \text{si }j=i-1\\
                0 & \text{en otro caso}

How can improve the code?. Thanks for the support.

  • What kind of "improvement" are you looking for?
    – Werner
    Jan 18, 2017 at 5:44
  • 1
    A minor suggestion: Use \mid instead of | to denote conditioning on some event.
    – Mico
    Jan 18, 2017 at 5:59
  • (Or \newcommand{\given}{\mid}, but yes.)
    – wchargin
    Jan 18, 2017 at 20:10

4 Answers 4


The issue seems to be that you want the "column" to the right of the brace to be centered rather than left justified, which is what happens in all of the cases environments (at least, in all of the ones that I know about). To fix this this the OP's idea of using an array seems to be the way to go, but a few tweaks are needed.

  • First, if you use \left\{ then there has to be a matching \right<delimiter>. As there isn't a matching right delimiter, in this case, you can use \right.. Personally, I don't like the sizes that \left....\right produces so, instead, I have defined a macro \Bigger that will scale the following delimiter to the specified height in millimeters, which defaults to 7mm. Except for the optional argument, this is similar to the \bigl, \biggl, \Big ... amsmath macros.
  • Next, as the OP says, the rows of the array are too close together. You can adjust the spacing between rows using the optional argument to the \\ command. So \\[3mm] will add an extra 3mm between the rows, which seems about right.
  • The array environment comes with padding, so there is too much space between the brace and the equations. You can remove the left-padding by adding @{} to the array specifications.
  • I have added some punctuation.
  • Finally, as suggested in the comments, \mid is better than |.

With these changes the MWE produces:

enter image description here

This is pretty close to the "ideal" image given at the top of the question. Here is the full code:


% an ams-style operator for resizing delimiters
% Usage: \Bigger[, \Bigger[8][, \Bigger[10](, ...


                \dfrac{N-i}{N}, & \text{si }j=i+1,\\[3mm]
                \dfrac{i}{N},   & \text{si }j=i-1,\\[3mm]
                0,              & \text{en otro caso}.


This seems to be a precise stylistic choice, so you should somehow make it the default by defining your own environment.


\makeatletter % some generic helpers



  \frac{N-i}{N} & si $j=i+1$,\\
  \frac{i}{N}  & si $j=i-1$,\\
  0            & en otro caso.


The ecases environment has the second column cells typeset in math mode, whereas in ecases* they're in text mode.

enter image description here

Say that the publisher to whom you submit your book tells you their editorial policy is to align left the cases. You can answer that it's really easy, because returning to the default just requires changing two lines:


and you'd get

enter image description here

  • I couldn't find \newcases described in either the amsmath or mathtools manuals, however, @Werner has given a nice description of it in his answer to tex.stackexchange.com/questions/27520/….
    – user30471
    Jan 18, 2017 at 8:59
  • @Andrew Yes, it's not really documented and perhaps it should be expanded a bit to allow for avoiding low level functions (something like I did it my code).
    – egreg
    Jan 18, 2017 at 9:24
  • 1
    Funny, I thought I had documented this back in the day but you are correct: it's not mentioned in the manual and should be. Jan 18, 2017 at 15:21
  • @MortenHøgholm I'm quite sure that at some point in time the macro was documented. Maybe adding some boilerplate macros like above would make it friendlier.
    – egreg
    Jan 18, 2017 at 17:47
  • @egreg I checked in my old sources and I didn't have it there either. Perhaps Lars has time to add it. Jan 18, 2017 at 17:59

Here, I use a TABstack for the cases. In particular, a \tabularCenterstack allows the column alignments to be individually specified. The baselineskip between cases can be simply set, as shown in the MWE.

\TABstackMathstyle{\displaystyle}% DEFINE STYLE OF MATH STACKS
\setstackgap{L}{2.5\baselineskip}% SETS BASELINESKIP FOR LONG-STACKED LINES
\setstacktabulargap{2\tabcolsep}% DEFINES INTERCOLUMN GAP
                \frac{N-i}{N}&\text{si }j=i+1\\
                \frac{i}{N}&\text{si }j=i-1\\
                0&\text{otro caso}

enter image description here


I would actually like to suggest that you not fully replicate the screenshot you've posted.

Instead, I'd go for a fully symmetrical look, in which the = symbols in the middle row to the right of the curly brace are perfectly aligned with the = symbols to the left. This may be achieved easily with the help of a judiciously constructed \vphantom term.

enter image description here

\usepackage{mathtools} % for 'dcases*' env.
\newcommand\zzz{\vphantom{\dfrac{\mathstrut}{\mathstrut}}} % to be inserted in all 3 rows
        \Pr[\, \chi^{}_{n+1}=j \mid \chi^{}_{n}=i \,]=
                \frac{N-i}{N}\zzz & si $j=i+1$\\
                \frac{i}{N}\zzz   & si $j=i-1$\\
                0 \zzz            & otro caso

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.