




























































































Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Esta página não é visível na pré-visualização
Não perca as partes importantes!





























































































Abstract It is often said that TEX was designed for mathematical or technical purposes. This may be true when we remember the reasons why Donald Knuth created TEX. But nowadays there are many examples in which TEX is used for publications with no mathematical or technical background content. However, writing publications with such material is one of the important advantages of TEX. Because it seems impossible to know all existing macros and options of (LA)TEX and the several additional packages, especially of AMSmath. This is the reason why I have attempted to gather all the relevant facts in this paper. An advanced german version of this paper is available as a book [25].
Please report typos or any other comments to this documentation to [email protected]. This file can be redistributed and/or modified under the terms of the LATEX Project Public License Distributed from CTAN archives in directory CTAN://macros/latex/base/lppl.txt.
∗Thanks for the feedback to: Hendri Adriaens; Juan Mari Alberdi; Heiko Bauke; Neal Becker; Andrea Blomenhofer; Alexander Boronka; Walter Brown; Christian Faulhammer; José Luis Gómez Dans; Zongbao Fang; Sabine Glaser; Sven Gleich; Azzam Hassam; Gernot Hassenpflug; Henning Heinze; Martin Hensel; Mathias Hoffmann; Jon Kirwan; Morten Høgholm; M. Kalidoss; Dan Lasley; Angus Leeming; Vladimir Lomov; Tim Love; Dan Luecking; Hendrik Maryns; Heinz Mezera; David Neuway; Luis Trucco Passadore; Joachim Punter; Carl Riehm; Will Robertson; Christoph Rumsmüller; José Carlos Santos; Arnaud Schmittbuhl; Rainer Schöpf; Jens Schwaiger; Uwe Siart; Martin Sievers; Heiko Stamer; Uwe Stöhr; Carsten Thiel; Juan Luis Varona; David Weenink; Philipp Wook; Michael Zedler; Zou Yuan-Chuan; and last but not least a special thanks to Monika Hattenbach for her excellent job of proofreading.
Contents
The following sections describe all the math commands which are available without any additional package. Most of them also work with special packages and some of them are redefined. At first some important facts for typesetting math expressions.
As the name says there are always math expressions which are in a standard textline, like this one: f (x) =
´ (^) b a
sin x x dx. There are no limitations for the height of the math expressions, so that the layout may be very lousy if you
insert a big matrix in an inline mode like this: A =
a b c d e f g h i
. In this
case it is better to use the \smallmatrix environment A =
a b c d e f g h i
from the AMSmath package (see section 26.6 on page 65) or the displaymath mode (section 3 on page 14). This inline mode is possible with three different commands:
∑n i=1 i^ =^
1 2 n^ ·^ (n^ + 1) ∑n i=1 i^ =^ 1 2 n^ ·^ (n^ + 1) ∑n i=1 i^ =^
1 2 n^ ·^ (n^ + 1)
1 (\ sum _{ i =1}^{ n } i =\ frac {1}{2} n \ cdot ( n +1) ) \[10 pt ] 2 $\ sum _{ i =1}^{ n } i =\ frac {1}{2} n \ cdot ( n +1) $\[10 pt ] 3 \ begin { math } 4 \ sum _{ i =1}^{ n } i =\ frac {1}{2} n \ cdot ( n +1) 5 \ end { math }
2.1 Limits 2 THE INLINEMODE
In the inline mode the limits are by default only in super or subscript mode and the fractions are always in the scriptstyle´ 1 font size. For example: ∞ 1
1 x^2 dx^ = 1, which is not too big for the textline. You can change this^ \limits with the command \limits, which must follow a math operator^2 like an \int \lim \prod \sum
integral (\int), a sum (\sum), a product (\prod) or a limes (\lim). But this ´^ ∞ 1
1 x^2 dx^ = 1^ ($\int\limits_{1}^...) does not look very nice in a text line when it appears between two lines, especially when there are multiline limits.^3
For inlined formulas the fractions are by default in the scriptstyle (see tabular 8 on page 38), which is good for typesetting y = (^) b+1a , because the linespacing is nearly the same, but not optimal, when the formula shows some important \frac facts. There are two solutions to get a better reading:
y = (^) b+1a =
a b + 1
1 $ y =\ frac { a }{ b +1}={\ displaystyle \ frac { a }{ b +1}}$
n i=
All commands which appear in positions like contents, index, header, ... must be robust^5 which is the case for $...$ but not for (...). The latest package fixltx2e defines an macro for declaring existing commands to be robust. The package itself does this already for: 1 \ MakeRobust ( 2 \ MakeRobust ) 3 \ MakeRobust [ (^1) See section 12 on page 38. (^2) To define a new operator see page 75 (^3) For more information about limits see section 6.1 on page 25 or section 35 on page 72. (^4) For an abbreviation see section 29 on page 67, there is a special \dfrac macro. (^5) robust means that the macro is not expanded before it is moved into for example the tableofcontents file (*.toc). No robustness is often a problem, when a macro is part of another macro.
2.6 Linebreak 2 THE INLINEMODE
LATEX can break an inline formula only when a relation symbol (=, <, >,.. .) or a binary operation symbol (+, −,.. .) exists and at least one of these symbols appears at the outer level of a formula. Thus $a+b+c$ can be broken across lines, but ${a+b+c}$ not.
If it is not possible to have any mathsymbol, then split the inline formula in two or more pieces ($...$ $...$). If you do not want a linebreak for the whole document, you can set in the preamble: \relpenalty= \binoppenalty= which is the extreme case of grudgingly allowing breaks in extreme cases, or \relpenalty= \binoppenalty= for absolutely no breaks.
LATEX defines the length \mathsurround with the default value of 0pt. This length is added before and after an inlined math expression (see table 1).
foo f (x) =
1
1 x^2 dx^ = 1^ bar^
1 foo \ fbox {$ f ( x ) =\ int _1^{\ infty }\ frac {1}{ x ^2}\ ,\ mathrm { d } x =1 $} bar
foo f (x) =
1
1 x^2 dx^ = 1^ bar
1 foo \ rule {20 pt }{\ ht \ strutbox }\ fbox {$ f ( x ) =\ int _1^{\ infty }\ frac {1}{ x ^2}\ ,\ mathrm { d } x =1 $}\ rule {20 pt }{\ ht \ strutbox } bar
foo f (x) =
1
1 x^2 dx^ = 1^ bar
1 \ setlength {\ mathsurround }{20 pt } 2 foo \ fbox {$ f ( x ) =\ int _1^{\ infty }\ frac {1}{ x ^2}\ ,\ mathrm { d } x =1 $} bar
Table 1: Meaning of \mathsurround
None of the AMSmath-functions are available in inline mode.
3 Displaymath mode
This means, that every formula gets its own paragraph (line). There are some differences in the layout to the one from the title of 2.3.
For example:
f (x) =
∏^ n
i=
i −
2 i
1 \ begin { equation } 2 f ( x ) =\ prod _{ i =1}^{ n }\ left (i -\ frac {1}{2 i }\ right ) 3 \ end { equation }
The delimiters \begin{equation} ... \end{equation} are the only difference to the inline version. There are some equivalent commands for the display-math mode: \begin{displaymath}
...
f (x) =
∏^ n
i=
i −
2 i
displayed, no number. Same as 1.
∏^ n
i=
i −
2 i
displayed, a sequential equation number, which may be reset when starting a new chapter or section.
(a) There is only one equation number for the whole environment. (^) \nonumber (b) There exists no star-version of the equation environment because [... ] is the equivalent. With the tag \nonumber it is possible to suppress the equation number:
f (x) = [...]
1 \ begin { equation } 2 f ( x ) = [...] \ nonumber 3 \ end { equation }
3.3 Equation numbering 3 DISPLAYMATH MODE
y = d y = cx + d y = bx^2 + cx + d y = ax^3 + bx^2 + cx + d (7)
1 \ begin { eqnarray } 2 y & = & d \ nonumber \ 3 y & = & cx + d \ nonumber \ 4 y & = & bx ^{2}+ cx + d
nonumber \ 5 y & = & ax ^{3}+ bx ^{2}+ cx + d 6 \ end { eqnarray }
3.2.1 Short commands It is possible to define short commands for the eqnarray environment 1 \ makeatletter 2 \ newcommand {\ be }{ % 3 \ begingroup 4 % \ setlength {\ arraycolsep }{2 pt } 5 \ eqnarray % 6 \ @ifstar {\ nonumber }{} % 7 } 8 \ newcommand {\ ee }{\ endeqnarray \ endgroup } 9 \ makeatother
Now you can write the whole equation as
f (x) =
sin x x
dx (8)
1 \be 2 f(x) &=& \int\frac{\sin x}{x},\mathrm{d}x 3 \ee
or, if you do not want to have a numbered equation as
f (x) =
sin x x dx
1 \be* 2 f(x) &=& \int\frac{\sin x}{x},\mathrm{d}x 3 \ee
For all equations which can have one or more equation numbers (for every \nonumber line/row) the numbering for the whole equation can be disabled with switching from the unstarred to the star version. This is still for the whole formula and doesn’t work for single rows. In this case use the \nonumber tag.
3.3 Equation numbering 3 DISPLAYMATH MODE
3.3.1 Changing the style \theequation With the beginning of Section 25.2 on page 53 the counting changes from “44” into the new style “II-51”. The command sequence is
1 \ renewcommand \ theequation {\ thepart -\ arabic { equation }}
See section 33 on page 70 for the AMSmath command.
3.3.2 Resetting a counter style Removing a given reset is possible with the remreset.^6 Write into the preamble @removefromreset 1 \ makeatletter 2 \ @removefromreset { equation }{ section } 3 \ makeatother
or anywhere in the text. Now the equation counter is no longer reset when a new section starts. You can see this after section 26.4 on page 62.
3.3.3 Equation numbers on the left side Choose package leqno^7 or have a look at your document class, if such an option exists.
3.3.4 Changing the equation number style
The number style can be changed with a redefinition of
\def@eqnnum{{\normalfont \normalcolor (\theequation)}}
For example: if you want the numbers not in parentheses write 1 \ makeatletter 2 \ def \ @eqnnum {{\ normalfont \ normalcolor \ theequation }} 3 \ makeatother
For AMSmath there is another macro, see section 33 on page 70.
3.3.5 More than one equation counter
You can have more than the default equation counter. With the following code you can easily toggle between roman and arabic equation counting.
(^6) CTAN://macros/latex/contrib/supported/carlisle/remreset.sty (^7) CTAN://macros/latex/unpacked/leqno.sty
3.5 Frames 3 DISPLAYMATH MODE
Similiar to the inline mode, displayed equations can also be framed with the \fbox command, like equation 13. The only difference is the fact, that the equation must be packed into a parbox or minipage. It is nearly the same for a colored box, where the \fbox{...} has to be replaced with \colorbox{yellow}{...}. The package color.sty must be loaded and –important – the calc package to get a correct boxwidth.
f (x) =
1
x^2 dx = 1 (13)
1 \ noindent \ fbox {\ parbox {\ linewidth -2\ fboxsep -2\ fboxrule }{ % 2 \ begin { equation }\ label { eq : frame 0} 3 f ( x ) =\ int _1^{\ infty }\ dfrac {1}{ x ^2}\ ,\ mathrm { d } x = 4 \ end { equation } % 5 }}
If the equation number should not be part of the frame, then it is a bit complicated. There is one tricky solution, which puts an unnumbered equation just beside an empty numbered equation. The \hfill is only useful for placing the equation number right aligned, which is not the default. The following four equations 14-17 are the same, only the second one written with the \myMathBox macro which has the border and background color as optional arguments with the defaults white for background and black for the frame. If there is only one optional argument, then it is still the one for the frame color (15). 1 \ makeatletter 2 \ def \ myMathBox {\ @ifnextchar [{\ my@MBoxi }{\ my@MBoxi [ black ]}} 3 \ def \ my@MBoxi [#1]{\ @ifnextchar [{\ my@MBoxii [#1]}{\ my@MBoxii [#1][ white ]}} 4 \ def \ my@MBoxii [#1][#2]#3#4{ % 5 \ par \ noindent % 6 \ fcolorbox {#1}{#2}{ % 7 \ parbox {\ linewidth -\ labelwidth -2\ fboxrule -2\ fboxsep }{#3} % 8 } % (^8) $ _ ˆ \ & % { }
9 \ parbox {\ labelwidth }{ % 10 \ begin { eqnarray }\ label {#4}\ end { eqnarray } % 11 } % 12 \ par % 13 } 14 \ makeatother
f (x) = x^2 + x (14)
f (x) = x^2 + x (^) (15)
f (x) = x^2 + x (^) (16)
f (x) = x^2 + x (^) (17)
1 \ begin { equation }\ label { eq : frame 2} 2 f ( x ) = x ^2 + x 3 \ end { equation } 4 \ myMathBox [ red ]{[ f ( x ) = x ^2 + x ]}{ eq : frame 3} 5 \ myMathBox [ red ][ yellow ]{[ f ( x ) = x ^2 + x ]}{ eq : frame 4} 6 \ myMathBox {[ f ( x ) = x ^2 + x ]}{ eq : frame 5}
If you are using the AMSmath package, then try the solutions from section 39 on page 79.
4 array environment \begin{array} ... \end{array}
This is simply the same as the eqnarray environment only with the possibility of variable rows and columns and the fact, that the whole formula has only one equation number and that the array environment can only be part of another math environment, like the equation environment or the displaymath environment. With @{} before the first and after the last column the additional space \arraycolsep is not used, which maybe important when using left aligned equations.
a) y = c (constant) b) y = cx + d (linear) c) y = bx^2 + cx + d (square) d) y = ax^3 + bx^2 + cx + d (cubic)
Polynomes (18)
1 \ begin { equation } 2 \ left. % 3 \ begin { array }{ @ {} r@ {\ quad } ccrr@ {}} 4 \ textrm { a }) & y & = & c & ( constant ) \