16

Consider the following example:

\documentclass{article}
\usepackage{amsmath,amssymb}
\begin{document}
    \begin{align}
    \prod a+bm      && \text{is a square in} && \mathbb{R}\\
    \prod a+b\theta && \text{is a square in} && \mathbb{R}[\theta]
    \end{align}

    \begin{eqnarray}
    \prod a+bm      & \text{is a square in} & \mathbb{R}\\
    \prod a+b\theta & \text{is a square in} & \mathbb{R}[\theta]
    \end{eqnarray}
\end{document}

enter image description here

The amount of white spce used by eqnarray is exactly what I want, whereas align adds a (in my opinion) freakishly large amount of white space. So I could just stick with eqnarray, but I've read that I should always (under any circumstances) refrain from using it.

So my question is, how do I make my equation look nice using align?

  • 1
    Why do you use two ampersands in the align environment and not just one? – malin Jul 27 '13 at 13:31
  • @malin Because if I use only one, then everything looks very messy. – Phil-ZXX Jul 27 '13 at 13:39
  • I added flush left for you. – dustin Jul 27 '13 at 13:43
19

You could use the alignat environment, which is similar to align.

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{mathtools}
\usepackage{amssymb}

\begin{document}
  \begin{alignat}{2}
    \prod a+bm      &\quad \text{is a square in} &&\quad\mathbb{R}\\
    \prod a+b\theta &\quad \text{is a square in} &&\quad\mathbb{R}[\theta]
  \end{alignat}
\end{document}

In the »Math mode« document you can find more about advanced math typesetting.


enter image description here


Update:

As requested the same example but with all columns left aligned.

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{mathtools}
\usepackage{amssymb}

\begin{document}
  \begin{alignat}{3}
    &\prod a+bm      &&\quad \text{is a square in} &&\quad\mathbb{R}\\
    &\prod a+b\theta &&\quad \text{is a square in} &&\quad\mathbb{R}[\theta]
  \end{alignat}
\end{document}

enter image description here

  • Great, just one more question: Is it possible to have the two products, i.e. the capital PIs, right underneath each other (just like the two Rs are right underneath each other)? – Phil-ZXX Jul 27 '13 at 13:36
  • @Tom: I have edited my answer accordingly. – Thorsten Donig Jul 27 '13 at 14:09
  • Is it possible to have center-aligned equations with alignat, as in the original question? Or only flushed left? – Dr_Zaszuś May 11 '15 at 13:22
5
\documentclass{article}
\usepackage{amsmath, amssymb}
\begin{document}
\begin{align}                                                                      
  \prod a+bm &\phantom{=} \text{is a square in}\quad \mathbb{R}\\                  
  \prod a+b\theta &\phantom{=} \text{is a square in}\quad \mathbb{R}[\theta]       
\end{align}
\end{document}

enter image description here


Flush left as requested:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\makeatletter
\newenvironment{lflalign}{%                                                         
  \def\align@preamble{%                                                             
    &\strut@                                                                        
    \setboxz@h{\@lign$\m@th\displaystyle{####}$}%                                   
    \ifmeasuring@\savefieldlength@\fi                                               
    \set@field                                                                      
    \hfil                                                                           
    \tabskip\z@skip                                                                 
    &\setboxz@h{\@lign$\m@th\displaystyle{{}####}$}%                                
    \ifmeasuring@\savefieldlength@\fi                                               
    \set@field                                                                      
    \hfil                                                                           
    \tabskip\alignsep@                                                              
  }                                                                                 
  \flalign}
{\endflalign}
\makeatother
\begin{document}
\begin{align}                                                                       
  \prod a+bm & \phantom{=}\text{is a square in}\quad \mathbb{R}\\                   
  \prod a+b\theta & \phantom{=}\text{is a square in}\quad \mathbb{R}[\theta]        
\end{align}
\begin{lflalign}
  \prod a+bm & \phantom{=}\text{is a square in}\quad \mathbb{R}\\
  \prod a+b\theta & \phantom{=}\text{is a square in}\quad \mathbb{R}[\theta]
\end{lflalign}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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