Math & ScienceAlign one formula to the left

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
jcc
Posts: 3
Joined: Fri Sep 04, 2009 2:37 pm

Align one formula to the left

Post by jcc »

Hi.
If I use:

\usepackage[fleqn]{amsmath}

i have formulas aligned to the left.

But how to align just one (or more) math formula (align, etc) to the left, and others to the right.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Align one formula to the left

Post by gmedina »

From a typographical standpoint, all formulas should keep the same alignment in a document. However, if it's really necessary, you can modify the alignment for a particular equation using the environments provided by the nccmath package.

Take a look at the following simple example:

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\usepackage{nccmath}

\begin{document}

% A centered formula:
\begin{align}
  a &= b\\
    &= c
\end{align}

% A flushed left formula:
\begin{fleqn}
\begin{align}
  a &= b\\
    &= c
\end{align}
\end{fleqn}

% A centered formula:
\begin{align}
  a &= b\\
    &= c
\end{align}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
jcc
Posts: 3
Joined: Fri Sep 04, 2009 2:37 pm

Re: Align one formula to the left

Post by jcc »

Thank you gmedina.
Just out of curiosity: in your example, how i can flush right (center, left, center, right)?

Best wishes
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Align one formula to the left

Post by gmedina »

For this purpose you can use the flalign environment (or its starred version) provided by the amsmath package:

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\usepackage{nccmath}

\begin{document}

% A centered formula:
\begin{align*}
  a &= b\\
    &= c
\end{align*}

% A flushed left formula:
\begin{fleqn}
\begin{align*}
  a &= b\\
    &= c
\end{align*}
\end{fleqn}

% A centered formula:
\begin{align*}
  a &= b\\
    &= c
\end{align*}

% A flushed right formula:
\begin{flalign*}
   && a &= b\\
   &&    &= c
 \end{flalign*}

\end{document}
But particularly, I find this to be really poor (typographically).
1,1,2,3,5,8,13,21,34,55,89,144,233,...
jcc
Posts: 3
Joined: Fri Sep 04, 2009 2:37 pm

Re: Align one formula to the left

Post by jcc »

Thank you again. I agree with you: is typographically poor and aesthetically ugly.
However, is very useful for my handouts and homeworks.

Best wishes ,

jcc
Post Reply