[go: up one dir, main page]

0% found this document useful (0 votes)
34 views117 pages

Embedded Objects

The document is a manual for LYX version 2.4.x, detailing the use of figures, tables, floats, notes, boxes, and external material. It includes comprehensive sections on various topics such as graphics, table customization, and float settings. The manual serves as a guide for users to effectively utilize the features of LYX.

Uploaded by

AJ Rush
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views117 pages

Embedded Objects

The document is a manual for LYX version 2.4.x, detailing the use of figures, tables, floats, notes, boxes, and external material. It includes comprehensive sections on various topics such as graphics, table customization, and float settings. The manual serves as a guide for users to effectively utilize the features of LYX.

Uploaded by

AJ Rush
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 117

LYX’s detailed Figure, Table, Floats,

Notes, Boxes and External Material


manual

by the LYX Team∗

Version 2.4.x

May 13, 2024

∗ 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

2.13. Table Width Calculation . . . . . . . . . . . . . . . . . . . . . . . . . 37


2.14. Table Customization . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
2.14.1. Row Spacing . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
2.14.2. Special Cell Alignment . . . . . . . . . . . . . . . . . . . . . . 39
2.14.3. Customized Cell/Column Format . . . . . . . . . . . . . . . . 40
2.14.4. Line Thickness . . . . . . . . . . . . . . . . . . . . . . . . . . 42
2.14.5. Dashed Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

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

5.6. Boxes for Words and Characters . . . . . . . . . . . . . . . . . . . . . 77


5.6.1. Prevent Hyphenation . . . . . . . . . . . . . . . . . . . . . . . 77
5.6.2. Vertical Alignment . . . . . . . . . . . . . . . . . . . . . . . . 77
5.7. Colored Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
5.8. Rotated and Scaled Boxes . . . . . . . . . . . . . . . . . . . . . . . . 79
5.8.1. Rotated Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
5.8.2. Scaled Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . 80

6. Objects Surrounded by Text 83


6.1. Wrap Floats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
6.2. Surrounded Fixed Objects . . . . . . . . . . . . . . . . . . . . . . . . 84
6.3. Initials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

7. External Document Parts 87


7.1. External Material . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
7.2. Child Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
7.2.1. External Subsection 1 . . . . . . . . . . . . . . . . . . . . . . 92
7.2.2. External Subsection 2 . . . . . . . . . . . . . . . . . . . . . . 93

8. Program Code Listings 95

A. Units available in LYX 99

B. Output File Formats with Graphics 101


B.1. DVI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
B.2. PostScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
B.3. PDF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

C. List of dvips color names 103

D. Explanation of Equation (2.1) 105

Bibliography 107

Index 109

iii
1. Figures

1.1. Graphics Dialog


To insert an image into your document, place the cursor at the text position you
want and click on the toolbar icon or use the menu Insert ▷ Graphics. Then a dialog
will appear to choose the file to load. The image will appear in the output exactly
at the position where it is in the text.
The graphics dialog can be called at any time by clicking on an image. This dialog
has three tabs:
Graphics Here you can choose an image file and adjust its appearance in the output.
The available units for the image size are explained in appendix A.
You can rotate images counter-clockwise by setting a rotation angle and a
rotation origin. The image will also be rotated inside LYX.
Images can be scaled by using a percentage value or by setting the width and
height explicitly. If you set only the width or only the height, the other size
will be determined automatically. If you set both, then the image will be
transformed to the given size, possibly distorting it. To prevent the image from
distortion, use the option Maintain aspect ratio. The image will then be scaled
so that its width and height don’t exceed the specified dimensions.
Images can be opened in a program of your choice by right-clicking on it and
choosing the entry Edit externally in the context menu. The program can be set
for every image format in the file format settings in LYX’s preferences.
Coordinates and Clipping Alternatively to the usage of scaling units it is possible
to set image coordinates to adjust the height and width of the image in the
output. The coordinates can also be calculated automatically by pressing the
button Get from File. The option Clip to bounding box will only print the image
region within the given coordinates. Normally you don’t need to worry about
image coordinates and can ignore this tab.
LaTeX and LyX options In this tab you can modify the appearance of the image
within LYX and LATEX experts can specify additional LATEX options.
The option Draft mode makes the image appear in the output only as a frame
with the size of the image.
In the section Graphics Group you can define or join an image settings group.
Images within such a group share their settings, so adjusting one image of the
group automatically also adjusts all other images of the group in the same way.

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.

This is an example image in PDF format1 within a separate, horizontally centered


paragraph:

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

1.2. Figure Floats


For general explanations about floats, have a look at section 3.1.
The toolbar button and the menu Insert ▷ Float ▷ Figure inserts a float with a caption
that has the label “Figure #:” (# is the actual number). You can insert the image
above the caption, like in Figure 1.1 or below the caption, like in Figure 1.2. More
about caption placement is described in section 3.10.
Figure 1.1 and 1.2 are examples of referenced figures. Figures can be 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 . It is important to use references
to floats, rather than using vague references like “the figure above”, because LATEX
will reposition the floats in the final document and it might not be “above” at all.
Referencing is explained in detail in section 3.4.
Normally only one image is inserted to a figure float, but sometimes you might want
to use two images with separate subcaptions. This can be done by inserting image
floats into existing image floats. Note that only the main caption of the float is added
to the List of Figures. Figure 1.3 is an example of a figure float with two images set
side by side. You can also set the images one below the other. Figure 1.3a and 1.3b
are the subfigures.

Figure 1.1.: A star in a float.

3
1. Figures

Figure 1.2.: A 3D object.

(a) Pink object. (b) A star.

Figure 1.3.: Two distorted images. Both images are in the image settings group
named “distorted”.

4
1.3. Image Formats

1.3. Image Formats


You can insert images in any known file format. But as explained in appendix B, each
output document format allows only a few image formats. LYX uses therefore the
program ImageMagick in the background to convert the images to the right format.
To increase your work flow by avoiding these conversions in the background, you
could choose to use only the image formats that can directly be embedded in the
output file format. The output file formats are explained in appendix B.
Similar to fonts there are two types of image formats:
Bitmap images consist of pixel values, often in a compressed form. They are there-
fore not fully scalable and look pixelated in large zooms. Well-known bitmap
image formats are “Graphics Interchange Format” (GIF, file extension “.gif”),
“Portable Network Graphics” (PNG, file extension “.png”), and “Joint Photo-
graphic Experts Group” (JPG, file extension “.jpg” or “.jpeg”).
Vector images consist of vectors and can therefore be scaled to any size without
data loss. The scaling ability is necessary if you want to create presentations,
because presentations are always scaled by the video projector. Scaling is also
useful for online documents to let the user zoom into diagrams.
Well-known scalable image formats are “Scalable Vector Graphics” (SVG, file
extension “.svg”), “Encapsulated PostScript” (EPS, file extension “.eps”),
“Portable Document Format” (PDF, file extension “.pdf”), and “Windows
Metafile” (WMF, file extension “.wmf”). We wrote “can be”, because you can
convert any bitmap image to a PDF or EPS-image and the result will still be a
bitmap image. In such cases only a header with the image properties is added
to the original image2 . The PDF-files generated by Adobe Photoshop are for
example bitmap images.
Normally it is not possible to convert a bitmap image into a scalable one, only vice
versa. Only the image formats PDF and EPS can directly be embedded to PDF
and PostScript output files, respectively. SVG and WMF-images are recalculated
to bitmaps when the output file is generated because there is currently no adequate
WMF/SVG→PDF/EPS converter available.

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

2.2. Table Dialog

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

2.3. Table Toolbar


The table toolbar is an alternative to the table dialog to be able to alter tables faster.
It should normally appear at the bottom of LYX’s main window when the cursor is
inside a table. You can alternatively switch it on to appear always, by right-clicking
in LYX’s main menu bar.
The toolbar has the following icons:
adds a row below the current cell or selection
adds a column right beside the current cell or selection
deletes the current row or selection
deletes the current column or selection
moves the row up
moves the column to the left
moves the row down
moves the column to the right
toggles a line at the top of every cell for the currently selected cells
toggles a line at the bottom of every cell for the currently selected cells
toggles a line at the left side of every cell for the currently selected cells
toggles a line at the right side of every cell for the currently selected cells
toggles a border around the currently selected cells
toggles inner lines for the currently selected cells
adds lines around the current or selected cells - if the current cell is not
a multicolumn cell this also affects the current row and column
deletes all lines of the current or selected cells - if the current cell is not
a multicolumn cell this also affects the current row and column
If using a formal table, this resets the border to its default (only horizontal
lines in top and bottom rows)
left-aligns the content of the current cell / column
centers the content of the current cell / column horizontally
right-aligns the content of the current cell / column
aligns the content of the current column at a character
aligns the content of the current cell vertically to the top
centers the content of the current cell vertically
aligns the content of the current cell vertically to the bottom

9
2. Tables

rotates the current cell or selection counter-clockwise by 90°


rotates the whole table counter-clockwise by 90°
sets the current cell or selection as a multicolumn
sets the current cell or selection as a multirow
Note: For the output the vertical alignment of the first cell in a row is used for all
following cells in the row.

2.4. Edit Table Menu


In addition to the table dialog and toolbar, the menu Edit ▷ Table allows you to add
and delete border lines for the current row/column and to set the current selection
as multicolumn. The menu is only available when the cursor is inside a table.

2.5. Table Floats


For general explanations about floats, have a look at section 3.1.

Table 2.1.: A table float.

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.

2.6. Multi-page Tables


If the table is too long to fit on one page, you can use the option Use multi-page table
in the tab Multi-page table of the table dialog to split the table automatically over
more pages. Doing this enables the following options:
Header: The current row is defined to be a header row that appears on all pages of
the multi-page table; except for the first page, if First header is defined. This is
therefore called the main header.
First header: The current row is defined to be a header row that appears on the first
page of the multi-page table.
Footer: The current row is defined to be a footer row that appears on all pages of
the multi-page table; except for the last page, if Last footer is defined.
Last footer: The current row is defined to be a footer row that appears on the last
page of the multi-page table.
Caption: The current row contains the table caption. The row is reset as single
column and a caption is inserted. More about multi-page table captions is
explained in sec. 2.6.3.
You can also specify a row where the table is split. See the following multi-page table
to see how it works:

Example Phone List (ignore the names)


NAME TEL.
Annovi Silvia 111
Bertoli Stefano 111
Bozzi Walter 111
Cachia Maria 111
Cachia Maurizio 111
Cinquemani Giusi 111
Colin Bernard 111
Concli Gianfranco 111
continued on next page

11
2. Tables

Example Phone List


NAME TEL.
Dal Bosco Carolina 111
Dalpiaz Annamaria 111
Feliciello Domenico 111
Focarelli Paola 111
Galletti Oreste 111
Gasparini Franca 111
Rizzardi Paola 111
Lassini Giancarlo 111
Malfatti Luciano 111
Malfatti Valeriano 111
Meneguzzo Roberto 111
Mezzadra Roberto 111
Pirpamer Erich 111
Pochiesa Paolo 111, 222
Radina Claudio 111
Stuffer Oskar 111
Tacchelli Ugo 111
Tezzele Margit 111
Unterkalmsteiner Frieda 111
Vieider Hilde 111
Vigna Jürgen 111
Weber Maurizio 111
Winkler Franz 111

Annovi Silvia 555


Bertoli Stefano 555
Bozzi Walter 555
Cachia Maria 555
Cachia Maurizio 555
Cinquemani Giusi 555
Colin Bernard 555
Concli Gianfranco 555
Dal Bosco Carolina 555
Dalpiaz Annamaria 555
Feliciello Domenico 555
continued on next page

12
2.6. Multi-page Tables

Example Phone List


NAME TEL.
Focarelli Paola 555
Galletti Oreste 555
Gasparini Franca 555
Rizzardi Paola 555
Lassini Giancarlo 555
Malfatti Luciano 555
Malfatti Valeriano 555
Meneguzzo Roberto 555
Mezzadra Roberto 555
Pirpamer Erich 555
Pochiesa Paolo 555, 222
Radina Claudio 555
Stuffer Oskar 555
Tacchelli Ugo 555
Tezzele Margit 555
Unterkalmsteiner Frieda 555
Vieider Hilde 555
Vigna Jürgen 999
Weber Maurizio 555
Winkler Franz 555
end

2.6.1. Footnotes in Multi-page tables


Footnotes can be inserted to every Multi-page table cell. They appear at the bottom
of the page where the table cell with the footnote appears. Table 2.6 has for example
a footnote.

2.6.2. Multi-page Table Alignment


The horizontal alignment of multi-page tables can be set in the table settings dialog.
For left- and right-alignment the table will be directly at the page border. To add
space between the table and the border one has to set the alignment to center and
change the value of the LATEX-lengths \LTleft or \LTright by inserting this line as
TEX Code before the multi-page table:

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

2.6.3. Multi-page Table Captions


A multi-page table cannot be put into a table float because floats can only be on one
page. But the caption environment of floats can also be used for multi-page tables
when you use the multi-page table option Caption as described in sec. 2.6. Only one
table row should contain a caption, either a header or a footer row.
Here is a short multi-page table to see how it works:

Table 2.2.: Multi-page table with caption

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.

2.6.3.1. References to multi-page tables

Table 2.3.: Referenced multi-page table

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

To reference a multi-page table, insert a label into the caption.


This is a reference to Table 2.3.
The caption layout can be set together with all other captions of your document
using the LATEX-package caption, see section 3.9.

2.6.3.2. Caption Width

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

Table 2.5.: Long full title


with width set
to 5 cm long
full title with
width set to
5 cm long full
title with width
set to 5 cm

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.

2.6.3.3. Different Captions for Table Pages

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.

Table 2.6.: Example Phone List

Example Phone List (ignore the names)


NAME TEL.
Annovi Silvia 111
Bertoli Stefano 111
Bozzi Walter 111
Cachia Maria 111
Cachia Maurizio 111
Cinquemani Giusi 111
Colin Bernard 111
continued on next page

16
2.6. Multi-page Tables

Continued Example Phone List

Example Phone List


NAME TEL.
Concli Gianfranco 111
Dal Bosco Carolina 111
Dalpiaz Annamaria 111
Feliciello Domenico 111
Focarelli Paola 111
Galletti Oreste 111
Gasparini Franca 111
Rizzardi 2
Paola 111
Lassini Giancarlo 111
Malfatti Luciano 111
Malfatti Valeriano 111
Meneguzzo Roberto 111
Mezzadra Roberto 111
Pirpamer Erich 111
Pochiesa Paolo 111, 222
Radina Claudio 111
Stuffer Oskar 111
Tacchelli Ugo 111
Tezzele Margit 111
Unterkalmsteiner Frieda 111
Vieider Hilde 111
Vigna Jürgen 111
Weber Maurizio 111
Winkler Franz 111

Annovi Silvia 555


Bertoli Stefano 555
Bozzi Walter 555
Cachia Maria 555
Cachia Maurizio 555
Cinquemani Giusi 555
Colin Bernard 555
continued on next page
2
Example footnote

17
2. Tables

Continued Example Phone List

Example Phone List


NAME TEL.
Concli Gianfranco 555
Dal Bosco Carolina 555
Dalpiaz Annamaria 555
Feliciello Domenico 555
Focarelli Paola 555
Galletti Oreste 555
Gasparini Franca 555
Rizzardi Paola 555
Lassini Giancarlo 555
Malfatti Luciano 555
Malfatti Valeriano 555
Meneguzzo Roberto 555
Mezzadra Roberto 555
continued on next page

2.7. Special Multi-page Table Issues

2.7.1. Multi-page Table Calculation

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}

2.7.2. Floats and Multi-page Tables

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

2.7.3. Forced Page Breaks


By default tables are only broken between rows. If you have a cell with multiples
lines and want to have a page break within the cell, insert the new line command
“\\” as TEX Code at the point of the cell where it can be broken. Before the \\
command you have to insert in TEX Code as many “&” characters as the number of
the following table columns. The & is the character to separate table cells. Write
in TEX Code after each & the content of the corresponding following cell and delete
the content of these cells.
After the \\ command, insert as many & characters as the number of table columns
before the current column. In Table 2.7 the cell that should be broken is in the second
column followed by another column. Therefore the following command was inserted
in the cell as TEX Code after “Castelchiodato,”:
& 111\\ \newpage
&
The “111” in the third column of the row was deleted. \newpage is only needed
when a page break should definitely occur at this position, otherwise it would be a
conditional break. If your footer row of the multi-page table has for a certain reason
no upper line but you would have a horizontal line where the cell is broken, use this
command instead:
& 111\\
\hline &
When the cell to be broken is in the last column, the command
\setlength{\parfillskip}{0pt}
must be inserted as TEX Code at the beginning of the cell. This ensures that the
part of the cell that will be displayed on the new page appears with the full width.

Table 2.7.: Table with forced page break in table cell

Example Phone List (ignore the names)


NAME TEL.
Annovi Silvia 111
Bertoli Stefano 111
Bozzi Walter 111
Cachia Maria 111
Cachia Maurizio 111
Cinquemani Giusi 111
Colin Bernard 111
Concli Gianfranco 111
continued on next page

19
2. Tables

Continued Example Phone List

Example Phone List


NAME TEL.
Dal Bosco Carolina 111
Dalpiaz Annamaria 111
Feliciello Domenico 111
Focarelli Paola 111
Galletti Oreste 111
Gasparini Franca 111
Lassini Giancarlo 111
Malfatti Luciano 111
Malfatti Valeriano 111
Meneguzzo Roberto 111
Mezzadra Roberto 111
Pirpamer Erich 111
Pochiesa Paolo 111, 222
Radina Claudio 111
Rizzardi Paolo, 11. Fürst 111
von
Montecompatri,
11. Fürst von
Sulmona und
Vivaro, 10.
Fürst von
Rossano, 5.
Herzog von
Canemorte, 11.
Herzog von
Palombara, 5.
Herzog von
Castelchiodato,
continued on next page

20
2.7. Special Multi-page Table Issues

Continued Example Phone List

Example Phone List


NAME TEL.
11. Herzog von
Poggionativo,
11. Markis von
Mentana,
Norma,
Civitella,
Pratica,
Moricone und
Percille, 11.
Graf von
Valinfreda, 11.
Baron von
Cropalati, 11.
Herr von
Scarpa,
Edelmann von
Rom, Patrizier
von Venedig,
Neapel und
Genua
Stuffer Oskar 111
Tacchelli Ugo 111
Tezzele Margit 111
Unterkalmsteiner Frieda 111
Vieider Hilde 111
Vigna Jürgen 111
Weber Maurizio 111
Winkler Franz 111
continued on next page

21
2. Tables

2.8. Multiple Lines, Columns and Rows

2.8.1. Multiple Lines in Table Cells

Table 2.8.: Table with multiple lines in cells

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.

Table 2.9.: Table with and without hyphenation

very-
b c
verylongtablecellword longtablecell- b c
d e f word
g h i d e f
g h i

2.8.2. Multicolumns

2.8.2.1. Multicolumn Basics

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:

abc def ghi jkl


A B C D
1 2 3 4

2.8.2.2. Multicolumn Calculations

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:

Wg n = (Wg multicolumn + (1 − n) · (12.4 pt))/n (2.1)

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

Wg 2 = 1.25 cm − 6.2 pt (2.2)

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

a long cell entry b c


e f
multirow
h i

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:

a long cell entry b c


t n m
e f
multirow h i

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

Therefore be careful with forced line breaks.

2.8.4. Cells with diagonal line(s)


To tell the reader what is meant by column and row headings in a table, it is helpful
to split the first cell of the table by one or two diagonal lines. This can be achieved
by loading the LATEX package diagbox in the document preamble. The package
provides the command \diagbox that is inserted as TEX Code and that can take 2
or 3 arguments:

25
2. Tables

\diagbox[options]{lower left}{upper right}


\diagbox[options]{lower left}{upper left}{upper right}
The first scheme divides the cell by a single diagonal line and the arguments are
placed below and above this line. The second scheme divides the cell by 2 lines.
Here is an example table where \diagbox is used in the 2-argument scheme in the
first cell:

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:

Result Team away


Tigers Panthers Falcons
Team home
Tigers — 1:3 0:1
Panthers 3:1 — 0:0
Falcons 1:0 0:0 —

For larger cross-tables one might use split cells in 2 or every corner of the table like
in this example:

Result Team away Team home Result


Tigers Panthers Falcons
Team home Team away
Tigers — 1:3 0:1 Tigers
Panthers 3:1 — 0:0 Panthers
Falcons 1:0 0:0 — Falcons
Team home Team away
Tigers Panthers Falcons
Result Team away Team home Result

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

is used. If no direction is given, it will be NW.


The necessary width of split cells is automatically calculated. Thus if you set a fixed
column width smaller than the calculated one, the cell’s content will protrude the
cell borders:

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].

2.9. Formal Tables


Tables are often typeset in books similar to Table 2.12. This kind of tables is called
“formal”. To make a table a formal table, select the table style “Formal. . . ” in the
Table Creation dialog or use the option Formal in the Borders tab of the table dialog
(if you additionally check the option Use Default Formal Style, the border lines are
adapted to a sensible default).

Table 2.12.: Example formal table

System Chip 1 Chip 2


Detector thickness in µm 300 300 700
Edge angle in ° 3.55 2.71 7.99
Spatial resolution in µm 4.26 10.17 10.56
MTF at fmax 0.53 0.37 0.39
LSF-spatial resolution
in µm 129.7 52.75 50.78
in % of pixel size 76.3 95.9 92.3

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].

Table 2.13.: Special (ugly) formal table

System Chip 1 Chip 2

Detector thickness in µm 300 300 700


Edge angle in ° 3.55 2.71 7.99
Spatial resolution in µm 4.26 10.17 10.56
MTF at fmax 0.53 0.37 0.39

LSF-spatial resolution
in µm 129.7 52.75 50.78
in % of pixel size 76.3 95.9 92.3

2.10. Vertical Table Alignment


To align tables vertically in a text line, the table must be inside a box. The box can
then be vertically aligned as described in section 5.2.
In the following example the tables are inside a minipage4 box that has a width of
15 col%:
• test test a d g
a d g b e h
b e h c f i
c f i
a d g
• test b e h
c f i
a d g a d g
b e h b e h
• test c f i test c f i
4
Minipages are described in section 5.4.

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.

2.11. Colored Tables

2.11.1. Colored Cells

Table 2.14.: Table colored without using the package colortbl

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

If you add the option


5
Raiseboxes are described in section 5.6.2.

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}

Lines are colored with the command


\rowcolor{name of color}
and cells are colored with the command
\cellcolor{name of color}
Both commands are inserted at the beginning of a cell as TEX Code.
To color characters in the table, mark the cells and use the Text Style dialog. If a cell
contains TEX Code mark only the characters, otherwise the colored TEX Code will
cause LATEX errors.
Note: Not all DVI-viewers are able to display self-defined colors.

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.

Table 2.15.: Table colored using the package colortbl

a b c
d e f
g h i

2.11.2. Colored Rows


In case every second table row needs to be colored there is an alternative to the
method described in the previous section: One loads the package xcolor in the
document preamble with the command
\usepackage[table]{xcolor}
xcolor automatically loads also the package colortbl, so colortbl must be installed
in your LATEX-distribution, otherwise you get LATEX-errors.
The table rows are colored with the command
\rowcolors[commands]{row number}{odd row color}{even row color}
that is either inserted in the document preamble or as TEX Code before the first table
to be colored. row number is the number of the first row which should be colored
according to the odd row color. commands can be additional commands that are
executed before every table row. So for example the command
\rowcolors{1}{white}{lightgray}
leads to the coloring scheme of Table 2.16. The command
\rowcolors[\hline]{1}{lightgray}{cyan}
leads to the coloring scheme of Table 2.17. If odd row color and/or even row color
are left empty, no color will be used so that the command
\rowcolors{1}{}{}
deletes all colors. \rowcolors affects all tables following that command.

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

2.11.3. Colored Lines


As described in section 2.14.4, the line thickness for all lines in a table can be adjusted
with the length \arrayrulewidth. It is set to 1.5 pt for all tables of this section.
To color vertical lines for example with green, create the following column format in
the document preamble, according to the description in section 2.14.3:
\newcolumntype{W}{!{\color{green}\vline}}
For Table 2.18 the LATEX-argument WcW was used for the last column and Wc for
the other columns.
If you want to have several colors, define more column formats.

Table 2.18.: Table with colored vertical lines

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}}

Table 2.19.: Table with colored horizontal lines

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

Table 2.20.: Table with colored lines

sd
sd
sd

Table 2.21.: Table with different horizontal line colors.

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.

2.12. Rotated Table Cells

Note: Not all DVI-viewers are able to display rotations.


Table 2.23 is an example where 3 cells were rotated by 45 °.

Table 2.23.: Table with rotated cells in the first row.


s
er
s
te
ps

uc
a
cu

sa
pl

45 33 21

Note: Line breaks (shortcut ) are not allowed in rotated cells.


If you want to rotate table cells containing line breaks, you have to put the cell
content into a minipage or a parbox.6 If you rotate this cell by 90 ° the width of
the box is the height of the cell. To avoid to estimate a suitable box width one
can use a minipage with a variable width. Such a box is inserted by loading the
module Variable-width Minipages in the document settings. Then one can use the
menu Insert ▷ Custom Insets ▷ Minipage (Var. Width). Table 2.24 is an example for a
rotated multiline cell where a variable width minipage is used.

6
For more about these boxes see sec. 5.4 and 5.5.

36
2.13. Table Width Calculation

Table 2.24.: Table with rotated multiline cell.

with line break


rotated cell
a e
b c d

2.13. Table Width Calculation


For wide tables it is sometimes difficult to assure that the table does not protrude
over the page margin. Setting a fixed width for every column of the table is the
solution, but what amount of space is needed for each column?
The table width Wtable can be calculated: Every column has the width of the spec-
ified column width Wcolumn (that the content of the column can consume) plus two
times the separation between the column content and the column border (LATEX
length \tabcolsep, default 6 pt) plus the width of a border line (LATEX length \ar-
rayrulewidth, default 0.4 pt): So if all n columns have the same width, the table
width is

Wtable = n (Wcolumn + 2\tabcolsep + \arrayrulewidth) + \arrayrulewidth (2.3)

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

\columnwidth = 3 Wcolumn + 2 · 0.75 Wcolumn + \arrayrulewidth


+ 5 (2\tabcolsep + \arrayrulewidth)
= 4.5 Wcolumn + 62.4 pt
\columnwidth − 62.4 pt
Wcolumn = (2.4)
4.5

37
2. Tables

In the table therefore the command


>{\centering}p{(1\columnwidth-62.4pt)/\real{4.5}}
is used for the wider columns and
>{\centering}p{(1\columnwidth-62.4pt)/\real{4.5}*\real{0.75}}
for the smaller ones:
1 2 3 4 5
111111 1111111 2222 22222 333333 333333
111111 222222 333333 33333
111111111 222222222 3333333 333
11111 11111 2222222 22
1111 22222

2.14. Table Customization

2.14.1. Row Spacing

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

3 mm space top of row


C
So inserting space in the top of row for normal tables is only useful when you
don’t have vertical lines.
Bottom of row will add space below the characters of the table row. If the table
is a formal table LYX will insert as default 0.5 em space, for normal tables the
default size is 2 pt.
Between rows adds space between the current and the following row. If the table
is a formal table 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:
7
Formal tables are explained in section 2.9.

38
2.14. Table Customization

A
↓ 3 mm space between row ↓

↑ 3 mm space between row ↑


So inserting space between rows for normal tables is only useful when you don’t
have vertical lines.

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.

Table 2.25.: Vertical alignment of text with large font sizes.


(b) Table using
the command
(a) Normal table. \strut.

Normal, g Normal, g
Large Large
Larger Larger
Largest Largest
Huge
Huger Huge
Huger

2.14.2. Special Cell Alignment


Sometimes it looks better when the cell entries of a column are aligned with a special
character, e. g. with the decimal separator as in Table 2.26. This alignment is achieved
by setting the cursor into the column and then either pressing the toolbar button or
setting the alignment in the table settings to At Decimal Separator. The alignment
character can be a character of your choice and is specified in the table settings.

39
2. Tables

Table 2.26.: Table cells of a column aligned with the decimal separator.

heading
12.6
0.68
-123.0

Table 2.27.: Table cells of a column aligned with the operators.

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.

Table 2.28.: Several table cell alignments.

units exponents relations


12×24 bottles 10·10-17 Γ(t) ∝ Υ(t)
1024×768 Pixels 5.78·107 A ̸= Bred
32×6 cm -33.5·104 sin(α) ≥ sin(β)

2.14.3. Customized Cell/Column Format

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.

For colored columns, you can define


\newcolumntype{K}[1]{>{\columncolor{#1}\hspace{0pt}}c}
The “c” at the end creates a column with a flexible width whose text is horizontally
centered. You can now enter
K{color name}
as LATEX-argument.

To create Table 2.29 use the LATEX-arguments


M{2.5cm}
for the first column and the multicolumn,
K{red}
for the last column, and
S{2.5cm}{2}
for the cells in the second column.

41
2. Tables

Table 2.29.: Table using user-defined table formats

very-
multiple lines
longtablecell- c
multicolumn
word
d e f g
h i j k

Table 2.30.: Table with 1.5 pt thick lines

sd
sd
sd

2.14.4. Line Thickness

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}

Table 2.31.: Table with 1.5 pt thick horizontal lines

sd
sd
sd

42
2.14. Table Customization

Table 2.32.: Table with 1.5 pt thick vertical lines

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.

2.14.5. Dashed Lines

Table 2.33.: Table with dashed lines

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.

Table 2.34.: Colored table with dashed lines

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.

3.2. Float Types


Besides figure and table floats that are described in sections 1.2 and 2.5 respectively,
LYX offers the float types Algorithm and Wrap. The latter are explained in sec. 6.1.

3.2.1. Algorithm Floats


This float type is inserted with the menu Insert ▷ Float ▷ Algorithm. It is used for
program codes and descriptions of algorithms and can be seen as an alternative to

47
3. Floats

Algorithm 3.1 Example Algorithm float

for I in 1..N loop


Sum := Sum + A(I); /* comment */
end loop

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.

3.3. Float Numbering


Floats are usually numbered either independently from the sections the floats are
in, or in the scheme “chapter.number” or “section.number”. This depends on the
document class used.
To change section-independent numbering, you can use this command in the docu-
ment preamble:
\renewcommand{\thetable}{\roman{table}}
\thetable is the command that prints the table number. For figure floats, the
command would be \thefigure. \roman in the command above prints the table
number as a small roman number.

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.

3.4. Referencing Floats

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.

3.4.1. Cross-Reference Formats

There are six varieties of cross-references:


<reference>: prints the float number, this is the default: 1.3

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

3.4.2. Automatic Reference Naming

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.

3.4.3. Reference Position

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

3.5. Float Settings


Float Settings can be adjusted at two places in LYX: in Document ▷ Settings. . . ▷
Float Settings, you can set some options that are used by default for all floats of
the document (placement on page and alignment of contents), unless you modify the
local settings of a float.
The latter can be done by right-clicking on a float-box and clicking on Settings. . . This
opens a dialog where you can, now only for the given float, alter the global placement
and alignment options, and adapt some other options that are only available for single
floats. All these options, both for Document ▷ Settings ▷ Float Settings and for local
Float Settings, are described in turn.

3.5.1. Float Placement


Both in Document ▷ Settings ▷ Float Settings and in the local Float Settings dialog, you
can modify the placement algorithm that LATEX uses for positioning floats on the
page, either for all floats (Document ▷ Settings ▷ Float Settings) or a particular float
(local Float Settings dialog). This is done via Placement Settings. By default, this is
set to Class Default in Document ▷ Settings ▷ Float Settings (meaning that the default
placement algorithm of the document class is used) or Document Default in the local
Float Settings dialog (meaning that the settings in Document ▷ Settings ▷ Float Settings
are used, which are the Class Defaults by default). If you want to change this, select
Placement Settings: Custom. This allows you to select one or more from:
Here if possible try to place the float on the position where it has been inserted
Here, definitely forces the placement of the float on the position where it has been
inserted
Top of page try to place the float at the top of the current page
Bottom of page try to place the float at the bottom of the current page
Page of floats try to place the float on its own page
The order of the above option is always used by LATEX. That means, if you use the
default placement, LATEX will first try out Here if possible, then Top of page, and then
the others. If you do not use the default, LATEX will try only the checked options but
in the same order. If none of the 4 placements is possible the procedure is internally
repeated trying to put the float on the following page.
By default, each option has its own rules:
Top of page only floats occupying less than 70 % of the page can be placed at the top
of a page (\topfraction)
Bottom of page: only floats occupying less than 30 % of the page can be placed at
the bottom of a page. (\bottomfraction)

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.5.2. Alignment of Float Contents


In this list of options, you can define how the contents of a float (or all floats by
default, if selected from Document ▷ Settings) are aligned. Class Default means that
the alignment of the class, or the default alignment of LATEX, is used. Document
Default (only visible in the Float Settings dialog, not in Document ▷ Settings) takes
the setting specified in Document ▷ Settings ▷ Float Settings. The other three options,
Left, Center, or Right, are self-explanatory. If one of these is selected in Document ▷
Settings ▷ Float Settings, all floats of the document will have this setting by default
(so it is fairly easy, for instance, to center all floats).

3.5.3. Other Float Options


These two options are only visible in the local Float Settings dialog, not in Document ▷
Settings.
The option Span columns is useful for two-column documents: If you select it, the
float will span both columns on the page instead of being confined to just one.
The option Rotate sideways is used to rotate floats, see section 3.6.

3.6. Rotated Floats


Especially for wide tables you might have floats rotated. To rotate a whole float
including the caption, right-click on the float-box and use the option Rotate sideways.
Rotated floats are always placed on a page of their own (or column of their own; in
case you have a multi-column document). You can let them span several columns
using the float settings option Span columns. Floats are rotated so that you can read
them from the outside margin. To force a certain rotation direction for all pages, you
can add either the option figuresleft or figuresright to the document class options.
Referencing rotated floats is the same as for normal floats, the caption format is also
the same: Table 3.1 is an example of a rotated table float.
Note: Not all DVI-viewers are able to display rotated 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

Table 3.2.: Two subtables placed side by side.


(a) This is subtable a. (b) This is subtable b.

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)

test test test test

(b)

a b c d e

3.8. Floats Side by Side


To place floats side by side, as in Figures 3.1 and 3.2, only one float is used. In it
two minipage boxes are inserted.2 The width is set to 45 -50 column% and the box
alignment to Bottom for each minipage. The minipage boxes contain the image and
the caption in the same way as they are in a float. The only difference is that the
image unit Column Width % is now calculated according to the width of the minipage
boxes.
2
Minipages are explained in section 5.4.

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.

3.9. Caption Formatting


The Caption environment is the default paragraph environment for Floats. On the
LYX screen captions appear as a label, e. g. “Figure #:” followed by the caption text.
“#” is the actual reference number. By default the label and the number are in the
same font as the caption text and a colon follows the number to divide the label from
the text. This caption format is suitable for many but not all documents.
To change the default caption format, load the LATEX-package caption in the docu-
ment preamble with this line:
\usepackage[format definition]{caption}
To have for example the label and the number in sans-serif, bold font and the table
captions always above the table as in this document, use the following command:
\usepackage[labelfont={bf,sf}, tableposition=top]{caption}
You can also define different caption formats for the different float types. In this case
load the caption package without format specific options and define the different
formats with the help of the command
\captionsetup[float type]{format definition}
in the document preamble. For example the caption formats of Figure 3.3 and Ta-
ble 3.4 can be created using these commands in the document preamble:
\usepackage[tableposition=top]{caption}
\captionsetup[figure]{labelfont={tt}, textfont=it, indention=1cm,%
labelsep=period}
\captionsetup[table]{labelfont={bf,sf}}
Note: The option tableposition=top has no effect when a KOMA-Script docu-
ment class is used. In this case the document class option captions=tableheading
must be used.
For more information about the package caption we refer to its documentation [6].
To change the label name from e. g. “Figure” to “Image” use this preamble command:
\renewcommand{\fnum@figure}{Image~\thefigure}
where \thefigure inserts the figure number and “~” creates a non-breaking space.

57
3. Floats

If you are using a KOMA-Script document class (article (KOMA-Script), book


(KOMA-Script), letter (KOMA-Script), or report (KOMA-Script) ), you can alterna-
tively to the caption package use KOMA-Script’s built-in command \setkoma-
font. For example, to have the caption label in bold, add this command to your
document preamble:
\setkomafont{captionlabel}{\bfseries}
For more information about \setkomafont we refer to the KOMA-Script docu-
mentation [12].

3.10. Caption Placement


The common caption placement rule is:
Figure: Caption is set below the figure
Table: Caption is set above the table
Having the caption above the table is unfortunately not supported in LATEX’s standard
classes. That means 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 necessary
space, load the LATEX-package caption in your document preamble with the option3
tableposition=top
If you are using a KOMA-Script document class (article (KOMA-Script), book
(KOMA-Script), letter (KOMA-Script), or report (KOMA-Script) ), you can alterna-
tively to the caption package set the document class option4
captions=tableheading
In documents with a KOMA-Script document class you can also right-click on a
caption and mark in the context menu if this should be a caption above or below the
table/figure. This way you can override the document-wide caption placement for
certain captions. Table 3.5 is an example where the caption is marked a being below
the table while it is above. For comparison the caption in Table 3.6 is not marked.

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

Table 3.5.: A caption marked as being below the table.


1 2 3
Joe Mary Ted
" #
a b
x2 dx 1+1=2
R
c d

Table 3.6.: A standard table caption.

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

Figure 3.4: This is a caption beside a


figure.

a b c Table 3.7: This


d e is a
cap-
f g h
tion
i j be-
side a
table.

\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

Figure 3.5: This is a vertically cen-


tered caption beside a fig-
ure.

3.11. Listings of Floats


Similar to the table of contents where the sections of the document are listed, there
are listings for all float types, like the figures of the documents. You can insert them
via the Insert ▷ List / TOC sub menus.
The list entries are the float captions or its short title, the float number, and the page
number where they appear in the document.
You can find the list of figures and tables at the end of this document.

62
4. Notes

4.1. LYX Notes


Notes are inserted with the toolbar button or the menu Insert ▷ Note. There are three
types of notes:
LYX Note This note type is for internal notes that won’t appear in the output. Its
note-box looks like this:

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:

This is text of a comment that appears grey in the output.

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

4.2.1. Footnote Numbering


To reset the footnote number back to 1 after each section, add this command to your
document preamble:
\@addtoreset{footnote}{section}

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}}

4.2.2. Footnote Placement


If you have several footnotes in one page, they appear without vertical space between
them at the bottom of the page. To make them more readable you can e. g. add
1.5 mm space with the following preamble command:
\let\myFoot\footnote
\renewcommand{\footnote}[1]{\myFoot{#1\vspace{1.5mm}}}

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}

Sei nun S unser normiertes Ausgangssignal Das Spektrum wird fouriertransformiert.


und P die Phasenverteilungsfunktion, so Die Fouriertransformation wird verwendet,
ergibt sich die Beziehung um die überlagerten Signale (Netzwerk,
 ∞ Lösungsmittel) zu trennen. Nachdem wir
S(t) = S0 (t) iφ
P (φ, t)e dφ (2) die Phasenverschiebung bestimmen konn-
−∞ ten, interessiert uns nun das Aussehen des
wobei S0 das Signal ohne Gradient Ausgangssignals. Im Experiment haben wir
ist und die Normierungsbedingung es mit sehr vielen Teilchen zu tun, so dass
1 3
Fourier transformation Fourier transformation
2 4
Phase distribution function Phase distribution function

Figure 4.1.: Standard footnote placement in two-column documents.

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

Figure 4.2.: Footnote placement in two-column documents when the LATEX-package


ftnright is used.

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”:

man über alle Phasen integrieren muss.


Sei nun S unser normiertes Ausgangssignal Notes
und P die Phasenverteilungsfunktion, so
ergibt sich die Beziehung 1
Fourier transformation
 ∞ 2
Phase distribution function
S(t) = S0 (t) P (φ, t)eiφ dφ (2)
3
−∞ Fourier transformation

wobei S0 das Signal ohne Gradient 4


Phase distribution function
ist
∞
und die Normierungsbedingung
−∞ P (φ, t) dφ = 1 gilt. Nun dürfen

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].

4.3. Margin Notes


Margin notes look and behave in LYX like footnotes. They are inserted via the menu
Insert ▷ Marginal Note or the toolbar button . A grey box with the red label “margin”
appears where you can enter the text of the margin note.
This is a At the side is an example margin note.
margin note. Margin notes appear at the right side in single-sided documents. In double-sided
documents they appear in the outer margin – left on even pages, right on odd pages.
The text of margin notes is aligned opposite to the outer margin – right-aligned when
the note appears in the left margin. The first line of the margin note is placed at the
position of the text line where it is inserted in the document.

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. Box Dialog

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


size will set the box height to 2 times the text height:
to 2 Height

Box height set


Total Height This is the Height + Depth:
to 1 Total Height

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.

This box text is horizontally stretched.

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

Oval box, thin This draws  an oval frame around


 the box. The frame line thickness
has the size 0.4 pt.  Oval box, thin 
Oval box, thick This draws
 an oval frame around
 the box. The frame line thickness
has the size 0.8 pt. Oval box, thick
 
Drop shadow This draws a rectangular frame with a shadow around the box. The
Shadow box
frame line thickness and the shadow can be specified.
Shaded background This draws a box with a red background. Unlike colored boxes1 ,
it always uses the whole column width and the box is set as its own paragraph.

Shaded background box

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:

Allow page break box

5.3. Box Customization


The diameter of the round corners of the oval boxes can be set with the command
\cornersize. The command
\cornersize*{1cm}
sets the diameter to 1 cm. The command
\cornersize{num}
sets the diameter to num × minimum(width and height of box). The default is \cor-
nersize{0.5}.
1
see sec. 5.7

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.

This a text within a parbox.


This a text within a parbox.
This footnote won’t ap-
pear:3

76
5.6. Boxes for Words and Characters

5.6. Boxes for Words and Characters

5.6.1. Prevent Hyphenation


You can use the box type Makebox to prevent words or text from being hyphenated.
Here is an example text:
This line is an example to show how you can prevent the hyphenation of “veryvery-
longword”.
To prevent the hyphenation of the word “veryverylongword”, put the word into a
box, set the Inner box to Makebox and use no explicit width.
This is the result:
This line is an example to show how you can prevent the hyphenation of “veryverylongword”.
You can alternatively set the command “\-“ as TEX Code directly before the word:
This line is an example to show how you can prevent the hyphenation of “veryverylongword”.
Of course the word now protrudes over the side margin. To avoid this, add via the
menu Insert ▷ Formatting ▷ Ragged Line Break (shortcut ) a line break before the word:
This line is an example to show how you can prevent the hyphenation of
“veryverylongword”.

5.6.2. Vertical Alignment


With the help of the command \raisebox you can align words, characters or other
boxes vertically relative to the surrounding text. \raisebox is used with the following
scheme:
\raisebox{lift}[height][depth]{box content}
The lift can be a positive value to raise the box or a negative value to lower the box.
To align for example the word “preventing” so that the bottom of the “deepest”
character “p” is at the baseline, insert the command
\raisebox{\depth}{
in TEX Code before the word. After the word insert a closing brace “}” in TEX Code.
This is the result:
This is a text line with the word “preventing” as a raised word.

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.

5.7. Colored Boxes

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

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.

Note: Floats are not allowed inside a rotated or scaled box.

5.8.1. Rotated Boxes

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

This is a line text.


hrot
wit

The box content can also be another box or an inline formula:


wit

B
hr

x=
ota

Ad
ted

This is a line framed text and a formula.


R

or an image or table:

79
5. Boxes

This is a line with a rotated image and table.

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.

5.8.2. Scaled Boxes


To scale material put it into a Scalebox. Such a box is inserted via the menu Insert ▷
Custom Insets ▷ Scalebox.
The Scalebox inset has the mandatory inset H-Factor and the optional inset V-Factor
(inserted via the menu Insert ▷ V-Factor). Input there the horizontal and vertical scale
factor, respectively. If no V-Factor inset is used, the horizontal factor will also be used
as the vertical one.
To get for example the double text size, compared to the document text size, insert
2 into the H-Factor inset. An example: Hello
2 as H-Factor and 1 as V-Factor distorts the Hello.
If the scaling factor is negative, the box content will be mirrored. Therefore -1 as
H-Factor and 1 as V-Factor can be used to create mirror writing: olleH
1 as H-Factor and -1 as V-Factor reflects the Hello at the base line.

The Reflectbox (menu Insert ▷ Custom Insets ▷ Reflectbox) is equivalent to -1 as H-


Factor and 1 as V-Factor for a Scalebox.
Note: If the H-Factor 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

2cm as Width and 1cm as Height produces: Hello


2cm as Width and ! as Height (or no Height) produces: Hello
Note: If the Width inset is empty or contains an invalid unit you will get LaTeX
errors when viewing/exporting the document.

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

of the column width. It can be inserted using the menu


Insert ▷ Floats ▷ Wrapped Figure or Wrapped Table if the
50

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

Figure 6.1.: This is a wrapped is often hard to approximate; so it is better only to


figure float. use it when you encounter float placement problems.
You can furthermore decide if LATEX is allowed to let
the float float within the paragraph or to surrounding paragraphs. Figure 6.1 is an
example text wrap float with a width of 40 col%, 1 cm overhang, set to the left.
Note: Text wrap float floats are fragile! E. g. having a figure too close to the bottom
of the page can mess things up in such a way that the float does not appear in the
output or that it is placed over some other text.
In general, the following applies for wrap floats:
• They should not be placed in paragraphs that run over a page break. That
means that wrap floats are better inserted in their exact place when the doc-
ument is almost finished and you are able to estimate where page breaks will
appear.
• They should either be placed in their own paragraph before the paragraph
where they should wrap into or within a paragraph.
• In consecutive paragraphs they may cause troubles, so ensure that there is a
text paragraph between them as separator.
• They are not allowed in section headings or tables.
• Their numbering and referencing works as described in chap. 3.
1
Installing a LATEX-package is explained it in the LATEX Configuration manual.

83
6. Objects Surrounded by Text

6.2. Surrounded Fixed Objects


The wrap floats described in sec. 6.1 have these positions in the paragraph:

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:

text text text text text text text text text


text text text text text text text

text text text text text text text


text text text text
text text text text text text text

you can use the LATEX-package picinpar. Here is an example:


It was in the spring of the year 1894 that all London was interested, and the fashion-
able world dismayed, by the murder of the Honourable Ronald Adair under most un-
usual and inexplicable cir- 1 cumstances. The public
5500

has already learned those 50 particulars of the crime


which2 came out in the 5000
police investigation, but a
good deal was suppressed 100
upon that occasion, since
the case for the prosecu- 150 tion was so overwhelm-
ingly strong that it was 4500 not necessary to bring for-
ward all the facts. Only 200 now, at the end of nearly
ten years, am I allowed to supply those missing links
which make up the whole 256
1 50 100 150 200 256
4000
of that remarkable chain.

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.

7.1. External Material


The external material feature allows you to insert files into your document without
converting them to a format that can be read by the document output format. LYX
takes care of the necessary conversions. This is similar to images that can be inserted
in various image formats in LYX documents. When you have enabled Instant Preview
in LYX’s preferences under Look and feel ▷ Graphics, the external material types Dia
and Xfig are directly shown in LYX.
External material can be inserted via the External Material dialog that is accessi-
ble with the menu Insert ▷ File ▷ External Material. Currently the following file types
(Templates) are allowed:
Chess diagram This template supports chess position diagrams made with the pro-
gram XBoard.
Dia diagram This template supports diagrams created with the program Dia.
Inkscape figure This template supports specific scalable images derived from scal-
able vector graphics (SVG), in which the contained text is replaced by a version
typeset by LATEX (and hence in the current document font). It relies on a fea-
ture of the program Inkscape which creates a special PDF or EPS and LATEX
file from a given SVG file (in Inkscape itself, the feature is available via the
option Omit text in PDF and create LaTeX file when saving a drawing as PDF

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.

7.2. Child Documents

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.

Here is a child document inserted using Include:

91
7. External Document Parts

7.2.1. External Subsection 1


This is a small dummy child document to show how files can be inserted into another
document.

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:

7.2.2. External Subsection 2


This is another small dummy child document to show how files can be inserted into
a document.
Verbatim With this method any text file can be included. The file is shown in the
output with its source code; no command used in the text is invoked. You can
use the option Mark spaces in output that displays the character “␣” for every
space character in the source code. The difference from the method via the
menu Insert ▷ File ▷ Plain Text is that the document content is not shown in LYX.
Here is a child document inserted as Verbatim:

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

Listings This type is described in chapter 8.


Note: Including the same document twice in a document using different methods
could cause LATEX-problems.
If you want to view/export only selected children of your master document, either
because you want to save compiling time or because you want to distribute single
chapters of the book you are just writing, you can exclude children from the output.
This is done via the menu Document ▷ Settings ▷ Child Documents. You can exclude/
include children by double-clicking on the include to output column of the respective
child document in the list (note that this only works for documents embedded via
“Include”, not with “Input”).
In the section Global Counters & References you can set how page numbers, references,
section counters etc. are handled.
• With the option Strictly maintain, LYX will assure that all page numbers, ref-
erences etc. are correct as if the whole document was output. This is useful if
you want the selected sub-documents to look exactly as in the context of the
whole document. However, LYX needs to process the whole document in the
background for this feature, which can take a long time.
• With the option Do not maintain, LYX only compiles the master and the included
documents. Thus the counters will differ from the complete document, and
references to excluded child documents will not be resolved. If you want to
save compile time and if counters and references do not need to be correct, use
this option as this is the fastest one.
• The option Maintain mostly is somewhat in-between the above two. If this is
selected, LYX will compile the whole document at the first output, which sets
up counters and references correctly. In subsequent outputs, it will compile the
whole document only if a change has been made in an excluded child document.
As long as you only edit the included files, this approach is as fast as the second
one, while giving you more or less correct counters and references. They are only
more or less correct since the change of size of included documents obviously
also changes the pagination of excluded documents, but this change cannot be
tracked with this method.
Alternatively, you can put each included file into a branch.1 By enabling/disabling
branches you can decide which included files will appear in the output. This has the
advantage that it also works with Input’ed sub-documents. However, counters and
references will not be maintained with this approach.

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 }

% t h e p a g e s o f t h e TOC are numbered roman


% and a PDF−bookmark f o r t h e TOC i s added

Inserting a formula into a listing can be done the following way:


1. Open the listings dialog and add
mathescape=true
to the field of the Advanced tab.
2. Create a formula outside the listing
3. Copy the content of the formula (not the formula inset) to the clipboard (short-
cut )
4. In the listing write “$$” and copy from the clipboard between the dollar-signs
(shortcut )
Listing 8.3: Example Listing float containing a formula
# Example l i s t i n g f l o a t
def f u n c ( param ) :
# ∞ 1
Q
n=1 x2
pass

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.

Table A.1.: Units

unit name/description LATEX command


bp big point (72 bp = 1 in) -
cc cicero (1 cc = 12 dd) -
cm centimeter -
dd didot (1 dd ≈ 0.376 mm) -
em width of letter M in current font -
ex height of letter x in current font -
in inch -
mm millimeter -
mu math unit (1 mu = 1/18 em) -
pt point (72.27 pt = 1 in) -
pc pica (1 pc = 12 pt) -
sp scaled point (65536 sp = 1 pt) -
Column Width % % of column width \columnwidth
% of height between baselines of two
Line Distance % \baselineskip
subsequent text lines
Line Width % % of line width \linewidth
Page Height % % of paper height \paperheight
Page Width % % of paper width \paperwidth
Scale Graphics % % of original image width
Text Height % % of text height \textheight
Text Width % % of text width \textwidth

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:

Wtot n = n · (Wg n + 2 · \tabcolsep) + (n + 1) · \arrayrulewidth (D.1)

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

Wtot mult = Wg mult + 2 · \tabcolsep + 2 · \arrayrulewidth (D.2)

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:

Wg mult + (1 − n) · (2 · \tabcolsep + \arrayrulewidth)


Wg n = (D.3)
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

Boxes Image Formats, 5


Alignment, 72 rotated, 1, 80
Box Dialog, 71 scaled, 1, 81
Color, 78 Settings grouping, 1
Customization, 74 File Formats
Decoration, 73 DVI, 101
for Characters, 77 PDF, 102
for Vertical Alignment, 77 PostScript, 101
Introduction, 71 Files
Minipages, 75 Include, 90
Parboxes, 76 Floats, 47
Raiseboxes, 77 Algorithms, 47
rotated, 79 Caption Formatting, 57
scaled, 80 Caption Placement, 58
Size, 71 Figures, 3
to Prevent Hyphenation, 77 Float Lists, 62
Introduction, 47
Caption Listings, 95
Formatting, 57 Numbering, 48
Placement, 58 Placement, 52
Color
References, 49
for Table Cells, 31
Rotating, 54
for Table Lines, 34
Settings, 52
for Table Rows, 33
Side by side, 56
DVI, see File Formats Subfloats, 54
Tables, 10
Endnotes, 67 Wrap Floats, 83
EPS, see Image formats Footnotes, 64
External Document Parts, 87 Numbering, 65
Child Documents, 90 Placement, 66
External Material, 87
GIF, see Image formats
Figures, 1 Graphics, see Figures
Floats, 3
Graphics Dialog, 1 Image Formats, 5

109
Index

Initials, 85 PNG, see Image formats


PostScript, see File Formats
JPG, see Image formats Program Code, 95
LATEX packages References
arydshln, 43, 107 Automatic Reference Naming, 51
booktabs, 30, 107 Formats, 49
calc, 24, 27, 37 Reference Position, 51
caption, 10, 15, 16, 57, 58, 107 to Figures, 3
colortbl, 31, 33, 45 to Floats, 49
diagbox, 107 to Tables, 11
endfloat, 53, 107 Rotated Material, 36, 79
fancybox, 74
footmisc, 68, 107 Scaled Material, 80
ftnright, 66 Surrounded by text, 83
hypcap, 51, 61 Fixed objects, 84
hyperref, 15, 51, 107 Initials, 85
KOMA-Script, 57, 58, 68, 107 Wrap Floats, 83
lettrine, 85, 107 SVG, see Image formats
listings, 95, 107 Table, 7
marginnote, 69, 107 Alignment, 30
minted, 95, 107 Color, 31
oberdiek, 51 Customization, 38
pdfpages, 88, 107 Dialog, 8
picinpar, 25, 84 Edit Menu, 10
prettyref, 50, 107 Floats, 10
PSTricks, 107 Formal, 28
refstyle, 50, 107 Introduction, 7
sidecap, 58, 107 Linebreaks, 22
wrapfig, 83 Multi-page Table, 11
xcolor, 33 Alignment, 13
Listings, 95 Calculation, 18
Caption Width, 15
Multi-page Table, 11
Captions, 14
Multicolumns, 22
Different Captions for Pages, 16
Calculations, 23
Floats, 18
Multiple Lines in Table Cells, 22
Footnotes, 13
Multirows, 24
Forced Page Breaks, 19
Notes References, 15
Footnotes, 64 Multicolumns, 22
LYX Notes, 63 Multirows, 24
Margin Notes, 68 Rotated Cells, 36
Toolbar, 9
PDF, 5, 102 Width, 8

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

WMF, see Image formats

111

You might also like