2

I am trying to position my equations as in the image below, but I cant seem to get it to work (mainly because I cant get the line breaks to work). How would I position my equation like in the image below? My latex code is below:

123

\documentclass[11pt,a4paper]{report}
\usepackage{amsmath,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}}

\begin{document}
\tableofcontents

\chapter{Addition}
\section{Basics}

\begin{defn}
Let $x, y$ be some unknowns, we let:
\begin{equation}
x^2 + y^2 := (x+y)(x-y) := (1+2)(3+4) := (3*7)
= 21
= 42/2
\nonumber
\end{equation}
\end{defn}


\end{document}
diabonas
  • 25,784
Gary
  • 2,033

1 Answers1

7

Use amsmath's align* environment, since you already load it:

enter image description here

\documentclass{report}
\usepackage{amsmath,amsthm}% http://ctan.org/pkg/{amsmath,amsthm}
\theoremstyle{definition}
\newtheorem{defn}{Definition} % definition numbers are dependent on theorem numbers

\begin{document}
\begin{defn}
Let $x, y$ be some unknowns, we let:
\begin{align*}
  x^2 - y^2 &:= (x+y)(x-y) \\
    &:= (5+3)(5-3) \\
    &:= (8\times 2) \\
    &\phantom{:}= 16 \\
    &\phantom{:}= 32/2
\end{align*}
\end{defn}
\end{document}

Alignment is ensured using &, and using \phantom{:} you can obtain the correct spacing around the alignment "operator". That is, your = signs line up horizontally.

If you're interested in a more vertically aligned colon, use \coloneqq of the mathtools package (an extension to amsmath):

\usepackage{mathtools}% http://ctan.org/pkg/mathtools
%...
\begin{align*}
  ... &\coloneqq ...
\end{align*}

However, you would need to perform some magic to correctly align the = signs if you plan on doing that.

Moriambar
  • 11,466
Werner
  • 603,163
  • 1
    Of course the math is wrong. :) And * as the multiplication symbol is frowned upon in math circles. – egreg Mar 03 '12 at 16:03
  • 3
    I like the nice vertical centring of \coloneqq from the mathtools package. http://tex.stackexchange.com/q/4216/9043 – qubyte Mar 03 '12 at 16:05
  • 1
    @egreg: I was too quick with the draw there, focussing on \phantom{:}=. :-| – Werner Mar 03 '12 at 16:05
  • @Werner: It's silly really. The alignment never bothered me before seeing that question. Having said that, terrible documents never bothered me before I was introduced to TeX! I hope this is asymptotic... – qubyte Mar 03 '12 at 16:14
  • Thanks everyone, most appreciated!

    @egreg Thanks, yes the maths is wrong, it was just an (wrong) example. :)

    – Gary Mar 03 '12 at 17:29
  • 3
    @Gary If $x^2+y^2=(x+y)(x-y)$ students would be very happy. – egreg Mar 03 '12 at 17:34
  • @egreg: Did you just finish grading a set of midterm exams on a math course? :-) – Mico Mar 03 '12 at 17:40
  • @Mico I've just started my course on Didactic of mathematics and I'm getting in the mood. :) – egreg Mar 03 '12 at 17:42
  • 1
    @egreg: Please accept my felicitations or, alternatively, my condolences. – Mico Mar 03 '12 at 17:49
  • 1
    Simpler use = {} & instead of &=, the {} is needed to make the = spacing correct, but other than that one can easily align to the right instead of to the left. – daleif Mar 03 '12 at 19:01