How can I align these cases? I also want to keep the equations indexed automatically.
I saw some previous topics on this but I wonder if it can be done without changing too much the code (not rewrite it completely).
\documentclass[journal]{IEEEtran}
\usepackage{amsmath,amsfonts}
\usepackage{algorithmic}
\usepackage{algorithm}
\usepackage{array}
\usepackage[caption=false,font=normalsize,labelfont=sf,textfont=sf]{subfig}
\usepackage{textcomp}
\usepackage{stfloats}
\usepackage{url}
\usepackage{verbatim}
\usepackage{graphicx}
\usepackage{cite}
\hyphenation{op-tical net-works semi-conduc-tor IEEE-Xplore}
% updated with editoria
\usepackage{booktabs}
\begin{document}
\begin{equation}
x_{1, 2} =
\begin{cases}
m x_{n} & \text{if } p_{2}=1 \\
(1-m) x_{n} & \text{if } q_{2}=1 \\
0 & \text{if } (p_{2}=0) \wedge (q_{2}=0)
\end{cases}
\end{equation}
\begin{equation}
x_{k} =
\begin{cases}
\frac{m }{1-m} x_{n}& \text{if } p_{3}\not=0 \\
\frac{(1-m)}{m}x_{n} & \text{if } q_{3}\not=0 \\
\end{cases}
\end{equation}
\end{document}
equation
environments, combine them into a singlealign
environment, placing an&
just before the=
sign in each, and placing\\
after the first\end{cases}
. You may want to add a bit of vertical space there too, say by specifying\\[6pt]
(or other appropriate amount, and no space before the opening bracket). Don't leave any blank lines.