I have the following code, where I have multiple cases and all need to be labelled. I tried using subnumcases, however I wanted some freedom in labelling (the $k^{th}$ case must be labelled C.k etc), which I could not achieve when using that custom package. I also tried to use two alignment tabs, using alignat, but that does not work inside cases environment.

When I tried to label manually, the labels are not right-aligned, and as such they appear odd. Is it possible to at least right align the manual equation labels? Or is there an elegant way to present these equations?

\usepackage{amsmath, amsfonts, amssymb, bbm, cases}

f(x) =
   x_1, & \text{if } x\in(\sum_{i=1}^n b_i\log(a_i/b_i)-(\sum_{i=1}^n b_i) \log(a_1/b_1),\infty),\quad \text{(C\textsubscript{1})}\\
  x_2, & \text{if } x\in (\sum_{i=2}^n b_i\log(a_i/b_i) -(\sum_{i=2}^n b_i) \log(a_2/b_2), \\ & \sum_{i=1}^n b_i\log(a_i/b_i) -(\sum_{i=1}^n b_i)\log(a_1/b_1)),\quad \text{(C\textsubscript{2})} \\
   & \vdots \\
   x_k, & \text{if } x\in (\sum_{i=k}^n b_i\log(a_i/b_i) -(\sum_{i=k}^n b_i) \log(a_k/b_k), \\ &\sum_{i=k-1}^n b_i\log(a_i/b_i) -(\sum_{i=k-1}^n b_i)\log(a_{k-1}/b_{k-1})),\quad \text{(C\textsubscript{k})}\\
   & \vdots \\
   x_n, & \text{if } x\in (0, \sum_{i=n-1}^n b_i\log(a_i/b_i) -(\sum_{i=n-1}^n b_i) \log(a_n/b_n)),\quad \text{(C\textsubscript{n})}.
  • 2
    See the empheq package, I think it is even an example in the manual. Btw: you have an error, there is no A4 class option it us called a4paper
    – daleif
    Jun 21, 2016 at 16:35
  • Off-topic: \geometry{left=1in,right=1in,top=1in,bottom=1in} may be written more succinctly as \geometry{margin=1in}.
    – Mico
    Jun 21, 2016 at 16:53

2 Answers 2


The following sets up a specific numcases environment to have the sequential numbering C1, C2, Ck, Cn using \setupnumcases. The setup is restored using \restorenumcases.

The idea is to update \theequation - the macro responsible for setting the equation counter or representation - to set a specific list of possibilities in sequence. This sequence is dictated by \thesaveeqncntr, which is used in place of \theequation.

enter image description here

\usepackage[margin=1in]{geometry}% Just for this example

\renewcommand{\thesaveeqncntr}{\ifcase\value{equation} % 0
  \or $C_1$ % 1
  \or $C_2$ % 2
  \or $C_k$ % 3
  \or $C_n$ % 4
  \else ? % 5+
  \setcounter{saveeqncntr}{\value{equation}}% Store equation counter
  \setcounter{equation}{\value{saveeqncntr}}% Restore equation counter


An equation before
  f(x) = ax^2 + bx + c.

Some text before.%
\begin{numcases}{f(x) =}
  x_1, & if $x \in (\sum_{i=1}^n b_i\log(a_i/b_i) - (\sum_{i=1}^n b_i) \log(a_1/b_1),\infty)$, \\
  x_2, & if $x \in (\sum_{i=2}^n b_i\log(a_i/b_i) - (\sum_{i=2}^n b_i) \log(a_2/b_2)$, \nonumber \\
  & $\sum_{i=1}^n b_i\log(a_i/b_i) - (\sum_{i=1}^n b_i)\log(a_1/b_1))$, \\
  & $\vdots$ \nonumber \\
  x_k, & if $x \in (\sum_{i=k}^n b_i\log(a_i/b_i) - (\sum_{i=k}^n b_i) \log(a_k/b_k)$, \nonumber \\
  & $\sum_{i=k-1}^n b_i\log(a_i/b_i) - (\sum_{i=k-1}^n b_i)\log(a_{k-1}/b_{k-1}))$, \\
  & $\vdots$ \nonumber \\
  x_n, & if $x \in (0, \sum_{i=n-1}^n b_i\log(a_i/b_i) - (\sum_{i=n-1}^n b_i) \log(a_n/b_n))$.
Some text after. And an equation after
  f(x) = ax^2 + bx + c.


One would have to update \setupnumcases in order to have a different numbering to a differing numcases.


Like this?

enter image description here

Considering comments to question, the code employ empheq package and also environment multlined from package mathtools, which is called by empheq:


x_1,    & \text{ if } x\in
        \Biggl(\sum_{i=1}^n b_i\log(a_i/b_i)-
            \left(\sum_{i=1}^n b_i\right) \log(a_1/b_1),\infty
        \Biggr),                 \tag{C\textsubscript{1}}        \\
x_2,    & \begin{multlined}[t][0.6\textwidth]
            \text{ if } x\in 
        \Biggl(\sum_{i=2}^n b_i\log(a_i/b_i) - \sum_{i=2}^n b_i \log(a_2/b_2), \\
              \sum_{i=1}^n b_i\log(a_i/b_i) -
            \left(\sum_{i=1}^n b_i\right) \log(a_1/b_1)
                                \tag{C\textsubscript{2}}        \\
        & \vdots                \notag                          \\
x_k,    & \begin{multlined}[t][0.6\textwidth]
            \text{ if } x\in
        \Biggl(\sum_{i=k}^n b_i\log(a_i/b_i)-\sum_{i=k}^n b_i \log(a_k/b_k), \\
            \sum_{i=k-1}^n b_i\log(a_i/b_i) -
            \left(\sum_{i=k-1}^n b_i\right) \log(a_{k-1}/b_{k-1})
                                \tag{C\textsubscript{k}}        \\
        & \vdots                \notag                          \\
x_n,    & \text{ if }
        \Biggl(0, \sum_{i=n-1}^n b_i\log(a_i/b_i) -
            \left(\sum_{i=n-1}^n b_i\right) \log(a_n/b_n)
  • Mathtools does not provide aligned/align (you're using eq numbers), it comes from amsmath. However, if I'm not mistaken, for align I think a modified version of aligned is used, with custom eqn no placement
    – daleif
    Jun 21, 2016 at 18:09
  • 1
    huh, now I see mistake, I didn't use aligned, which is from amsmath but multlined, which is from mathtools. Thank you for pointed k me this.
    – Zarko
    Jun 21, 2016 at 18:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .