Embedded Objects
Embedded Objects
Version 2.4.x
∗ Ifyou have comments or error corrections, please send them to the LYX Documentation
mailing list: lyx-docs@lists.lyx.org
Contents
1. Figures 1
1.1. Graphics Dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2. Figure Floats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3. Image Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2. Tables 7
2.1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2. Table Dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3. Table Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.4. Edit Table Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.5. Table Floats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.6. Multi-page Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.6.1. Footnotes in Multi-page tables . . . . . . . . . . . . . . . . . . 13
2.6.2. Multi-page Table Alignment . . . . . . . . . . . . . . . . . . . 13
2.6.3. Multi-page Table Captions . . . . . . . . . . . . . . . . . . . . 14
2.6.3.1. References to multi-page tables . . . . . . . . . . . . 15
2.6.3.2. Caption Width . . . . . . . . . . . . . . . . . . . . . 15
2.6.3.3. Different Captions for Table Pages . . . . . . . . . . 16
2.7. Special Multi-page Table Issues . . . . . . . . . . . . . . . . . . . . . 18
2.7.1. Multi-page Table Calculation . . . . . . . . . . . . . . . . . . 18
2.7.2. Floats and Multi-page Tables . . . . . . . . . . . . . . . . . . 18
2.7.3. Forced Page Breaks . . . . . . . . . . . . . . . . . . . . . . . . 19
2.8. Multiple Lines, Columns and Rows . . . . . . . . . . . . . . . . . . . 22
2.8.1. Multiple Lines in Table Cells . . . . . . . . . . . . . . . . . . . 22
2.8.2. Multicolumns . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.8.2.1. Multicolumn Basics . . . . . . . . . . . . . . . . . . 22
2.8.2.2. Multicolumn Calculations . . . . . . . . . . . . . . . 23
2.8.3. Multirows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.8.4. Cells with diagonal line(s) . . . . . . . . . . . . . . . . . . . . 25
2.9. Formal Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.10. Vertical Table Alignment . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.11. Colored Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.11.1. Colored Cells . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.11.2. Colored Rows . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.11.3. Colored Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.12. Rotated Table Cells . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
i
Contents
3. Floats 47
3.1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.2. Float Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.2.1. Algorithm Floats . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.3. Float Numbering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3.4. Referencing Floats . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
3.4.1. Cross-Reference Formats . . . . . . . . . . . . . . . . . . . . . 49
3.4.2. Automatic Reference Naming . . . . . . . . . . . . . . . . . . 51
3.4.3. Reference Position . . . . . . . . . . . . . . . . . . . . . . . . 51
3.5. Float Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.5.1. Float Placement . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.5.2. Alignment of Float Contents . . . . . . . . . . . . . . . . . . . 54
3.5.3. Other Float Options . . . . . . . . . . . . . . . . . . . . . . . 54
3.6. Rotated Floats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
3.7. Subfloats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
3.8. Floats Side by Side . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
3.9. Caption Formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
3.10. Caption Placement . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
3.11. Listings of Floats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
4. Notes 63
4.1. LYX Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
4.2. Footnotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
4.2.1. Footnote Numbering . . . . . . . . . . . . . . . . . . . . . . . 65
4.2.2. Footnote Placement . . . . . . . . . . . . . . . . . . . . . . . . 66
4.3. Margin Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
5. Boxes 71
5.1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
5.2. Box Dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
5.2.1. Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
5.2.2. Alignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
5.2.3. Decoration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
5.3. Box Customization . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
5.4. Minipages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
5.5. Parboxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
ii
Contents
Bibliography 107
Index 109
iii
1. Figures
1
1. Figures
So you can for example change the size for a bunch of images without the need
to manually change each of them. Joining an existing group can also be done
using the context menu of the image by checking the name of the desired group.
1 5500
50
5000
100
150
4500
200
256 4000
1 50 100 150 200 256
This is the same image like the one above but in draft mode:
32_usr_local_share_lyx-2_4_0_devel_doc_clipart_2D-intensity-
1
Image formats are explained in section 1.3.
2
1.2. Figure Floats
3
1. Figures
Figure 1.3.: Two distorted images. Both images are in the image settings group
named “distorted”.
4
1.3. Image Formats
2
In the case of PDF, the original image is additionally compressed.
5
2. Tables
2.1. Introduction
You can insert a table using either the toolbar button or the menu Insert ▷ Table. The
toolbar button offers you a graphical selection: move the mouse to set the column/row
number of the table that should be created and then press a mouse button. When
you use the menu to create a table, a dialog will appear, asking you for the number
of rows and columns, and you can select a specific (border) style.
The default table has lines around any cell and the first row appears separated from
the rest of the table. This separation occurs due to a double line: The cells of the
first row have a line below them and the cells of the second row have a line above
them. Here is an example table:
1 2 3
A
B
C
This corresponds to the “Grid with Head” table style listed in the style selection.
Other available styles include:
• A “simple grid” which looks line the above table, but without the first row
being separated via double line,
• a border-less table with no lines at all,
• and a so-called “formal table” as often used in professional publishing with
horizontal lines only and bold top/bottom lines (see Embedded Objects manual,
section Formal Tables). It is also possible to have an horizontal (thin) Footline
above the last line.
The default style used in the dialog as well as the style used by the toolbar button
can be changed in Document ▷ Settings ▷ Text Layout. So if the default style above is
not the one you need, you should alter this setting.
7
2. Tables
You can alter a table by clicking on it with the right mouse button, which brings up
the context menu. Under the menu entry More you can adjust the settings of that
cell and row/column respectively where the cursor is currently placed. The context
menu More ▷ Settings opens the table dialog where you can adjust more things. Most
of the dialog options also work on selections. This means if you select more cells,
columns or rows, the action is done for the whole selection. Note that there is a
difference between selecting the contents of the cell, and the cell itself.
With the dialog option Immediate Apply every change you make in the dialog is
directly applied. If you move the cursor to another table cell the dialog will then also
be updated with the parameters of the new cell. If you change length values in the
dialog you must press Return to get the change applied.
You can alter tables with the following tabs of the table dialog:
Table Settings Here you can set the table width, and the horizontal alignment and
the width of the current column. The alignment At Decimal Separator is de-
scribed in section 2.14.2. When you have set a width you can also adjust the
vertical alignment of the current row. A given width will allow the cell to have
line breaks and multiple paragraphs of text, see sec. 2.8.1. If you set no width,
the column is as wide as the content of its widest cell.
Furthermore, you can mark one or multiple cells of one row as a multicolumn
cell, see sec. 2.8.2 or the cells of one column as multirow cell, see sec. 2.8.3.
The rotate check boxes rotate the current cell, a selection, or the whole table
counter-clockwise by 90 °. The rotation is not shown within LYX, only in the
output. For more information see sec. 2.12.
Note: Not all DVI-viewers are able to display rotations.
The table-wide vertical alignment is used for tables within text lines:
1
1 A
A line with tables with different alignments:
1 A
A
It is also possible to enter a LATEX-argument which is needed for special table
formattings, see sec. 2.8.2.2 and 2.11.
Borders In this tab you can add and delete border lines for the current row/column.
Using the style option Formal will convert the table to a formal table as described
in sec. 2.9.
You can also add space here to table rows as described in sec. 2.14.1.
Multi-page table This tab is to make a table a multi-page table that can run over
several pages. Sections 2.6 and 2.7 describe the multi-page table features in
detail.
8
2.3. Table Toolbar
9
2. Tables
1 2 3
Joe Mary Ted
" #
a b
x2 dx 1+1=2
R
c d
Table floats can be inserted using the menu Insert ▷ Float ▷ Table or the toolbar button
.
The float appears as a collapsible box with a caption that has the label “Table #:”
(# is the actual table number). You can insert tables in the float above or below the
caption.
Table 2.1 is an example table within a table float.
Having the caption above the table is the common rule that is unfortunately not
supported in LATEX’s standard classes. This means that, if you are using the document
classes article, book, letter, or report, there will be no space between the caption and
the table. To insert the needed space, add the following option to the load command
of the LATEX-package caption in your document preamble:1
tableposition=top
1
For more information have a look at section 3.10.
10
2.6. Multi-page Tables
The package caption, which is described in section 3.9, is used to adjust the caption
format.
Tables can be cross-referenced in the text by referencing their label. To do this insert
a label in the caption using the menu Insert ▷ Label or the toolbar button . You can
now refer to the label using the menu Insert ▷ Cross reference or the toolbar button .
Referencing is explained in detail in section 3.4.
11
2. Tables
12
2.6. Multi-page Tables
13
2. Tables
\setlength{\LTleft}{value}
The value can have any of the units listed in Table A.1. \LTleft controls the horizon-
tal distance from the left page border to the multi-page table, \LTright the distance
from the right side. The default value for both lengths is \fill, which is in this case
the same as an horizontal fill in LYX.
The following multi-page table was centered and \LTleft set to 0.1\columnwidth:
1 2 3 4 5
asd s s s asd
asd s s s asd
asd s s s asd
asd asd asd asd asd
1 2 3 4 5
asd s s s asd
asd s s s asd
asd s s s asd
asd asd asd asd asd
Note 1: The table number is increased for every multi-page table, even if you did not
set a caption for it. For this reason you could have the case that e. g. Table 2.4 follows
Table 2.1 in the list of tables if there are two multi-page tables without captions. To
avoid this you can add the following command in TEX Code after every multi-page
table without a caption:
\addtocounter{table}{-1}
This is not needed when none of your multi-page tables has a caption and you add
the following code to the document preamble:
\let\myEnd\endlongtable
\renewcommand{\endlongtable}{\myEnd\addtocounter{table}{-1}}
14
2.6. Multi-page Tables
Note 2: If you are using hyperref in the PDF Properties of the Document Settings
dialog to link cross-references, the link to a multi-page table caption will always point
to the beginning of the document.
1 2 3 4 5
asd s s s asd
asd s s s asd
asd s s s asd
asd sad asd asd asd
The maximal width of caption lines is defined by the length \LTcapwidth. Its
default value is 4 in. To change it add the following command to your document
preamble or as TEX Code into your document before the multi-page table that should
be affected
\setlength{\LTcapwidth}{width}
where the width can have one of the units listed in appendix A.
The following tables show the difference:
Table 2.4.: Long full title with default width long full title with default width long
full title with default width
1 2 3 4 5
asd s s s asd
asd s s s asd
asd s s s asd
asd sad asd asd asd
15
2. Tables
1 2 3 4 5
asd s s s asd
asd s s s asd
asd s s s asd
asd sad asd asd asd
Note: When the LATEX-package caption is used, as in this document, the full page
width is used for the caption when you use the default value of 4 in for \LTcapwidth.
To get in this case exactly a 4 in wide caption, you can either use a value slightly differ-
ent from 4.0 in, e. g. 3.99 in, or the LATEX-command \captionsetup{width=value}
that is provided by the caption-package.
When the table captions for the following pages should differ from the one of the first
table page, mark a empty row as header which contains a caption. Then right-click
on the caption and select in the context menu Caption (Unnumbered). Table 2.6 is an
example of a multi-page table with different heading where the second caption does
not include the table number.
16
2.6. Multi-page Tables
17
2. Tables
LATEX calculates the height of table pages and their page breaks using so called chunks.
Chunks are parts of tables that held at the same time in LATEX’s memory. The default
value was historically set to only 20 table rows. If you are using multi-page tables
with many pages this may slow down the creation of your document. You can safely
increase the chunk size to values of 100 -- 1000 by adding this command line to your
document preamble:
\setcounter{LTchunksize}{100}
There might be problems when a float appears on the same page where a multi-
page table starts. To avoid such a situation, insert a “clear page” (menu Insert ▷
Formatting ▷ Clear Page) before your multi-page table.
18
2.7. Special Multi-page Table Issues
19
2. Tables
20
2.7. Special Multi-page Table Issues
21
2. Tables
multiple
b c
lines
d e f
g h i
Setting a fixed width for a column enables you to enter text as a paragraph with
multiple lines and hyphenation.
To produce Table 2.8, create a 3×3 table, mark the first cell and right-click on it. In
the appearing table dialog we set a cell width of 2.5 cm and choose centered for the
vertical and horizontal alignment. The vertical alignment is used for all cells of the
row. As our text is smaller than 2.5 cm, only one line will appear. To get two lines, a
justified line break (shortcut ) was added. If the text is wider than the set cell width,
it will automatically be broken to several lines.
If you have a long word in a cell with a fixed width, it cannot be hyphenated by
LATEX if it is the first entry. Therefore you need to insert something to prevent the
word not being the first entry. So add a horizontal space of 0 pt before the word. As
the space is zero, it doesn’t change the output. Table 2.9 shows the effect.
very-
b c
verylongtablecellword longtablecell- b c
d e f word
g h i d e f
g h i
2.8.2. Multicolumns
To merge cells over multiple columns, select as many cells within a row as you want to
merge and use either the table-toolbar button , or the menu Edit ▷ Table ▷ Multicolumn,
or right click on the marked cells and choose Multicolumn in the context menu.
22
2.8. Multiple Lines, Columns and Rows
Multicolumns have their own cell settings. That means changing cell borders, cell
alignment, and the width only affects the multicolumn. Here is an example table
with a multicolumn cell in the first row and one in the last row without the upper
border:
LYX supports multicolumns directly, but we have to take account of the cell width of
the columns spanned by the multicolumn cell.
Table 2.10.: Table with centered multicolumn text above two columns that have
exactly half the width of the multicolumn cell
multiple lines
c
multicolumn
d e f
g h i
To create for example Table 2.10, mark the first two cells in the first row of a 3×3 table
and right-click on them. Now choose for this cell multicolumn, centered alignment
and a width of 2.5 cm in the table dialog. The merged columns should have exactly
half the width of the multicolumn cell, so that you would set a width of 1.25 cm
for the first column. The second column has then automatically a width of 1.25 cm
(multicolumn width - width of first column). This was done for Table 2.11.
You can see that the first column is not half the width of the multicolumn cell, it is
a bit bigger. The reason is that the specified width of a cell Wg is not its total width
Wtot because a cell is always a bit larger than specified. Appendix D explains this in
detail.
Table 2.11.: Table where the spanned table columns are not exactly half the width
of the multicolumn cell
multiple lines c
multicolumn
d e f
g h i
23
2. Tables
The width Wg n which the user needs to set when n columns are spanned can be
calculated, so that each column has a total width of Wtot multicolumn /n:
In our case we have n = 2, Wg multicolumn = 2.5 cm and the default values for the
lengths, so that equation 2.1 becomes
To enable calculations in LATEX, the LATEX-package calc must be loaded with the
document preamble line
\usepackage{calc}
LYX does not allow you to calculate lengths in the Width field of the table dialog.
Therefore you have to format the column by inserting a LATEX-argument in the dialog.
Here is an overview about the arguments:
• p{width} creates cell with a fixed width, its text is vertically top-aligned
• m{width} creates cell with a fixed width, its text is vertically centered
• b{width} creates cell with a fixed width, its text is vertically bottom-aligned
By entering a LATEX-argument, all cell settings set in the table dialog are overwritten.
Note: Due to a bug, LYX shows the overwritten settings anyway.
As the text should be horizontally centered, the command \centering is added. You
can now enter the following LATEX-argument for the first spanned column:
>{\centering}m{1.25cm-6.2pt}
The command >{ } means, that the commands inside the braces are applied before
the cell is created.
Although we have chosen centered alignment for the text of the multicolumn cell, it
is still left aligned. This is because LYX only applies the alignment to single columns.
So for the multicolumn cell we have to use the LATEX-argument
>{\centering}m{2.5cm}
2.8.3. Multirows
To merge cells over multiple rows, select as many cells within a column as you want
to merge and use either the table-toolbar button , or the menu Edit ▷ Table ▷ Multirow,
or right click on the marked cells and choose Multirow in the context menu.
Here is an example table with a multirow in the first column:
24
2.8. Multiple Lines, Columns and Rows
The width of multirow cells is set by setting the width and alignment for the whole
column. The Vertical Offset shifts the content of the multirow up/down if the offset
is positive/negative.
If the column of a multirow cell has no explicit width, the multirow cell inherits the
alignment of the column. Otherwise it is by default left-aligned. To override the
default, renew the command \multirowsetup with the command
\renewcommand{\multirowsetup}{\centering}
in the document preamble. Then all entries of multirow cells in the document are
centered. If centering is only needed for several tables, you can renew the command
in a TEX Code box just before the table instead of the preamble. If the text should
be right-aligned, replace \centering by \raggedleft. To return to left-alignment
\raggedright is used.
This is an example table with a right-aligned multirow cell that has a vertical offset
of -4 mm and is in a 3 cm wide column:
To start a new line in a multirow you can use a forced line break (shortcut ) but this
will not respect the cell lines as demonstrated in this table:
aaa ccc
aaa ddd
wrong cell
bbb eee
25
2. Tables
Parameter
Thickness in nm Transparency in % Hardness in MPa
Name
Perfect Green 45 80 504
Dark Multi-P 60 72 982
Crystal Clear Pro 18 86 374
The 3-argument scheme is for example useful for cross-tables of sports leagues or
distances:
For larger cross-tables one might use split cells in 2 or every corner of the table like
in this example:
To rotate the diagonal lines, the command option dir=direction is used. direction is
either NE, SE, SW or NW and represent a point of a compass. SW is for example
the south-west corner. Thus in the lower left cell of the above table the command
\diagbox[dir=SW]{Team home}{Result}{Team away}
26
2.8. Multiple Lines, Columns and Rows
Parameter
Thickness in nm
Name
Perfect Green 45
If you need a certain width for columns with a split cell, use the command option
width=3cm (replace ’3cm’ by the width you need). In the following table the width
of the first column is set to 4 cm. For \diagbox a width of 4 cm + 2 \tabcolsep is
necessary because the overall width is the width for the text (in this case the 4 cm)
plus two times the separation of the text and the cell border. The calculation of the
width cannot be done in the command option of \diagbox so one needs to create a
new length which can be used later. This is done with the TEX Code commands
\newlength{\diagtest}
\setlength{\diagtest}{4cm+2\tabcolsep}
To enable calculations in LATEX one needs to load the package calc in the document
preamble.
In this table you can now use the command
\diagbox[width=\diagtest]{A}{B}
in the first cell:
B
Thickness in nm
A
Perfect Green 45
Note that the split cell needs to be the widest one in the column. Otherwise the
length of the diagonal line cannot be calculated correctly like in this table:
B
Thickness in nm
A
Perfect Green 45
In this case use the width option of the \diagbox command. It is then not necessary
to add 2\tabcolsep because the cell width is now the width of the column. In this
table a width of 3 cm is used:
B
Thickness in nm
A
Perfect Green 45
27
2. Tables
For multiple text lines in split cells one needs some extra height to fit the text to the
cell. This can be achieved with the \diagbox option height=3cm (replace ’3cm’
by the height you need). In the following table the command
\diagbox[width=3cm,height=1.4cm]{A\\B}{C\\D}
is used in the first cell. The command \\ creates hereby the line break.3
C
A Thickness in nm
D
B
Perfect Green 45
For more info about the LATEX-package diagbox, see its documentation, [7].
Spaces to table rows can be added using the Borders tab of the table dialog as de-
scribed in section 2.14.1.
Unlike normal tables, formal tables have no vertical table lines. The horizontal table
lines can be set as for normal tables but they appear with different widths in the
output:
3
Breaking lines with Ctrl+Return is only possible when the column has a fixed width.
28
2.9. Formal Tables
The first and the last table line have a default width of 0.08 em while the other lines
have a default width of 0.05 em.
The default widths can be changed with the following preamble lines
\let\mytoprule\toprule
\renewcommand{\toprule}{\mytoprule[width]}
This example is for the first line, the so called toprule. If you want to change the
width for the last line, replace toprule by bottomrule. To change the width for the
other lines replace toprule by midrule. You can use all units listed in appendix A
to set the width.
As in table 2.12, formal tables often use shortened lines to group columns. This can
be done in the borders widget of the table dialog. With formal tables, the top and
bottom borders have to small offset lines to the left and the right. Clicking on these
will trim the line respectively.
If you need to adjust the length of the trimming or the height of the rules, you have
to resort to TEX Code. The respective command (which is also used for the trimmed
mid rules) is this:
\cmidrule[height](trim){startcol-endcol}
The default for the optional height is 0.03 em. startcol is the number of the column
where the line starts and endcol the column number where the line ends. The endcol
always needs to be specified, also when the line should span only one column. The
optional parameter trim could either be l{trimwidth} or r{trimwidth} where the
trimwidth is also optional. Using for example the parameter l{2pt} means that the
line is trimmed from its left end by 2 pt. If you don’t specify the trimwidth the line
is trimmed by the default of 0.5 em (this is what is done if you use trimming from
the dialog).
The height option of \cmidrule is currently not supported by LYX, and neither are
the trimwidth parameters. If you need this you can manually insert a \cmidrule
with the respective settings as TEX Code as the first cell entry of the first cell of a row.
The line is then drawn in the output above the current row. Table 2.13 exemplifies
this (in the sixth row).
You also might want to have overlapping \cmidrules as exemplified as well in Ta-
ble 2.13, even though this is considered bad style (so only use it if you really need
to). This can be achieved with the TEX Code command
\morecmidrules
The command that was used for the second row of Table 2.13 is
\morecmidrules\cmidrule{2-4}
The command for the sixth row is
\morecmidrules\cmidrule{3-4}
29
2. Tables
If you are in any way not satisfied with the border line spacing, you can use the
following command to produce lines that span over all table columns:
\specialrule{width}{space above}{space below}
For more information about these features, refer to the manual of the LATEX-package
booktabs [5].
LSF-spatial resolution
in µm 129.7 52.75 50.78
in % of pixel size 76.3 95.9 92.3
30
2.11. Colored Tables
As you will see, the content of the first and last table row is not correctly aligned. To
get this alignment, the minipage box must be set into a raisebox.5 In the example
above the second table in the first item is aligned using the TEX Code command
\raisebox{0.85\baselineskip}{
before the box. After the box the closing brace } is inserted as TEX Code. For the
second table in the last item the command
\raisebox{-0.32\baselineskip}{
is used.
Note: The alignment of the table row content to the surrounding text line is not
exact. The required value for the \raisebox command for this alignment depends
on the document font, the font size, and the table line thickness.
a b c
d e f
g h i
If you only need colored text, mark the cells and choose a color in the Text Style
dialog (toolbar button ). This was used to create Table 2.14. In any other case you
have to use the LATEX-package colortbl.
To create colored tables, colortbl must be loaded in the preamble with the line
\usepackage{colortbl}
The color of a column is adjusted with the command
\columncolor{name of color}
inside the command >{ }. More about the command >{} is contained in sec-
tion 2.8.2.2.
The following color names are predefined:
red, green, yellow, blue, cyan, magenta, black and white
31
2. Tables
dvipsnames
to the document class options in the document settings, you can additionally use
further 61 colors. These colors are listed in appendix C. One of these colors, Maroon,
is used as example in Table 2.15.
You can also define your own color with the command
\definecolor{color name}{color model}{color values}
The color model can be
cmyk: cyan, magenta, yellow, black
rgb: red, green blue
gray gray
and the color values are comma separated numbers between 0 and 1 describing the
factor for the corresponding color of the color model.
You can e. g. define the color "darkgreen" in the preamble with
\definecolor{darkgreen}{cmyk}{0.5, 0, 1, 0.5}
and the color "lightgray" with
\definecolor{lightgray}{gray}{0.8}
To create Table 2.15 do the following: The color of the first column should be dark-
green. So insert
>{\columncolor{darkgreen}\centering}c
as LATEX-argument for this column. The first row should be light blue, therefore the
TEX Code command
\rowcolor{cyan}
is inserted to the first cell of this row. Note that this overwrites the column color
for the first cell. The last cell of the last row is colored maroon by inserting the TEX
Code command
32
2.11. Colored Tables
\cellcolor{Maroon}
The characters could now be colored using the menu Edit ▷ Text Style.
a b c
d e f
g h i
Table 2.16.: Table where every second row is colored light gray.
X Y Z
1 2 3
4 5 6
7 8 9
33
2. Tables
Table 2.17.: Table where every second row is colored cyan and at which there is a
line between each row.
X Y Z
1 2 3
4 5 6
7 8 9
sd
sd
sd
To color all horizontal lines for example with red, as in Table 2.19, insert these
commands in TEX code before the table or table float:
\let\myHlineC\hline
\renewcommand{\hline}
{\arrayrulecolor{red}\myHlineC\arrayrulecolor{black}}
sd
sd
sd
To return to the default line color black, insert this command in TEX code after the
table or table float:
34
2.11. Colored Tables
sd
sd
sd
Y Y
\renewcommand{\hline}{\myHlineC}
Table 2.20 is an example with colored vertical and horizontal lines.
To color only some of the table lines another strategy is necessary. To color all
following horizontal lines, insert this command as TEX code as last thing in the row
that should be above the first colored line:
\\\arrayrulecolor{blue}%
To go back to black lines, add this command as first thing in the row that is above
the black lines:
\arrayrulecolor{black}
With this one can color table lines like in Table 2.21. However, with this method it
is not possible to color the line above the first row of a table.
To change the color of vertical lines within a row, like in Table 2.22, one needs to use
multicolumns. At first one needs to remove all vertical lines that don’t run along the
whole column. Now one colors all lines using the command
\\\arrayrulecolor{blue}%
as above. Finally one inserts this command as TEX code to every cell in the row
where one needs a vertical line in a different color:
\multicolumn{1}{!{\color{green}\vline}c!{\color{red}\vline}}{
This adds a vertical line to both sides of the cell. The left one will be green, the right
one red. If no color change is necessary one can omit the \color command in the
above command. To get for example a black left line and a blue right line you can
write:
\multicolumn{1}{!{\color{black}\vline}c|}{
35
2. Tables
Table 2.22.: Table with different vertical line colors in one row.
Y Y
because the color blue was already set for all lines. The | creates hereby the vertical
line while \vline does this when \color is used. To set vertical lines without changing
any color use
\multicolumn{1}{|c|}{
After this command insert the cell content the normal way and end the cell with a
closing brace } in TEX code.
uc
a
cu
sa
pl
45 33 21
6
For more about these boxes see sec. 5.4 and 5.5.
36
2.13. Table Width Calculation
The available width for a table is the space between the page margins or the width
of a text column (for a two-column document) (LATEX length \columnwidth). If
all table columns should have the same width and Wtable should be 1 \columnwidth,
Wcolumn can easily be calculated.
To be able to perform calculations you need to load the LATEX-package calc in the
document preamble. To set the width in the table dialog you have to use the field
LATEX argument. The command scheme for this field is the same that is explained in
section 2.8.2.2. For a table with 5 columns with an uniform width and centered text,
enter there for each column the command
>{\centering}p{(1\columnwidth-62.4pt)/5}
For a table with 5 columns where 2 should have 0.75 times the width than the 3
others, the calculation is
37
2. Tables
You can add vertical space to table rows in the Borders tab of the table dialog. You
find there three possibilities:
Top of row will add space above the characters of the table row. If the table is
a formal table7 LYX will insert as default 0.5 em space. For normal tables
the inserted space will unfortunately destroy the vertical table lines as in the
following table:
A
38
2.14. Table Customization
A
↓ 3 mm space between row ↓
When you want to add extra height to all cells of all tables, you can do this with the
following preamble lines:
\@ifundefined{extrarowheight}
{\usepackage{array}}{}
\setlength{\extrarowheight}{height}
where the height can have one of the units listed in appendix A. But this has the
disadvantage that the cell texts are no longer exactly vertically centered.
If you are using font sizes larger than the normal size, the table borders are often too
close to the letters. This can be corrected by inserting the command \strut in TEX
Code at the beginning of a table row. Table 2.25 illustrates the effect.
Normal, g Normal, g
Large Large
Larger Larger
Largest Largest
Huge
Huger Huge
Huger
39
2. Tables
Table 2.26.: Table cells of a column aligned with the decimal separator.
heading
12.6
0.68
-123.0
heading
12 + 6
0 − 68
−123 / 0
For alignments at characters in formulas this method does not work because the field
to specify the alignment character does not allow formulas. In this case one need
to use the method from Table 2.27. This table was created with a 4×2 table. The
heading is a centered multicolumn. The first column is right-aligned and contains
the first part including the operator. The second column is left aligned and contains
the rest. A small space was added at the beginning of each cell of the second column
to get the space that is usually around operators. To omit the space that is normally
between two table columns, the following LATEX-argument was used for the second
column:
@{}l
Table 2.28 shows some example alignments. For the alignment with the relation sign,
a small space was added like for the second column of Table 2.27.
Calculating the required width for normal columns as described in section 2.13 or
for spanned columns as described in section 2.8.2.2 is very annoying if you have
several tables where a calculation is necessary. To make life easier, you can define a
40
2.14. Table Customization
cell/column format in the preamble, that can be used in all tables of the document.
The format is defined with the command
\newcolumntype{name of format}[number of arguments]{commands}
The format name may only consist of one letter. The letters b, c, l, m, p and r are
predefined and cannot be used. But all letters are allowed as capitals.
For vertically and horizontally centered multicolumn cells with a fixed width you can
define the cell format
\newcolumntype{M}[1]{>{\centering\hspace{0pt}}m{#1}}
where \hspace{0pt} avoids the problem of hyphenating the first word, as described
in section 2.8.1. Now you can simply enter
M{width}
as LATEX-argument in the table dialog to create a multicolumn.
For cells spanned by a multicolumn cell, you can define the format
\newcolumntype{S}[2]{>{\centering\hspace{0pt}}
m{(#1+(2\tabcolsep+\arrayrulewidth)*(1-#2))/#2}}
This format uses equation (2.1) to calculate the required width so that each spanned
cell has the same width.
You can now enter
S{width of multicolumn cell}{number of spanned columns}
as LATEX-argument of the column.
41
2. Tables
very-
multiple lines
longtablecell- c
multicolumn
word
d e f g
h i j k
sd
sd
sd
The line thickness for all lines in a table can be adjusted with the length \ar-
rayrulewidth. To set for example a line thickness of 1.5 pt, as in Table 2.30, insert
the command
\setlength{\arrayrulewidth}{1.5pt}
in TEX Code before the table or table float. The changed thickness is valid for all
subsequent tables. To use the default value again, set \arrayrulewidth to 0.4 pt in
TEX Code after the table or table float.
To set the line thickness to 1.5 pt only for horizontal lines, as in Table 2.31, insert
these commands in TEX Code before the table or table float:
\let\myHline\hline
\renewcommand{\hline}
{\noalign{\global\arrayrulewidth 1.5pt}
\myHline\noalign{\global\arrayrulewidth 0.4pt}}
To return to the default line thickness, insert this command in TEX Code after the
table or table float:
\renewcommand{\hline}{\myHline}
sd
sd
sd
42
2.14. Table Customization
sd
sd
sd
To set the line thickness to 1.5 pt only for vertical lines, create the following column
format in the document preamble, according to the description in section 2.14.3:
\newcolumntype{V}{!{\vrule width 1.5pt}}
For Table 2.32 the LATEX-argument
VcV
was used for the last column and
Vc
for the other columns.
a b c d e
f g h i j
k l m n o
p q r s
t u v w x
LYX does not natively support dashed lines, so you have to use TEX Code. As a
prerequisite the LATEX package arydshln must be loaded in the document preamble
with the command
\usepackage{arydshln}
To make a vertical line dashed, enter the colon “:” together with the character for
the horizontal alignment as LATEX argument in the table cell dialog.
For a horizontal dashed line add the command
\hdashline
in TEX Code as first element of the first cell in the table row.
For dashed multicolumn lines use the command
\cdashline{line number}
43
2. Tables
in TEX Code as the first element of the first cell in the table row. If you have for
example a multicolumn spanning columns 2 to 4 and you want to have a dashed line
above, add the command
\cdashline{2-4}
as the first element of the first cell in the row of the multicolumn.
Table 2.33 was created using “:c” as LATEX argument of the third column. The TEX
Code command \hdashline was inserted in the first cell of the third row and the
TEX Code command
\cdashline{4-5} was inserted in the first cell of the fourth row.
Tables with dashed lines can also be colored as shown by Table 2.34.
a b c d e
f g h i j
k l m n o
p q r s
t u v w i
The coloring of lines, columns and lines works as decribed in section 2.11. Coloring
horizontal lines works analogically as described there as well, one only needs to replace
in the commands \myHlineC by \myHdashline and \hline by \hdashline; so
one uses the command
\let\myHdashline\hdashline
\renewcommand{\hdashline}
{\arrayrulecolor{red}\myHdashline\arrayrulecolor{black}}
To color \cdashline, the command is
\let\myCdashline\cdashline
\renewcommand{\cdashline}[1]
{\arrayrulecolor{red}\myCdashline{#1}\arrayrulecolor{black}}
To get back the black line color, one needs to insert the following commands as TEX
Code behind the table:
For \hdashline
\renewcommand{\hdashline}{\myHdashline}
and for \cdashline
\renewcommand{\cdashline}{\myCdashline}
To color the gaps between the dashes the command
44
2.14. Table Customization
\dashgapcolor{color}
can be used in front of a table as TEX Code. color is hereby the name of a defined
color. The command
\nodashgapcolor
unsets the changes made by \dashgapcolor.
Note: If there are multiple commands in a cell, the command of arydshln needs to
be the first one in the cell. Therefore in cell k of Table 2.34 the command \hdashline
is before \rowcolor.
Note: The LATEX-package arydshln must be loaded in the document preamble
before the LATEX-package colortbl.
For more information about dashed lines see the documentation of arydshln, [4].
45
3. Floats
3.1. Introduction
A float is a block of text associated with some sort of label, which doesn’t have a
fixed location. It can “float” forward or backward a page or two, to wherever it fits
best. Footnotes and Margin Notes are also floats because they can float to the next
page when there are too many notes on the page.
Floats allow a high quality layout. Images and tables can be spread evenly among
the pages to avoid white space and pages without text. As the floating often destroys
the context between the text and the image/table, every float can be referenced in
the text. Floats are therefore numbered. Referencing is described in section 3.4.
To insert a float, use the menu Insert ▷ Float (toolbar button or ). This inserts the
Caption inset, a box with a label. The label will automatically be translated to the
document language in the output. After the label you can insert the caption text.
The image or table is inserted above or below the caption in a separate paragraph
within the float. More about the caption placement is contained in section 3.10. To
keep your LYX document readable, you can open and close the float box by left-
clicking on the box label. A closed float box looks like this: – a gray
button with a red label.
It is recommended that you insert floats as separate standard paragraphs to avoid
possible LATEX-errors that can occur when the surrounding text is specially formatted.
Existing figures or tables can be put into a float by highlighting them and then
pressing the corresponding toolbar button for a new float.
47
3. Floats
program code listings that are explained in chapter 8. A possible environment for
algorithms is the LYX Code, described in LYX’s Userguide. Algorithm 3.1 is an example
of an algorithm float where -4 mm vertical space was added at the end of the float to
have the bottom rule exactly below the last text line.
The float label is not automatically translated into the document language. If your
document is not in English, you have to do this manually by adding the following
line to the document preamble:
\floatname{algorithm}{your name}
where your name is the word “algorithm” in your language.
To insert the list of algorithms you can use the menu Insert ▷ List / TOC ▷ List of Algo-
rithms when your document has the same language as LYX’s menu names. In other
cases use this command in TEX Code instead:
\listof{algorithm}{your name}
where your name is the word “List of Algorithms” in your language.
Algorithm floats are not by default numbered in the scheme “chapter.algorithm” as is
the case for table and figure floats in many document-classes. To number algorithm
floats in the same scheme, add this command to your document preamble:
\numberwithin{algorithm}{chapter}
To be able to use the command \numberwithin, set in the tab Math Options in the
document settings the option Use AMS math package.
48
3.4. Referencing Floats
To change the numbering scheme for example to “subsection.number”, use this com-
mand in the preamble:
\numberwithin{table}{subsection}
To be able to use the command \numberwithin, set in the tab Math Options in the
document settings the option Use AMS math package.
Please also have a look at section 4.2.1 for the details and important notes about the
numbering commands.
To reference a float, insert a label into its caption using the menu Insert ▷ Label or
the toolbar button . A grey label box like this one: will be inserted
and the label window pops up asking for the label text. LYX offers as text the first
words of the caption with a prefix. The prefix depends on the float type, e. g. for
figure floats the prefix will be "fig:".
The label is used as anchor and name for the reference. You can refer to the label using
the menu Insert ▷ Cross-reference or the toolbar button . The cross-reference window
appears showing all labels of the document. If you have multiple LYX documents
opened, choose the one you are working on from the drop-list at the top of the
dialog. You can now sort the labels alphabetically and then choose one. A grey
cross-reference box like this one: will be inserted. At the position
of the cross-reference box the float number will appear in the output.
It is recommended that you use a non-breaking space between the cross-reference
name and its number to avoid line breaks between them. If a cross-reference refers
to a non-existing label, you will see two question marks in the output instead of the
reference.
You can change labels at any time by clicking on the label box. References to the
changed label will automatically update their links to the new label text.
The button Go to Label in the cross-reference window sets the cursor before the
referred label. The button text changes then to Go Back and you can use it to set
the cursor back to the cross-reference.
49
3. Floats
(<reference>): prints the float number within two parentheses, this is the style
normally used to reference formulas, especially when the reference name “Equa-
tion” is omitted: (2.1)
<page>: prints the page number: Page 4
on page <page>: prints the text "on page" and the page number: on page 4
<reference> on page <page>: prints the float number, the text "on page", and
the page number: 1.3 on page 4
Formatted reference: prints a self-defined cross-reference format.
Note: This feature is only available when you have the LATEX-package pret-
tyref or refstyle installed.
You can select which LATEX-package should be used for this feature by setting
the option Use refstyle (not prettyref) for cross-references in the menu Docu-
ment ▷ Settings ▷ Document Class. The format is specified by adding the com-
mand \newrefformat (prettyref) or \newref (refstyle) to the preamble of
the document. For example redefining all references to figures (which have the
label prefix “fig”) can be done with this command
\newref{fig}{refcmd={Image on page \pageref{#1}}}
For more information about the format, have a look at the package documen-
tations, [18, 20].
The options Plural and Capitalized are only available if you use the LATEX-
package refstyle. Plural adds an s to the name, e. g. “figures”; Capitalized
outputs the name capitalized, e. g. “Figure”. Both options can be combined to
get e. g. “Figures”.
Textual reference: prints the caption of the reference: Two distorted images. Both
images are in the image settings group named “distorted”.
Label only: prints only the LATEX label for the reference: fig:Two-distorted-images
This allows to use the label for commands in TEX code. With the option No
Prefix one can omit the prefix of the label name: Two-distorted-images
<page> will not print the page number if the label is on the previous, the same, or
the next page. You will e. g. see the text “on this page” instead. The style <reference>
on page <page> will not print anything about the page if the label is on the same
page.
The number and current page of the part of the document referred to in the output
is automatically calculated by LATEX. The varieties are adjusted in the field Format
of the cross-reference window that appears when you click on the cross-reference box.
Note: It is recommended to use the LATEX-package refstyle because prettyref does
not know all of LYX’s possible label shortcuts1 and is not internationalized.
1
“fig:” is for example LYX’s shortcut for labels in figure captions.
50
3.4. Referencing Floats
The LATEX-package hyperref , that is enabled in the PDF Properties of the Document
Settings dialog, provides a very useful feature that cross-references automatically
include the name of the referenced floats (or text parts like section). So you will save
having to write e. g. the name “Figure” before every reference to a figure. To use this
feature, enable hyperref and insert this line to the LATEX preamble:
\AtBeginDocument{\renewcommand{\ref}[1]{\mbox{\autoref{#1}}}}
When you prefer other reference names than the default ones, for example you want
instead of “section” the name “sec. “, you can redefine the name by inserting this in
the preamble:
\addto\extrasenglish{\renewcommand{\sectionautorefname}
{sec.\negthinspace}}
When you are using another document language than English, replace
\extrasenglish by \extras***, where *** is the name of the language used.
To get automatic names, but not for certain reference types, for example not for
equations, use this preamble code:
\addto\extrasenglish{\renewcommand*{\equationautorefname}[1]{}}
More about this topic can be found in hyperref ’s documentation [11].
Note: Automatic reference naming cannot be used when you use cross-references in
the Formatted reference style, as described in section 3.4.1.
The Math manual is an example where automatic reference naming is used.
If you use hyperref in the PDF Properties of the Document Settings dialog to link
cross-references in the output, you will see that clicking on an image float reference
jumps to the image label. The caption will be the first text part on the screen, so that
you cannot see the image without scrolling. This is because the reference link anchor
is placed at the position of the label. With the use of the package hypcap, which
is part of the LATEX-package oberdiek, the link anchor is placed at the beginning of
a float. To use this feature for figure floats, load hypcap in the document preamble
with the line
\usepackage[figure]{hypcap}
You can also use hypcap for all float types but this is not recommended for stability
reasons. For more information, have a look at hypcap’s manual [10].
Note: hypcap has no effect on references to subfigures.
51
3. Floats
52
3.5. Float Settings
Page of floats: only if more than 50 % of the page is occupied by floats, several floats
can be set together on a page. (\floatpagefraction)
If you don’t like these rules, you can ignore them by using the additional option
Ignore LATEX rules.
You can also redefine the rules with LATEX-commands that are given in parentheses
after the rules description above. To increase for example the often too small default
of the bottom-rule to 50 % of the page, add this line to your document preamble:
\renewcommand{\bottomfraction}{0.5}
Sometimes you might need, under all circumstances, a float to be placed exactly at
the position where it is inserted. For this case you can use the option Here definitely.
Use this option very rarely and only if the document is almost ready to be printed,
because the float is then no longer able to “float” when you change your document
and this will often destroy the page layout.
There are no placement options for text wrap floats, because they are always sur-
rounded by the text of a certain paragraph.
Sometimes you have the problem that a float is placed at the top of a page while
its corresponding section starts at the middle of the page, so that the reader could
think the float is part of the previous section. To avoid this the LATEX-command
\suppressfloats can be used. It suppresses a given float placement for the page
where it is inserted and can therefore be used to avoid floats being set before a
section starts. To get this, add these commands to your document preamble:
\let\mySection\section
\renewcommand{\section}{\suppressfloats[t]\mySection}
You can define the same for all section headings, like chapters and subsections. This
definition is not recommended to be used for small text parts like subsubsections
because LATEX may then have problems finding a suitable placement.
In some cases it is required to have all figures/tables at the end of the document.
For this purpose the LATEX-package endfloat was developed. It puts all figure and
table floats at the end of the document into their own sections. At the original float
position a text hint like “[Figure 3.2 about here.]” is inserted. The endfloat-package
is loaded in the preamble with the line
\usepackage[options]{endfloat}
There are various package options to format the created figure/table sections. For
more information we refer you to the endfloat documentation [8].
Note: endfloat doesn’t provide an automatic translation for the text hint, you have
to do this manually, see section 4 in [8].
Note: There is currently a bug in endfloat when the caption contains a German
“ß”. Use in this case the command “\ss” in TEX Code instead of “ß”.
For more details about float placements, have a look at LATEX books, [1, 2, 3].
53
3. Floats
3.7. Subfloats
Subfloats are for example used when a figure consists of several images. They are
created by inserting a float into an existing float. The placement of the subfloats can
be controlled in the same way as for paragraphs as shown in table 3.2 and 3.3.
Referencing subfloats works as for normal floats: Table 3.2a and 3.2b are subtables
of table 3.2.
54
Table 3.1.: Rotated table
test b c d e
55
3.7. Subfloats
3. Floats
test b c d e e d c b test
Table 3.3.: Two subtables placed one above the other. (a) table with 4 cells, (b)
table with 5 cells.
(a)
(b)
a b c d e
1 5500
50
5000
100
150
4500
200
256 4000
1 50 100 150 200 256
Figure 3.1.: Float on the left side. Figure 3.2.: Float on the right side.
56
3.9. Caption Formatting
An alternative and simpler solution is to use the module Variable-width Minipages, see
sec. 5.4. Variable-width minipages adapt automatically to the width of the figures
and tables. They do not require an explicit width to be given, and they improve the
horizontal alignment of the figures. The LyX example file varwidth-floats-side-by-side
gives examples of how to do this.
57
3. Floats
It is also possible to set the caption beside a figure or table. To get this the LATEX-
package sidecap has to be loaded in the document preamble with the line
\usepackage[option]{sidecap}
If you set no option, the caption is placed on the side of the outer page margin – to
the right on odd pages, to the left on even pages. You can change the placement to
3
See section 3.9 for more information of the package caption.
4
That option is used in this document.
58
3.10. Caption Placement
1 5500
50
5000
100
150
4500
200
256 4000
1 50 100 150 200 256
Figure 3.3.. This is an example figure caption that is longer than one line to
show the different caption format. Here a self-defined caption
format is used.
Table 3.4.: This is an example table caption that is longer than one line to show the
different caption format. Here the standard caption format for tables in
this document is used.
a b c d e
1 2 3
Joe Mary Ted
" #
a b
x2 dx 1+1=2
R
c d
59
3. Floats
inner margin with the option innercaption. To force the placement always to the
right or left, use the option rightcaption or leftcaption, respectively.
To place in LYX the caption of a float on the side, it is necessary to add these
commands to the document preamble:
\newcommand{\TabBesBeg}[1][1.0]{%
\let\MyTable\table
\let\MyEndtable\endtable
\renewenvironment{table}[1]{\begin{SCtable}[#1]##1}{\end{SCtable}}}
\newcommand{\TabBesEnd}{%
\let\table\MyTable
\let\endtable\MyEndtable
\newcommand{\FigBesBeg}[1][1.0]{%
\let\MyFigure\figure
\let\MyEndfigure\endfigure
\renewenvironment{figure}[1]{\begin{SCfigure}[#1]##1}{\end{SCfigure}}}
\newcommand{\FigBesEnd}{%
\let\figure\MyFigure
\let\endfigure\MyEndfigure}
The commands allow you to redefine the floats so that the caption is set on the side.
For figure floats use the command
\FigBesBeg
in TEX Code before the float. And insert the command
\FigBesEnd
in TEX Code at the point where you want to get back to the original float definition.
For table floats use the corresponding commands
\TabBesBeg and \TabBesEnd
Figure 3.4 and Table 3.7 are examples where the caption is set beside.
You can see in the examples that the caption text appears at the top of the floats
for table floats and at the bottom for figure floats. To change this, you can use the
command
\sidecaptionvpos{float type}{placement}
in the document preamble or in TEX Code before the float. The float type is either
figure or table, the placement can be “t” for top, “c” for center, or “b” for bottom. To
have for example the caption of figure floats vertically centered, use the command
60
3.10. Caption Placement
\sidecaptionvpos{figure}{c}
This was used for Figure 3.5.
The default caption width is the width of the image/table. For thin image/tables,
like in Table 3.7, this leads to captions that are too thin. You can increase the width
by specifying a factor that will be multiplied with the image/table width to get the
caption width. The caption width will automatically be recalculated in case it would
protrude over the page or column margin due to the specified width. The factor can
either be given as optional argument for \FigBesBeg:
\FigBesBeg[factor]
or in the definition of \FigBesBeg by replacing the 1.0 with another value. If
you do the latter, your factor will be the default if \FigBesBeg is used without an
argument. For Table 3.8 the factor 5 was used.
Note: For floats with captions set beside, you cannot use the float placement option
Here definitely because it is not supported by sidecap.
For more information about the package sidecap we refer to its documentation [21].
Note: The LATEX-package hypcap, described in section 3.4.3, has no effect on floats
with the caption set beside.
a b c Table 3.8: This caption is wider than the one in Table 3.7.
d e
f g h
i j
61
3. Floats
62
4. Notes
Comment This note also doesn’t appear in the output but it appears as LATEX-
comment, when you export the document to LATEX via the menu File ▷ Export ▷
LaTeX (pdflatex) / (plain). Its note-box looks like this:
Greyed Out This note will appear in the output as grey text. Its note-box looks like
this:
As you can see in the example, the first line of greyed out notes is a bit in-
dented and greyed out notes can have footnotes.
When you use the toolbar button to insert notes, a LYX Note is inserted. You can
switch between the three note types by right-clicking on the note-box. If you want
to turn existing text into a note, mark it and click on the note toolbar button. To
change a note to text, press the backspace key when the cursor is in the first position
of a note, or press the delete key when the cursor is in the very last position of the
note, respectively.
You can change the text color of the greyed out notes in the menu Document ▷
Settings ▷ Colors.
63
4. Notes
4.2. Footnotes
Footnotes can be inserted using the toolbar button or the menu Insert ▷ Footnote. You
will then see the following footnote-box: where you can enter the footnote
text. If you want to turn existing text into a footnote, mark it and click on the
footnote toolbar button. To change a footnote to text, press the Backspace key when
the cursor is in the first position of a footnote, or press the Delete key when the cursor
is in the very last position of the footnote, respectively.
Here is an example footnote:1
The footnote will appear in the output as a superscript number at the text position
where the footnote box is placed. The footnote text is placed at the bottom of
the current page. The footnote number is calculated by LATEX; the numbers are
consecutive. Whether the footnote number is reset for every chapter depends on
your document class.
Footnotes can be referenced like floats: Insert a label into the footnote and cross-
reference this label in the text as described in section 3.4.
This is a cross-reference of Footnote 1.
Footnotes in title environments are usually not numbered with symbols and they
cannot contain several paragraphs. See for example the footnote in the titling of this
document.
Footnotes in multi-page tables are described in section 2.6.1.
Footnotes in minipage boxes are printed, but inside the box and with a different
numbering because a minipage box is like a page inside a page. (For more about
minipages, see section 5.4.) To get a footnote in the minipage that is output at the
bottom of the page like normal footnotes use this method: Instead of the footnote
the command \footnotemark{} is inserted as TEX code. The text of the footnote is
entered as an argument of the TEX code command \footnotetext after the minipage.
This was done for the following minipage with the command
\footnotetext{Footnote outside the minipage.}
This an example text in a minipage.a
This an example text in a minipage.2
a
Footnote in the minipage.
To refer to the same footnote several times without printing the footnote text every
time, use the command \footnotemark[number] in TEX code.
As you do not know the number of the repeating footnote while you are writing the
1
This is an example footnote.
2
Footnote outside the minipage.
64
4.2. Footnotes
text, you have to store its number. For the following footnote mark example, these
commands were inserted in TEX code after Footnote 1 to store the footnote number:
\newcounter{MyRepeatFoot}
\setcounter{MyRepeatFoot}{\thefootnote}
The footnote mark was then created with this command:
\footnotemark[\theMyRepeatFoot]
Here is a repeated footnote:1
If you want to repeat the previous footnote, you can omit the storage of the footnote
number and just use this command instead:
\footnotemark[\thefootnote]
Here is another repeated footnote:2
The following preamble command changes the footnote numbering style to small
roman numerals:
\renewcommand{\thefootnote}{\roman{footnote}}
This is a footnote with roman numbering:iii
To change the numbering style to capital roman numerals replace in the command
above \roman by \Roman. To “number” footnotes with capital or small Latin
letters use \Alph or \alph, respectively. To “number” footnotes with symbols use
\fnsymbol.
Note: You can only number 26 footnotes with Latin letters, because this numbering
is limited to single letters.
Note: You can only number 9 footnotes with symbols.
To return to the default numbering style after you have changed to another one, use
\arabic instead of \roman in the command above.
If you want to have footnotes numbered in the scheme “chapter.footnote”, add the
following command to your document preamble:
\numberwithin{footnote}{chapter}
iii
This is an example footnote with roman numbering.
65
4. Notes
To be able to use the command \numberwithin, set in the tab Math Options in the
document settings the option Use AMS math package.
This is another example footnote:4.4
Note: \numberwithin always prints out the footnote number as arabic number;
previous redefinitions to get non-arabic numbers are overwritten.
So to get for example the scheme “chapter.\Roman{footnote}”, use this command
instead of \numberwithin:
\renewcommand{\thefootnote}{\thechapter.\Roman{footnote}}
In a two-column document the footnotes appear at the bottom of every column, see
Figure 4.1. If the footnotes should only appear at the bottom of the right column, as
in Figure 4.2, use the LATEX-package ftnright with this command in the document
preamble:
\usepackage{ftnright}
4.4
This is a footnote numbered in the scheme “chapter.footnote”.
66
4.2. Footnotes
man über alle Phasen integrieren muss. Das Spektrum wird fouriertransformiert.
Sei nun S unser normiertes Ausgangssignal Die Fouriertransformation wird verwendet,
und P die Phasenverteilungsfunktion, so um die überlagerten Signale (Netzwerk,
ergibt sich die Beziehung Lösungsmittel) zu trennen. Nachdem wir
die Phasenverschiebung bestimmen konn-
∞
ten, interessiert uns nun das Aussehen des
S(t) = S0 (t) P (φ, t)eiφ dφ (2)
−∞
1. Fourier transformation
wobei S0 das Signal ohne Gradient 2. Phase distribution function
ist
∞
und die Normierungsbedingung 3. Fourier transformation
−∞ P (φ, t) dφ = 1 gilt. Nun dürfen 4. Phase distribution function
In some scientific literature it is usual to collect the footnotes and print them in a
separate paragraph at the end of a section, as in Figure 4.3. They are then called
“endnotes”. To use endnotes instead of footnotes in your document, load in the
menu Document ▷ Settings ▷ Modules the module Foot to End. To insert the collected
footnotes, insert the command
\theendnotes
in TEX Code at the end of a section or chapter.
The paragraph heading for the endnotes isn’t automatically translated into the doc-
ument language, this must be done manually. The following preamble command
translates the default English “Notes” into the German “Anmerkungen”:
Figure 4.3.: Endnotes – footnotes are printed in a separate paragraph at the end of
sections or chapters.
67
4. Notes
\renewcommand{\notesname}{Anmerkungen}
The numbering of endnotes can be changed like the footnote numbering as described
in section 4.2.1; just replace the command \thefootnote by \theendnote. To reset
the endnote number use the command \@addtoreset as described in section 4.2.1
and replace the command parameter footnote by endnote.
For endnotes there is the command \endnotemark[number] similar to the com-
mand \footnotemark, that is described in section 4.2.
Footnotes can also be placed in the page margin and the footnote text alignment can
be changed, see the LATEX-package footmisc, [9] for more information about this.
For various further footnote formatting issues have a look at LATEX-books, [1, 2, 3]. If
you are using a KOMA-Script document class, you can adjust all footnote settings
using class-specific commands, see [12].
To place the margin note in the inner margin, add the command
\reversemarginpar
in TEX Code before a margin note. The new placement is valid for all subsequent
margin notes. This is a
Note: There is often not enough space in the inner margin so that the notes are not margin not
correctly displayed in the output. in the inner
To return to the default placement insert the command margin.
\normalmarginpar
in TEX Code.Note: The command is ignored when it is within a paragraph where
also the command \reversemarginpar is inserted.
AVeryLong-
MarginPar-
Word that
isn’t
68
hyphenated.
4.3. Margin Notes
Similar to the case described in section 2.8.1, long words cannot be hyphenated when
they are the first word in a margin note. To avoid this, insert 0 pt horizontal space
before the word. AVeryLong-
MarginPar-
Note: Margin notes can normally not be used inside tables, floats, and footnotes. Word that is
hyphenated.
This restriction can be evaded by using the LATEX-package marginnote. By adding
these two lines to your document preamble, the command used by LYX for margin
notes is redefined to use the command provided by the marginnote-package:
\usepackage{marginnote}
\let\marginpar\marginnote
This is also used in this document because marginnote has another useful feature:
You can set a vertical offset for the note. This is often needed when too many margin
notes are too close together or for a better page layout. The offset is set in LYX as
TEX Code directly after the margin note in the scheme
[offset]
This margin
where the offset is a length with one of the units listed in Table A.1. A negative note is shifted
value shifts the note up, a positive value shifts it down. For example the margin note up 1.5 cm
beside this text line is shifted up 1.5 cm with the TEX Code command “[-1.5cm]” from its
original
With marginnote you can also change the alignment of the text in the margin note. position.
For example the commands
\renewcommand*{\raggedleftmarginnote}{\centering}
\renewcommand*{\raggedrightmarginnote}{\centering}
set the alignment to centered. \raggedleftmarginnote denotes margin notes that
appear at the left side. The default is The text of
this margin
\renewcommand*{\raggedleftmarginnote}{\raggedleft}
\renewcommand*{\raggedrightmarginnote}{\raggedright} note is
centered.
For the other features of marginnote refer to its documentation [16].
You can adjust the layout of margin notes by changing its definition. To create for
example a header for all margin notes with the underlined, sans-serif, and bold header
text “Attention!”, add this to your document preamble:
\let\myMarginpar\marginpar
\renewcommand{\marginpar}[1]{\myMarginpar{% Attention!
\hspace{0pt}\textsf{\textbf{\underbar{Attention!}}}% This is a
\vspace{1.5mm}\\#1}} margin note
with a
defined
heading.
69
5. Boxes
5.1. Introduction
Boxes are used to format a block of text. Boxes can be used to write documents with
multiple languages, see section 5.4, to frame texts, see section 5.2.3, to prevent words
from being hyphenated, see section 5.6.1, to align text, see section 5.6.2, or to set the
background color of texts, see section 5.7.
Boxes can be inserted with the menu Insert ▷ Box or the toolbar button . A grey box
with the label Box (Minipage): will be inserted. The box type can be
specified by right-clicking on the box and selecting Settings. The box dialog offers the
Inner Box types Makebox, Parbox and Minipage. The type Minipage is the default for
new boxes and is explained in section 5.4; the type Parbox is described in section 5.5
and the type Makebox in 5.6.1.
Boxes are not numbered and can therefore not be referenced like floats or footnotes.
Note: Boxes must not be the item in an Itemize or Description environment.
Note: For an unknown reason you can only set the Inner Box type to None when you
use a framed box. Boxes without an Inner Box type and without frames are explained
in section 5.6.1.
5.2.1. Size
In the box dialog you can adjust the box geometry in the fields Width and Height.
The available units for the geometry are explained in Table A.1. The field Height
offers the following additional sizes:
Depth This is the plain text “height”. It ignores the total depth when there are
multiple text lines in the box:
Box
height set
to
1 Depth
71
5. Boxes
Height This is the height of the text that is inside the box. A value of e. g. 2 for this
Box
height set
Width This sets the width of the box as height:
to
1 Width
5.2.2. Alignment
When you have chosen an Inner Box, the vertical box alignment can be:
Top This is an example text line. This is an example text line.
This box
is top-
aligned.
This box
Middle This is an example text line. is middle- This is an example text line.
aligned.
This box
is
bottom-
Bottom This is an example text line. aligned. This is an example text line.
Note: The vertical box alignment can be lost in the output when you have two boxes
in a line and one has e. g. a shadow and the other one not.
The horizontal box alignment can be set via LYX’s paragraph dialog when you set
the box into its own paragraph.
When you have chosen an Inner Box, the box content can be aligned vertically to:
This box
text is
top-
top This is an example text line. This is an example text line.
aligned.
72
5.2. Box Dialog
This box
text is
middle This is an example text line. This is an example text line.
middle-
aligned.
This box
bottom This is an example text line. This is an example text line.
text is
bottom-
aligned.
This box
stretch This is an example text line. text is This is an example text line.
stretched.
To stretch the box content, it must consist of more than one paragraph. In the
example above every text line is in an own paragraph.
To align the box content horizontally you can use LYX’s paragraph dialog when you
have chosen an Inner Box.
This box
text is
stretched.
If you have not set an Inner Box, you can align the box content horizontally in the
box dialog.
5.2.3. Decoration
The type of the box can be specified in the box dialog in the drop-down list Decoration.
The following types are possible:
No frame Nothing is drawn.
Simple rectangular frame This draws a rectangular frame around the box. The
frame line thickness can be specified. Rectangular box
73
5. Boxes
Double rectangular frame This draws a double-line rectangular frame around the
box. The line thickness of the inner frame is 0.75 line thickness, the thick-
ness of the outer frame is 1.5 line thickness. The distance between the lines is
Double
1.5 line thickness + 0.5 pt.
rectangular box
LYX’s box label will reflect the different frame types. To be able to use all types, the
LATEX-package fancybox must be installed.
When you use the decoration simple rectangular frame and no inner box, you can
allow page breaks within a box. Note that then, unlike other framed boxes, the
frame always uses the whole column width and the box is set as its own paragraph:
74
5.4. Minipages
Oval box with \cor-
nersize = 1.5 cm
The default background color red of shaded background boxes can either be changed
locally with the command \definecolor{shadecolor} or globally with the menu
Tools ▷ Preferences ▷ Colors ▷ shaded box. The scheme of the \definecolor command
is explained in section 2.11.2 For example the appearance of the following shaded
background box is set with the TEX Code command
\definecolor{shadecolor}{cmyk}{0.5,0,1,0.5}
This is yellow text in a shaded background box with dark green background.
Manually changed sizes and colors are valid for all boxes following the commands
that change them.
5.4. Minipages
Minipages are treated by LATEX as pages within pages and can therefore for example
have their own footnotes.
Minipages are useful when you write documents with different languages.
Below are two example minipages side by side. Their width is set to 45 col% and they
are separated by a horizontal fill, that was inserted via the menu Insert ▷ Special For-
matting ▷ Horizontal Fill.
2
Note that \definecolor requires the LATEX-package color in the preamble, see section 5.7.
75
5. Boxes
Dies ist ein deutscher Text. Dies ist This is an English Text. This is an
ein deutscher Text. Dies ist ein deut- English Text. This is an English Text.
scher Text. Dies ist ein deutscher Text. This is an English Text. This is an
Dies ist ein deutscher Text. Dies ist English Text. This is an English Text.
ein deutscher Text. Dies ist ein deut- This is an English Text. This is an
scher Text. Dies ist ein deutscher Text. English Text. This is an English Text.
Dies ist ein deutscher Text. Dies ist This is an English Text. This is an
ein deutscher Text. Dies ist ein deut- English Text. This is an English Text.
scher Text. Dies ist ein deutscher Text. This is an English Text. This is an
Dies ist ein deutscher Texta . Dies ist English Text. This is an English Text.
ein deutscher Text. Dies ist ein deut- This is an English Text.a This is an
scher Text. English Text.
a
Dies ist eine deutsche Fußnote. a
This is an English footnote.
The document-wide paragraph settings are ignored within minipages. That means
that there will be no space between paragraphs in minipages although you set it to
e. g. MedSkip in the document settings.
Minipages can also be used to set a background color for text parts, see section 5.7.
Note: You cannot have floats or margin notes inside minipages but minipages can
be used inside tables, floats, and other boxes.
LYX has also basic support for minipages whose size is automatically determined
by the width of their contents, via the module Variable-width Minipages. The LYX
example file varwidth-floats-side-by-side gives examples of variable-width minipages
used for placing two floats side-by-side.
5.5. Parboxes
Parboxes are very similar to minipages with the difference that they cannot have
footnotes.
76
5.6. Boxes for Words and Characters
When you raise or lower characters in a line, the line distance will be spread:
This is a text line with the word “preventing” as a lowered word.
“testing”
This is a text line with the word as a raised word.
77
5. Boxes
If you want to prevent this for a certain reason, set the box height to a zero value.
For example use
\raisebox{-\depth}[0pt]{
This is a text line with the word “preventing” as a lowered word.
“testing”
This is a text line with the word as a raised word.
To color the background of a box just select the color you like in the box dialog. This
is for example a box with orange background: Box with orange background
If you use the decoration Simple rectangular frame you can set a frame color. In this
case you must also specify a background color (LyX sets white as default). Here is
an example: Box with teal frame color and yellow background color
Of course you can also have colored text inside a colored box:
This is colored text within a colored, framed box
If you need another color than the predefined ones, you can define your own color as
described in section 2.11. To use your own color you must typeset the box by using
TeX code:
Colored boxes without frame are created with the command \colorbox. It has the
following scheme:
\colorbox{color}{box content}
The box content can also be a box and colored boxes can also be within other boxes.
To have e. g. a darkgreen background for a word, insert the command
\colorbox{darkgreen}{
before the word in TEX Code. After the word insert a closing brace “}” in TEX Code.
This is the result:
This is a line where the word “Attention!” has a darkgreen background.
Framed, colored boxes are created with the command \fcolorbox. It has the follow-
ing scheme:
\fcolorbox{frame color}{box color}{box content}
78
5.8. Rotated and Scaled Boxes
To use the boxes described in this section, the module GraphicBoxes must be loaded
in the document settings.
Note: Not all DVI viewers are able to display rotated or scaled material.
To rotate material, you can put it into a Rotatebox. Such a box is inserted via the
menu Insert ▷ Custom Insets ▷ Rotatebox.
The rotation origin can be specified via the inset Origin (menu Insert ▷ Origin) in the
form origin=position. The following positions are possible: c (center), l (left), r
(right), b (bottom), t (top), along with meaningful combinations of the four base
positions. For example lt means that the rotation origin is at the top left corner
of the box. When no rotation origin is specified, the position l will be used. The
rotation angle is a number that can be negative that specifies the angle in degrees.
The rotation direction is counterclockwise.
In the following example origin=c was inserted to the Origin inset and 60 was
inserted to the Angle inset.
ted
a
B
hr
x=
ota
Ad
ted
or an image or table:
79
5. Boxes
q
e
w
r
Note: If the Angle inset is empty or contains other characters than numbers you will
get LATEX errors when viewing/exporting the document.
The Resizebox (menu Insert ▷ Custom Insets ▷ Resizebox) is used to scale the content
to a defined width and height. The Resizebox inset has the mandatory inset Width
and the optional inset Height (inserted via the menu Insert ▷ Height). Input there the
width and height, respectively, as value with a unit. A.1 lists the possible units. If
there is an exclamation mark ! in one of the two insets, the size is set so that the
aspect ratio of the box content is kept. If no Height inset is used an exclamation
mark will internally be used for the height.
80
5.8. Rotated and Scaled Boxes
The boxes can be combined in any order. As example a Reflectbox inside a Resizebox
which is in turn inside a Rotatebox:
ol
le
H
Images, tables, and inline formulas are allowed as box content:
w q
B = xd A
R
r e
When the global formula style fleqn is used in the document4 , display style formulas
can also be scaled.
4
When “fleqn” is added to the document class options.
81
6. Objects Surrounded by Text
6.1. Wrap Floats
This float type is used if you want to wrap text around
1 a figure or table so that it only occupies some fraction
5500
100
5000
LATEX-package wrapfig is installed.1 The settings of
the float can be modified by right-clicking on the float
150
4500
box. The mandatory settings are the float Placement
200
and its Width. Optional are the Overhang that specifies
how much the float is set into the paragraph / page
256 4000 margin, and the Line span that specifies how many text
lines the float will approximately need. The line span
1 50 100 150 200 256
83
6. Objects Surrounded by Text
text text
or
text text text text
To get an object exactly at the position where it is inserted, for example to get one
of these positions:
Surrounded fixed objects are used to let text float around them, at which the object’s
position in the paragraph can be determined by the number of lines above it. In
contrary to floats is it not possible to have a numbered caption.
A fixed object is inserted by adding the command
\begin{window}[2,c,{
as TEX Code at the beginning of the paragraph. The first parameter in the bracket,
here ’2’, defines the number of lines above the object, the second, here ’c’, the position
of the object. The positions ’l’, ’c’ and ’r’ (for left, center, right) are possible. Behind
the command you insert the object. In this example an image with a width of 40 %
2
Footnote of the paragraph with the fixed object.
84
6.3. Initials
of the text column width was inserted. The object can also be a table, a box or an
equation. Behind the object the command
},description text]
{}
is inserted. Note that the “{}” is in the second line. The description text is optional.
The text surrounding the object must be in the same paragraph as the object, so it
must begin directly after the {}. At the end of the paragraph insert the command:
\end{window}
Within a paragraph with a fixed object, you cannot insert footnotes in the normal
way. You have to use instead the command \footnotemark inside the paragraph
and outside the command \footnotetext as described in sec. 4.2.
6.3. Initials
To use initials, you must have the LATEX-package lettrine installed and use the
module Initials in your document (menu Document ▷ Settings ▷ Modules). To insert an
initial, use the style Initial. This style has a mandatory and two optional arguments.
The arguments are inserted via the Insert menu. The mandatory argument Initial
contains the letter(s) that is the initial, the argument Rest of Initial contains the rest
of the word or text of the initial letter(s). The argument Options contains parameters
to modify the initial. For more information about the possible parameters see the
documentation of lettrine, [13]. The style itself contains the text that is surrounding
the initial. The usual style is hereby that the word whose first letter is the initial, is
printed with small caps.
Here are some examples:
1. No optional argument, the initial is the letter ’I’ in the math font Fraktur:
t was in the spring of the year 1894 that all London was interested, and
I the fashionable world dismayed, by the murder of the Honourable Ronald
Adair under most unusual and inexplicable circumstances. The public has
already learned those particulars of the crime which came out in the police
investigation, but a good deal was suppressed upon that occasion, since the
case for the prosecution was so overwhelmingly strong that it was not necessary
to bring forward all the facts.
85
6. Objects Surrounded by Text
2. Only one line is surrounding the initial, which is formed by two letters in
standard font and no text is printed in small caps:
It was in the spring of the year 1894 that all London was interested, and the
fashionable world dismayed, by the murder of the Honourable Ronald Adair
under most unusual and inexplicable circumstances. The public has already
learned those particulars of the crime which came out in the police investigation,
but a good deal was suppressed upon that occasion, since the case for the
prosecution was so overwhelmingly strong that it was not necessary to bring
forward all the facts.
3. Magenta, hanging initial over 3 lines in the math font CALLIGRAPHIC,
the text “t was in the spring” is in small caps; to color the initial, you must
insert this command before the initial:
\renewcommand{\LettrineFontHook}{\color{color}}
where the second color can be “red”, “blue”, “green”, “yellow”, “cyan”, “ma-
genta”, “black” or “white”, and add this command to the document preamble:
\@ifundefined{textcolor}
{\usepackage{color}}{}
I t was in the spring of the year 1894 that all London was interested,
and the fashionable world dismayed, by the murder of the Honourable
Ronald Adair under most unusual and inexplicable circumstances. The
public has already learned those particulars of the crime which came out in
the police investigation, but a good deal was suppressed upon that occasion,
since the case for the prosecution was so overwhelmingly strong that it was not
necessary to bring forward all the facts.
86
7. External Document Parts
With the menu Insert ▷ File you can insert external material into your document. This
can be:
LyX Document Another LYX document; its content is directly inserted to your doc-
ument.
Plain Text A text document; each line is inserted in your document as a separate
paragraph.
Plain Text, Join Lines A text document; text lines are inserted in your document
continuously but an empty text line creates a new paragraph.
External Material Files in various formats.
Child Document LYX or LATEX documents.
87
7. External Document Parts
or EPS). The benefit of such files is a uniform text style throughout the whole
document.
The external template reads SVG files and uses a converter program to gener-
ate the respective PDF/EPS and LATEX files (via Inkscape) on the fly, so you
don’t have to export those files yourself. If you prefer the latter and want use
given *.pdf and *.pdf_tex or *.eps and *.eps_tex files instead, simply input
the respective *.pdf_tex or *.eps_tex file via the Child Documents dialog (see
sec. 7.2) rather than using this template.
You can use TEX code commands such as \Large, \small, etc. in the text
of the SVG. The size of the font will be taken from the settings of the LYX
document. Please refer to [22] for more information and examples.
Lilypond typeset music This template is used for music notation typeset with the
program
LilyPond. For LYX’s extended support for LilyPond have a look at LYX’s
example file lilypond.lyx.
PDF pages With this template you can insert PDF documents to your document.
To specify the range of pages that should be included, use the option pages
in the Option field in the LaTeX and LyX options tab. The argument of this
option is a comma separated list, containing page numbers (insert as option
pages={3,5,6,8}), ranges of page numbers (pages={4-9}) or any combina-
tion. To insert empty pages use {}. E. g. pages={3,{},8-11,15} will insert
page 3, an empty page, and pages 8, 9, 10, 11 and 15. Page ranges are specified
in the syntax start-stop. This selects all pages from start to stop. Omitting
start defaults to the first page; omitting stop defaults to the last page of the
document. The last page can also be selected with the keyword last. (This
is only permitted in a page range.) So pages=- will insert all pages of the
document and pages=last-1 will insert all pages in reverse order. If the pages
option is not specified, only the first page of the PDF is inserted.
The option noautoscale inserts the pages with their original size, if this option
is not given, the pages will be resized to fith the width of the page of your doc-
ument. In the tab Size and Rotation you can specify the width and height of the
input pages and their rotation. If another width than 100 Scale% is used, the
option noautoscale will be overwritten. For more info and possible options,
have a look into the documentation of the LATEX-package pdfpages [17].
To use this template in a Beamer presentation you need to first insert an End-
Frame environment and in a subsequent paragraph a TEX Code box contain-
ing the command \setbeamertemplate{background canvas}{}. Then you
can insert as many paragraphs containing the PDFPages template as you wish.
Behind the included PDF pages you can resume the Beamer presentation by
beginning a new frame or by starting a new section. To avoid stray blank pages
prior to the PDF pages, make sure to use the Default alignment for the para-
graph containing the template.
Here is an included PDF which is rotated by -5°:
88
Abstract
This is an ab
stract. As yo
printed in a sm u can see, it
aller font size is
paragraph typ than the other
es.
Also several p
aragraphs are
abstract. possible in th
e
This is a “Sta
ndard” paragra
ences in the fo ph to visualize
nt size. the differ-
7. External Document Parts
Raster image This can be used for bitmap images. The image can be treated in
the External material dialog like the images that are usually included via the
Graphics dialog as described in section 1.1. Here is an inserted raster image:
Spreadsheet With this template you can insert spreadsheets / tables in the format
of Gnumeric, OpenDocument, Microsoft Office XML and Office Open XML.
For this feature LYX must have found the program ssconvert during its con-
figuration. This program is part of Gnumeric, so that you must have Gnumeric
installed, also if you don’t have tables in the Gnumeric format. For examples
and possible limitations have a look at LYX’s example file spreadsheet.lyx.
Vector graphics This can be used for vector graphics. The image can be treated in
the External material dialog like the images that are usually included via the
Graphics dialog as described in section 1.1. Here is an inserted vector graphics:
Xfig figure This template supports images created with the program Xfig.
When you use the option Draft in the File tab of the External Material dialog, only
the path to the inserted file is shown in the output.
External material is displayed in LYX either as a box like this: or
as image, depending on the option Show in LyX in the LaTeX and LyX options tab of
the dialog.
The Customization manual explains how you can define your own templates.
Child documents are used if you have a long document consisting of several larger
parts or sections. For maintenance it is often useful and sometimes even required
to split the document into several files that can be revised separately. The different
documents are then the so called “child documents”, and a master document connects
them to print the full document or parts of it. A child document inherits elements
90
7.2. Child Documents
from its master, for example the LATEX preamble, the bibliography, and labels for
cross-references.
To be able to work on child documents without the need to open their master, specify
in the child document the master in the menu Document ▷ Settings ▷ Document Class.
This master document will then be used in the background by LYX when you edit
the child document.
Included documents are displayed in LYX as a box like this:
To include child documents in a master document use the menu Insert ▷ File ▷ Child Doc-
uments. A dialog pops up where you can choose between four include methods:
Include You can include LYX and LATEX documents. When you press the Edit button
in the Child Document dialog, the included document will be opened in LYX in
a new file tab so that you can modify it.
91
7. External Document Parts
92
7.2. Child Documents
The section numbering includes the sections of the included files in the order they are
inserted in the master document. The included example document has for example
a subsection that is numbered as a subsection of this section. Labels of included
documents can be referenced: Subsection 7.2.1.
The preamble of the child document is ignored; only the preamble of the master doc-
ument is used. Branches in child documents will be ignored by the master document
when the master document does not have a branch with the same name. Included
documents are inserted starting on a new page and ending with a page break.
Note: If you have included a LYX or LATEX file, you are warned when you export/view
the document in case the child document uses another document class than the master
document as this will lead to unexpected outputs.
Input This method is very similar to the Include method. The differences are:
• Input files don’t start with a new page and don’t end with a page break.
• Input files can be previewed in LYX when Instant Preview is enabled in
LYX’s preferences under Look and feel ▷ Graphics.
• You cannot exclude Input files via the menu Document ▷ Settings ▷ Child
Documents.
Here is a child document inserted using Input:
This is a small dummy child text document to show how files can be inserted into a doc
Here is a child document inserted as Verbatim using the Mark spaces in output option:
This␣is␣a␣small␣dummy␣child␣text␣document␣to␣show␣how␣files␣can␣be␣inserted␣into␣a␣doc
Note: As you can see in the examples above, the text of the documents included as
verbatim is not broken at the end of the document lines.
93
7. External Document Parts
1
Branches are described in section Branches of the LYX Userguide.
94
8. Program Code Listings
To include and typeset program code you can use the Listings inset that can be in-
serted via the menu Insert ▷ Program Listing. The LATEX packages listings or minted
provide a powerful and flexible way to insert program source code into your docu-
ment. One can only use one of these packages in a document. listings is used by
default.
Right-clicking on a listings inset opens the context menu containing where you can
set the listings format.
By default, a listing starts a new paragraph in the output. The placement option
Inline listing prints the listing inline like this: int a=5;
The option Float creates a listings float where you can specify the placement options
“h”, “t”, “b”, and “p” corresponding to the float placement options described in
section 3.5. The placement options can be mixed and are inserted without any
separation, e. g. “htbp”. The option “h” has sometimes no effect, but you don’t need
to use the Float option in this case as also non-float listings can have captions and
be referenced.
You can add captions to listings that are not inline with the menu Insert ▷ Caption.
Listings can be referenced like floats: Listing 8.1. A list of listings which contains all
listings with captions can be created via the menu Insert ▷ List / TOC ▷ List of Listings.
The list entries are the listing caption and the listing number.
Listing 8.1: Example Listing float
# Example l i s t i n g f l o a t
def f u n c ( param ) :
’ t h i s ␣ i s ␣a␣ python ␣ f u n c t i o n ’
pass
Note: The listings package places captions before the listing by default.
The minted package places them after the listing by default if it is floating. If it is
not floating, caption will be typeset before the listing if it is inserted to its first line,
otherwise it will be typeset after the listing. If you want to force the placement in
every case before the listing, you have to add the following lines as last thing to the
preamble:
\@ifundefined{newfloat}
{\usepackage{float}}{}
\floatstyle{plaintop}
95
8. Program Code Listings
When you have set a programming language in the listings dialog, the keywords of
this language will be recognized and specially typeset in the output. In the example
listings the Python keyword “def” is recognized and printed bold in the output.
Note: If you don’t get bold keywords when using typewriter fonts, your typewriter
font probably doesn’t provide a bold shape. In this case select a different one in
the menu Document ▷ Settings ▷ Fonts. (The fonts LuxiMono, BeraMono and Courier
provide bold shapes.)
In section Line numbering of the listings dialog you can specify the line numbering
style. You can insert a number to specify which lines are numbered in the field Step.
When you insert e. g. “3”, only every 3rd line will be numbered.
You can furthermore specify a range of lines; only these will then appear in the output.
The option Extended character table is only meaningful for the listings package and
should be used when you use national characters like the German umlauts in the
listing.
Here is an example listing with left line numbering, step “3”, language “Python”,
options “Extended character table” and “Space as symbol”, range lines 3 - 8:
␣␣␣␣ pass
2 def ␣ f u n c ( param ) :
’ This ␣ i s ␣a␣German␣word : ␣ Tschüß ’
pass
5 def ␣ f u n c ( param ) :
’ t h i s ␣ i s ␣a␣ python ␣ f u n c t i o n ’
When you have tabulators in your listing, you can specify the number of characters
that are spanned by a tabulator in the field Tabulator size.
Note: Due to a bug in the listings package the line numbering is shifted by a line
by every previous listing. That’s the reason why the lines 2 and 5 are numbered in
the above listing and not the lines 3 and 6.
It is also possible to print lines from a file as listing. To do this, use the menu Insert ▷
File ▷ Child Document and choose the type Listings.1 In the child document dialog
you can specify the listing parameters in a text box. To show a list of all available
parameters, type in a question mark “?” in the text box.
To reference child document listings, write a label text into the corresponding field of
the child document dialog. The label can then be referenced using the menu Insert ▷
Cross-Reference.
Listing 8.2 is an example for a listing of a file; there the lines 10 - 15 of this LYX file
are listed.
1
The other child document types are described in section 7.2.
96
Listing 8.2: Lines 10 - 15 of this LyX file
% t o t h e b e g i n n i n g o f t h e f l o a t and
% not t o i t s c a p t i o n
\usepackage [ f i g u r e ] { hypcap }
Global listings settings can be set in the Document ▷ Settings ▷ Listings dialog. To get
there a list of available options, type in a question mark “?”.
For more information about the listings and minted packages, we refer to their
documentation [14, 15].
97
A. Units available in LYX
To understand the units described in this documentation, Table A.1 explains all units
available in LYX.
99
B. Output File Formats with
Graphics
B.1. DVI
This file type has the extension “.dvi”. It is called “device-independent” (DVI),
because it is completely portable; you can move them from one machine to another
without needing to do any sort of conversion. At the time when this file-format was
developed, this was no matter of course. DVIs are used for quick previews and as
pre-stage for other output formats, like PostScript.
Note: DVI-files do not contain images; they will only be a linked. So don’t forget
this, if you move your .dvi file to another computer. This property can also slow
down your computer when you view the DVI, because the DVI-viewer has to convert
the image in the background to make it visible when you scroll in the DVI. So it is
recommended that you use PDF for files with many images.
You can export your document to DVI by using the menu File ▷ Export ▷ DVI. You can
view your document as DVI via the View menu.
B.2. PostScript
This file type has the extension “.ps”. PostScript was developed by the company
Adobe as a printer language. The file therefore contains commands that the printer
uses to print the file. PostScript can be seen as a “programming language”; you can
calculate with it and draw diagrams and images.1 Due to this ability, the files are
often bigger than PDFs.
PostScript can only contain images in the format “Encapsulated PostScript” (EPS,
file extension “.eps”). As LYX allows you to use any known image format in your
document, it has to convert images in the background to EPS. If you have e.g. 50 im-
ages in your document, LYX has to do 50 conversions whenever you view or export
your document. This will slow down your work flow with LYX drastically. So if
you plan to use PostScript, you can insert your images directly as EPS to avoid this
problem.
1
If you are interested to learn more about this, have a look at the LATEX-package PSTricks [19].
101
B. Output File Formats with Graphics
You can export your document to PostScript using the menu File ▷ Export ▷ Postscript.
You can view your document as PostScript via the View menu.
B.3. PDF
This file type has the extension “.pdf”. The “Portable Document Format” (PDF)
was developed by Adobe as a derivative of PostScript. It is more compressed and it
uses fewer commands than PostScript. As the name “portable” implies, it can be
processed at any computer system and the printed output looks exactly the same.
PDF can contain images in its own PDF format, in the format “Joint Photographic
Experts Group” (JPG, file extension “.jpg” or “.jpeg”), and in the format “Portable
Network Graphics” (PNG, file extension “.png”). Nevertheless you can use any other
image format, because LYX converts them in the background to one of these formats.
But as described in the section about PostScript, the image conversion will slow
down your work flow. So it is recommended that you use images in one of the three
mentioned formats.
You can export your document to PDF via the menu File ▷ Export in three different
ways:
PDF (ps2pdf) This uses the program ps2pdf that creates a PDF from a PostScript-
version of your file. The PostScript-version is produced by the program dvips
which uses a DVI-version as intermediate step. So this export variant consists
of three conversions.
PDF (dvipdfm) This uses the program dvipdfm that converts your file in the back-
ground to DVI and in a second step to PDF.
PDF (pdflatex) This uses the program pdftex that converts your file directly to
PDF.
It is recommended that you use PDF (pdflatex) because pdftex supports all features
of actual PDF-versions, is quick and works stable. The program dvipdfm is not under
development and therefore a bit outdated.
You can view your document as PDF via the View menu or by using a toolbar button.
102
C. List of dvips color names
Color Color name Color Color name Color Color name Color Color name
Apricot Aquamarine Bittersweet BlueGreen
BlueViolet BrickRed Brown BurntOrange
CadetBlue CarnationPink Cerulean CornflowerBlue
Dandelion DarkOrchid Emerald ForestGreen
Fuchsia Goldenrod Gray GreenYellow
JungleGreen Lavender LimeGreen Mahogany
Mahogany Maroon Melon MidnightBlue
Mulberry NavyBlue OliveGreen Orange
OrangeRed Orchid Peach Periwinkle
PineGreen Plum ProcessBlue Purple
RawSienna RedOrange RedViolet Rhodamine
RoyalBlue RoyalPurple RubineRed Salmon
SeaGreen Sepia SkyBlue SpringGreen
Tan TealBlue Thistle Turquoise
Violet VioletRed WildStrawberry YellowGreen
YellowOrange
103
D. Explanation of Equation (2.1)
We can calculate the total width of n table cells Wtot n as follows:
where Wg n is the given width of all cells, \tabcolsep is the LATEX-length between
the cell text and the cell border (its default value is 6 pt). \arrayrulewidth is the
thickness of the cell border line, the default is 0.4 pt.
Following equation (D.1), the total width of a multicolumn Wtot mult is
By setting equation (D.1) and (D.2) equal we can calculate the needed given width
Wg n when n columns are spanned, so that each column has a total width of Wtot mult /n:
105
Bibliography
[1] Frank Mittelbach and Michel Goossens: The LATEX Companion Second Edition.
Addison-Wesley, 2004
[2] Helmut Kopka and Patrick W. Daly: A Guide to LATEX Fourth Edition. Addison-
Wesley, 2003
[3] Leslie Lamport: LATEX: A Document Preparation System. Addison-Wesley, sec-
ond edition, 1994
[4] Documentation of the LATEX-package arydshln
[5] Documentation of the LATEX-package booktabs
[6] Documentation of the LATEX-package caption
[7] Documentation of the LATEX-package diagbox
[8] Documentation of the LATEX-package endfloat
[9] Documentation of the LATEX-package footmisc
[10] Documentation of the LATEX-package hypcap
[11] Documentation of the LATEX-package hyperref
[12] Documentation of the LATEX-package KOMA-Script
[13] Documentation of the LATEX-package lettrine and an example
[14] Documentation of the LATEX-package listings
[15] Documentation of the LATEX-package minted
[16] Documentation of the LATEX-package marginnote
[17] Documentation of the LATEX-package pdfpages
[18] Documentation of the LATEX-package prettyref
[19] Web page of the LATEX-package PSTricks
[20] Documentation of the LATEX-package refstyle
[21] Documentation of the LATEX-package sidecap
[22] Documentation of the option Omit text in PDF of the program Inkscape
107
Index
109
Index
110
Index
Table Color
for Cells, 31
for Lines, 34
for Rows, 33
Table Customization, 38
Cell/Column Format, 40
Dashed Lines, 43
Line Thickness, 42
Rotating, 80
Row Spacing, 38
Scaling, 81
Special Cell Alignment, 39
Units, 99
111