# How to align decimal points when using cases statement

I have a statement like

\begin{equations*}
\begin{cases}
{\zeta}_{A} = -10.1234567 \cdots, \\
{\zeta}_{B} = 1{,}001.2345678 \cdots.
\end{cases}
\end{equations*}


How do I align the decimal points with the equations being left justified and the case spacing remaining unaffected.

A solution that uses an array environment; note that using a cases environment seems like overkill for the case (pun intended) at hand. \documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
\left\{
\begin{array}{@{} r @{{}={}} r}
\zeta_A & -10.1234567\cdots,\\
\zeta_B & 1{,}001.2345678\cdots.\\
\end{array} \right.
\end{equation*}
\end{document}


Addendum: The preceding solution assumes that both numbers have the same number of digits following the decimal marker. If this assumption isn't valid, the following modified solution, which still uses an array environment but now employs three rather than just two columns, should work for you. \documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
\left\{
\begin{array}{@{} r @{{}={}} r @{.} l}
\zeta_A     &     -10 & 1234\cdots,\\
\zeta_{BCD} & 1{,}001 & 12345678901 \cdots.\\
\end{array} \right.
\end{equation*}
\end{document}

• but this works as desired only if you've got the same number of digits following the decimal point. – barbara beeton Dec 26 '14 at 15:33
• @barbarabeeton - Thanks. I've posted an addendum to provide a solution that works in the general case. – Mico Dec 26 '14 at 16:50

Some \phantoms can be used to push content into the appropriate location. Overlapping allows also for accommodating for the use of \phantoms. \documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{align*}
A &= \begin{cases}
\zeta_A = -10.1234567 \cdots, \\
\zeta_B = 1{,}001.2345678 \cdots.
\end{cases} \\
B &= \begin{cases}
\rlap{$\zeta_{A}$}\phantom{\zeta_B} = \phantom{1{,}001}\llap{$-10$}.1234567 \cdots, \\
\zeta_B = 1{,}001.2345678 \cdots.
\end{cases}
\end{align*}

\end{document}


With siunitx and its powerful features for printing numbers.

\documentclass{article}
\usepackage{amsmath,siunitx}

\newenvironment{xcases}[]
{\left\lbrace\def\arraystretch{1.2}% like cases does
\begin{array}{
@{} r @{}
>{{}}c<{{}} @{}
S[table-format=#2,table-space-text-post={#1}] @{}
}}
{\end{array}\right.}

\begin{document}

\begin{equation*}
\begin{xcases}[$\,\cdots$,]{4.7}
\zeta_A &=& -10.1234567$\,\cdots$, \\
\zeta_B &=& 1001.2345678$\,\cdots$.
\end{xcases}
\end{equation*}

\begin{equation*}
\begin{xcases}{-4.7}
\zeta_A &=& -1001.1234567 \\
\zeta_B &=&  1001.2345678
\end{xcases}
\end{equation*}

\end{document}


The mandatory argument is the number format; in the first case four digits for the integral part and seven for the fractional part. Also some text can be added, the optional argument is a literal text that specifies the allotted space. In the second case, four digits and the sign for the integral part. • To replicate the "look" specified by the OP a bit more closely, you could set the options group-digits=integer, group-four-digits=true, and group-separator={,} when loading siunitx. – Mico Dec 27 '14 at 0:00
• @Mico Separating thousands with a comma is forbidden by my religion. ;-) – egreg Dec 27 '14 at 0:05

Use of tabular with @{.} skill as an alternative. Further Mico's kind reminder: use of array. Code

\documentclass[]{article}

\usepackage{amsmath,array}

\begin{document}
Given

$\begin{cases} {\zeta}_{A} = -10.1234567 \cdots, \\ {\zeta}_{B} = 1{,}001.2345678 \cdots. \end{cases}$

Suggested
$\begin{cases} \begin{tabular}{ >{}r<{} @{ = } >{} r <{} @{.} >{}l<{}} {\zeta}_{A} & -10 & 1234567 \cdots, \\ {\zeta}_{B} & 1{,}001 & 2345678 \cdots. \end{tabular} \end{cases}$

@Mico's credits

$\begin{cases} \begin{array}{ r @{ = } r @{.} l} {\zeta}_{A} & -10 & 1234567 \cdots, \\ {\zeta}_{B} & 1{,}001&2345678 \cdots. \end{array} \end{cases}$

\end{document}

• Ha, thanks Mico, you are quite right. I knew something can be improved, just can not think of it. will add one more option. soon. – Jesse Dec 26 '14 at 4:31
• In the array example, you should specify @{{}={}} rather than @{ = } to get an amount of spacing that's appropriate for an item of type mathrel. (@{ = } treats = as being of type mathord.) – Mico Dec 26 '14 at 4:48
• Yes, indeed. You have shown that. Will keep that in mind. – Jesse Dec 26 '14 at 4:51

Here I use the tabstackengine package. The OP's example can be done with a \tabbedCenterstack, though I then show a slightly more difficult version that requires a \tabularCenterstack.

\documentclass{article}
\usepackage{amsmath,tabstackengine}
\setstackEOL{\#}% end-of-line character in stack
\setstackTAB{\&}% end-of-field character in stack
\setstackgap{L}{16pt}% Inter-baseline gap in stack
\setstacktabulargap{0pt}% Inter-field gap in tabularstack
\stackMath
\begin{document}
\begin{equation*}
\begin{cases}
\tabbedCenterstack[r]{\zeta_{A} =\& -10.\&1234567 \cdots,\#
\zeta_{B} =\& 1,001.\&2345678 \cdots.}%
\end{cases}
\end{equation*}
\begin{equation*}
\begin{cases}
\tabularCenterstack{rrl}{\zeta_{AC} =\& -10.\&1234 \cdots,\#
\zeta_{B} =\& 1,001.\&2345678 \cdots.}%
\end{cases}
\end{equation*}
\end{document} • I am trying to use the tabstackengine example and I am using TexShop on a Mac. I can't properly install the package. Any suggestions. – menkelh Dec 26 '14 at 19:09
• @menkelh The package is at ctan.org/pkg/tabstackengine. If you download the .sty file in your working directory it should compile. In the long run, you need to find out where TeXShop stores its downloaded packages and put it there. (I myself use MikTeX, and so I am of no help for that). The PDF documentation is also available at the ctan site. – Steven B. Segletes Dec 26 '14 at 19:19