1

A simple piece-wise function:

\[ \begin{cases} 
      0 & x\leq 0 \\
      \frac{100-x}{100} & 0\leq x\leq 100 \\
      0 & 100\leq x 
   \end{cases}
\]

It will build as equation (1).

I want it to build as (1a) and (1b).

How to do this? Why is this inadvisable?

2 Answers2

2

With the extension cases:

\documentclass{article}
\usepackage{cases}
\begin{document}
\begin{subequations}
\begin{numcases}{f(x) = }
0 & if $x\leq 0$ \\
\frac{100-x}{100} & if $0\leq x\leq 100$ \\
0 & if $100\leq x$ 
\end{numcases}
\end{subequations}
\end{document}

Result of the above code

F. Pantigny
  • 40,250
1

Here are two ways: with the subnumcases environment from cases, and with alignat and package empheq. Note that in the latter case, needless to load amsmath: the package loads mathtools, which loads amsmath. I also give two variant layouts, one with the formulæ in each case vertically centred w.r.t. each other (uses eqparbox):

\documentclass[a4paper,12pt]{article}

\usepackage{empheq}
\usepackage{cases}
\usepackage{eqparbox}
\newcommand{\eqmathbox}[2][M]{\eqmakebox[#1]{$\displaystyle#2$}}

\begin{document}

\begin{subequations}
 \begin{empheq}[left={f(x) = \empheqlbrace\,}]{alignat = 2}
     & \eqmathbox{0} &\qquad & x\leq 0 \\
      &\eqmathbox{\frac{100-x}{100}} & & 0\leq x\leq 100 \\
      &\eqmathbox{0 }& &100\leq x
   \end{empheq}
\end{subequations}
\bigskip

 \begin{subnumcases}{f(x) =}
  0 & $ x\leq 0 $ \\
  \frac{100-x}{100} & $ 0\leq x\leq 100 $ \\
  0 & $ 100\leq x $
\end{subnumcases}

\end{document} 

enter image description here

Bernard
  • 271,350