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.

Apologies if this has been asked before, but I couldn't find it after searching in a few places. I'm currently working with arrays of equations like the following:

\begin{align}

y_i^3=y_i^2&=z_i^2=z_i^3 &&\text{if\, $1\leq i\leq n-1$}\\

y_iz_iy_i=y_i,\quad &z_iy_iz_i=z_i &&\text{if\, $1\leq i\leq n-1$}\\

y_iz_i&=z_{i+1}y_{i+1} &&\text{if\, $1\leq i\leq n-2$}

\end{align}

But I'd really like to drop the &'s in the equations themselves, so that the equations are centre justified, the "if..." bits are left justified, and I still have labels on each line. If I drop the &'s and change the &&'s to &&&'s, then I get everything I want except that the equations are right justified.

Can anyone help?

share|improve this question
add comment

1 Answer 1

The right-left alignment of align is set up in what is called an "align preamble" (stored in \align@preamble). You can update this preamble to adjust the alignment/layout of the align structure.

Below is a MWE that provides myalign, which centres the "left column" and left-aligns the "right column" within a regular align. In essence, only the "left column" alignment is altered to be centred by inserting an additional \hfil on the right side of the "left column" contents:

enter image description here

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\makeatletter
\newenvironment{myalign}{%
  \def\align@preamble{% Definition taken from amsmath.dtx
    &\hfil
     \strut@
     \setboxz@h{\@lign$\m@th\displaystyle{####}$}%
     \ifmeasuring@\savefieldlength@\fi
     \set@field
     \hfil% <---------- Alignment added
     \tabskip\z@skip
    &\setboxz@h{\@lign$\m@th\displaystyle{{}####}$}%
     \ifmeasuring@\savefieldlength@\fi
     \set@field
     \hfil
     \tabskip\alignsep@
  }\align}{\endalign}
\begin{document}
\begin{align}
  y_i^3 = y_i^2 = z_i^2 = z_i^3 &\qquad \text{if $1 \leq i \leq n-1$} \\
  y_iz_iy_i = y_i, \quad z_iy_iz_i = z_i &\qquad \text{if $1 \leq i \leq n-1$} \\
  y_iz_i = z_{i+1}y_{i+1} &\qquad \text{if $1 \leq i \leq n-2$}
\end{align}

\begin{myalign}
  y_i^3 = y_i^2 = z_i^2 = z_i^3 &\qquad \text{if $1 \leq i \leq n-1$} \\
  y_iz_iy_i = y_i, \quad z_iy_iz_i = z_i &\qquad \text{if $1 \leq i \leq n-1$} \\
  y_iz_i = z_{i+1}y_{i+1} &\qquad \text{if $1 \leq i \leq n-2$}
\end{myalign}
\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.