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}
Gary
  • 2,033

2 Answers2

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.

David Carlisle
  • 757,742
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
David Carlisle
  • 757,742
Chel
  • 6,110