2

I have the following equation:

\documentclass{article}

\usepackage{amsmath}
\usepackage{cases}

\begin{document}

\begin{numcases}{x = }
    \label{eq:case1} x+1\\                        
    \label{eq:case2} x-1\\                       
    \label{eq:case3} x/3         
\end{numcases}

\end{document}

I want to add conditions in the way shown in the picture below, while maintaining the numbering of the individual cases, as in the initial equation. I tried inserting the second and third cases in an array, but that creates only one numbering for them. Any recommendations would be much appreciated.

enter image description here

1 Answer 1

5

One way is to employ raisebox for moving comment condition for the second and third and ˙TikZ library tikzmark for drawing curly brace. In this are used decorations.pathreplacing and calligraphy libraries:

\documentclass[margin=3mm, varwidth]{standalone}

\usepackage{amsmath}
\usepackage{cases}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,%
                    calligraphy,% had to be after decorations.pathreplacing
                tikzmark}
\tikzset{
BC/.style = {
        decorate,
        decoration={calligraphic brace, amplitude=4pt,
                    raise=1pt, #1},% #1 is for mirroring of brace, if needed
        very thick},
        }

\begin{document}

\begin{numcases}{x = }
    \label{eq:case1} x+1                    & if $x=3$     \\
    \label{eq:case2} \tikzmarknode{A}{x-1}  & \smash{\raisebox{-0.75\baselineskip}{if $x=1$}}     \\
    \label{eq:case3} \tikzmarknode{B}{x/3}  &
\end{numcases}
\begin{tikzpicture}[overlay, remember picture]
\draw[BC] (A.north east) -- (A.north east |- B.south);
\end{tikzpicture}

see \ref{eq:case1}, \ref{eq:case2} and \ref{eq:case3} ...

\end{document}

enter image description here

4
  • 1
    The x=3 part should probably be in math.
    – mickep
    Sep 19 at 14:48
  • 1
    @mickep, of course! Corrected now. Thank you very much for pointing me to this a embarrassing error.
    – Zarko
    Sep 19 at 14:53
  • Thank you so much for your answer, it is exactly what I wanted! I guess there is no easier way to do this, right?
    – E-O
    Sep 19 at 15:02
  • 1
    @E-O, maybe it exist, however now no other cross my mind :-)
    – Zarko
    Sep 19 at 15:21

You must log in to answer this question.

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