# Efficient way to align columns in cases environment

I wanted to know if there was an efficient way to align the first column in a cases environment instead of using the \phantom code as I have used below?

The code I did somehow feels like a hack???

Here is the code:

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{equation*}
-\tau \ddot{e} - \dot{e} = %
\begin{cases}
\phantom{-}A; & e+T_{L}\dot{e}>0\\
\phantom{-~}0; & e + T_{L}\dot{e}=0\\
-A; & e+T_{L}\dot{e}<0
\end{cases}
\end{equation*}

\end{document}


Without cases, one could

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
-\tau \ddot{e} - \dot{e} = %
\left\{\begin{aligned}
A; && e+T_{L}\dot{e}&>0\\
0; && 1e + T_{L}\dot{e}&=0\\
-A; && e+T_{L}\dot{e}&<0
\end{aligned}\right.
\end{equation*}
\end{document}


This also aligns on the right-hand relational operator.

Alternately, if one desired more control over the equation baselineskip in the case, one could use a TABstack. The vertical baselineskip is set via \setstackgap{L}{<length>}. Similarly, the horizontal gap between align groups can be set via \setstackaligngap{<length>} (default 1em).

\documentclass{article}
\usepackage{amsmath,tabstackengine}
\TABstackMath
\setstackgap{L}{1.3\normalbaselineskip}% EQ BASELINESKIP SET HERE
\begin{document}
\begin{equation*}
-\tau \ddot{e} - \dot{e} = %
\left\{\alignCenterstack{
A; && e+T_{L}\dot{e}&>0\\
0; && 1e + T_{L}\dot{e}&=0\\
-A; && e+T_{L}\dot{e}&<0
}\right.
\end{equation*}
\end{document}


Use eqparbox's \eqmakebox[<tag>][<align>]{<stuff>} to set all <stuff> with the same <tag> in a box of maximum width. You can also adjust the <align>ment as needed.

\documentclass{article}

\usepackage{amsmath,eqparbox}

\begin{document}

% Original
\begin{equation*}
-\tau \ddot{e} - \dot{e} = %
\begin{cases}
\phantom{-}A; & e + T_{L}\dot{e} > 0 \\
\phantom{-~}0; & e + T_{L}\dot{e} = 0 \\
-A; & e + T_{L}\dot{e} < 0
\end{cases}
\end{equation*}

% Updated
\begin{equation*}
-\tau \ddot{e} - \dot{e} =
\begin{cases}
\eqmakebox[lhs][r]{$A$}; & e + T_L \dot{e} > 0 \\
\eqmakebox[lhs][r]{$0$}; & e + T_L \dot{e} = 0 \\
\eqmakebox[lhs][r]{$-A$}; & e + T_L \dot{e} < 0
\end{cases}
\end{equation*}

\end{document}


Since eqparbox uses the .aux file to gather the maximum width, you need at least two compilations on the first go (or with any change in the boxes) for the maximum width to be established.

Without cases, one could

\def\casesR#1{\left\{\vcenter{\openup2pt
\halign{\hfil$##$&&\quad\hfil$##$\cr#1\crcr}}\right.}
$$-\tau \ddot e - \dot e = \casesR{ A; & e + T_L \dot e > 0 \cr 0; & 1e + T_L \dot e = 0 \cr -A; & e + T_L \dot e < 0 }$$

\bye


The empheq package with its left key, combined with the alignat* environment gives a particularluy simple code. Note you don't have to load amsmath, since empheq loads mathtools, which loads and extends the former: \documentclass{article} \usepackage{empheq}

\begin{document}

\begin{empheq}[left ={-\tau \ddot{e} - \dot{e} =\empheqlbrace}]{alignat* = 2}