LYX Math Manual Overview
LYX Math Manual Overview
Version 2.4.x
∗ Ifyou have comments or error corrections, please send them to the LYX Documentation
mailing list: lyx-docs@[Link]
Contents
1. Introduction 1
2. General Instructions 1
3. Basic Functions 3
3.1. Exponents and Indices . . . . . . . . . . . . . . . . . . . . . . . . . 3
3.2. Fractions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3.3. Roots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.4. Binomial Coefficients . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.5. Case Differentiations . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.6. Negations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.7. Placeholders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.8. Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.9. Ellipses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4. Matrices 10
6. Arrows 15
6.1. Horizontal Arrows . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
6.2. Vertical and Diagonal Arrows . . . . . . . . . . . . . . . . . . . . . . 17
7. Accents 17
7.1. Accents for One Character1 . . . . . . . . . . . . . . . . . . . . . . . 18
7.2. Accents for Several Characters . . . . . . . . . . . . . . . . . . . . . 19
8. Space 19
8.1. Predefined Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
8.2. Variable Space2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
8.3. Space Besides Inline Formulas . . . . . . . . . . . . . . . . . . . . . 21
ii
9.4. Paragraph Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
[Link] 27
10.1. Big Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
10.2. Operator Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
10.3. Decoration for Operators . . . . . . . . . . . . . . . . . . . . . . . . 30
10.4. Binary Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
10.5. Self-defined Operators . . . . . . . . . . . . . . . . . . . . . . . . . . 31
[Link] 32
11.1. Font Styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
11.2. Bold Formulas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
11.3. Colored Formulas . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
11.4. Font Sizes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
[Link] Letters 35
12.1. Small Letters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
12.2. Big Letters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
12.3. Bold Letters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
13.Symbols3 37
13.1. Mathematical Symbols . . . . . . . . . . . . . . . . . . . . . . . . . 37
13.2. Miscellaneous Symbols . . . . . . . . . . . . . . . . . . . . . . . . . 37
13.3. The Euro-Symbol € . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
[Link] 38
[Link] 39
15.1. Predefined Functions . . . . . . . . . . . . . . . . . . . . . . . . . . 39
15.2. Self-defined Functions . . . . . . . . . . . . . . . . . . . . . . . . . . 39
15.3. Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
15.4. Modulo-Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
[Link] Characters 41
16.1. Special Characters in Mathematical Text . . . . . . . . . . . . . . . 41
16.2. Accents in Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
16.3. Old-style Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
[Link] Styles 43
[Link] Formulas 43
18.1. General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
18.1.1. Line Separation . . . . . . . . . . . . . . . . . . . . . . . . . 44
3
A list with all symbols of most of the LATEX-packages can be found in [4].
iii
18.1.2. Column Separation . . . . . . . . . . . . . . . . . . . . . . . 44
18.1.3. Long Formulas . . . . . . . . . . . . . . . . . . . . . . . . . 46
18.1.4. Multiline Fractions . . . . . . . . . . . . . . . . . . . . . . . 47
18.1.5. Multiline Brackets . . . . . . . . . . . . . . . . . . . . . . . 47
18.2. Align Environments . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
18.2.1. Standard Align Environment . . . . . . . . . . . . . . . . . 48
18.2.2. Alignat Environment . . . . . . . . . . . . . . . . . . . . . . 48
18.2.3. Flalign Environment . . . . . . . . . . . . . . . . . . . . . . 49
18.3. Eqnarray Environment . . . . . . . . . . . . . . . . . . . . . . . . . 49
18.4. Gather Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
18.5. Multline Environment . . . . . . . . . . . . . . . . . . . . . . . . . . 49
18.6. Multiline Formula Parts . . . . . . . . . . . . . . . . . . . . . . . . . 50
18.7. Text in Multiline Formulas . . . . . . . . . . . . . . . . . . . . . . . 51
[Link] Numbering 52
19.1. General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
19.2. Cross-References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
19.3. Subnumbering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
19.4. Numbering with Roman Numbers and Letters . . . . . . . . . . . . 54
19.5. User-defined Numbering . . . . . . . . . . . . . . . . . . . . . . . . . 55
[Link] 58
21.1. Amscd Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
21.2. Xymatrix Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
21.3. Feynman Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
[Link]-defined Commands 60
22.1. The Command \newcommand . . . . . . . . . . . . . . . . . . . . . 60
22.2. Math Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
22.3. Math Macros for External Commands . . . . . . . . . . . . . . . . . 63
[Link] 65
24.1. Negative Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
24.2. Comma as decimal Separator . . . . . . . . . . . . . . . . . . . . . . 65
24.3. Physical Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
24.4. Self-defined Fractions . . . . . . . . . . . . . . . . . . . . . . . . . . 66
24.5. Canceled Formulas . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
24.6. Formulas in Section Headings . . . . . . . . . . . . . . . . . . . . . . 68
24.6.1. Heading without formula in table of contents . . . . . . . . 68
iv
√
24.6.2. Heading with formula in table of contents −1 = i . . . . . 68
24.7. Formulas in multi-column Text . . . . . . . . . . . . . . . . . . . . . 68
24.8. Formulas with Description of Variables . . . . . . . . . . . . . . . . 69
24.9. Upright small Greek Letters . . . . . . . . . . . . . . . . . . . . . . 70
24.10. Text Characters in Formulas . . . . . . . . . . . . . . . . . . . . . . 70
24.11. LATEX-comments in formulas . . . . . . . . . . . . . . . . . . . . . . 71
A. Typographic Advice 72
B. Synonyms 73
References 74
Index 75
v
1. Introduction
This document details LYX’s math features and the LATEX-commands used for math-
ematical characters and constructs. It is oriented toward the use of commands. The
user should read the Mathematical Formulas section of the User’s Guide before
proceeding.
Most of the characters and many constructs explained in this manual are also ac-
cessible via the menu Insert ▷ Math or the math toolbar. But everybody who has to
write lots of formulas will notice that it is much faster to use commands instead of
the math toolbar. Therefore this manual is focused on commands but also mentions
the corresponding toolbar buttons when available.
Unless specially mentioned, math commands are only available within formulas. To
be able to use all of the commands explained in this document, the option Use AMS
math package must be checked in the document settings (menu Document ▷ Settings ▷
Math Options).4
This document doesn’t list all AMS-math commands5 for lucidity reasons.
2. General Instructions
To create an inline formula that is embedded in a text line, use one of the shortcuts
or the toolbar button .
To create a display style formula which will appear bigger, has a different format,
and will be in a separate paragraph, use one of these shortcuts: .
To change a display style formula to an inline formula, place the cursor inside the
formula and use the shortcut or the menu Edit ▷ Math ▷ Change formula type. Similarly
you can use the shortcut to change from an inline to a display style formula.
To display parts of an inline formula in the size of a display style formula, enter the
command \displaystyle in a formula. A new blue box will appear in which the
desired formula part is inserted.
Only inline formulas are allowed inside tables.
Math toolbar visibility is controlled in the menu View ▷ Toolbars ▷ Math. Three options
will be presented, On, Off, and Automatic. Selecting On will cause the toolbar to
be shown permanently at the bottom of the screen. Selecting Off will disable the
toolbar. Selecting Automatic will cause the toolbar to automatically appear when
4
The option Use AMS math package automatically only uses AMS-math when math constructs are
found that are supported by LYX.
5
A list containing all AMS-math commands is in the file [Link], which is part of every LATEX
standard installation.
1
the cursor is located within a formula. The active state of the toolbar is indicated
by a checkmark next to the current menu selection.
TEX mode is invoked by pressing the toolbar button or by using the menu Insert ▷
TeX Code (shortcut ).
To change the LATEX-preamble, use the menu Document ▷ Settings ▷ LaTeX Preamble.
To edit matrices, case differentiations and multiline formulas, use the menus Edit ▷
Math and Edit ▷ Rows & Columns, or the table toolbar. When lines and columns are
swapped via the menu, the column or line where the cursor is in is exchanged with
the column to the right or the line below, respectively. If the cursor is in the last
column or row, the exchange is done with the column to the left or the line above.
To write text in formulas6 mathematical text is used. This mode is invoked with the
shortcut or by the insertion of the command \text. The text appears black in LYX
and can therefore be distinguished from the other formula parts which appear blue.
In the output, mathematical text is set upright contrary to other formula parts.
Command Scheme
Most LATEX-commands for math constructs have the following syntax:
\commandname[optional argument]{required argument}
A command always starts with a backslash „\“. To omit the optional arguments,
also omit the associated brackets. The braces around the required arguments are
referred to in this document as TEX braces. If you append a left brace to a command
name inside a formula, LYX automatically creates a right TEX brace. In all other
cases standalone TEX braces are created in formulas with the command \{. Normal
braces are created by typing {. TEX braces appear red in LYX, normal braces appear
blue. In TEX mode a command is not needed to get TEX braces. TEX braces don’t
appear in the output while normal braces do.
When commands without arguments, like commands for symbols, are entered in TEX
mode, a space character must always be behind the command to end it. This space
doesn’t appear in the output. When the space should appear in the output, the space
must be followed by a non-breaking space in normal text.
A non-breaking space is inserted with or with the menu selection Insert ▷ Formatting ▷
Non-Breaking Normal Space or Ctrl+Space.
6
For multiline formulas the command \intertext is used, see sec. 18.7.
2
Explanation of Syntax Used in this Manual
• The symbol ␣ denotes a space character to be input by the user.
• An arrow like → denotes the usage of the corresponding arrow key on the
keyboard. The Tab key can often be used instead of → and ↓, and Shift+Tab
instead of ← and ↑.
Available Units
Table 1: Available units
3. Basic Functions
3.1. Exponents and Indices
Indices are created with an underscore “_” or via the math toolbar button , exponents
with a caret “^” or via the math toolbar button .
Command Result
B_V BV
B^V BV
B^␣A BA
3
As the caret is in some languages an accent, vowels will be accentuated in this case
and not set as exponents7 . To get exponents in this case, press Space after the caret
as in the last example.
3.2. Fractions
Fractions are generated with the command \frac or via the math toolbar button .
The font size is adjusted automatically, depending on whether the fraction is in an
inline or display style formula. With the math toolbar button you can select different
fraction types.
With the command \dfrac a fraction can be created that always has the size of a
display style formula. With \tfrac the fraction appears always with the size of an
inline formula. An example:
1
A line with the fraction 2
that was created with the command \frac.
1
A line with the fraction that was created with the command \dfrac.
2
Command Result
A
\frac␣A↓B B
A
\dfrac␣A↓B
B
1
e2
\dfrac␣e^\frac␣1↓2↓↓3
3
7
Depending on the keyboard settings used this can also happen for characters other than vowels.
4
For nested fractions the command \cfrac can be used. Here is an example:
\cfrac always sets the fraction size to that of a displayed formula, even when it is
part of another fraction.
It is possible to specify the alignment of the numerator. The command \cfracleft is
used to left align it, the command \cfracright to right-align it. \cfrac centers the
numerator. These fractions demonstrate the different alignments:
A A A
, ,
B+C B+C B+C
Note: \cfracleft and \cfracright are not real LATEX commands but represent the
command \cfrac[alignment]{numerator}{denominator} . Therefore you can-
not use them in TEX code.
A
E
C+ F
B+
D
For inline fractions with a sloped fraction stroke you can use the command \nicefrac:
5/31or \unitfrac: 5/31 There is also the command \unitfracthree which allows you
to write a fraction in combination with a number: 2 1/3
Note: \unitfracthree is not a real LATEX command but the command
\unitfrac[number]{numerator}{denominator} . Therefore you cannot use it
in TEX code.
How to define your own fractions where the fraction stroke can be changed is explained
in sec. 24.4.
Multiline fractions are explained in sec. 18.1.4.
5
3.3. Roots
Square roots are created with \sqrt or the math toolbar button , all other roots with
the command \root or with the math toolbar button .
Command Result
√
\sqrt␣A-B A−B
√
3
\root␣3↓A-B A−B
A square root can also be created with \root when the root index field is left empty.
√
With certain indices the distance to the root is too small, like in this formula: β B
The β touches the root. To avoid this, the commands \leftroot and \uproot are
used with the following scheme:
Distance is the number of Big Points (unit bp; 72 bp = 1 inch), that the index should
be moved to the left or up, resp.. The commands are written to the index. This way
the command
\root\leftroot{-1→\uproot{2→\beta␣→B √
β
produces a correct typeset formula: B
Command Result
A
\binom␣A↓B B
!
A
\dbinom␣A↓B
B
A
\tbinom␣A↓B B
h i
A
\brack␣A↓B B
n o
A
\brace␣A↓B B
6
3.5. Case Differentiations
Command Result
n
\cases␣A→B>0 A B>0
A for x > 0
\cases␣
B for x = 0
After inserting \cases or pressing the math toolbar button you can create new lines
with the shortcut or the table toolbar button .
The command \cases is also available via the menu Insert ▷ Math ▷ Cases-Environment.
3.6. Negations
By inserting \not every character can be displayed canceled. The characters are
quasi accentuated by a slash.
Command Result
\not= ̸ =
\not \le ̸≤
\not \parallel ̸∥
The last example shows that not all negations look good. Therefore there are special
commands for some negations (see sec. 13.1 and sec. 14).
3.7. Placeholders
When displaying e. g. isotopes8 the following problem occurs:
19
Indices created with sub- and superscripts: 9 F
19
Correct indices: 9F
The shorter index is placed by default below or above the first character of the longer
index. This is corrected using the command \phantom or the math toolbar button 9
to create one or more phantom characters. When inserting phantom characters a
small blue box appears that is superposed with two red arrows. The arrows indicate
the width and height of the box to be created as a placeholder. Phantom characters
are placeholders with the same character size.
8
Typesetting isotopes and chemical symbols is described in sec. 20.
9
Found in the submenu of the toolbar button
7
Command Result
19
^19␣_\phantom␣1→9␣\mathrm␣F 9F
235
^235␣_\phantom␣23→9␣\mathrm␣F 9F
\Lambda␣^\phantom␣ii→t␣_MMt ΛMtM t
Furthermore there are the commands \vphantom (toolbar button ) and \hphan-
tom (toolbar button ). \hphantom creates only space for the maximal height of
the characters in the box but not for its width. \vphantom creates only space for
the width of the box content. Therefore the boxes of both commands have only one
red arrow.
For example the command \vphantom␣a\int creates space for the height of the
integral sign,10 because this is the larger character. An example application is in
sec. 18.1.5.
Placeholders can also be used for text when they are inserted via the menu Insert ▷
Formatting ▷ Phantom:
This is a sentence.
is a sentence.
3.8. Lines
Command Result
\overline␣A+B A+B
\underline␣A+B A+B
\overline␣\underline␣A+B A+B
Custom lines can be created using the command \rule which has the following
scheme:
\rule[vertical offset]{length}{thickness}
The optional vertical offset shifts the line upwards (or downwards, when the value
is negative). The units listed in Table 1 can be used for the values. Here are two
example lines created with the commands
\rule[-2ex]{3cm}{2pt} and \rule{2cm}{1pt}:
10
The command \int creates an integral sign, see sec. 10.1.
8
This is a sentence with two lines.
\rule can also be used for text when a line is inserted via the menu Insert ▷ Formatting ▷
Horizontal Line:
This is a sentence with one line.
3.9. Ellipses
There are different types of ellipses available.11 For listings, dots at the baseline are
used (\ldots), while for operations, dots are needed that are on the same height as
the operators (\cdots). When using the command \dots, LATEX decides on the basis
of the next character what type is used.
Command Result
A_1␣,\dots␣,A_n A1 , . . . , An
A_1␣+\dots␣+A_n A1 + · · · + An
A_1␣,\ldots␣,A_n A1 , . . . , An
A_1␣+\cdots␣+A_n A1 + · · · + An
..
\vdots .
..
\ddots .
.
\iddots ..
A11 · · · A1m
3×3 matrix with the different dots .. .. ..
. . .
An1 · · · Anm
To use \iddots, the option Use mathdots package (automatically) must be set in the
document settings under Math Options.
Using the option Use mathdots package will improve the appearance of all dots in the
documents if their font style or size is not the default.
Specially for matrices there are ellipses that span over several columns. They are
created with the command \hdotsfor and have the following scheme (mathtools
must be loaded always under Math Options for this to work):
\hdotsfor[distance]{number of columns}
11
In the math toolbar in the submenu of the button
9
The number of columns specifies how many columns should be spanned. Distance is
a factor for the distance between the dots.
In the following matrix the command \hdotsfor[2]{4} was inserted in the first box
of the second line to get an ellipsis with a dot distance twice as long as with the
command \dots:
A B C D
. . . . . . . . .
q w e r
Note that the matrix fields that should be spanned must be empty, otherwise you
get LATEX-errors.
Furthermore you can fill with the command \dotfill the rest of a line with dots. The
effect of these commands is the same as with \hfill, see sec. 8.2.
For example the command A\dotfill␣B produces
A. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .B
Similar to \dotfill there is for a line the command \hrulefill:
A B
To use the commands for text, they have to be inserted in TEX mode.
4. Matrices
Matrices can be inserted via the math toolbar button or the menu Insert ▷ Math ▷
Matrix. In the matrix dialog you can specify the number of columns and rows, the
alignment and the decoration. The vertical alignment is only of importance for
matrices in inline formulas:
A D G J
The first matrix is top A D G J , the second middle B E H K and the
B E H K C F I L
C F I L
A D G J
B E H K
third bottom C F I L aligned.
The horizontal alignment specifies how the column entries should be aligned. It is set
by entering a letter for every column. l denotes left aligned, c centered and r right
aligned. To create for example a 4×4 matrix where the first column is left aligned,
the second and third are centered and the last one is right aligned, one enters for the
10
horizontal alignment lccr. Normally in a matrix all columns are centered, therefore
the default for every column is a c.
Horizontal alignment:
10000 D G 10000 D G 10000 D G
lll : B 10000 H , ccc : B 10000 H , rrr : B 10000 H
C F 10000 C F 10000 C F 10000
To subsequently add or delete rows and columns, the math toolbar buttons , , etc. ,
or the menu Edit ▷ Rows & Columns can be used. New rows can also be created with .
Appearance can be used to add parentheses in the selected style around the matrix
or to select the small style, suitable for an inline matrix like this one 0i -i0 . Here the
parentheses have been added manually using commands \bigl( and \bigr).
Alternatively, parentheses can be created with the commands \left and \right
(shortcut Alt+M Parenthesis), see sec. 5.1.2, or by using the following commands:
When e. g. \vmatrix is inserted, a blue box appears between two vertical lines where
the matrix is inserted.
Note that decorated matrices ignore the vertical alignment.
As all multiline formulas are matrices, the length \arraycolsep that is described in
sec. 18.1.2 can also be used to change the column separation of matrices.
To change the row separation, the command \arraystretch is used as follows:
\renewcommand{\arraystretch}{stretch factor}
The command \renewcommand assigns the stretch factor to the predefined com-
mand \arraystretch. For example to double the row separation, use a stretch factor
of 2. This is then used for all following matrices. To restore the original separation,
assign a stretch factor of 1 to \arraystretch.
Small inline matrices can also be obtained using the command \smallmatrix. When
it is inserted in a line a blue box with two dashed lines appears. Adjust the matrix
rows and columns as desired.
11
This is a matrix ( CA D
B ) in a text line with automatic delimiters around it.
Note: In TEX mode the command \textbackslash must be used for the backslash,
because the command \\ produces a line break there.
For all characters listed above the size can be adjusted with the commands described
in the following two subsections. When using these commands, the characters < and
> can directly be used instead of the commands \langle and \rangle.
For the second formula the command \Big((A+B)(A-B)\Big)^␣C has been used.
Here is an example containing all bracket sizes:
\Bigg(\exp\bigg<\Big[\big{\ln(3x)\big}^2␣\sin(x)\Big]^␣A␣\bigg>\Bigg)^0,5
A + 0,5
*
n o2
exp ln(3x) sin(x)
In addition to the \big-commands there is a variant, \bigm, that adds a bit more
space between the bracket and its content. Other variants \bigl and \bigr, don’t
12
add additional space. The l at the end of the command \bigl is for a left bracket;
for a right bracket this is replaced by an r. A left or right bracket can each be an
opening or closing bracket.
The following table contains comparisons of the variants:
Command Result
2
\Bigm(\bigm(\ln(3x)\bigm)^2␣\Bigm) ln(3x)
2
\Big(\big(\ln(3x)\big)^2␣\Big) ln(3x)
2
\Bigl(\bigl(\ln(3x)\bigr)^2␣\Bigr) ln(3x)
\bigl)\ln(3x)\bigr( ln(3x)
Instead of \left and \right the shortcut Alt+M Bracket can be used. This has the
advantage that you can see in LYX immediately the real bracket size and that the
matching right bracket will be created too.
The command for the last example would then be: \ln Alt+M (\frac␣A↓C
To omit a left or right bracket, a dot is inserted for the omitted bracket. For example
the command \left.\frac␣A↓B␣\right} creates:
A
B
The commands \left and \right will be converted by LYX to brackets with the
correct size when the document is reloaded and an omitted bracket will appear as
dashed line.
13
Because all popular LATEX distributions use eTEX, an extension to LATEX, the com-
mand \middle is available for all brackets and limits. With this command the
height of the following character is adapted to the one of the surrounding brackets,
for example in the case of physical vectors:
3
ϕ J= , MJ
2
For physical vectors there is a special LATEX-package, described in sec. 24.3.
If in document settings under Math Options the option for the package mathtools
is set to Load always, you will also have access to square brackets:
Command Result
3
\overbracket{A+B␣^3 A+B
\underbracket{A+B␣_5 A+B
5
C
\overbracket{\underbracket{A+B_w␣␣_7␣␣^C A + Bw
7
For \overbracket and \underbracket you can change the thickness of the bracket’s
stroke by specifying the desired thickness in square brackets behind the command:
Command Result
3
\overbracket[3pt]\{A+B␣^3 A+B
\underbracket[1pt]\{A+B␣_5 A+B
5
14
When brackets overlap each other, multiline formulas as described in sec. 18 must be
used:
In the first row, the formula is inserted together with the first brace. It is important
that the space command12 \: is inserted before the first d because the brace that
ends behind the q prevents the following “+” from being surrounded by spaces.13 The
second brace is inserted in the second row. As it should begin before the b, first the
command \hphantom{gggg+\:} is inserted.14 This space is needed because the
“+” is surrounded by spaces in the formula. The brace is placed under the command
\hphantom{bbqq+dddd}.
It gets more complicated when brackets overlap each other above and under the
formula as in the following example:
s
z }| {
A = gggg + bbqq + dddd
| {z }
r
The first formula row is the same as the second row of the previous example, with
the difference that the brace is above. The second row contains the formula together
with the second brace. To avoid the space between the upper brace in the first row
and the formula, the row spacing needs to be reduced. This is not easily done due to
a bug in LYX.15 As a solution for the problem, the global formula row separation \jot
must be changed to -6 pt before the formula with the command \setlength{\jot}{-
6pt} in TEX mode. \jot is set back after the formula to the standard value of 3 pt
using the same command. More about the row separation in formulas is explained
in sec. 18.1.1.
6. Arrows
Arrows can be inserted via the math toolbar button or the commands listed in the
following subsections.
12
Space commands are explained in sec. 8.1.
13
Because a bracket is not handled as a character, see sec. 10.4
14
More about \hphantom see sec. 3.7
15
LyX-bug #1505
15
6.1. Horizontal Arrows
Command Result Command Result
\gets ← \to →
\Leftarrow ⇐ \Rightarrow ⇒
\longleftarrow ←− \longrightarrow −→
\Longleftarrow ⇐= \Longrightarrow =⇒
\leftharpoonup ↼ \rightharpoonup ⇀
\leftharpoondown ↽ \rightharpoondown ⇁
\hookleftarrow ←- \hookrightarrow ,→
Command Result
Command Result
\leftrightarrow ↔
\mapsto 7 →
\Leftrightarrow ⇔
\longmapsto 7−→
\longleftrightarrow ←→
\leadsto ;
\Longleftrightarrow ⇐⇒
\dasharrow 99K
\rightleftharpoons ⇌
Labeled arrows are also available using the commands \xleftarrow and \xrightar-
row. When inserting one of these commands in a formula, an arrow with two blue
boxes appears indicating where the labels can be inserted. The length of the arrow
adapts to the label width.
Command Result
x=a
F(a)\xleftarrow␣x=a↓x>0→F(x) F (a) ←−− F (x)
x>0
x=a
F(x)\xrightarrow␣x=a↓x>0→F(a) F (x) −−→ F (a)
x>0
If in the document settings under Math Options for the package mathtools the option
Load always is set, you will have access to the following labeled arrows:
16
Command Example Command Example
x>0 x>0
\xleftrightarrow ←−→ \xleftharpoondown ↽−−
x=a
x=a
x>0 x>0
\xLeftarrow ⇐== \xleftharpoonup ↼−−
x=a x=a
x>0 x>0
\xRightarrow ==⇒ \xrightharpoondown −−⇁
x=a x=a
x>0 x>0
\xLeftrightarrow ⇐x=a
==⇒ \xrightharpoonup −−⇀
x=a
x>0 x>0
\xhookleftarrow ←−−- \xleftrightharpoons ↼
−−
−−
⇁
x=a x=a
x>0 x>0
\xhookrightarrow ,−−→ \xrightleftharpoons −−
↽−⇀
−
x=a x=a
Command Result
x>0
F(a)\xleftrightarrow[x=a]\{x>0→F(x) F (a) ←−→ F (x)
x=a
Command Result
Command Result
\uparrow ↑
\Uparrow ⇑ \nearrow ↗
\updownarrow ↕ \searrow ↘
\Updownarrow ⇕ \swarrow ↙
\Downarrow ⇓ \nwarrow ↖
\downarrow ↓
Vertical arrows can also be used as delimiters together with the commands described
in sec. 5.1.1 and sec. 5.1.2.
7. Accents
Accents can be inserted via the math toolbar button or the commands listed in the
following subsections.
17
7.1. Accents for One Character16
Command Result
Command Result
\dot␣A Ȧ
\tilde␣A Ã
\ddot␣A Ä
\hat␣A Â
\dddot␣A ˙˙˙
A
\check␣A Ǎ
\ddddot␣A ˙˙˙˙
A
\acute␣A Á
\vec␣A A⃗
\grave␣A À
\bar␣A Ā
\breve␣A Ă
\mathring␣A Å
You can directly insert accents such as é in formulas. LYX will transform them to
the corresponding accent command. For umlauts however it is better to insert a
quotation mark before the vowel. These two characters are then treated by LATEX
as one character when the formula part with the umlaut is marked as German. In
contrast to \ddot, with this method “real” umlauts are created as demonstrated in
the following example:
Command Result
“i ı̈
\ddot␣i ï
One advantage with \ddot is that umlauts can be directly converted to mathematical
text because the accent commands above are not allowed in mathematical text. To
convert an accented character to mathematical text, only the character under the
accent may be converted. This applies for all conversions, e. g. to italic or bold.
LYX also supports a tilde under the character if the LATEX-package undertilde is
installed on your system:
You need to install the LATEX-package undertilde to see the rest of this subsection
in the output.
16
For accents in text see sec. 16.2
18
7.2. Accents for Several Characters
Command Result Command Result
←−−−− −−−−→
\overleftarrow␣A=B A=B \overrightarrow␣A=B A=B
\underleftarrow␣A=B \underrightarrow␣A=B A =−→
B
←−=
A −−B
− −−−
←−−→
\overleftrightarrow␣A=B A=B \widetilde␣A=B A^=B
\underleftrightarrow␣A=B A
←−=−→
B \widehat␣A=B =B
A\
Using these commands you can accent as many characters as you like. But the
accents \widetilde and \widehat will only be set in the output with a length of
three characters, as shown in the following example:
=C −D
A + B^
It is also possible to accent several characters using the commands \overset and \un-
derset described in the previous subsection. The command \underset␣A=B↓***
creates:
=B
A ∗∗∗
8. Space
8.1. Predefined Space
Sometimes it is necessary to insert horizontal space into a formula. This is done by
inserting a non-breaking space (shortcut ). A “␣” appears and by pressing Space
several times one can select one of eight different space sizes. The spaces can also
be inserted using the math toolbar button or special commands. The size can be
adjusted at any time by positioning the cursor on the and pressing Space until the
desired size is achieved.
19
Space’s 5 – 7 are variable spaces which are explained in sec. 8.2. Space 9 appears to
produce no space. It is displayed red in LYX contrary to the other sizes, because it
is a negative space. There are two more negative spaces:
Negative spaces can lead to characters overlapping each other. Thus they can be
used to enforce ligatures, which are useful for things such as summation operators:
Command Result
PP
\sum\sum␣f_kl fkl
PP
\sum\negmedspace\sum␣f_kl fkl
Relational operators, for example equal or less than signs, are always surrounded
by space. To suppress this, the operator is placed into a TEX brace. The following
example demonstrates this:
Normal equation A=B
Equation without space A=B
The command for the last formula is: A\{=→B
Another example of controlled spaces is physical units. The space between a value
and its unit is smaller than a normal space, typically a thin space is used. For units
in text, the smaller space is inserted via the menu Insert ▷ Formatting ▷ Thin Space
(shortcut ).
An example to visualize the difference:
24 kW·h Space between value and unit
24 kW·h Thin space between value and unit
20
\hspace or left-click on the “␣” and check the option Protect.
To insert as much space as is available, the command \hfill is used.
In the last example the available space is given by the longest column entry of the
table. In an inline formula the space depends on the length of the line in which \hfill
is inserted. Thus, when the line uses the full width, no space will be created. \hfill
only has an effect on displayed formulas when the formula style Indented is used.
(Formula styles are explained in sec. 17.)
Besides \hfill, there are also commands, \dotfill and \hrulefill, that fill the space
with a pattern. See sec. 3.9 for an example.
For text, variable space can be inserted via the menu Insert ▷ Formatting ▷ Horizontal Space:
This is a line with 2 cm space.
This is a line with maximum space.
21
9.1. Boxes with Frame
It is possible to frame a formula or part of one with the commands \fbox and
\boxed.
When one of these commands is inserted in a formula, a blue box appears within
a frame to enter formula parts. For \fbox an additional formula has to be created
by Ctrl+M within this box, because the box content will otherwise be treated as
mathematical text. When \boxed is used, a new formula is automatically created
inside the frame.
The command \fbox is not suitable to frame displayed formulas because the formula
will always be set in the size of the documents text. Conversly \boxed is not
suitable to frame inline formulas because the formula will always be set in the size of
a displayed formula.
An extension to \fbox is the command \framebox with which the frame width and
the alignment can be specified. \framebox is used in the following scheme:
The position can either be l or r. l left aligns and r right aligns the formula in the
box. If no position is given the formula will be centered.
If width is not given then position can not be given. In this case the frame width is
adjusted to the box content like for \fbox.
When the command \framebox is inserted, a box appears containing three blue
boxes. The first two boxes are surrounded by brackets and denote the two optional
arguments. The third box is for formula parts like for \fbox.
Command Result
´
\fbox␣Ctrl+M \int␣A=B A=B
ˆ
\boxed␣\int␣A=B A=B
A+\fbox␣B A+ B
A
\framebox␣20mm→→Ctrl+M \frac␣A↓B B
To adjust the frame thickness the following commands are inserted in TEX mode
before the formula:
“distance” specifies the minimum distance between the frame and the first character
22
in the box. An example of this is given in the following framed formula:
A+B =C
were inserted in TEX mode. These values are then used for all following boxes.
\raisebox{height}{box content}
When the box contains a formula, an extra formula is needed like for \fbox.
Note: For \raisebox this extra formula is created by pressing Ctrl+M twice instead
of once because LYX doesn’t yet support \raisebox directly.
Command Result
H\raisebox{2mm→\{al→ lo H allo
H\raisebox{-2mm→\{al→lo H allo
A=\raisebox{-2mm→\{Ctrl+M Ctrl+M \sqrt␣B A = √B
23
9.3. Colored Boxes
To be able to use all commands explained in this section, the LATEX-package color18
must be loaded in the LATEX-preamble with the line19
\usepackage{color}
To create color boxes, the command \colorbox is used in the following scheme:
\colorbox{color}{box content}
The box content can also be a box and a \colorbox can also be part of another box
(see the 2nd and 3rd example). When the box should contain a formula, an extra
formula has to be created, the same way as for \raisebox.20
One of the following predefined colors can be chosen:
black, blue, cyan, green, magenta, red, white and yellow
Command Result
\colorbox{yellow→\{A=B A=B
\colorbox{green→\{\fbox␣←←A=B A=B
´
\fbox␣←←\colorbox{green→\{Ctrl+M Ctrl+M \int␣C=D C=D
\colorbox only colors the box background, not the characters in the box. To color
all characters, the whole formula is highlighted and the desired color is chosen in
the Text Style dialog. The dialog can be called with the toolbar button or the menu
Edit ▷ Text Properties ▷ Customized. The formula number will have the same color as
the formula. If a different color for the formula number is desired, the color must be
changed within the formula.
An example:
ˆ
A=B (1)
ˆ
A=B (2)
18
The LATEX-package color is part of every LATEX standard installation.
19
When text is colored somewhere in the document with a predefined color, LYX loads the LATEX
package color automatically. Thus it is possible that the package is loaded twice, but this does
not cause problems.
20
This also applies for the command \fcolorbox.
24
Formula (1) is completely colored red.
Formula (2) was first completely colored green to set the color for the formula number.
Subsequently the formula characters were colored red.
To color the frame different than the rest of the box, the command \fcolorbox is
used in the following scheme:
\fcolorbox{frame color}{color}{box content}
So \fcolorbox is an extension of the command \colorbox. The frame width is set,
like for \framebox, with \fboxrule and \fboxsep. An example:
A=B
To use colors other than predefined ones, they must be defined first.
One can for example define the color “darkgreen” with the LATEX-preamble line:
\definecolor{darkgreen}{cmyk}{0.5, 0, 1, 0.5}
cmyk is the color space denoting the colors cyan, magenta, yellow and black. The
four comma separated numbers are the portion factors for the corresponding colors
of the color space. The factors can be in the range of 0 - 1. Instead of cmyk, the
color space rgb can also be used for definitions. rgb denotes red, green and blue,
so there are three portion factors for the corresponding colors. Furthermore there is
the color space gray with one portion factor for the gray value.
As an example here is a framed box with the newly defined color darkgreen where
the characters have been colored yellow:
ˆ √
5
B
A dx =
1
(3)
ln 3
Self-defined colors can also be used for text with the help of the command \textcolor:
This sentence is “darkgreen”.
\textcolor is used in the scheme \textcolor{color}{characters to color}.
25
The following example shows a framed parbox in a line:
Such a box is created by right-clicking on the gray box inset. A dialog pops up
showing the box properties. In our case set: Decoration: Rectangular box, Inner
Box: Parbox, Width: 5 cm, Vertical Box Alignment: Middle
In LATEX a parbox is created with the command \parbox which has the following
scheme:
\parbox[position]{width}{box content}
The positions b and t are possible. b for “bottom” means that the box is aligned
within the surrounding text with its last line. With t for “top” this is done with the
first line. When no position is given, the box will be vertically centered, see section
Boxes of the Embedded Objects manual for examples.
To frame formulas completely, including the formula number, the formula must be set
into a parbox. To do this, the command \fbox{\parbox{\linewidth-2\fboxsep-
2\fboxrule}{ is inserted in TEX mode before the formula. \linewidth is the line
width set for the document. Because the frame is outside the parbox, two times the
frame separation and the frame thickness must be subtracted from the line width.
To be able to multiply and subtract in arguments, the LATEX-package calc21 must be
loaded in the LATEX-preamble with the line
\usepackage{calc}
Behind the formula both boxes are closed by entering }} in TEX mode. Here is an
example:
ˆ √
5
B
A dx =
1
(4)
ln 3
26
Paragraph boxes are very useful to comment formulas directly. To do this, \parbox
is used in combination with the command \tag. (more about \tag see sec. 19.5)
An example of a formula commented with \parbox:
This is a description. It
5x − 7b = 3b is distinctly separated from
the formula and multiline.
Such a formula must be inserted completely in TEX mode because LYX does not
yet support the command \parbox in formulas. The formula is created with the
following command sequence:
The command \[5x-7b=3b\tag*\{\parbox{5cm}{ is inserted in TEX mode.22
Then the description follows as normal text and finally }}\] is inserted in TEX mode.
The commands \[ and \] create a displayed formula.
The advantages of \parbox can be seen in this example that was “commented” using
the mathematical textmode:
10. Operators
10.1. Big Operators
To be able to use all of the integral operators listed here, the Load automatically option
for the esint package must be set in the document settings under Math Options.
22
When the formula style Indented is used, \tag*\{ can also be replaced by \hfill. (formula
styles see sec. 17)
27
All big operators can also be inserted via the math toolbar button .
The operators are called big because they are bigger than the sometimes equal look-
ing binary operators. All big operators can have limits as described in the next
subsection.
For all integral operators there is a second version available, ending in op: \intop,
\ointop etc. These operators differ in the style the operator limits are displayed, see
sec. 10.2.
Command Result
Q∞
\prod^\infty␣→_0→A(x) 0 A(x)
Limits of inline formulas are set on the right side of the operator. Limits in displayed
formulas are set above or below the operator, except for integral limits.
To force the limits to be set beside the operator, the cursor is placed directly behind
the operator and the limits type is changed with the menu Edit ▷ Math ▷ Change Limits
Type to Inline (shortcut ). An example:
The default displayed formulas limits type is this:
∞
X 1
2
x=0 x
23
Font styles see sec. 11.1
28
This is how it looks when the limits type is changed to Inline:
X∞ 1
x=0 x2
For integrals, except those ending with op like \intop, \ointop etc., the limits by
default are set beside the operator. But for multiple integrals the limits are often set
below the operator. In the following example the limits type was set to Display and
so set below the integrals: ˚
X dV = U (5)
V
To specify conditions for limits, the commands \subarray and \substack are used.
To create this expression
n
k −2
X
(6)
0<k<1000
k∈N
As in formula (6) there can be too much space beside an operator. This occurs
because the characters following the operator are set beside the limits. To avoid this
the command \smashoperator can be used. To use it, set the package mathtools
in the document settings under Math Options to Load always. \smashoperator sets
the space besides the operator to 0 pt.
Applied on formula (6), one uses the command
\smashoperator{
and inserts the operator with its limits into the braces. Behind the brace one continues
the formula: n
k −2
X
0<k<1000
k∈N
29
It is possible to set the space of only one side of the operator to 0 pt. To do this write
either [l] or [r] between \smashoperator and its brace. l stands for the left and r for
the right side of the operator. Here is an example of the possible \smashoperator
forms:
n=3456
X n=3456
X n=3456
X
Y Xij = Y Xij = Y Xij
1≤i≤j≤n 1≤i≤j≤n 1≤i≤j≤n
When several consecutive operators have limits the typesetting of the limits looks
often imperfect in the output, for example:
To improve the typesetting, in the document settings under Math Options for the
package mathtools, set the option to Load always. Then insert the command \ad-
justlimits directly before the first operator. The example will then look like this:
How to use one limit for several operators is described in sec. 10.5.
k=1
30
Note: \sideset can only be used to decorate big operators, binary operators are
not allowed.
\overset and \underset can also be used to decorate symbols and characters. For
example, the command \overset␣\maltese␣↑a produces:
a
✠
All binary operators can also be inserted via the math toolbar button .
To typeset the Laplace operator, \Delta or \nabla^2 (∇2 ) can also be used instead
of \bigtriangleup.
The character Menu Separator from the menu Insert ▷ Special Character is the operator
\triangleright.
31
can have limits as described in sec. 10.2.
\DeclareMathOperator*{\Lozenge}{\blacklozenge}
defines the command \Lozenge, that inserts a big operator consisting of the black
lozenge symbol from sec. 13.2:
∞
♦
n=1
When self-defined operators are not used several times in the document, they can also
be defined with the commands \mathop and \mathbin, which have the following
scheme:
N
XX
i,j=1
11. Fonts
11.1. Font Styles
Latin letters in formulas can be set in one of the following font styles:
32
Command Result Shortcut
\mathit␣AbC AbC -
\mathrm␣AbC AbC
\mathsf␣AbC AbC
\mathtt␣AbC AbC
\mathscr␣ABC A BC -
Note: The styles \mathbb, \mathcal and \mathscr can only be used for big
letters.
The style \mathnormal is predefined.
The style commands also work for letters in mathematical constructs:
b
A=
C
Characters in mathematical text don’t appear in a math font style but in the text
font style \textrm. Note that their style can’t be set correctly via the text style
dialog. This is a known bug in LYX.24
Instead of the style commands, Edit ▷ Math ▷ Text Style dialog, or the toolbar button,
can be used.
ˆ 2
f (θ) = Γ equation with \mathbf
n
33
11.3. Colored Formulas
Formulas can be colored like normal text: Highlight a formula or a formula part and
use the Text Style dialog. Here is a formula in magenta:
ˆ √
5
B
A dx =
1
ln 3
You can also define your own colors as described in sec. 9.3. They can be used with
the TEX code command \textcolor in the scheme
\textcolor{color}{characters or formula}
The following example was colored completely dark green and partly red:
ˆ √
5
B
A dx =
1
ln 3
Due to a bug in LYX only complete formulas can be colored with self-defined colors.25
The font size produced by the commands depends on the document’s original font
size, which corresponds to the command \normalsize. The other commands produce
character sizes smaller or larger than \normalsize. There are however limits to how
small or large the font size can be changed. If for example the document font size is
12 pt, the command \Huge switches to the same size as \huge.
A size command is inserted in TEX mode before a formula and sets the size for all
of the following formulas and text characters. To switch back to the initial size, the
command \normalsize is inserted behind the formula, again in TEX mode.
Size can also be changed within a formula using the following size commands or the
toolbar button :
25
LyX-bug #5269
34
Command Result
K
\displaystyle Epot1 =
l + nm2
K
\textstyle Epot1 = l+ nm
2
\scriptstyle Epot1 = l+Km
n2
\scriptscriptstyle Epot = Km
1 l+
n2
After entering these commands, a blue box appears in which the formula parts are
inserted.
There is another method for changing the font size, although it only works for symbols
or letters in mathematical text. To use it, one of the above text size commands is
inserted into mathematical text. All characters until the end of the mathematical
text or until another size command will have the selected size. Two examples:
B
A= ·✠
c
✠A✠A ✠A
Before the first formula the command \huge was inserted. The command for the
35
12.1. Small Letters
Command Result
Command Result Command Result
\iota ι
\alpha α \varrho ϱ
\kappa κ
\beta β \sigma σ
\varkappa κ
\gamma γ \varsigma ς
\lambda λ
\delta δ \tau τ
\mu µ
\epsilon ϵ \upsilon υ
\nu ν
\varepsilon ε \phi ϕ
\xi ξ
\zeta ζ \varphi φ
o o
\eta η \chi χ
\pi π
\theta θ \psi ψ
\varpi ϖ
\vartheta ϑ \omega ω
\rho ρ
The big Greek letters appearing upright is caused by a design bug in TEX. To create
correct italic big letters, begin every command with var. For example the command
\varGamma produces Γ . Another way is to load the package fixmath26 with the
LATEX-preamble line
\usepackage{fixmath}
Then all big Greek letters in a document will automatically be typeset italic.
36
Command Result
\Upsilon\boldsymbol\Upsilon ΥΥ
\theta\boldsymbol\theta θθ
13. Symbols27
Many of the symbols listed in this section can also be inserted via the toolbar buttons
and .
37
13.3. The Euro-Symbol €
To use the Euro symbol in formulas, the LATEX-package eurosym must be installed
and loaded with the LATEX-preamble line
\usepackage[gennarrow]{eurosym}
The Euro symbol can now be inserted with the command \euro.
The Euro symbol can directly be inserted with the € key in mathematical text,
without having eurosym installed. When eurosym is installed, \euro can also be
inserted in TEX mode. The official currency symbol can then be inserted with the
command \officialeuro, which is also only available in TEX mode.
An overview about the different Euro symbols:
Command Symbol
formula \euro B
C
mathematical text € €
TEX mode \officialeuro e
14. Relations
All of the following relations can also be inserted via the toolbar button .
38
The characters \lhd and \rhd are bigger than the equal looking operators \trian-
gleleft and \triangleright, respectively.
LYX supports also many special relations. Use the toolbar button to see a list of
these relations.
Contrary to symbols, relations are always surrounded by space.
Relations with labels can be created with the command \stackrel:
Command Result
r→∞
A(r)\stackrel␣r\to\infty␣↓\approx␣␣B A(r) ≈ B
15. Functions
15.1. Predefined Functions
In general, variables are set italic in mathematical expressions, but not function
names, because sin could be misunderstood as s · i · n. Also predefined functions are
separated a bit from the character in front of them. They are inserted as commands
starting with a backslash before their name.
39
• Define the function by inserting the following line in the LATEX-preamble28
\DeclareMathOperator{\sgn}{sgn}
Now the newly defined function can be called with the command \sgn.
• Write the formula as usual, mark the formula name, in our example the letters
sgn, and change it to mathematical text. Finally, insert a space between the
prefactor and function.
The result is the same with both methods as with a predefined function29 :
Command Result
A\sgn(x)+B A sgn(x) + B
A\, sgn (x)+B A sgn(x) + B
|{z}
Alt+M M
The first method is more suitable when the self-defined function will be used several
times.
15.3. Limits
For limits, in addition to the commands \lim, \liminf and \limsup the following
functions are defined:
Command Result
\varliminf lim
\varlimsup lim
\varprojlim lim
←−
\varinjlim lim
−→
The limit is created by inserting a subscript. It is set right beside the function in an
inline formula:
Command Result
\lim_x\to␣A␣x=B limx→A x = B
In a displayed formula the limit is set below the formula, as usual:
lim x = B
x→A
28
For more about \DeclareMathOperator see sec. 10.5.
29
In LYX self-defined functions are displayed red, predefined ones black.
40
How to adjust the typesetting of the limits see sec. 10.2.
15.4. Modulo-Functions
The modulo-function is special, because it exists in four variants. The variants in an
inline formula are:
Command Result
a\mod␣b a mod b
a\pmod␣b␣ a (mod b)
a\bmod␣b␣ a mod b
a\pod␣b␣ a (b)
In a display formula, more space is set before the function names for all variants but
\mod. This later version is also the only one that does not take the b as argument
but acts as a binary operator.
Command Result
\^␣ ˆ
\_ _
The characters Å and Ø can also be inserted via the math toolbar button .
41
The commands !‘ and ?‘ are exceptions because they can be inserted in LYX directly
to text.
With the command \t also two different characters can be accented. The command
\t␣sz creates: s z
The accents ‘ , ’ and ^ can in combination with vowels be directly inserted with the
keyboard without using TEX mode. The same applies for the tilde30 ~ in combination
with a , n , or o.
The commands \b , \c , \d , \H , \t , \u , \v and accents that are inserted
directly with the keyboard are also available in mathematical text. For the other
accents there are special math commands used in formulas, see sec. 7.1.
With the command \textcircled any number or letter can be set into a circle, quasi
accented with a circle, similar to the copyright symbol.
Command Result
\textcircled{w} ⃝
w
\Large \textcircled{\normalsize\protect\raisebox{-1.5pt}{W}} ⃝
W
One has to take care that the character fits into the circle. \Large31 specifies the
size of the circle. With the help of \raisebox32 the character can be centered.
30
This only applies for keyboards where the tilde is defined as accent.
31
See sec. 11.4
32
See sec. 9.2
42
16.3. Old-style Figures
Old-style figures (also known as old-style numerals) are created with the command
\oldstylenums. The command can be used in formulas and in TEX mode. The
command scheme is:
\oldstylenums{number}
The command \oldstylenums{0123456789} produces: 0123456789
43
18.1.1. Line Separation
Sometimes there is not enough space in multiline formulas between the lines:
In LATEX additional line space is specified as an optional argument of the new line
command. This is not yet possible in LYX33 , therefore the whole formula must be
inserted in TEX mode. To add in our example space, the command \\[3mm] is
inserted at the end of the first line. One gets:
To set the line separation for all lines in a formula, the length of \jot is changed.
The definition is: line separation = 6 pt + \jot. \jot is predefined as 3 pt. To create
3 mm of additional line separation as in the previous example, the command
\setlength{\jot}{3mm+3pt}
is inserted in TEX mode before the formula. This requires that the LATEX-package
calc34 was loaded in LATEX-preamble with the line
\usepackage{calc}
One gets:
To get restore \jot to its original value, \jot is set to the value 3 pt.
44
The column separation is specified with the length \arraycolsep according to the
formula: column separation = 2 \arraycolsep
Thus, the command
\setlength{\arraycolsep}{1cm}
inserted in TEX mode, sets all following formula column separations to 2 cm. To
return to the predefined distance, \arraycolsep is set to 5 pt.
A formula with 2 cm column separation:
A = B
C ̸= A
A = B
C ̸= A
45
18.1.3. Long Formulas
Long formulas can be typeset using these methods:
• If one side of an equation is much shorter than the line width, this is chosen
for the left side and the right side is typeset over two lines:
ℏ2 ℏ2 ℏ2 e2
H = WSB + Wmv + WD − ∆− ∆1 − ∆2 −
2m0 2m1 2m2 4πε0 |r − R1 |
2 2
e e
− + (7)
4πε0 |r − R2 | 4πε0 |R1 − R2 |
The minus sign at the beginning of the second line does normally not appear
as an operator because it is the first character of the line. Thus it would not be
surrounded by space and could not be distinguished from the fraction bar. To
avoid this, a 3 pt space was inserted behind the minus sign with the command
\hspace.35
• When both sides of the equation are long, the command \lefteqn is used. It
is inserted in the first column of the first line and causes all further insertions
to overwrite the following columns:
4x2 B 2 + x20 + 4x0 x D − B 2 + B 2 B 2 − 2rg2 + 2x20 − 2rk2 + D2
q
− B 2 − 2B rg2 − x2 + 2x0 x − x20 + rg2 − x2 + 2x0 x − x20
2
rg2 + 2x0 x − x20 − rk2
= B 2 + 2 rg2 + 2x0 x − x20 − rk2 + (8)
B2
After the insertion of \lefteqn, the cursor is in a purple box that is shifted a
bit to the left from the blue one. The formula is inserted there.
The content of additional lines is inserted in the second or another formula
column. The greater the insertion column number , the larger the indentation.
Note the following when using \lefteqn:
∗ The formula doesn’t use the full page width. When e. g. the term −B 2 is
added to the first line in the above example, it would have been outside
the page margin. To better use the width, negative space can be inserted
at the beginning of the first line.
∗ Due to a bug in LYX the cursor cannot be set with the mouse in the first
line.36 One can only set the cursor at the beginning of the line and move
it with the arrow keys.
• Other methods to set long formulas are offered by the environments described
in sec. 18.5 and sec. 18.6.
35
For more about \hspace see sec. 8.2
36
LyX-bug #1429
46
18.1.4. Multiline Fractions
There are cases where the denominator and/or the numerator of a fraction is so long
that the fraction does not fit on one line. It is then necessary to add a line break
within the fraction. This can be done using the command \splitfrac. To activate
it, go to the document settings under Math Options for the package mathtools and
set its option to Load always. \splitfrac has the scheme
\splitfrac{first line}{second line}
and is used for either the denominator or numerator:
xy + xy + xy + xy + xy xy + xy
z
+ xy + xy + xy
+ wy + wy + wy + wy + xy + xy + xy + xy
a= ̸ =
z z
The command for the first numerator above is:
\splitfrac{xy+xy+xy+xy+xy␣\{+wy+wy+wy+wy
The closing bracket is smaller than the opening bracket because brackets with variable
size may not span multiple lines.
To set the bracket size for the second line correctly, the first line is ended with
\right. and the second line with \left.37 . After \left. the command \vphan-
tom␣\prod^␣\infty␣↓_R=1} is inserted, because the multiplication operator with
its limits is the largest symbol in the first line and this should be the size for the
bracket in the second line.
The result is this:
" ∞
Y 1
A = sin(x) + ···
R=1 R
#
··· + B − D
37
For more about \left and \right see sec. 5.1.2
47
18.2. Align Environments
Align environments can be used for every kind of multiline formulas. They are espe-
cially useful to set several formulas side by side.
Align environments consist of columns. The odd columns are right aligned, the even
ones left aligned. Every line in an Align environment can be numbered.
Align environments are created via the menu Insert ▷ Math. With the menu Edit ▷
Math ▷ Change Formula Type pre-existing formulas can be converted to Align environ-
ments.
To add or delete columns, use the math toolbar buttons or respectively, or the menu
option Edit ▷ Rows & Columns can be used.
A = sin(B) C=D
C ̸= A B ̸= D
As it can be seen, the formulas in this environment are placed so as if there would
be a \hfill38 before the first and after every even column. When the formula style
Indented39 is used, the formula is set without the \hfill before the first column.
A = sin(B) C=D
C ̸= A B ̸= D
Because the column separation can be set separately for every column, this environ-
ment is especially suitable to set three or more formulas side by side.
38
For more about \hfill see sec. 8.2
39
For formula styles see sec. 17
48
18.2.3. Flalign Environment
In this environment the first column is always set to the left as much as possible and
the last one to the right. An example:
The first two columns contain the formula. To indent it as with the formula style
Indented, a 30 pt space was inserted at the beginning of the first column.
A=1 (10)
X = -1 (11)
49
Therefore this environment is suitable for long formulas. Using example formula (8)
in the multline environment:
4x2 B 2 + x20 + 4x0 x D − B 2 + B 2 B 2 − 2rg2 + 2x20 − 2rk2 + D2
q
− B 2 − 2B rg2 − x2 + 2x0 x − x20 + rg2 − x2 + 2x0 x − x20
2
rg2 + 2x0 x − x20 − rk2
= B 2 + 2 rg2 + 2x0 x − x20 − rk2 + (12)
B2
In the output, only the last line of a multline environment appears numbered when
the document numbering is on the right . If the document numbering is on the left
then only the first line will appear numbered.40
With the commands \shoveright and \shoveleft a centered line can be right or left
aligned, respectively. The commands are used as follows:
The length \multlinegap specifies the distance of the first line from the left page
margin. Predefined is the length 0 pt.
\setlength{\multlinegap}{2cm}
50
The first three have the same properties as the corresponding multiline formula envi-
ronments, but it is possible to set additional formula parts beside them. An example:
ℏ
∆x∆p ≥
2 Uncertainty relations
ℏ
∆E∆t ≥
2
To get this formula, a displayed formula is created where the command \aligned is
inserted. A purple box appears around the blue formula box where now columns and
lines can be added. Outside the multiline environment other formula parts can be
set, like the brace.
The aligned environment is also suitable for long formulas whose lines are horizontally
aligned. Using aligned in a displayed formula has the advantage that the formula
number is vertically centered behind the lines. For example here is formula (7) in the
aligned environment:
ℏ2 ℏ2 ℏ2 e2
H = WSB + Wmv + WD − ∆− ∆1 − ∆2 −
2m0 2m1 2m2 4πε0 |r − R1 |
2 2
(14)
e e
− +
4πε0 |r − R2 | 4πε0 |R1 − R2 |
51
\intertext always creates some vertical space between the text and the formula
lines. To avoid this space, in the document settings under Math Options for the
package mathtools set the option to Load always. Then you can use the command
\shortintertext instead of \intertext:
√ ˆ 2π q
I=a 2 1 + cos(ϕ) dϕ (17)
0
integrand is symmetric to ϕ = π, therefore
√ ˆ πq
= 2a 2 1 + cos(ϕ) dϕ (18)
0
19.2. Cross-References
All labeled formulas can be cross-referenced. A label is added with the menu Insert ▷
Label or the toolbar button . The cursor must be inside a displayed formula. Alter-
natively you can right-click on the formula and choose Equation Label. A dialog pops
up displaying the prefix eq: in a text field. The label is inserted behind the prefix.
The predefined prefix means “equation” and makes it easier to find labels in large
documents because it marks it as a formula label to distinguish it from e. g. section
labels. To change a label, the menu Insert ▷ Label is used again or you can right-click
on a formula and then on Equation Label.
The name of the label is displayed in LYX within parentheses behind the formula
number. A formula with a label is always numbered.
Cross-references are inserted via the menu Insert ▷ Cross-Reference or with the toolbar
button . A formula cross-reference appears in the output as formula number. When
52
in the cross-reference dialog window the format (<reference>) is chosen, the cross-
reference appears in the output as formula number in parentheses.
By right-clicking on a cross-reference in LYX, one jumps to the formula that is refer-
enced.
Here are as examples cross-references to formulas of the following subsections:
The equations (something) and (20b) are equivalent. In (Y) big Latin letters are
used for the numbering in contrary to (XXIII).
When the argument of \tag41 contains a box like in sec. 9.4, the formula cannot be
referenced.
19.3. Subnumbering
Formulas can be numbered as subequations. To activate this feature, add the module
Subequations to the document in the menu Document ▷ Settings ▷ Modules. To insert
subequations use the menu Insert ▷ Custom Insets ▷ Subequations.
The equations to be subnumbered are put into the Subequations inset. An example:
A=C −B (19)
B =C −A (20a)
C =A+B (20b)
53
Here is an example of a multiline formula where the numbering is customized and
turned off for the second line:
54
E = Arabic (26)
As you see, formulas are numbered serially independent from the numbering style.
When then numbering should start with “1” when the style is changed, new equation
counters have to be defined. A description of this can be found in the file Formula-
[Link].
When there should be an expression of your choice instead of the consecutive formula
number in parentheses behind the formula, the command \tag is used:
A+B =C (something)
To restart the formula numbering with new document parts or sections, the following
command is used:
\@addtoreset{equation}{part}
resp.
\@addtoreset{equation}{section}
55
To be able to use these commands in TEX mode, the “@” character has to be made
“active” for LATEX using the command \makeatletter. The command \makeatother
disables this. So the command sequence in TEX mode is:
\makeatletter
\@addtoreset{equation}{section}
\makeatother
In the LATEX-preamble \makeatletter and \makeatother can be omitted as they
are automatically internally inserted by LYX.
To revert \@addtoreset, the file remreset.sty44 has to be loaded in the LATEX-
preamble with the line
\usepackage{remreset}
Then the command \@removefromreset can be used with the same scheme as
\@addtoreset.
56
\renewcommand{\theequation}{\arabic{equation}}
or
\renewcommand{\thetable}{\arabic{table}}
\numberwithin internally uses the command \@addtoreset, described above, and
would also need to be reverted.
2 Na+ + SO2−
4 −→ Na2 SO4 (28)
Command Result
\ce␣H2CO3 H2 CO3
\ce␣SO4^2- SO42−
\ce␣(NH4)2S (NH4 )2 S
\ce␣KCr(SO4)2.12H2O KCr(SO4 )2 · 12 H2 O
\ce␣A-B\dbond␣C\tbond␣D A−B−C−
−D
227 +
\ce␣^227↓_90→Th+ 90Th
\ce␣\mu␣\hyphen␣Cl µ-Cl
\ce␣CO2␣+␣C␣<=>␣2CO CO2 + C −
↽−
−⇀
− 2 CO
α
\ce␣CO2␣+␣C␣->[\alpha][\beta]␣2CO} CO2 + C −−
β
→ 2 CO
Note: It is not possible in LYX to use the character ^ to get an up-arrow as described
in the mhchem manual. One instead uses a negative thin space followed by the
command \uparrow: Fe + 2 H+ −−→ Fe2+ + H2↑
45
For font styles see sec. 11.1
57
Using \ce the command for equation (28) is:
\ce␣2Na+␣+␣SO4^2-␣␣->␣Na2SO4
To create multiline chemical equations first a multiline formula is created as described
in sec. 18. Afterwards the command \ce is used in every small blue box of the formula.
(29) and (30) are an example of a multi-stage chemical reaction where every equation
has its own number.
Besides \ce the mhchem package provides the command \cf that is used for spe-
cial cases. For more information about \cf and more examples have a look at the
documentation of mhchem, [7].
21. Diagrams
LYX supports two types of commutative diagrams: amscd and xymatrix and are
explained below.
A −−−→ B −−−→ C
x
y
F ←−−− E ←−−− D
To create them, the command \CD is inserted to a formula. A blue box appears
with two dashed lines where additional commands can be inserted. With a new line
is created. Horizontal relations are inserted in odd formula lines, vertical in even
formula lines.
To create the relations use the following commands:
• @<<< creates a left arrow, @>>> a right arrow and @= a long equal sign
• @AAA creates an up arrow, @VVV a down arrow and @| a vertical equal
sign
• @. is a placeholder for non-existent relations
All arrows can be labeled as follows:
58
• If text inserted between the first and second < or >, resp., it is placed above
the arrow. When it is inserted between the second and third one, it appears
under the arrow.
• When text for vertical arrows is inserted between the first and second A or V,
resp., it is placed left beside the arrow. When it is inserted between the second
and third one, it appears right beside the arrow. If the text contains an A or
V, these letters must be set into a TEX brace.
j
A −−−→ B −−−→ C F
k
x
m V
y
k
D ←−−− E −−−→ F C
j
Contrary to amscd diagrams, xymatrices support diagonal and curved arrows, and
much more. The commands used to create commutative diagrams and decorations are
explained in detail in the XY-pic manual found in the menu Help ▷ Specific Manuals.
59
22. User-defined Commands
Note: The names of user-defined commands and macros may only consist of Latin
letters.
60
A test of the new defined commands:
Command Result
A\gr␣B A =⇒ B
\us{ABcd ABcd
´
\fb{[2cm]→\{→\{\int␣A=B A=B
´
\cb{red→\{\int␣A=B A=B
´
\cb[green]\{red→\{\int␣A=B A=B
As is obvious, commands defined in the preamble do not display ‘nicely’ in LyX itself.
Most such commands can be defined in LyX using ‘math macros’, however, which we
are about to explain, and these do display nicely.
To define a command for the solution formula where only the three parameters λ,
p and q need to be specified and the index of λ can be given optionally, the LATEX-
preamble line is
\newcommand{\qG}[4][1,\,2]{#2_{#1}=-\frac{#3}{2}\pm
\sqrt{\frac{#3^{2}}{4}-#4}}
To create with this the solution formula, the command
\qG{\lambda→\{p→\{q is inserted to a formula.
The definition of the new command is unintuitive because one has to know the
schemes of all used LATEX commands, e. g. that a fraction is inserted in LATEX as
\frac{numerator}{denominator}. Furthermore one can easily forget a brace
in the definition and cannot see in LYX what the new command is doing. To avoid
these problems LYX offers the possibility to use math macros instead of the command
\newcommand.
A math macro is created by using the menu Insert ▷ Math ▷ Macro or the toolbar but-
ton . The math macro toolbar appears together with the following box where the
61
macro is defined:
\newmacroname is the default name of the macro that should be changed to some-
thing sensible. The wanted formula is inserted in the first blue box. An argument
placeholder is inserted with the command \#argumentnumber, e. g \#1 or by
using the macro toolbar button . Argument placeholders are displayed red. A maxi-
mum of 9 arguments are possible. Optional arguments are created with the toolbar
button . The first non-optional argument can be transformed to an optional one with
the toolbar button . In the second blue box the appearance of the macro in LYX can
be defined. Normally you want to see it as it is defined, so the box is kept empty.
But when you have created a macro that needs lot of space on the screen, you can
insert in the box for example
qG: \#1 , \#2 , \#3, \#4
For the macro only the arguments with the macro name in front of them will then be
displayed in LYX, leading to a better overview. The formula appears in the output
as defined in the first box.
The appearance of macros in formulas can furthermore be changed for single macros
by setting the cursor in the macro and using the menu View ▷ (Un)fold Math Macro.
To use a macro, the macro name is inserted as command to a formula, in our case
\qG. Our macro looks in LYX like this:
s
ln(x) ln(x)2
x1, 2 =− ± −B
2 4
LYX offers in the menu Tools ▷ Preferences ▷ Editing ▷ Control different styles to edit
macros. To find the style that suits you best, choose a style and set the cursor in a
macro formula to see the difference.
A math macro is transformed internally to a \newcommand command when ex-
porting the document. The created \newcommand command is not placed in the
LATEX-preamble, therefore macros can only be used in formulas that are in the doc-
ument below the macro definition box.
Math macros can also be directly created from a \newcommand command. When
writing for example the command
\newcommand{\larrow}[2]{\xleftarrow[#2]{#1}}
in LYX as normal text, highlighting it completely and using the shortcut Ctrl+M, the
command will be transformed to a math macro. Using this method you need to be
62
careful that the \newcommand command is typed correctly, otherwise you get a
faulty macro leading to LATEX errors.
Math macros currently have the problem that further formulas in macro definitions
are handled wrong. Therefore the example \fb from sec. 22.1 cannot be created as
macro.
When the cursor is in a macro definition box, you will see the macro toolbar in LYX:
The macro toolbar contains from left to right the following buttons:
63
a single argument into corner quotes. To get a nice LYX display of this macro, just
do:
The same trick, of course, can be used for commands defined in the preamble.
23.1. Usage
Write some expression in a formula, go to the Edit ▷ Math ▷ Use Computer Algebra
System menu and choose the application you have installed on the computer. After
that the result of computation should show on the right side of the expression together
with the “=” operator.
Here are few simple examples (with results from Maxima) to show what kind of com-
putations can be performed:
37 P3
• 3
∗2− i=1 ii = − 22
3
37.0
• 3
= 12.33333333333333
´2
• 1
sin(x)dx = cos 1 − cos 2
´ log( ) x2 −x+1 arctan 2 √x−1
+ log(x+1)
1 3
• dx = −
1+x3 6
+ 3
√
3
Note: One needs to use proper delimiter insets () instead of simple ’(’ ’)’
characters.
1 6 7
• det 2 5 8 = −56
3 4 17
sin(x)
• limx→0 x
=1
P∞ 4−i2 −1 (x−1)i2 +1
• powerseries (− log (5 − x) , x, 1) = i2 =0 − log 4 i2 +1
√ 3 √ 3
3 2 4 y1 −4 y1 +1−1 4 y1 −4 y1 +1+1
• solve (x1 + y1 = y1 + x1 , x1 ) = x1 = − 2
, x1 = 2
64
23.2. Keyboard shortcut
Currently there is no keyboard shortcut for calling the algebra applications. One
can easily bind a shortcut to the math-extern LYX function (see the LYX Functions
manual). One could e. g. bind the Return key inside the math editor. To bind it to
Maxima one would use this shortcut definition command:
command-alternatives paragraph-break;math-extern maxima
24. Miscellaneous
24.1. Negative Numbers
Negative numbers often look ugly in formulas because the minus sign before the
number is set with the same length as the minus operator sign. When writing the
negative number in normal text, the minus sign appears correctly.
Thus, the problem disappears when converting the minus sign to mathematical text.
An example to visualize the problem:
normal text: x = -2
formula: x = −2
solution: x = -2
65
The following commands are defined:
Command Result
\Bra{\psi ⟨ψ|
\Ket{\psi |ψ⟩
\Braket{\psi|\phi ⟨ψ | ϕ⟩
The command \Braket assures that all vertical bars are set in the size of the sur-
rounding brackets:
3
ϕ J = , MJ
2
The effect of \Braket can also be achieved using the command \middle, that is
described in sec. 5.1.2.
For example, the commands \dfrac and \tbinom from sec. 3.2 are defined with the
commands
\newcommand{\dfrac}[2]{\genfrac{}{}{}{0}{#1}{#2}}
and
\newcommand{\tbinom}[2]{\genfrac{(}{)}{0pt}{1}{#1}{#2}}
To define a fraction where the fraction bar thickness can be given as optional argu-
ment, the following line is inserted to the LATEX-preamble:
66
\newcommand{\fracS}[3][]{\genfrac{}{}{#1}{}{#2}{#3}}
A test:
A
Result
B
B
As one can see, the distance of the numerator and the denominator to the fraction
bar is round about three times the bar thickness.
Command Result
´
\cancel␣\int␣A=B A=B
´X
\bcancel␣\int␣A=B AX=XB
X
´
X
\xcancel␣\int␣A=B A=XB
XXX
X
´ :
1
\cancelto␣\int␣A=B→1 A=B
To change the size of \cancelto’s “subscript” value one can add the LATEX-preamble
line
\PassOptionsToPackage{option}{cancel}
where option is either samesize which leads to the same size as for the canceled
value, or Smaller which makes is it a bit smaller than normal.
To color the cancellation bar one adds this command as TEX code:
\renewcommand{\CancelColor}{\color{red}}
red can be replaced by a color of your choice.
67
(x0 + bB)2 x20 + B 2 − rg2
2 =
1+
b2
(1 + b2 )3
For further customizations, see the documentation of the package cancel, [5].
68
multicol48 , that is loaded with the LATEX-preamble line
\usepackage{multicol}
Note that in this case the setting Two-column document in the menu Document ▷
Settings under Text Layout must not be selected.
Before the multi-column text the command
\begin{multicols}{column number}
is written in TEX mode. The column number is a number in the range of 2 - 10.
Before the formula the multi-column text is ended by inserting the command
\end{multicols}
in TEX mode.
Due to the command some space is automatically added before the formula. To
correct this, -6 mm vertical space is inserted before the formula. When the formula
style Indented49 is used, a -9 mm space is inserted instead.
As example a multi-column text with a displayed formula:
Das Spektrum wird fouriertransformiert. riment haben wir es mit sehr vielen Teil-
Die Fouriertransformation wird verwen- chen zu tun, so dass man über alle Pha-
det, um die überlagerten Signale (Netz- sen integrieren muss. Sei nun S unser nor-
werk, Lösungsmittel) zu trennen. Nach- miertes Ausgangssignal und P die Pha-
dem wir die Phasenverschiebung bestim- senverteilungsfunktion, so ergibt sich die
men konnten, interessiert uns nun das Beziehung
Aussehen des Ausgangssignals. Im Expe-
ˆ ∞
S(t) = S0 (t) P (ϕ, t)eiϕ dϕ (31)
−∞
wobei S0 das Signal ohne Gradient beginnt sich die Magnetisierung zu ent-
ist
´ ∞ und die Normierungsbedingung fokussieren, wodurch sich das Signal zu-
−∞
P (ϕ, t) dϕ = 1 gilt. Nun dürfen wir sätzlich abschwächt. Diese Abschwächung
aber nicht den Relaxationsprozess außer verläuft exponentiell in Abhängigkeit der
Acht lassen. Direkt nach dem π/2 -rf-Puls so genannten T2 -Zeit.
69
smaller size, before the matrix e. g. the command \footnotesize is inserted.51
When the formula style Indented52 is used, a \hfill53 is inserted before and after
the matrix to have the same separation of the matrix from the equation and the side
margin.
When the formula style Centered is used, the method described in sec. 18.2.3 is
used to indent formulas. Formula (32) consists of five columns where in the first two
columns contain the equation, the third the matrix and the last one an empty TEX
brace.
ρ density
FA = ρ · V · g V volume (32)
g gravitational acceleration
π+ → µ+ + νµ
The upright letters are more bold and wider than the italic ones. They should
therefore not be used for units like “µm”.
70
\Declare Inputtext{183}{\ifmmode\cdot\else\textperiodcentered\fi}
The character encoding (menu Document ▷ Settings ▷ Language) specifies what char-
acter appears when a keyboard key is pressed. When the key for the character ’·’ is
pressed, internally the command \textperiodcentered is used. But this command
is not available in a formula so that you would get LATEX-errors. With the changed
encoding the correct command is chosen automatically, depending on if the character
was inserted into a formula or not.
The encoding of several characters is saved in definition files. For example the encod-
ing latin9 is defined in the file [Link] which is in the installation folder of LATEX.
Encodings should only be changed via the LATEX-preamble and not in the definition
files. Otherwise documents could not be edited by other LYX users working on other
computers.
Besides the centered dot, in this document the degree sign ° is defined with the
following LATEX-preamble line so that it can be directly inserted into a formula:
\DeclareInputtext{176}{\ifmmode^\circ\else\textdegree\fi}
A=B
56
LyX-bug #9002
71
A. Typographic Advice
This section is a summary of the most important typographic rules, listed in ISO
norms.57
• Physical units are always set upright58 , no matter if they appear in italic text:
30 km/h
Between the value and the unit is the smallest space, see sec. 8.1.
This convention is automatically fulfilled when the command \unittwo is
used. When it is entered in a formula, two boxes appear. In the first one
the value is inserted, in the second one the unit, and the result is as above:
30 km/h . Note that \unittwo is not a real LATEX command but the command
\unit[value]{unit}, therefore you cannot use it in TEX code.
• Percent and perthousand signs are set like physical units:
1.2 ‰ alcohol in blood
• The degree sign follows the value directly: 15°, except when it is used in units:
15 °C
• In numbers with more than four digits the smallest space is inserted before
every third digit to group them: 18 473 588
• For dimensions like 120×90×40 cm the multiplication sign “×” is used. It is
available either via the command \times or via the menu Insert ▷ Special Char-
acter ▷ Symbols.
• Functions with names consisting of several letters are set upright to avoid con-
fusions, see sec. 15.1.
• Indices consisting of several letters, are set upright: Ekin
Components of matrices are set italic: Ĥkl
• The differentiation/integration operator ’d’, the Euler’s number ’e’ and the
imaginary unit ’i’ should be set upright, to avoid mixing them up with other
variables.
• The character that denotes a Fourier transformation is inserted either by the
command \mathscr␣F or via the menu Insert ▷ Special Character ▷ Symbols ▷
Letterlike Symbols: F
57
This collection was partly taken from the German semi-official dictionary called “Duden” [8] that
lists some of the ISO rules. More rules are listed in [9].
58
Done with font styles, see sec. 11.1
72
B. Synonyms
Some characters and symbols can be created with several commands. Here is a list
of the synonym commands:
73
References
[1] F. Mittelbach; M. Goossens: The LATEX Companion. Addison Wesley, 2004
[2] Description of LATEX’s math abilities
[3] Description of AMS-LATEX
[4] List of all symbols available with LATEX-packages
[5] Documentation of the LATEX-package cancel
[6] Documentation of the LATEX-package hyperref
[7] Documentation of the LATEX-package mhchem
[8] Duden Band 1. 22. Auflage, Dudenverlag, 2000
[9] Check list for reviewing manuscripts
74
Index
e, 38 \arabic, 54, 57
\arraycolsep, 11, 45
Accents, 17 \arraystretch, 11
for one character, 18 B
for several characters, 19 \big, 12
in text, 42 \bigl – \bigr, 12
Arrows, 15 \bigm, 12
diagonal, 17 \binom, 6
horizontal, 16 \boldmath, 33
labeled, 16 \boldsymbol, 36
vertical, 17 \boxed, 22
Binomial coefficients, 6 \brace, 6
Boxes, 21 \brack, 6
as paragraph, 25 C
colored, 24 \cases, 7
with frame, 22 \CD, 58
without frame, 23 \cdots, 9
Bracket size \ce, 57
automatic, 13 \cf, 58
manual, 12 \cfrac, 5
Brackets, 12 \colorbox, 24
for multiline expressions, 47 D
horizontal, 14 \DeclareMathOperator, 31, 40
vertical, 12 \dbinom, 6
\definecolor, 25
Case differentiations, 7 \dfrac, 4
Chemical characters \displaystyle, 1, 35
Isotopes, 7 \dotfill, 10
Symbols, 57 \dots, 9
Chemical equations, 57 E
Comma, 65 \euro, 38
Commands F
@ \fbox, 22
\@addtoreset, 55 \fcolorbox, 25
\@removefromreset, 56 \frac, 4
A \framebox, 22
\Alph, 54 G
\adjustlimits, 30 \gathered, 51
\aligned, 51 \genfrac, 66
\alignedat, 51 H
\alph, 54 \hdotsfor, 9
75
\hfill, 21 \right, 11, 13, 47
\hphantom, 8 \roman, 54
\hrulefill, 10 \root, 6
\hspace, 20, 46 \rule, 8
I S
\int, 27 \setlength, 21
\intertext, 51 \shortintertext, 52
J \shoveleft, 50
\jot, 15, 44 \shoveright, 50
L \sideset, 30
\ldots, 9 \smallmatrix, 11
\left, 11, 13, 47 \smashoperator, 29
\lefteqn, 46 \split, 51
\leftroot, 6 \splitfrac, 47
\lim, 40 \sqrt, 6
\linewidth, 26 \stackrel, 39
M \subarray, 29
\makebox, 23 \substack, 29
\mathbin, 32 \sum, 27
\mathop, 32 T
\mathsurround, 21 \tag, 55
\mbox, 23 \tbinom, 6
\middle, 14 \texorpdfstring, 68
\multlinegap, 50 \text, 2
N \textbackslash, 12
\newcommand, 60 \textcircled, 42
\nicefrac, 5 \textcolor, 25, 34
\not, 7 \tfrac, 4
\numberwithin, 56 U
O \unboldmath, 33
\officialeuro, 38 \underbrace, 14
\oldstylenums, 43 \underbracket, 14
\overbrace, 14 \underline, 8
\overbracket, 14 \underset, 19, 30
\overline, 8 \unitfrac, 5
\overset, 19, 30 \uproot, 6
P V
\parbox, 26 \vphantom, 8, 47
\phantom, 7 X
\prod, 27 \xleftarrow, 16
R \xrightarrow, 16
\Roman, 54 Comparisons, see Relations
\raisebox, 23 Cross-references
\renewcommand, 11, 54 to formulas, 52
76
Delimiters, 12 multiline, 47
Diagrams self-defined, 66
amscd, 58 Frames, see Boxes
Feynman, 59 Functions
xymatrix, 59 modulo-, 41
predefined, 39
Ellipses, 9 self-defined, 39
Exponents, 3
Greek letters, 35
Font big, 36
size, 34 bold, 36
style, 32 small, 36
Fonts, 32 upright, 70
Formula
bold, 33 Indices, 3
canceled, 67 Integrals, 27
colored, 34 Isotopes, see Chemical characters
display style, 1 LATEX-preamble, 2
in multi-column text, 68 LATEX-comments, 71
in section headings, 68 Limits, 40
inline, 1 Lines, 8
long, 46
multiline, 43 Macros, 61
align environment, 48 Toolbar, 63
alignat environment, 48 Mathematical text, 2
Column separation, 44 Matrices, 10
eqnarray environment, 49 Miscellaneous, 65
flalign environment, 49
formula parts, 50 Negations, 7
gather environment, 49 Numbers
Line separation, 44 negative, 65
multline environment, 49 Old-style Figures, 43
text, 51 Operators, 27
numbering, see Formula numbering big, 27
styles, 43 binary, 31
underlined, 8 Decoration, 30
with description of variables, 69 Limits, 28
Formula numbering, 52 self-defined, 31
self-defined delimiters, 55
subnumbering, 53 Packages
user-defined, 55 braket, 65
with letters, 54 calc, 26, 44
with Roman numbers, 54 cancel, 68, 74
Fractions, 4 carlisle, 56
77
color, 24 Vectors, 18
eurosym, 38 physical, 65
fixmath, 36
hyperref, 68, 74
icomma, 65
mathtools, 14, 16, 29, 30, 47, 52
mhchem, 57, 74
multicol, 69
remreset, 56
undertilde, 18
upgreek, 70
was, 36, 65, 70
Placeholders, 7
Relations, 38
Roots, 6
Space
besides inline formulas, 21
horizontal, 19
predefined, 19
variable, 20
Special characters, 41
Subscripts, see Indices
Sums, 27
Superscripts, see Exponents
Symbols, 37
chemical, 57
Euro-symbol, 38
mathematical, 37
miscellaneous, 37
Synonyms, 73
TEX-braces, 2
TEX-mode, 2
Text
colored, 25
in formulas, 2, 51, 70
Tilde, 42
Typographic advice, 72
Umlauts, 18
User-defined commands, 60
Math macros, 61
\newcommand, 60
78
Math mode and TEX mode in LYX offer different functionalities, impacting scientific documentation significantly. Math mode provides a WYSIWYG interface for creating and editing mathematical formulas, with automatic formatting and error-checking features. TEX mode, however, allows access to the raw LATEX code, offering greater flexibility and precision in more complex formula formatting and customization, essential for advanced users dealing with intricate mathematical expressions .
The \unittwo command in LYX automatically formats physical units by separating the value and unit with the smallest space, adhering to typographical norms. However, this command is not a true LATEX command and thus incompatible with direct TEX code. Users must consider this limitation and decide whether to use \unit[value]{unit} for compatibility across different LATEX editors and environments .
The \parbox command in LATEX is advantageous for adding multi-line comments directly to formulas, enhancing readability and contextual understanding. This command is necessary in TEX mode for LYX because LYX does not yet support \parbox in its formula interface, requiring manual entry through TEX commands to achieve the desired separation between the formula and its description .
The command syntax in LATEX, characterized by commands starting with backslashes and encompassing both optional and required arguments, is central to text formatting and mathematical expression creation. LYX facilitates this through its intuitive menu options, automatically structuring commands with necessary syntax elements, such as TEX braces, offering users a combination of WYSIWYG editing and traditional LATEX coding .
In LYX, TEX braces and normal braces have distinct functionalities and visual representations. TEX braces, which are produced when a left brace is attached to a command name inside a formula, are highlighted in red and do not appear in the output. They are essential for denoting required arguments in LATEX commands. Normal braces, however, appear blue in LYX and are displayed in the final output, serving as content delimiters within formulas .
In LYX, limits in inline formulas are set to the right side of operators, while in displayed formulas they are typically placed above or below the operator. This distinction affects the visual presentation and clarity of formulas, necessitating consideration of formula type when setting limits for accurate display in document formatting .
Big operators, such as sums and integrals, are pivotal in LYX for representing significant operations in mathematical expressions. Their larger size distinguishes them from binary operators. Effective management of their limits involves understanding LYX's behavior where limits in displayed formulas are placed above or below the operators, contrasting with inline formulas where they appear to the right .
Changing LATEX preambles in LYX is significant for document customization, allowing modifications such as character encoding settings that influence character input and display in formulas. Through the Document Settings menu, users can adjust these preambles to ensure that specific LATEX commands are used for characters in the correct contexts, aiding adaptability across different document requirements or language needs .
Typographical rules in LYX dictate that physical units should always be upright regardless of surrounding italic text, with the smallest space separating value and unit. Similarly, percent and per-thousand signs are treated as units and follow numerical values directly. Adhering to these rules ensures consistency and clarity in scientific and mathematical documentation, aligning with standardized conventions .
Character encoding plays a crucial role in inputting symbols correctly in formulas using LYX. For characters like the centered dot and degree sign, encoding is defined such that specific commands (\cdot and \degree) are automatically selected based on whether the symbol is used in a formula or regular text. This automatic selection ensures accurate representation and prevents LATEX errors .