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.

Consider the following piece of code

\documentclass[twocolumn]{article}

\usepackage{amsmath}

\begin{document}

\begin{align*}
A_i &= B_i + C_i\\
&= D_i + E_i+F_i + G_i + H_i\\
&= I_i + J_i+K_i + L_i\\
&\hspace{5.5em},\;i=1,\dotsc,m
\end{align*}

\end{document}

which produces the following output using pdfLaTeX

I would like to automatically align the final line, i.e., i=1,...,m, exactly as in the previous picture (in this example far right is at H_i), without manually setting an \hspace{xx} each time.

How can I do that?

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

You should use alignat to introduce multiple alignment points:

enter image description here

\documentclass[twocolumn]{article}
\usepackage{amsmath,lipsum}% http://ctan.org/pkg/{amsmath,lipsum}
\begin{document}

\lipsum*[1]
\begin{alignat*}{2}
  A_i &= B_i + C_i \\
      &= D_i + E_i+F_i + G_i + H_i \\
      &= I_i + J_i+K_i + L_i \\
      &                           &&i = 1,\dotsc,m
\end{alignat*}
\lipsum*[2]
\end{document}

The above introduces a left-alignment of i=.... To obtain a right-alignment, use \llap{$i = 1,\dotsc,m$}. This introduces a left overlap at the correct alignment position:

enter image description here

%...
\begin{alignat*}{2}
  A_i &= B_i + C_i \\
      &= D_i + E_i + F_i + G_i + H_i \\
      &= I_i + J_i + K_i + L_i \\
      &                             &&\llap{$i = 1,\dotsc,m$}
\end{alignat*}
%...

An illustration of the different alignment options using amsmath is given in Herbert's mathmode document. See section 25 align environments (p 43):

enter image description here

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.