Javascript required
Skip to content Skip to sidebar Skip to footer

Draw a Box Around Equation Latex

LaTeX logo.svg

LaTeX

Getting Started
  1. Introduction
  2. Installation
  3. Installing Extra Packages
  4. Basics
  5. How to get help

Common Elements

  1. Document Structure
  2. Text Formatting
  3. Paragraph Formatting
  4. Colors
  5. Fonts
  6. List Structures
  7. Special Characters
  8. Internationalization
  9. Rotations
  10. Tables
  11. Title creation
  12. Page Layout
  13. Customizing Folio Headers and Footers‎
  14. Importing Graphics
  15. Floats, Figures and Captions
  16. Footnotes and Margin Notes
  17. Hyperlinks
  18. Labels and Cross-referencing
  19. Initials

Mechanics

  1. Errors and Warnings
  2. Lengths
  3. Counters
  4. Boxes
  5. Rules and Struts

Technical Text

  1. Mathematics
  2. Advanced Mathematics
  3. Theorems
  4. Chemical Graphics
  5. Algorithms
  6. Source Code Listings
  7. Linguistics

Special Pages

  1. Indexing
  2. Glossary
  3. Bibliography Management
  4. More Bibliographies

Special Documents

  1. Scientific Reports (Available Written report, Chief Thesis, Dissertation)
  2. Messages
  3. Presentations
  4. Teacher's Corner
  5. Curriculum Vitae

Creating Graphics

  1. Introducing Procedural Graphics
  2. MetaPost
  3. Picture show
  4. PGF/TikZ
  5. PSTricks
  6. Xy-pic
  7. Creating 3D graphics

Programming

  1. Macros
  2. Plain TeX
  3. Creating Packages
  4. Creating Packet Documentation
  5. Themes

Miscellaneous

  1. Modular Documents
  2. Collaborative Writing of LaTeX Documents
  3. Export To Other Formats

Help and Recommendations

  1. FAQ
  2. Tips and Tricks

Appendices

  1. Authors
  2. Links
  3. Packet Reference
  4. Sample LaTeX documents
  5. Index
  6. Command Glossary

edit this box • edit the TOC

This folio outlines some more than avant-garde uses of mathematics markup using LaTeX. In item it makes heavy utilize of the AMS-LaTeX packages supplied past the American Mathematical Society.

Equation numbering [edit | edit source]

The equation environment automatically numbers your equation:

                                        \begin                    {equation}                    f(x)=(10+a)(x+b)                    \stop                    {equation}                  

f ( x ) = ( x + a ) ( x + b ) w west ( 1 ) {\displaystyle {f(10)}=(x+a)(x+b){\color {White}ww}(1)\,}

You can also employ the \label and \ref (or \eqref from the amsmath parcel) commands to label and reference equations, respectively. For equation number 1, \ref results in one {\displaystyle 1\,} and \eqref results in ( ane ) {\displaystyle (1)\,} :

                                        \begin                    {equation}                    \label                    {eq:someequation}                    half-dozen^ii - v = 36-5 = 31                    \end                    {equation}                    this references equation                    \ref                    {eq:someequation}.                  

6 2 5 = 36 5 = 31 ( 1 ) {\displaystyle 6^{2}-5=36-5=31\qquad (one)}
this references equation ane. {\displaystyle {\text{this references equation i.}}\,}

Farther data is provided in the labels and cross-referencing chapter.

To have the enumeration follow from your department or subsection heading, yous must use the amsmath package or use AMS class documents. Then enter

                        \numberwithin            {equation}{section}          

to the preamble to get enumeration at the section level or

                        \numberwithin            {equation}{subsection}          

to take the enumeration go to the subsection level.

                                        \documentclass                    [12pt]                    {article}                    \usepackage                    {amsmath}                    \numberwithin                    {equation}{subsection}                    \begin                    {document}                    \department                    {First Section}                    \subsection                    {A subsection}                    \begin                    {equation}                    50' =                    {L}{                    \sqrt                    {1-\frac                    {five^ii}{c^2}}}                    \end                    {equation}                    \finish                    {document}                  

L = 50 1 5 ii c 2 w w ( one.1.one ) {\displaystyle L'={L}{\sqrt {ane-{\frac {v^{2}}{c^{ii}}}}}{\color {White}ww}(ane.ane.1)\,}

If the style you follow requires putting dots subsequently ordinals (as it is required at least in Polish typography), the \numberwithin {equation}{subsection} command in the preamble will event in the equation number in the above example being rendered equally follows: (one.1.1).

To remove the duplicate dot, add the post-obit control immediately after \numberwithin {equation}{department} :

                        \renewcommand            {            \theequation            }{            \thesection\arabic            {equation}}          

For a numbering scheme using \numberwithin {equation}{subsection} , use:

                        \renewcommand            {            \theequation            }{            \thesubsection\arabic            {equation}}          

in the preamble of the document.

Note: Although it may look like the \renewcommand works by itself, it won't reset the equation number with each new department. It must be used together with transmission equation number resetting later on each new section beginning, or with the much cleaner \numberwithin .

Subordinate equation numbering [edit | edit source]

To number subordinate equations in a numbered equation environment, place the part of document containing them in a subequations environment:

                                        \begin                    {subequations}                    \label                    {eq:Maxwell}                    Maxwell'due south equations:                    \begin                    {marshal}                    B'&=-\nabla                    \times                    E,                    \label                    {eq:MaxB}                    \\                    Eastward'&=\nabla                    \times                    B - iv\pi                    j,                    \label                    {eq:MaxE}                    \cease                    {align}                    \end                    {subequations}                  

Maxwell'south equations: {\displaystyle {\text{Maxwell'south equations:}}\,}

B = × East , ( 1.1 a ) E = × B 4 Ï€ j , ( 1.1 b ) {\displaystyle {\begin{aligned}B'&=-\nabla \times Due east,&\quad &\mathrm {(1.1a)} \\E'&=\nabla \times B-four\pi j,&&\mathrm {(1.1b)} \end{aligned}}}

Referencing subordinate equations tin be done using either of two methods: adding a characterization after the \brainstorm {subequations} command, viz. \label {eq:Maxwell} , which volition reference the main equation (1.one in a higher place), or adding a characterization at the end of each line, before the \\ command, which volition reference the sub-equation (1.1a or one.1b above). Every bit shown, it is possible to add both labels in case both types of references are needed.

Vertically aligning displayed mathematics [edit | edit source]

A trouble often encountered with displayed environments (displaymath and equation) is the lack of any ability to bridge multiple lines. While information technology is possible to define lines individually, these will not be aligned.

Above and below [edit | edit source]

The \overset and \underset commands[1] typeset symbols above and below expressions. Without AmsTex the same result of \overset can be obtained with \stackrel . This can be particularly useful for creating new binary relations:

                                        \[                                                              A                                        \overset                    {                    !                    }{                    =                    } B; A                                        \stackrel                    {                    !                    }{                    =                    } B                    \]                  

A = ! B ; A = ! B {\displaystyle A{\overset {!}{=}}B;~~A{\stackrel {!}{=}}B\,}

or to show usage of Fifty'Hôpital's rule:

                                        \[                                                                                \lim                    _{10                    \to                                                            0                    }{                    \frac                    {e^x                    -                    ane                    }{                    two                    10}}                                                            \overset                    {                    \left                    [                    \frac                    {                    0                    }{                    0                    }                    \right                    ]                    }{                    \underset                    {                    \mathrm                    {H}}{                    =                    }}                                                            \lim                    _{x                    \to                                                            0                    }{                    \frac                    {e^x}{                    2                    }}                    =                    {                    \frac                    {                    1                    }{                    2                    }}                    \]                  

lim x 0 e ten 1 2 x = H [ 0 0 ] lim 10 0 due east ten 2 = i ii {\displaystyle \lim _{x\to 0}{\frac {due east^{x}-1}{2x}}{\overset {\left[{\frac {0}{0}}\right]}{\underset {\mathrm {H} }{=}}}\lim _{x\to 0}{\frac {east^{x}}{two}}={\frac {1}{ii}}}

Information technology is convenient to define a new operator that will set the equals sign with H and the provided fraction:

                        \newcommand            {            \Heq            }[1]{            \overset            {            \left            [#one\correct]            }{            \underset            {            \mathrm            {H}}{=}}}          

which reduces the above case to:

                        \[                                                \lim            _{x            \to                                    0            }{            \frac            {eastward^ten            -            1            }{            2            x}}                                    \Heq            {            \frac            {            0            }{            0            }}                                    \lim            _{x            \to                                    0            }{            \frac            {eastward^x}{            2            }}            =            {            \frac            {            1            }{            2            }}            \]          

If the purpose is to make comments on item parts of an equation, the \overbrace and \underbrace commands may be more useful. However, they have a dissimilar syntax (and can be aligned with the \vphantom command):

                                        \[                                                              z                                        =                                                            \overbrace                    {                                                            \underbrace                    {x}_                    \text                    {existent}                                        +                                          i                                                            \underbrace                    {y}_                    \text                    {imaginary}                                          }^                    \text                    {complex number}                    \]                  

z = x existent + i y imaginary complex number {\displaystyle z=\overbrace {\underbrace {x} _{\text{real}}+i\underbrace {y} _{\text{imaginary}}} ^{\text{complex number}}}

Sometimes the comments are longer than the formula being commented on, which tin cause spacing problems. These can be removed using the \mathclap command[ii]:

                                        \[                                                              y                                        =                                          a                                        +                                          f                    (                    \underbrace                    {b ten}_{                                                            \ge                                                            0                                                            \text                    { past assumption}}                    )                                                                                                    =                                          a                                        +                                          f                    (                    \underbrace                    {b x}_{                                                            \mathclap                    {                    \ge                                                            0                                                            \text                    { past assumption}}}                    )                                        \]                  

LaTeX-mathclap-example.png

Alternatively, to utilize brackets instead of braces use \underbracket and \overbracket commands[2]:

                                        \[                                                              z                                        =                                                            \overbracket                    [                    3                    pt                    ]                    {                                                            \underbracket                    {x}_{                    \text                    {real}}                                        +                                                                                \underbracket                    [                    0                    .                    5                    pt                    ][                    7                    pt                    ]                    {iy}_{                    \text                    {imaginary}}                                          }^{                    \text                    {complex number}}                                        \]                  

LaTeX-mathtools-brackets.png

The optional arguments set the rule thickness and bracket meridian respectively:

                        \underbracket            [dominion thickness][bracket elevation]            {argument}_{text below}          

The \xleftarrow and \xrightarrow commands[1] produce arrows which extend to the length of the text. Yet once more, the syntax is different: the optional argument (using [ and ]) specifies the subscript, and the mandatory statement (using { and }) specifies the superscript (which tin can be left empty by inserting a bare space).

                                        \[                                                              A                                        \xleftarrow                    {                    \text                    {this way}} B                                                                                \xrightarrow                    [                    \text                    {or that way}                    ]                    { } C                    \]                  

A this manner B or that mode C {\displaystyle A{\xleftarrow {\text{this fashion}}}B{\xrightarrow[{\text{or that way}}]{}}C\,}

For more extensible arrows, you must use the mathtools parcel:

                                        \brainstorm                    {get together}                    a                    \xleftrightarrow                    [under]                    {over}                    b\\                    %                    A                    \xLeftarrow                    [under]                    {over}                    B\\                    %                    B                    \xRightarrow                    [under]                    {over}                    C\\                    %                    C                    \xLeftrightarrow                    [nether]                    {over}                    D\\                    %                    D                    \xhookleftarrow                    [under]                    {over}                    E\\                    %                    E                    \xhookrightarrow                    [under]                    {over}                    F\\                    %                    F                    \xmapsto                    [nether]                    {over}                    G\\                    \end                    {gather}                  

LaTeX-mathtools-arrows.png

and for harpoons:

                                        \begin                    {get together}                    H                    \xrightharpoondown                    [under]                    {over}                    I\\                    %                    I                    \xrightharpoonup                    [under]                    {over}                    J\\                    %                    J                    \xleftharpoondown                    [nether]                    {over}                    K\\                    %                    K                    \xleftharpoonup                    [under]                    {over}                    L\\                    %                    Fifty                    \xrightleftharpoons                    [nether]                    {over}                    M\\                    %                    1000                    \xleftrightharpoons                    [under]                    {over}                    N                    \stop                    {gather}                  

LaTeX-mathtools-harpoons.png

align and align* [edit | edit source]

The align and align* environments, bachelor through the amsmath packet, are used for arranging equations of multiple lines. Equally with matrices and tables, \\ specifies a line break, and & is used to bespeak the point at which the lines should be aligned.

The marshal* surroundings is used like the displaymath or equation* environment:

                                        \begin                    {align*}                    f(x)                    &= (x+a)(x+b)                    \\                    &= ten^ii + (a+b)x + ab                    \cease                    {align*}                  

f ( 10 ) = ( ten + a ) ( 10 + b ) = x ii + ( a + b ) 10 + a b {\displaystyle {\begin{aligned}f(x)&=(x+a)(10+b)\\&=10^{two}+(a+b)x+ab\end{aligned}}\,}

Notation that the align environment must not exist nested inside an equation (or similar) environment. Instead, marshal is a replacement for such environments; the contents within an align are automatically placed in math style.

align* suppresses numbering. To force numbering on a specific line, use the \tag {...} command before the line break.

marshal is similar, simply automatically numbers each line like the equation environs. Individual lines may exist referred to by placing a \characterization {...} before the line suspension. The \nonumber or \notag control tin exist used to suppress the number for a given line:

                                        \begin                    {marshal}                    f(x)                    &= 10^4 + 7x^three + 2x^2                    \nonumber                    \\                    &                    \qquad                    {}                    + 10x + 12                    \end                    {align}                  

f ( x ) = x 4 + seven x 3 + 2 x 2 + 10 x + 12 ( 3 ) {\displaystyle {\begin{aligned}f(ten)&=x^{four}+7x^{3}+2x^{ii}\\&\qquad {}+10x+12\qquad \qquad (three)\end{aligned}}}

Notice that we've added some indenting on the second line. As well, nosotros need to insert the double braces ({}) before the + sign, otherwise latex won't create the right spacing after the + sign. The reason for this is that without the braces, latex interprets the + sign as a unary operator, instead of the binary operator that information technology actually is.

More than complicated alignments are possible, with additional & 's on a single line specifying multiple "equation columns", each of which is aligned. The following example illustrates the alignment rule of align*:

                                        \begin                    {align*}                    f(x)                    &= a x^2+b x +c                    &                    g(10)                    &= d x^iii                    \\                    f'(x)                    &= two a x +b                    &                    g'(x)                    &= 3 d x^2                    \end                    {align*}                  

f ( x ) = a ten two + b 10 + c g ( x ) = d 10 3 f ( ten ) = ii a x + b thousand ( 10 ) = 3 d ten 2 {\displaystyle {\begin{aligned}f(x)&=ax^{2}+bx+c&g(10)&=dx^{iii}\\f'(x)&=2ax+b&g'(x)&=3dx^{two}\end{aligned}}\,}

Braces spanning multiple lines [edit | edit source]

If you desire a brace to continue across a new line, do the following:

                                        \begin                    {align}                    f(ten)                    &=                    \pi                    \left\{                    x^four + 7x^3 + 2x^2                    \correct.\nonumber\\                    &                    \qquad                    \left.                    {}                    + 10x + 12                    \right\}                    \finish                    {align}                  

f ( x ) = π { x 4 + 7 x 3 + 2 x 2 + 10 x + 12 } ( 4 ) {\displaystyle {\brainstorm{aligned}f(x)&=\pi \left\{x^{four}+7x^{3}+2x^{2}\right.\\&\qquad \left.{}+10x+12\correct\}\qquad \qquad (four)\cease{aligned}}}

In this structure, the sizes of the left and right braces are not automatically equal, in spite of the apply of \left\{ and \right\} . This is because each line is typeset as a completely separate equation —notice the use of \right. and \left. so in that location are no unpaired \left and \correct commands within a line (these aren't needed if the formula is on one line). Y'all can control the size of the braces manually with the \big , \Large , \bigg , and \Bigg commands.

Alternatively, the height of the taller equation tin be replicated in the other using the \vphantom command:

                                        \brainstorm                    {align}                    A                    &=                    \left(\int                    _t Xxx                    \right.\nonumber\\                    &                    \qquad                    \left.\vphantom                    {                    \int                    _t}                    YYY                    \dots                    \correct)                    \terminate                    {align}                  

A = ( t X X 10 Y Y Y ) ( 5 ) {\displaystyle {\begin{aligned}A&=\left(\int _{t}Thirty\right.\\&\qquad YYY\dots {\biggr )}\qquad \qquad \mathrm {(5)} \end{aligned}}}

Using aligned braces for piecewise functions [edit | edit source]

You tin can likewise use \left\{ and \right. to typeset piecewise functions:

                                        \[                    f                    (                    10                    )                                                            =                                                            \left\{                                                                                \begin                    {array}{lr}                                          x^                    2                                          & : x <                                        0                    \\                                                              x^                    3                                          & : x                                        \ge                                                            0                                                                                \end                    {array}                    \right                    .                    \]                  

f ( x ) = { x 2 : x < 0 x 3 : x 0 {\displaystyle f(x)=\left\{{\begin{array}{lr}x^{2}&:x<0\\x^{3}&:x\geq 0\end{array}}\right.}

The cases environment [edit | edit source]

The cases environs[1] allows the writing of piecewise functions:

                                        \[                                                              u                    (                    x                    )                                                            =                                                                                                    \brainstorm                    {cases}                                                                                \exp                    {x} &                                        \text                    {if } 10                                        \geq                                                            0                                                            \\                                                                                1                                          &                                        \text                    {if } x <                                        0                                                                                \stop                    {cases}                    \]                  

u ( x ) = { exp x if x 0 1 if ten < 0 {\displaystyle u(x)={\begin{cases}\exp {x}&{\text{if }}10\geq 0\\1&{\text{if }}x<0\end{cases}}} u(x)={\begin{cases}\exp {10}&{\text{if }}x\geq 0\\1&{\text{if }}x<0\end{cases}}

LaTeX will and then accept intendance of defining and or adjustment the columns.

Within cases, text way math is used with results such as:

a = { ten d ten b ii {\displaystyle a={\begin{cases}\int x\,\mathrm {d} ten\\b^{2}\cease{cases}}}

Brandish manner may be used instead, by using the dcases environment[2] from mathtools:

                                        \[                                                              a                                        =                                                                                \brainstorm                    {dcases}                                                            \int                                          10                    \,                                                            \mathrm                    {d} 10                    \\                                                              b^                    2                                                                                \end                    {dcases}                    \]                  

a = { x d ten b ii {\displaystyle a={\begin{cases}\displaystyle \int x\,\mathrm {d} x\\\displaystyle b^{ii}\end{cases}}}

Frequently the 2d column consists mostly of normal text. To set it in the normal Roman font of the document, the dcases* environment may be used:[ii]

                                        \[                                                              f                    (                    x                    )                                                            =                                                            \begin                    {dcases                    *                    }                                          x  & when $x$ is even                    \\                                                                                -                    x & when $10$ is odd                                                            \end                    {dcases                    *                    }                    \]                  

f ( x ) = { 10 when x  is even 10 when x  is odd {\displaystyle f(x)={\brainstorm{cases}10&{\text{when }}ten{\text{ is fifty-fifty}}\\-x&{\text{when }}ten{\text{ is odd}}\end{cases}}}

Other environments [edit | edit source]

Although align and marshal* are the most useful, there are several other environments that may besides exist of interest:

Environment name Clarification Notes
eqnarray and eqnarray* Similar to align and marshal* Not recommended because spacing is inconsistent
multline and multline* [1] First line left aligned, final line correct aligned Equation number aligned vertically with outset line and not centered every bit with other environments
gather and gather* [1] Consecutive equations without alignment
flalign and flalign* [one] Like to marshal, but left aligns first equation column, and right aligns last cavalcade
alignat and alignat* [1] Takes an statement specifying number of columns. Allows control of the horizontal space between equations This environment takes one argument, the number of "equation columns": count the maximum number of & s in any row, add 1 and split up by 2. [1]

There are also a few environments that don't form a math environment past themselves and tin can be used every bit building blocks for more elaborate structures:

Math surroundings name Description
gathered [1] Allows gathering equations to be set under each other.
split [1] Similar to marshal, but used inside some other displayed mathematics environment and only supports a single equation cavalcade (i.e. a single & symbol).
aligned [i] Like to align, to exist used inside another mathematics environs.
alignedat [1] Similar to alignat, and likewise takes an boosted argument specifying the number of columns of equations to gear up. Information technology can stack inside alignat.

For example:

                                        \begin                    {equation}                    \left.\begin                    {aligned}                    B'&=-\partial                    \times                    E,\\                    Due east'&=\partial                    \times                    B - 4\pi                    j,                    \end                    {aligned}                    \correct\}                    \qquad                    \text                    {Maxwell's equations}                    \terminate                    {equation}                  

B = × E , E = × B four Ï€ j , } Maxwell s equations ( 1.one ) {\displaystyle \left.{\begin{aligned}B'&=-\partial \times E,\\E'&=\partial \times B-four\pi j,\end{aligned}}\right\}\quad {\text{Maxwell}}'{\text{south equations}}\qquad \mathrm {(1.1)} }

                                        \begin                    {alignat}{2}                    \sigma                    _i                    &= x + y                    &                    \quad                    \sigma                    _2                    &=                    \frac                    {x}{y}                    \\                    \sigma                    _1'                    &=                    \frac                    {                    \fractional                    x + y}{                    \fractional                    x}                    &                    \sigma                    _2'                    &=                    \frac                    {                    \partial                    \frac                    {x}{y}}{                    \partial                    x}                    \end                    {alignat}                  

σ 1 = ten + y σ ii = x y ( one ) σ ane = x + y ten σ 2 = x y x ( 2 ) {\displaystyle {\begin{aligned}\sigma _{1}&=x+y&\sigma _{2}&={\frac {x}{y}}&\qquad &\qquad &(1)\\\sigma _{1}'&={\frac {\partial x+y}{\fractional 10}}&\sigma _{ii}'&={\frac {\partial {\frac {10}{y}}}{\partial x}}&&&(2)\cease{aligned}}}

                                        \begin                    {gather*}                    a_0=\frac                    {1}{                    \pi                    }                    \int\limits                    _{-\pi                    }^{                    \pi                    }f(x)\,\mathrm                    {d}x\\                    [6pt]                    \brainstorm                    {dissever}                    a_north=\frac                    {ane}{                    \pi                    }                    \int\limits                    _{-\pi                    }^{                    \pi                    }f(x)\cos                    nx\,\mathrm                    {d}x=\\                    =\frac                    {one}{                    \pi                    }                    \int\limits                    _{-\pi                    }^{                    \pi                    }x^2\cos                    nx\,\mathrm                    {d}10                    \end                    {separate}                    \\                    [6pt]                    \begin                    {split}                    b_n=\frac                    {1}{                    \pi                    }                    \int\limits                    _{-\pi                    }^{                    \pi                    }f(ten)\sin                    nx\,\mathrm                    {d}x=\\                    =\frac                    {one}{                    \pi                    }                    \int\limits                    _{-\pi                    }^{                    \pi                    }10^2\sin                    nx\,\mathrm                    {d}x                    \end                    {dissever}                    \\                    [6pt]                    \finish                    {get together*}                  

LaTeX example split gather.png

Indented Equations [edit | edit source]

To indent an equation, you can set fleqn in the document grade and then specify a certain value for the \mathindent variable:

                                        \documentclass                    [a4paper,fleqn]                    {study}                    \usepackage                    {amsmath}                    \setlength                    {                    \mathindent                    }{1cm}                    \begin                    {document}                    \noindent                    Euler's formula is given beneath:                    \brainstorm                    {equation*}                    east^{ix}                    =                    \cos                    {ten}                    + i                    \sin                    {x}.                    \end                    {equation*}                    \noindent                    This is a very important formula.                    \cease                    {document}                  

LaTeX - Indented Equations.png

Page breaks in math environments [edit | edit source]

To suggest that LaTeX insert a folio break inside an amsmath surroundings, y'all may apply the \displaybreak command before the line break. Only every bit with \pagebreak , \displaybreak can take an optional statement between 0 and 4 denoting the level of desirability of a page suspension. Whereas 0 means "it is permissible to break here", iv forces a break. No argument means the same as 4.

Alternatively, you may enable automated page breaks in math environments with \allowdisplaybreaks . Information technology also can accept an optional statement cogent the priority of page breaks in equations. Similarly, i ways "allow page breaks but avoid them" and 4 means "break whenever yous want". You tin can prohibit a folio interruption after a given line using \\* .

LaTeX will insert a page break into a long equation if it has additional text added using \intertext {} without whatever additional commands.

Specific usage may look similar this:

                                        \brainstorm                    {align*}                    &                    \vdots\\                    &=12+7                    \int                    _0^two                    \left(     -\frac                    {1}{four}                    \left(e^{-4t_1}+e^{4t_ane-viii}                    \right)                    \right)\,dt_i\displaybreak                    [3]                    \\                    &= 12-\frac                    {7}{four}                    \int                    _0^2                    \left( due east^{-4t_ane}+due east^{4t_one-8}                    \right)\,dt_1\\                    &                    \vdots                    %                                        \stop                    {marshal*}                  

LaTeX-displaybreak-in-math.png

Folio breaks earlier display maths (of all various forms) are controlled by \predisplaypenalty . Its default 10000 means never pause immediately before a display. Knuth (TeXbook chapter 19) explains this as a printers' tradition non to accept a displayed equation at the start of a page. It can be relaxed with

Sometimes an equation might look best kept together preceding text by a higher penalty, for case, a unmarried-line paragraph about a unmarried-line equation, especially at the stop of a section.

Boxed Equations [edit | edit source]

For a single equation or alignment building block, with the tag outside the box, use \boxed {} :

                                        \begin                    {equation}                    \boxed                    {ten^2+y^2 = z^2}                    \terminate                    {equation}                  

LaTeX-boxed-equation.png

If you want the entire line or several equations to be boxed, utilise a minipage inside an \fbox {} :

                                        \fbox                    {                    \addtolength                    {                    \linewidth                    }{-ii\fboxsep                    }                    %                    \addtolength                    {                    \linewidth                    }{-2\fboxrule                    }                    %                    \brainstorm                    {minipage}{                    \linewidth                    }                    \begin                    {equation}                    ten^two+y^2=z^2                    \end                    {equation}                    \end                    {minipage}                    }                  

LaTeX-boxed-formula-minipage.png

There is too the mathtools \Aboxed {} which is able to box across alignment marks:

                                        \brainstorm                    {marshal*}                    \Aboxed                    {                    f(x)                    &                    =                    \int                    h(x)\,                    dx}                    \\                    &                    = g(10)                    \finish                    {marshal*}                  

Latex-Aboxed-example.png

Custom operators [edit | edit source]

Although many common operators are available in LaTeX, sometimes you will need to write your own, due east.1000. to typeset the argmax operator. The \operatorname and \operatorname* commands[1] brandish custom operators; the * version sets the underscored option underneath like the \lim operator:

                                        \[                                                                                \operatorname                    {arg                    \,                    max}_a f                    (                    a                    )                                                                                                    =                                                            \operatorname                    *                    {arg                    \,                    max}_b f                    (                    b                    )                                        \]                  

a r g m a 10 a f ( a ) = a r grand m a 10 b f ( b ) {\displaystyle \operatorname {arg\,max} _{a}f(a)={\underset {b}{\operatorname {arg\,max} }}f(b)}

However, if the operator is ofttimes used, it is preferable to ascertain a new operator that can be used throughout the unabridged certificate. The \DeclareMathOperator and \DeclareMathOperator* commands[1] are specified in the header of the document:

                        \DeclareMathOperator*            {            \argmax            }{arg\,max}          

This defines a new command which may exist referred to in the body:

a r g g a 10 c f ( c ) {\displaystyle {\underset {c}{\operatorname {arg\,max} }}f(c)}

Advanced formatting [edit | edit source]

Limits [edit | edit source]

In that location are defaults for placement of subscripts and superscripts. For case, limits for the lim operator are usually placed below the symbol:

                                        \brainstorm                    {equation}                    \lim                    _{a\to                    \infty                    }                    \tfrac                    {1}{a}                    \end                    {equation}                  

lim a 1 a {\displaystyle \lim _{a\to \infty }{\tfrac {1}{a}}}

To override this beliefs, employ the \nolimits operator:

                                        \brainstorm                    {equation}                    \lim\nolimits                    _{a\to                    \infty                    }                    \tfrac                    {1}{a}                    \terminate                    {equation}                  

lim a 1 a {\displaystyle \lim \nolimits _{a\to \infty }{\tfrac {1}{a}}}

A lim in running text (inside $ ... $ ) will have its limits placed on the side, so that additional leading won't be required. To override this behavior, use the \limits command.

Similarly ane can put subscripts under a symbol that usually has them on the side:

                                        \begin                    {equation}                    \int                    _a^b x^two                    \mathrm                    {d}                    x                    \end                    {equation}                  

a b 10 two d x {\displaystyle \int _{a}^{b}x^{two}\mathrm {d} x}

Limits below and nether:

                                        \begin                    {equation}                    \int\limits                    _a^b x^ii                    \mathrm                    {d}                    ten                    \cease                    {equation}                  

a b x 2 d x {\displaystyle \int \limits _{a}^{b}x^{2}\mathrm {d} x}

To change the default placement of summation-blazon symbols to the side for every case, add the nosumlimits selection to the amsmath package. To alter the placement for integral symbols, add intlimits to the options. nonamelimits can be used to change the default for named operators similar det, min, lim, etc.

To produce one-sided limits, use \underset as follows:

                                        \brainstorm                    {equation}                    \lim                    _{a                    \underset                    {>}{                    \to                    }                    0}                    \frac                    {1}{a}                    \terminate                    {equation}                  

lim a > 0 1 a {\displaystyle \lim _{a{\underset {>}{\to }}0}{\frac {1}{a}}}

Subscripts and superscripts [edit | edit source]

You can place symbols in subscript or superscript (in summation style symbols) with \nolimits :

                                        \brainstorm                    {equation}                    \sum\nolimits' C_n                    \terminate                    {equation}                  

C n {\displaystyle \sum \nolimits 'C_{n}}

It's impossible to mix them with typical usage of such symbols:

                                        \begin                    {equation}                    \sum                    _{n=1}                    \nolimits' C_n                    \end                    {equation}                  

n = 1 C north {\displaystyle \sum _{n=1}\nolimits 'C_{north}}

To add together both a prime and a limit to a symbol, 1 might use the \sideset command:

                                        \begin                    {equation}                    \sideset                    {}{'}                    \sum                    _{n=i}C_n                    \terminate                    {equation}                  

n = one C n {\displaystyle \sideset {}{'}\sum _{due north=one}C_{n}}

It is very flexible: for example, to put letters in each corner of the symbol utilise this control:

                                        \begin                    {equation}                    \sideset                    {_a^b}{_c^d}                    \sum                    \stop                    {equation}                  

a b c d {\displaystyle \sideset {_{a}^{b}}{_{c}^{d}}\sum }

If you lot wish to place them on the corners of an capricious symbol, you lot should utilise \fourIdx from the fouridx bundle.

But a simple grouping can likewise solve the problem:

                                        \brainstorm                    {equation}                    {                    \sum\limits                    _{northward=1}                    }'C_due north                    \end                    {equation}                  

n = i C northward {\displaystyle {\sum \limits _{n=1}}'C_{n}}

since a math operator tin can be used with limits or no limits. If you want to change its land, simply group it. You can make it another math operator if you want, then you tin can have limits and then limits again.

Multiline subscripts [edit | edit source]

To produce multiline subscript, utilise the \substack command:

                                        \begin                    {equation}                    \prod                    _{                    \substack                    {                    ane\le                    i                    \le                    northward\\                    1\le                    j                    \le                    m}}                    M_{i,j}                    \end                    {equation}                  

1 i northward one j yard M i , j {\displaystyle \prod _{i\leq i\leq n \atop i\leq j\leq one thousand\ }M_{i,j}}

Text in aligned math brandish [edit | edit source]

To add together pocket-sized interjections in math environments, use the \intertext command:

                                        \begin                    {minipage}{3in}                    \begin                    {align*}                    \intertext                    {If}                    A                    &=                    \sigma                    _1+\sigma                    _ii\\                    B                    &=                    \rho                    _i+\rho                    _2\\                    \intertext                    {then}                    C(ten)                    &= e^{Ax^2+\pi                    }+B                    \cease                    {marshal*}                    \cease                    {minipage}                  

Latex-intertext.png

Note that whatsoever usage of this command does not change the alignment.

Also, in the higher up example, the command \shortintertext {} from the mathtools package could accept been used instead of \intertext to reduce the amount of vertical white space added between the lines.

Irresolute font size [edit | edit source]

There may exist a time when y'all would adopt to have some control over the font size. For case, using text-style maths, by default a simple fraction will look like this: a b {\displaystyle \textstyle {\frac {a}{b}}} , whereas you may prefer to take it displayed larger, like when in display way, merely still keeping information technology in-line, like this: a b {\displaystyle \displaystyle {\frac {a}{b}}} .

A simple approach is to utilize the predefined sizes for maths elements:

Size control Clarification
\displaystyle Size for equations in display mode
\textstyle Size for equations in text style
\scriptstyle Size for first sub/superscripts
\scriptscriptstyle Size for subsequent sub/superscripts

A classic example to come across this in apply is typesetting continued fractions (though it'southward better to utilise the \cfrac command[1] described in the Mathematics chapter instead of the method provided below). The following code provides an example.

                                        \begin                    {equation}                    10 = a_0 +                    \frac                    {ane}{a_i +                    \frac                    {1}{a_ii +                    \frac                    {1}{a_3 + a_iv}}}                    \cease                    {equation}                  

x = a 0 + 1 a i + 1 a two + 1 a three + a four {\displaystyle ten=a_{0}+{\frac {1}{a_{1}+{\frac {1}{a_{two}+{\frac {i}{a_{3}+a_{4}}}}}}}}

As you tin run into, as the fractions continue, they get smaller (although they will not get whatsoever smaller than in this example, where they have reached the \scriptstyle limit). If y'all want to keep the size consistent, y'all could declare each fraction to use the display style instead; e.g.

                                        \begin                    {equation}                    ten = a_0 +                    \frac                    {ane}{                    \displaystyle                    a_1            +                    \frac                    {1}{                    \displaystyle                    a_2            +                    \frac                    {ane}{                    \displaystyle                    a_three + a_4}}}                    \finish                    {equation}                  

x = a 0 + 1 a 1 + 1 a 2 + 1 a 3 + a 4 {\displaystyle 10=a_{0}+{\frac {1}{\displaystyle a_{ane}+{\frac {1}{\displaystyle a_{2}+{\frac {i}{\displaystyle a_{3}+a_{iv}}}}}}}}

Some other approach is to use the \DeclareMathSizes command to select your preferred sizes. Yous tin can only define sizes for \displaystyle , \textstyle , etc. I potential downside is that this command sets the global maths sizes, as it tin only be used in the document preamble.

But it's fairly easy to employ: \DeclareMathSizes {ds}{ts}{ss}{sss} , where ds is the display size, ts is the text size, etc. The values you input are assumed to exist point (pt) size.

Note that the changes but accept place if the value in the first argument matches the current document text size. It is therefore common to see a set of declarations in the preamble, in the result of the principal font existence changed. Eastward.one thousand.,

                        \DeclareMathSizes            {10}{18}{12}{8}            % For size 10 text            \DeclareMathSizes            {11}{19}{13}{ix}            % For size 11 text            \DeclareMathSizes            {12}{twenty}{fourteen}{x}            % For size 12 text          

Forcing \displaystyle for all math in a document [edit | edit source]

Put

                        \everymath            {            \displaystyle            }          

before

to strength all math to

.

Adjusting vertical white infinite around displayed math [edit | edit source]

At that place are 4 parameters that control the vertical white space around displayed math:

                        \abovedisplayskip=12pt            \belowdisplayskip=12pt            \abovedisplayshortskip=0pt            \belowdisplayshortskip=7pt          

Short skips are used if the preceding line ends, horizontally, earlier the formula. These parameters must be gear up afterwards

.

Clipboard

To do:

  • Consider including stuff from mathtools.

Notes [edit | edit source]

  1. a b c d e f g h i j k l grand n Requires amsmath packet
  2. a b c d requires the mathtools package

stevensoncoraven.blogspot.com

Source: https://en.wikibooks.org/wiki/LaTeX/Advanced_Mathematics