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.

How can I align arrays like the ones below so that they start at the same distance from the left edge of the paper?

\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}

\begin{document}

  \begin{itemize}
    \item Lorem ipsum dolor sit lorem ipsum dolor sit lorem ipsum dolor sit l
      \[\begin{array}{l}
          a + b = c \\
          a + c = b \\
          a + b = c
      \end{array}\]
    \item Lorem ipsum dolor sit lorem ipsum dolor sit lorem \[ a + b + c + d + e + f = g \]
    \item Lorem ipsum dolor sit lorem ipsum dolor sit lorem ipsum dolor sit lorem ipsum dolor sit lorem ipsum dolor sit l
      \[\begin{array}{l}
          a = x \\
          a + b = y \\
          a + b + c = z
      \end{array}\]
  \end{itemize}

\end{document}

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

You can left justify equations using the flalign and flalign* environments from the amsmath package. To indent the equations, just include an appropriate amount of space in the first line of each environment.

\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\newcommand{\myindent}{\hspace*{2cm}}

\begin{document}
  \begin{itemize}
    \item Lorem ipsum dolor sit lorem ipsum dolor sit lorem ipsum dolor sit l
      \begin{flalign*}
          \myindent & a + b = c & \\
          & a + c = b & \\
          & a + b = c &
      \end{flalign*}
    \item Lorem ipsum dolor sit lorem ipsum dolor sit lorem
     \begin{flalign*}
     \myindent & a + b + c + d + e + f = g &
     \end{flalign*}
    \item Lorem ipsum dolor sit lorem ipsum dolor sit lorem ipsum dolor sit lorem ipsum dolor sit lorem ipsum dolor sit l
      \begin{flalign*}
          \myindent & a = x & \\
           & a + b = y & \\
           & a + b + c = z &
      \end{flalign*}
  \end{itemize}

\end{document}

There is a temptation to define a new environment that automatically inserts a \myindent inside an flalign, but doing this sort of thing with an amsmath environment usually ends in tears (see section 6 of the amsmath technical note for details).

share|improve this answer
    
Works like a charm. Thanks a lot! –  aioobe May 27 '11 at 13:16
add comment

While Ian Thompson answer the question asked about aligning the equations on the left, the usual way of aligning equations is on the equal sign. Below I show two different way of doing this (with array as originally set up, and with the align environment from the amsmath package):

  1. Using a \hphantom{} to add the appropriate amount of horizontal space.
  2. Using a \makebox{<size>}{<text>} to set the given text in the appropriate amount of space.

Notes:

  • The calc package provides the \widthof macro to compute the length used by the \FitInBox to typeset the left hand side of the equation with a right alignment within the approriate amount of space.

All yields similar results:

enter image description here

Code:

\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}% provides the align environment
\usepackage{calc}% for the \widthof macro


\begin{document}
Using \verb|array| along with \verb|\hphantom{}|:
  \begin{itemize}
    \item Lorem ipsum dolor sit lorem ipsum dolor sit lorem ipsum dolor sit l
      \[\begin{array}{r@{}l}
          \hphantom{{}+c+d+e+f} a + c &{}= b \\
          a + c &{}= b \\
          a + b &{}= c
      \end{array}\]
    \item Lorem ipsum dolor sit lorem ipsum dolor sit lorem 
    \[ a + b + c + d + e + f = g \]
    \item Lorem ipsum dolor sit lorem ipsum dolor sit lorem ipsum dolor sit lorem ipsum dolor sit lorem ipsum dolor sit l
      \[\begin{array}{r@{}l}
          a &{}= x \\
          \hphantom{{}+c+d+e+f} a + b &{}= y \\
          a + b + c &{}= z
      \end{array}\]
  \end{itemize}

\hrule\medskip

Using \verb|align| from the \verb|amsmath| package with \verb|\hphantom{}|:
  \begin{itemize}
    \item Lorem ipsum dolor sit lorem ipsum dolor sit lorem ipsum dolor sit l
      \begin{align*}
          \hphantom{{}+c+d+e+f} a + b &= c \\
                                a + c &= b \\
                                a + b &= c
      \end{align*}
    \item Lorem ipsum dolor sit lorem ipsum dolor sit lorem 
    \[ a + b + c + d + e + f = g \]
    \item Lorem ipsum dolor sit lorem ipsum dolor sit lorem ipsum dolor sit lorem ipsum dolor sit lorem ipsum dolor sit l
      \begin{align*}
                                    a &= x \\
          \hphantom{{}+c+d+e+f} a + b &= y \\
                            a + b + c &= z
      \end{align*}
  \end{itemize}

\newpage

\newcommand*{\WidestLeftHandSide}{$a + b + c + d + e + f$}
\newcommand*{\FitInBox}[1]{\makebox[\widthof{\WidestLeftHandSide}][r]{$#1$}}%

Using \verb|align| from the \verb|amsmath| package with \verb|\makebox{}|:
  \begin{itemize}
    \item Lorem ipsum dolor sit lorem ipsum dolor sit lorem ipsum dolor sit l
      \begin{align*}
          \FitInBox{a + b} &= c \\
                     a + c &= b \\
                     a + b &= c
      \end{align*}
    \item Lorem ipsum dolor sit lorem ipsum dolor sit lorem 
    \[ a + b + c + d + e + f = g \]
    \item Lorem ipsum dolor sit lorem ipsum dolor sit lorem ipsum dolor sit lorem ipsum dolor sit lorem ipsum dolor sit l
      \begin{align*}
          \FitInBox{a} &= x \\
                 a + b &= y \\
             a + b + c &= z
      \end{align*}
  \end{itemize}
\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.