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?
Asked
Active
Viewed 8.4k times
2 Answers
21
For inline math use $...$ (or \( ... \)). For display math style equations, if you use aligned then alignment with enumerate's \item works better:

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}
Peter Grill
- 223,288
-
2Why is there a
\,space at the beginning of thealignedenvironment? might be interesting if one notices the different spacing beforey = mx + band thealignedblocks. – Qrrbrbirlbel Feb 16 '13 at 16:31 -
-
@JaiKumar: Sorry for the delayed response, but I was going to suggest posting a new question as it is not clear from your comment what the requirements were, but looks like you already did that. – Peter Grill May 27 '20 at 08:54
-
@PeterGrill. Thank you very much for your response. https://tex.stackexchange.com/q/546433/137779 – Jai Kumar May 27 '20 at 09:00
19
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}

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*"
Ethan Bolker
- 9,333
- 3
- 42
- 69
-
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 01: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 -
@Toscho Of course you can use blank lines to separate paragraphs. You just can't put them right before
\end{equation}or `\end{align} - the compiler will complain. Don't use them right after unless you want to start a new paragraph there. Sorry if I confused you. – Ethan Bolker Mar 17 '13 at 00:56 -
What if, depending on document section, I would like to numerate them as (1.1), (1.2),...; (2.1), (2.2),(2.3),... etc. ? How do I do that? – Kusavil Jan 25 '18 at 17:35
-
1@Kusavil Search for "numberwithin" at https://en.wikibooks.org/wiki/LaTeX/Advanced_Mathematics – Ethan Bolker Jan 25 '18 at 19:23
equationoralign, etc, environments. By the way, you should never use$$ $$for displayed equations but rather\[ \]. – Corentin Feb 15 '13 at 19:37