5

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}
7

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.

enter image description here

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}

enter image description here

| improve this answer | |
3

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.

enter image description here

\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.

| improve this answer | |
1

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
| improve this answer | |
1

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}
A; &\quad& e+T_{L}\dot{e}&>0\\
0; && 1e + T_{L}\dot{e}&=0\\
-A; && e+T_{L}\dot{e}&<0
\end{empheq}

\end{document} 

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.