10

I have 2 equations which looks like:

A = B+ C + D... , While x is true.

The problem is, the equation is quite big which goes on for 2 lines. How do I give an indent to the second line so it looks like:

A = B + C + D + E + F +
    G + H + I + ... , while x is true.
cmhughes
  • 100,947

4 Answers4

10

Try something like

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{equation}
\begin{split}
  A ={} & B + C + D + E + F + \\
        & G + H + I + \dots, \quad\text{while $x$ is true}.
\end{split}
\end{equation}
\end{document} 

Output

enter image description here

If you don't want the equation to be numbered use equation* instead of equation.

As Svend suggested in the comment, in this case it is probably better using \dotsb instead of \dots.

enter image description here

karlkoeller
  • 124,410
10

You can use the align environment if you want. Remove the * to get the numbered equation form. The following is MWE:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
A {}={} & B + C + D + E + F +\\
        & G + H + I + \dotsb, \quad \text{while $x$ is true.}
\end{align*}
\end{document}

Another flavor would be like:

\[
\begin{aligned}
A {}={} & B + C + D + E + F +\\
        & G + H + I + \dotsb, \quad \text{while $x$ is true.}
\end{aligned}
\]

or

\[
\begin{array}{r@{}c@{}l}
A   &{}={}& B + C + D + E + F +\\
    &     & G + H + I + \dotsb, \quad \text{while $x$ is true.}
\end{array}
\]

This does not give any numbered version but keeps the alignment. I recommend you read the amsmath documentation and other math related sources to get acquainted with alignments in equations. For example, here in TeX.SX you can make a quick search and you will see several examples of alignment. For instance if I search alignment in equations I would get lots of examples. (click me)

I will also invite you to read the following links:

  1. https://tex.stackexchange.com/a/147149/10898
  2. https://tex.stackexchange.com/a/122497/10898
karlkoeller
  • 124,410
azetina
  • 28,884
2

You also may use the multlined environment if you load the mathtools package (don't load amsmath in that case, it does it for you) ; this code lets you shift the second equation with respect to the first one, instead of aligning them

\begin{equation}  
  \begin{multlined}  
   A = B + C + D + E + F + \\\  
   G + H + I + \dots,\qquad \text{\rlap{while $x$ is true. }}  
  \end{multlined} 
\end{equation}

Here is the result:enter image description here

Bernard
  • 271,350
  • By the way, how does one incorporate a nice-looking output? I converted my pdf to a png, but the result displays poorly. – Bernard Nov 29 '13 at 21:59
1

Just for comparing Karlkoeller's answer that used split with mine that uses aligned.

\documentclass[preview,border=12pt]{standalone}
\usepackage[a5paper,landscape]{geometry}
\usepackage{amsmath}

\begin{document}

\begin{minipage}{.5\linewidth}
\hrulefill
\begin{equation}  
\begin{split}
A = {} 
& B + C + D + \\
& E + F + \\
& G + H + I + \dots, \quad\text{using split}.
\end{split}
\end{equation}
\hrulefill
\end{minipage}
\begin{minipage}{.5\linewidth}
\hrulefill
\begin{equation}  
A = 
\!
\begin{aligned}[t]
& B + C + D + \\
& E + F + \\
& G + H + I + \dots, \quad\text{using aligned}.
\end{aligned}
\end{equation}
\hrulefill
\end{minipage}

\end{document} 

enter image description here

karlkoeller
  • 124,410