GeneralAn issue with a multiline formula

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Rc3g
Posts: 6
Joined: Mon Dec 01, 2008 6:34 pm

An issue with a multiline formula

Post by Rc3g »

Hi, I'm trying to typeset a definition, but I'm not getting things aligned the way I want them to. This is the code:

Code: Select all

\begin{eqnarray*}
p_n & = m_{(n)} = \sum_{i} x_i^n,			& n \geq 1 \\
p_{\lambda} & = p_{\lambda_1} p_{\lambda_2} \dotsb,	& \text{if } \lambda = (\lambda_1, \lambda_2, \dotsc).
\end{eqnarray*}
and as you can see in the attached image, the first equals sign in each row are not aligning properly. Can anything be done about this?
Attachments
f.PNG
f.PNG (3 KiB) Viewed 2756 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
balf
Posts: 158
Joined: Sat Jan 12, 2008 1:11 am

An issue with a multiline formula

Post by balf »

First, you shouldn't use eqnarray: it is obsolete and it may give bad spacing. Load amsmath instead, and the align* environment:

Code: Select all

\begin{align*}
p_n & = m_{(n)} = \sum_{i} x_i^n,         \quad n \geq 1 \\
p_{\lambda} & = p_{\lambda_1} p_{\lambda_2} \dotsb,   \quad \text{if } \lambda = (\lambda_1, \lambda_2, \dotsc).
\end{align*}
I'm not sure whether the second alignment is necessary: if you want it, just write

Code: Select all

\begin{align*}
p_n & = m_{(n)} = \sum_{i} x_i^n,         && n \geq 1 \\
p_{\lambda} & = p_{\lambda_1} p_{\lambda_2} \dotsb,   &&\text{if } \lambda = (\lambda_1, \lambda_2, \dotsc).
\end{align*}
and if you want to specify the horizontal space between the two columns, say 1em, use:

Code: Select all

\begin{alignat*}{2}
p_n & = m_{(n)} = \sum_{i} x_i^n,         &\quad &n \geq 1 \\
p_{\lambda} & = p_{\lambda_1} p_{\lambda_2} \dotsb,   && \text{if } \lambda = (\lambda_1, \lambda_2, \dotsc).
\end{alignat*}

B.A.
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

An issue with a multiline formula

Post by localghost »

As balf already stated there are some very good reasons not to use the eqnarray environment [1]. The amsmath package provides some useful environments. Refer to its manual.

[1] The PracTeX Journal, TeX Users Group | Lars Madsen: Avoid eqnarray!


Best regards
Thorsten¹
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
Rc3g
Posts: 6
Joined: Mon Dec 01, 2008 6:34 pm

An issue with a multiline formula

Post by Rc3g »

Thanks, your last example was exactly what I was looking for.
First, you shouldn't use eqnarray: it is obsolete and it may give bad spacing. Load amsmath instead, and the align* environment:
Well, to be honest I did use align* at first for this formula, but I thought it looked worse than eqnarray!
Post Reply