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'm looking for something synonymous to tabbing, but for math mode.

I read that alignat* should do the trick, but this behaves differently it seems. For example:

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{alignat*}{2}
S_4^{t} &= \{&\langle rdi, r12, rax' \rangle \mid \langle rdi, r12, rax \rangle \in S_4~\wedge \\
&& rax' = \{ rax \mid rax > 0 \} \}\\
\end{alignat*}

\end{document}

The second line appears to be right aligned, whereas I would like the & markers to be aligned with each other and then all text left aligned (like in tabbing).

Is anyone able to fix this code, or suggest an alternative.

share|improve this question
2  
Welcome to TeX.SE, and thanks for posting a complete MWE. –  Peter Grill Sep 10 '12 at 20:36
add comment

1 Answer

As per Math indentation environment, the alignat provides multiple rl align pairs. Since your second alignment is intended to be l aligned, you need to use a double &&. The first & skips over the r aligned column of the rl align pair:

enter image description here

Notes:

  • The align environment also provides multiple rl alignment pairs. However, the alignat does not insert additional space that the align environment does between the rl alignment pairs. So, for cases where a separation is required between the alignment points with the alignat environment those would need to be inserted manually.
  • An alternative is to use the array environment. But one does need to be careful to remove inter column spacing using @{}, and to ensure that the relational or binary operators have the correct spacing by using {} to make TeX think that there is an element on the other side of the operator. This produces results identical to the above.

Code:

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{alignat*}{3}
S_4^{t} &= \{&&\langle rdi, r12, rax' \rangle \mid \langle rdi, r12, rax \rangle \in S_4~\wedge \\
        &    &&rax' = \{ rax \mid rax > 0 \} \}
\end{alignat*}

\[\begin{array}{l@{}l@{}l}
S_4^{t} &{}= \{&\langle rdi, r12, rax' \rangle \mid \langle rdi, r12, rax \rangle \in S_4~\wedge \\
        &      &rax' = \{ rax \mid rax > 0 \} \} \\
\end{array}\]
\end{document}
share|improve this answer
    
Thanks for your answer. Is there an environment that aligns all cells left? There must be. –  vext01 Sep 10 '12 at 21:21
    
@vext01: You could use the array environment, but have to be careful about math spacing issues. I'll add an example. –  Peter Grill Sep 11 '12 at 3:56
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.