Navigating the Future of Technology: Different Alignment Methods for Formulas
February 19,2024 Features
Written by CHEN Chen, Library
Edited by GONG Weifan, Library
Updated 1000 CST Feb 19, 2024
Edited by GONG Weifan, Library
Updated 1000 CST Feb 19, 2024
In the previous workshop, there was considerable demand from readers regarding the alignment and numbering of multiline formulas in daily writing. In LaTeX, formulas can be categorized as inline formulas and display formulas. Inline formulas are usually used to insert short mathematical expressions within the text, rather than as complete independent formulas. Adding numbering to inline formulas may make them too prominent or disrupt the overall layout of the text. In most cases, alignment and numbering are typically applied to independent long formulas. For long formulas and display formulas, we can use different environments and commands to achieve alignment and numbering. Formula alignment refers to vertically aligning multiple formulas or multiline formulas to facilitate the presentation and understanding of the formula structure.
Display formulas can be represented using several types: \[ \], $$...$$, and those starting with \begin{xx} and ending with \end{xx}. Among them, \[ \] and $$...$$ can only input single-line formulas, and the line break command \\ is ineffective within them. Using \begin{equation}...\end{equation} instead is generally recommended. Although it can also only input single-line formulas and the line break command \\ is ineffective within it, it can be combined with the split command and the line break command \\ to input multiline formulas and have only one numbering:
In addition to the equation environment, we can also use align, alignat, flalign, gather, and multline. Among them, align and alignat are similar, with default right alignment. flalign provides more flexible editing options, including alignment and spacing. gather cannot use the & symbol to specify the alignment position and all formulas are centered by default. multline aligns the first line to the left, the middle lines are centered, and the last line is aligned to the right, but it is less commonly used.
For systems of equations, it is recommended to use the case command in combination:
Website QR Code: (LaTeX Quick Reference Guide)
Display formulas can be represented using several types: \[ \], $$...$$, and those starting with \begin{xx} and ending with \end{xx}. Among them, \[ \] and $$...$$ can only input single-line formulas, and the line break command \\ is ineffective within them. Using \begin{equation}...\end{equation} instead is generally recommended. Although it can also only input single-line formulas and the line break command \\ is ineffective within it, it can be combined with the split command and the line break command \\ to input multiline formulas and have only one numbering:
In addition to the equation environment, we can also use align, alignat, flalign, gather, and multline. Among them, align and alignat are similar, with default right alignment. flalign provides more flexible editing options, including alignment and spacing. gather cannot use the & symbol to specify the alignment position and all formulas are centered by default. multline aligns the first line to the left, the middle lines are centered, and the last line is aligned to the right, but it is less commonly used.
For systems of equations, it is recommended to use the case command in combination:
Website QR Code: (LaTeX Quick Reference Guide)