catalogs
- Numbering/non-numbering of a formula
- Integral numbering of certain formulas
- Splitting and numbering longer formulas
in writing articles, we will encounter a variety of formula numbering requirements, such as some formulas and other formulas do not mark the number of the formula, the overall number of some formulas, the last line of a longer formula split into several lines of numbering and so on. This article summarizes the above three cases of the processing method, after encountering other cases and then back to add.
Numbering/non-numbering of a formula
latex gives us a lot of ways to edit formulas, specifically in the terminal (command prompt window) enter the following commands to view the official documents, here we do a brief summary.
texdoc lshort %English version
texdoc lshort-zh %Chinese version
Although latex provides the following method for entering individual formulas, it is not recommended.
$$x^2+y^2=r^2$$ %Interline equations
$$x^2+y^2=r^2$$ %Interline equation
Separate rows of interlinear formulas are usually given byequationEnvironmental Wrap.equationThe environment automatically generates a number for the formula, which can be cross-referenced by "\label" and "\ref", as well as by theamsmathThe "\eqref" command automatically appends parentheses to references (if you want to use the "\eqref" command, you need to add theamsmathmacro package), if the introduction of theamsmathmacro package, you can also use the "\tag" command to manually modify the formula number, or use the "\notag" command to cancel the numbering for the formula (if you don't want to number the formulas, you can just use theequation* environment). Illustrated with the following example:
Code:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
The Pythagorean theorem is:
\begin{equation}
a^2 + b^2 = c^2 \label{pythagorean}
\end{equation}
Equation \eqref{pythagorean} is
called ‘Gougu theorem’ in Chinese.
It’s wrong to say
\begin{equation}
1+1=3 \tag{dumb}
\end{equation}
or
\begin{equation}
1+1=4 \notag
\end{equation}
\end{document}
The result of the compilation is shown below (because of the existence of cross-references, it needs to be compiled twice):
Notes:
- Spaces entered in the math mode are ignored, and commands such as "\quad" and "\qquad" are used when artificial spacing needs to be introduced.
- No blank lines (subparagraphs) allowedThe formula between lines cannot be changed using the ''\" command. Interline formulas can not use the ''\" command line feed, layout of multi-line formulas given in the following subsection.
- All letters are treated as variables in math formulas, letter spacing does not match the text pattern, and spaces between words cannot be generated. If you want to enter orthographic text in a math formula, use theamsmathThe "\text" command is provided as an example:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
$x^{2} \geq 0 \qquad \text{for all}\quad x\in R$
\end{document}
The effect is shown below:
Integral numbering of certain formulas
Some times we are asked to number certain formulas as a whole, as in the following example:
Method 1 Code:
\begin{equation}
\begin{split}
\frac{\partial F}{x}&=-\frac{2}{9}x \\
\frac{\partial F}{y}&=-\frac{1}{2}y \\
\frac{\partial F}{z}&=1
\end{split}
\end{equation}
Method 2 code (this method depends on the amsmath macro package):
\begin{equation}
\begin{aligned}
\frac{\partial F}{x}&=-\frac{2}{9}x \\
\frac{\partial F}{y}&=-\frac{1}{2}y \\
\frac{\partial F}{z}&=1
\end{aligned}
\end{equation}
If we do not need the equals sign alignment, but center alignment can be, then the default with the above code is again on its, the following code can make multi-line formula center alignment.
\begin{gather}
\frac{\partial F}{x}=-\frac{2}{9}x \\
\frac{\partial F}{y}=-\frac{1}{2}y \\
\frac{\partial F}{z}=1
\end{gather}
Splitting and numbering longer formulas
When we encounter longer formulas, can not layout in a line, it requires us to split the formula in the appropriate location, and in accordance with some kind of alignment, the most commonly used here is thealignenvironment, which separates and aligns formulas in two parts with "&", with the separator usually placed to the left of the equals sign.alignThe environment will number each line of the formula, you can use the "\notag" command to remove the number of a line, we give a few examples below.
Code:
\begin{align}
a&=b+c \\
&=d+e
\end{align}
To cancel the numbering of one of the line formulas, simply use the "\notag" command on the appropriate line, as follows:
Code:
\begin{align}
a&=b+c \notag \\
&=d+e
\end{align}
Align by the plus sign (to align the plus sign, we put the separator to the right of the equals sign, which requires adding a pair of brackets " {}" after the equals sign to produce normal) spacing:
Code:
\begin{align}
a ={} & b + c \\
={} & d + e + f + g + h + i
+ j + k + l \notag \\
& + m + n + o \\
={} & p + q + r + s
\end{align}