14

I'm writing a math paper in LaTeX and for math formulas I'm just using $$math formula$$. Is is possible to numerate formulas? Or do I have to you use some specific commands such as align?

16

Vanilla displayed equation idioms:

\documentclass{article}

\usepackage{amsmath}

\begin{document}

The \verb|equation| environment creates numbered formulas you can
label and refer to elsewhere:
%  this commented blank line prevents start of a new paragraph
\begin{equation}\label{eq:pythagoras}
a^2 + b^2 = c^2 .
\end{equation}
%  this commented blank line prevents start of a new paragraph
Equation~\ref{eq:pythagoras} is the heart of the Pythagorean theorem.

Use the \verb|\eqref| macro to put parentheses around equation
references: \eqref{eq:pythagoras}.

For equations with no numbers, use \verb|equation*|:
%
\begin{equation*}
2 + 2 = 4 .
\end{equation*}

For multiline formulas, use \verb|align| or \verb|align*|:
%
\begin{align}
e^{i\pi} & = \cos(\pi) + i\sin(\pi) \notag \\
         & = -1 .
\end{align}

\end{document}

enter image description here

Edit: TeX will complain if it sees a blank line before the \end of one of these environments. Debugging that error message is difficult since you tend to think that TeX automatically does the right thing with white space. See "File ended while scanning use of \align*"

  • 4
    +1 I think this is what the OP was asking for. Just one edit needed- never put blank lines before a displayed equation, it throws the spacing off. Either remove them, or put in a comment symbol – cmhughes Feb 15 '13 at 19:55
  • @cmhughes Added the % and will remember to do that in my own documents from now on. – Ethan Bolker Feb 15 '13 at 20:06
  • @EthanBolker To complete cmhughes’ statement: Use blank lines if you want to start a new paragraph (blank lines after displayed math is only correct if it ends a paragraph). Do not use blank lines to structure your input. – Qrrbrbirlbel Feb 16 '13 at 1:21
  • You mean: "Do not use blank lines to format your source file." Of course, the input (in the sense of content) should be structured in paragraphs and therefore needs blank lines (or \pars). – Toscho Mar 16 '13 at 20:16
  • 1
    @Kusavil Search for "numberwithin" at en.wikibooks.org/wiki/LaTeX/Advanced_Mathematics – Ethan Bolker Jan 25 '18 at 19:23
13

For inline math use $...$ (or \( ... \)). For display math style equations, if you use aligned then alignment with enumerate's \item works better:

enter image description here

Code:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{enumerate}
\item $\begin{aligned}[t]
    E &= mc^2 \\
    F & = ma
\end{aligned}$
\item $\begin{aligned}[t]
    E &= mc^2 \\
    F & = ma
\end{aligned}$
\end{enumerate}
\end{document}

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.