Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have this weird requirement, to align two sets of numbers, one under another, in groups of three.

Here is how it should look:

desiredResult

I tried the following:

\begin{align*}
x_F &= 1.368 &808 & 107 & 853 & 223 &5… \text{ — Approximate answer;}\\
x_T &= 1.368 &808 & 107 & 821 & 372 &6… \text{ — true (correct) value.}
\end{align*}

but all I get is this: myResult

As you can see for some reason 808107 does not want to separate!

P.S.: Bonus points if you give me a hint on how to align that text on the right too!

share|improve this question
    
\num{} command from siunitx may be? Or, if you prefer manually, just add \, where you want that tiny space. By the way that's not a correct way of using align. In your code, only the & before the = should be there, the other aligning/spacing shouldn't be obtained in that way. And what do you exactly want to align in the right? –  Manuel Mar 6 '13 at 21:41
    
otherwise alignat –  cmhughes Mar 6 '13 at 21:46
add comment

2 Answers

There are a number of ways to obtain this, but siunitx provides this in the most consistent (and manageable) way possible:

enter image description here

\documentclass{article}
\usepackage{siunitx,amsmath}% http://ctan.org/pkg/{siunitx,amsmath}
\begin{document}
\begin{align*}
x_F &= 1.368 &808 & 107 & 853 & 223 &5\ldots \text{ -- Approximate answer;}\\
x_T &= 1.368 &808 & 107 & 821 & 372 &6\ldots \text{ -- true (correct) value.}
\end{align*}
\begin{alignat*}{6}
x_F &= 1.368 &\,& 808 &\,& 107 &\,& 853 &\,& 223 &\,& 5\ldots \text{ -- Approximate answer;}\\
x_T &= 1.368 &\,& 808 &\,& 107 &\,& 821 &\,& 372 &\,& 6\ldots \text{ -- true (correct) value.}
\end{alignat*}
\begin{align*}
x_F &= \num{1.3688081078532235}\ldots \text{ — Approximate answer;}\\
x_T &= \num{1.3688081078213726}\ldots \text{ — true (correct) value.}
\end{align*}
\end{document}

The above alignat inserts a \, (\thinspace) at at the required alignment locations. However, by default, \num from siunitx has a three-digit separation. Moreover, the code is legible, and easily modifiable.

This naturally leads to a correct left-alignment of the text.

share|improve this answer
add comment

enter image description here

You can use the fact that the default math font uses digits that are all the same width, so you only need one alignment point.

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{align*}
x_F &= 1.368 \,808 \, 107 \, 853 \, 223 \,5\ldots \quad \text{ --- Approximate answer;}\\
x_T &= 1.368 \,808 \, 107 \, 821 \, 372 \,6\ldots \quad \text{ --- true (correct) value.}
\end{align*}

\end{document
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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