# Thread: LaTeX question

1. ## LaTeX question

How do you align a series of equations in the center like Krizalid does in this thread?

http://www.mathhelpforum.com/math-he...opic-sums.html

I tried to duplicate the appropriate LaTeX code but don't seem to be able to. Could someone tell me what I'm doing wrong?

\begin{aligned}\int{f(x)g(x)}dx&
=f(x)+200g(x)&
=5\end{aligned}

Code:
\begin{aligned}\int{f(x)g(x)}dx&
=f(x)+200g(x)&
=5\end{aligned}

2. Originally Posted by Mathstud28
How do you align a series of equations in the center like Krizalid does in this thread?

http://www.mathhelpforum.com/math-he...opic-sums.html

I tried to duplicate the appropriate LaTeX code but don't seem to be able to. Could someone tell me what I'm doing wrong?

\begin{aligned}\int{f(x)g(x)}dx&
=f(x)+200g(x)&
=5\end{aligned}

\begin{aligned}\int{f(x)g(x)}dx&
=f(x)+200g(x) \\ &
=5\end{aligned}
You left out the "new line" code \\ after your &

3. You can also use \hfill in case you want the parts between & & to be aligned to the left.

Another command to align things is \begin{gathered} \end{gathered} :
$\begin{gathered}
p \text{ is a prime.} \hfill \\
\text{In } \mathbb{Z}/p \mathbb{Z},~ \forall \overline{n},~ \overline{n}^p-\overline{n}= \prod_{k=0}^{n-1} (\overline{n}-k) \hfill \end{gathered}$

Code:
\begin{gathered}
p \text{ is a prime.} \hfill \\
\text{In } \mathbb{Z}/p \mathbb{Z},~ \forall \overline{n},~ \overline{n}^p-\overline{n}= \prod_{k=0}^{n-1} (\overline{n}-k) \hfill \end{gathered}
$\begin{gathered}
p \text{ is a prime.} \\
\text{In } \mathbb{Z}/p \mathbb{Z},~ \forall \overline{n},~ \overline{n}^p-\overline{n}= \prod_{k=0}^{n-1} (\overline{n}-k) \end{gathered}$

Code:
\begin{gathered}
p \text{ is a prime.} \hfill \\
\text{In } \mathbb{Z}/p \mathbb{Z},~ \forall \overline{n},~ \overline{n}^p-\overline{n}= \prod_{k=0}^{n-1} (\overline{n}-k) \end{gathered}
(without \hfill)

4. \begin{aligned}\int{f(x)g(x)}dx&\\
=f(x)+200g(x)&\\
=5
\end{aligned}

How do I get them lined up correctly?

Code:
\begin{aligned}\int{f(x)g(x)}dx&\\
=f(x)+200g(x)&\\
=5
\end{aligned}

5. The &'s help you align them. Play around with them and you should be able to catch on:

\begin{aligned}
& \int{f(x)g(x)}dx \\
& = f(x)+200g(x) \\
& = 5
\end{aligned}

Code:
\begin{aligned}
& \int{f(x)g(x)}dx \\
&  =  f(x)+200g(x) \\
& = 5
\end{aligned}
__________________________________________________ ____

\begin{aligned}
\int{f(x)g(x)}dx & = f(x)+200g(x) \\
& = 5
\end{aligned}

Code:
\begin{aligned}
\int{f(x)g(x)}dx & = f(x)+200g(x) \\
& = 5
\end{aligned}

6. \begin{aligned}
A_n&=\int{f(x)g(x)}dx\\
&=f(x)+200g(x)\\
&=5\\
&=4+1\\
&=\frac{5!}{4!}\\
&=\frac{\int_0^{\infty}t^5e^{-t}dt}{\int_0^{\infty}t^4e^{-t}dt}
\end{aligned}

Thank you