6

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.
  • You can use the align or array environment. – azetina Nov 29 '13 at 15:37
7

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
  • If you remove the * you get two numbered equations. – karlkoeller Nov 29 '13 at 15:47
  • @karlkoeller Oops guess am still sleepy...... – azetina Nov 29 '13 at 15:49
  • Thank you. Your first example worked. I do not have a lot of equations, just a few here and there. – ctrl-shift-esc Nov 29 '13 at 16:16
  • @ctrl-shift-esc glad to have helped. happy texing – azetina Nov 29 '13 at 16:18
8

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

  • \dots --> \dotsb. – Svend Tveskæg Nov 29 '13 at 15:56
  • @SvendTveskæg Yes, in this case it is probably the best choice. – karlkoeller Nov 29 '13 at 16:02
1

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

  • 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
0

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

  • I suggest making the following adjustment & E + F +{} \\ to fine tune the alignment. – azetina Nov 29 '13 at 22:35
  • @azetina: That is correct. I will edit later. – kiss my armpit Nov 29 '13 at 23:05

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.