5

This is a follow up from my previous question, Positioning of equations. I managed to get my equations alligned to the left, but in my latex document, I have also been using:

\begin{equation}
X^2 := x^2 - 123. \nonumber
\end{equation}

I have alot of other equations that I want to be centered. For example, for all my equations wrapped around:

\begin{equation}
\end{equation}

How would I center it? Thanks, my code is below.

enter image description here

\documentclass[11pt,a4paper]{report}
\usepackage[fleqn]{amsmath}
\setlength{\mathindent}{0pt}
\usepackage{amsfonts,amssymb,amsthm,epsfig,epstopdf,titling,url,array}

\theoremstyle{plain}
\newtheorem{thm}{Theorem}[chapter] % reset theorem numbering for each chapter
\newtheorem{lem}[thm]{Lemma}
\newtheorem{prop}[thm]{Proposition}
\newtheorem*{cor}{Corollary}

\theoremstyle{definition}
\newtheorem{defn}[thm]{Definition} % definition numbers are dependent on theorem numbers
\newtheorem{exmp}[thm]{Example} % same for example numbers
\newtheorem{conj}[thm]{Conjecture}

\theoremstyle{remark}
\newtheorem*{rem}{Remark}
\newtheorem*{note}{Note}


\title{My Thesis Title}
\author{My Name}
\date{\today}
\renewcommand\labelenumi{(\theenumi)}
\renewcommand\theenumi{\roman{enumi}}
\setlength{\parindent}{1em}

\begin{document}

\chapter{Addition}

\begin{exmp} 
Here is an example.
\begin{align} \nonumber
(a+b)^3 &= (a+b)^2(a+b)\\ \nonumber
&=(a^2+2ab+b^2)(a+b)\\ \nonumber
&=(a^3+2a^2b+ab^2) + (a^2b+2ab^2+b^3)\\ \nonumber
&=a^3+3a^2b+3ab^2+b^3 \nonumber
\end{align}
\end{exmp}

\begin{exmp}
A simple equation:
\begin{equation}
X^2 := x^2 - 123. \nonumber
\end{equation}
\end{exmp}
\end{document}
  • Why should some equations go centered and other left aligned? – egreg Mar 31 '12 at 19:20
4

A more general solution is to load the nccmath package and wrap each equation you want flush-left in a fleqn environment:

\documentclass{article}
\usepackage{nccmath}
\begin{document}
\begin{fleqn}
    \begin{align*}
    a&=b\\
    &=c
    \end{align*}
\end{fleqn}
Which implies
    \begin{equation}
    a=c
    \end{equation}
But
\begin{fleqn}
    \[ 0\ne 5 \]
And
    \[ 2\ne 3 \]
\end{fleqn}
\end{document}

If nccmath causes problems, you could also define fleqn like this:

\makeatletter
\newenvironment*{fleqn}{
    \@fleqntrue
    \setlength\@mathmargin{0pt}%
    \ignorespaces
}{%
    \ignorespacesafterend
}
\makeatother
5

Instead of using the [fleqn] option which is a global option, leave the default centering behaviour but use flalign rather than align environment when you want flush left alignment.

  • 1
    I was about to say the same thing. :-) – azetina Mar 31 '12 at 18:41
  • How would I use the flalign command in my case? – Gary Mar 31 '12 at 18:48
  • @Gary write \begin{flalign} and \end{flalign} instead of the usual align environments. flalign probably has a starred version as well. – jmc Mar 31 '12 at 19:08

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.