Additional LyX Features
Additional LyX Features
Version 2.4.x
∗ Principal
maintainer of this file is Richard Kimberly Heck. If you have com-
ments or error corrections, please send them to the LYX Documentation mailing list,
<[email protected]>.
Contents
1 Introduction 1
3 Document classes 13
3.1 Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.1.1 AMS-LATEX (American Mathematical Society) . . . . . . . . . 13
3.1.1.1 What these layouts provide . . . . . . . . . . . . . . 14
3.1.2 Extra font sizes . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.1.3 Hebrew . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.1.4 Japanese (Standard Classes) . . . . . . . . . . . . . . . . . . . 17
3.1.5 Japanese (JS Bundle) . . . . . . . . . . . . . . . . . . . . . . . 17
3.1.6 Japanese (BX Bundle) . . . . . . . . . . . . . . . . . . . . . . 17
3.1.7 Japanese (JLReq Class) . . . . . . . . . . . . . . . . . . . . . 18
3.1.8 KOMA-Script . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.1.8.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . 18
3.1.8.2 KOMA-Script Article, KOMA-Script Report, and KOMA-
Script Book . . . . . . . . . . . . . . . . . . . . . . . 19
3.1.8.3 The new letter class: KOMA-Script Letter (V. 2) . . 22
3.1.8.4 Problems . . . . . . . . . . . . . . . . . . . . . . . . 22
3.1.9 Polish M. W. collection . . . . . . . . . . . . . . . . . . . . . . 23
3.1.10 Tufte Collection . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.2 Articles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.2.1 Astronomy & Astrophysics . . . . . . . . . . . . . . . . . . . . 24
3.2.1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . 24
iii
Contents
iv
Contents
4 Modules 53
4.1 Academic Field Specifics . . . . . . . . . . . . . . . . . . . . . . . . . 53
4.1.1 Chemistry: Hazard and Precautionary Statements . . . . . . . 53
4.1.2 Chemistry: Risk and Safety Statements . . . . . . . . . . . . . 53
4.1.3 Linguistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
4.2 Accessibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
4.2.1 Braille . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
4.3 Annotation & Revision . . . . . . . . . . . . . . . . . . . . . . . . . . 53
4.3.1 FiXme Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
4.3.2 PDF Comments . . . . . . . . . . . . . . . . . . . . . . . . . . 54
4.3.3 PDF Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
4.3.4 Ruby (Furigana) . . . . . . . . . . . . . . . . . . . . . . . . . 54
4.3.5 TODO notes . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
4.4 Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
4.4.1 APA Style with Natbib . . . . . . . . . . . . . . . . . . . . . . 54
v
Contents
4.5 Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
4.5.1 Fancy Colored Boxes . . . . . . . . . . . . . . . . . . . . . . . 55
4.5.2 Graphic boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
4.5.3 Section Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
4.5.4 Variable-width Minipages . . . . . . . . . . . . . . . . . . . . 56
4.6 Fixes & Hacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
4.6.1 Fix Computer Modern Fonts . . . . . . . . . . . . . . . . . . . 56
4.6.2 LATEX Kernel Fixes (Obsolete) . . . . . . . . . . . . . . . . . . 56
4.6.3 Minimalistic Insets . . . . . . . . . . . . . . . . . . . . . . . . 56
4.6.4 Title and Preamble Hacks . . . . . . . . . . . . . . . . . . . . 56
4.7 Floats & captions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
4.7.1 Algorithm2e Float . . . . . . . . . . . . . . . . . . . . . . . . 57
4.7.2 Bilingual Captions AKA Multilingual Captions . . . . . . . . 57
4.7.3 Number Figures by Section . . . . . . . . . . . . . . . . . . . 57
4.7.4 Number Tables by Section . . . . . . . . . . . . . . . . . . . . 57
4.8 Foot- and Endnotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
4.8.1 Endnotes (Basic) . . . . . . . . . . . . . . . . . . . . . . . . . 57
4.8.2 Endnotes (Extended) . . . . . . . . . . . . . . . . . . . . . . . 57
4.8.3 Footnotes as Endnotes (Basic) . . . . . . . . . . . . . . . . . . 58
4.8.4 Footnotes as Endnotes (Extended) . . . . . . . . . . . . . . . 58
4.9 Leisure, Sports and Music . . . . . . . . . . . . . . . . . . . . . . . . 58
4.9.1 Chess Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
4.9.2 Lilypond Music Notation . . . . . . . . . . . . . . . . . . . . . 58
4.10 List enhancements . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
4.10.1 Customizable Lists . . . . . . . . . . . . . . . . . . . . . . . . 58
4.10.1.1 Custom Enumerate Lists . . . . . . . . . . . . . . . . 59
4.10.1.2 Numbered Paragraphs in Reports . . . . . . . . . . . 59
4.10.1.3 Resumed Enumeration . . . . . . . . . . . . . . . . . 60
4.10.1.4 List Spacing . . . . . . . . . . . . . . . . . . . . . . . 60
4.10.1.5 Further Customization . . . . . . . . . . . . . . . . . 61
4.10.2 Paragraph Lists . . . . . . . . . . . . . . . . . . . . . . . . . . 61
4.11 Literate Programming . . . . . . . . . . . . . . . . . . . . . . . . . . 62
4.11.1 Noweb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
4.11.2 Rnw (knitr) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
4.11.3 Sweave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
4.12 Maths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
4.12.1 AMS Theorems . . . . . . . . . . . . . . . . . . . . . . . . . . 62
4.12.2 AMS Theorems (Extended) . . . . . . . . . . . . . . . . . . . 63
4.12.3 AMS Theorems (Extended, Numbered by Type within Chapters) 63
4.12.4 AMS Theorems (Extended, Numbered by Type) . . . . . . . . 63
4.12.5 AMS Theorems (Numbered by Type within Chapters) . . . . 63
4.12.6 AMS Theorems (Numbered by Type) . . . . . . . . . . . . . . 64
4.12.7 Number Equations by Section . . . . . . . . . . . . . . . . . . 64
4.12.8 Standard Theorems . . . . . . . . . . . . . . . . . . . . . . . . 64
vi
Contents
5 Bibliography 81
5.1 Alternative Citation Styles . . . . . . . . . . . . . . . . . . . . . . . . 81
5.2 Subdivided Bibliographies . . . . . . . . . . . . . . . . . . . . . . . . 81
5.3 Multiple Bibliographies . . . . . . . . . . . . . . . . . . . . . . . . . . 82
6 Bullets 85
6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
6.2 How it looks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
6.3 How to use it . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
7 Supplemental Tools 87
7.1 Multipart Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
7.1.1 General Operation . . . . . . . . . . . . . . . . . . . . . . . . 87
7.1.2 Cross-References Between Files . . . . . . . . . . . . . . . . . 88
7.1.3 Bibliography Lists in all Subdocuments . . . . . . . . . . . . . 88
7.2 LYX Archives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
vii
Contents
9 DocBook Output 97
viii
Contents
1
Note that this command will work only with subversion ≧ 1.5
ix
Contents
Index 135
x
1 Introduction
This manual is essentially Part II of the User’s Guide. The reason for separating the
two documents is simple: the User’s Guide is already quite lengthy, and it contains
information on all of the basic features one needs to know in order to prepare most
documents. However, the LYX Team has worked to make LYX extensible through
various configuration files and external packages. That means that if you want to
support the Fizzwizzle LATEX package, you can create a layout file (or module) for it
without having to alter LYX itself. We’ve already had contributions of several new
features this way, and some of them are documented here. There are also some more
‘advanced’ features, such as how to control the presentation of bibliographies and
how to work with multi-part documents, that are not covered in the User’s Guide
and are discussed here.
This manual also documents some special features, like fax support and version
control, which require additional software to work properly. There is also a chapter
on LYX’s support for HTML. And lastly, there’s a chapter of LATEX tools and tips,
things you can use to spruce up your documents by directly using the powerful
features of LATEX. After all, LYX is only WYSIWYM and will only ever interface to
some, not all, LATEX features.
If you haven’t read the Introduction yet, you are definitely in the wrong manual.
The Introduction is the first place to go, since it describes the notation and format
of all of the manuals. You should also be thoroughly familiar with the User’s Guide
and all of the basic features of LYX before attempting to read this one.
Since many of the topics in this manual depend heavily on LYX’s interaction with
L TEX, this first chapter covers the inner workings of LYX and how to direct LYX to
A
generate exactly the LATEX code you want. It is obviously for more seasoned LYX
users.
1
2 LYX and LATEX
2.1 How LYX Uses LATEX
This chapter is for both TEX-nicians and the LATEX-curious. In it, we’ll explain how
LYX and LATEX work together to produce printable output. This is the only place in
any of the manuals where we assume you know something about LATEX.
At one time, LYX was called a “WYSIWYM frontend to LATEX,” but that’s no
longer true. There are frontends to LATEX out there.1 These are basically text editors
with the ability to run LATEX and mark any errors in the file you’re editing. Although
LYX is an editor, and it does run LATEX, and it also indicates errors in the file, it
also does much, much more. For one thing, you don’t need to know LATEX to use
LYX effectively. And LYX has added its own extensions to LATEX. Try the following
sometime: select Export ▷ LaTeX from the File menu (or View ▷ Source Pane), then
look at the preamble of the resulting .tex file. You’ll notice a variety of new macros
defined specifically by LYX. These macros are defined automatically, according to
the features you use in the document.
There are several commands that automatically invoke LATEX. They are:
• Document ▷ View
• Document ▷ Update
They will only invoke LATEX if the file has changed since the last time LATEX was run.
When LYX runs LATEX on the file you’re editing, it performs these steps:
1. Convert the document to LATEX and save to a file with the extension .tex in
place of .lyx.
2. Run LATEX on the .tex file (maybe several times), and run any other commands
(such as bibtex or makeindex) needed to compile the LATEX file.
3. If there are any errors, show the error log.
If you have run LATEX using View ▷ DVI, LYX then runs a DVI viewer to display the
DVI-file. If you have used View ▷ PostScript, LYX performs further steps:
1. Run dvips to convert the DVI file to PostScript.
2. Run a PostScript viewer, such as ghostview, to display the PostScript file.
LYX does similar things when viewing, or exporting, other formats.
1
Some familar ones are TEXmaker and kile, on Linux, and TEXshop, OSX. There are also the
LATEX modes for vi and emacs, of course.
3
2 LYX and LATEX
\begin{tabular}{ll}
\begin{minipage}{5cm}
This is an example of a minipage environment. You
can put nearly everything in it, even (non-floating)
figures and tables.
\end{minipage}
&
\begin{minipage}{5cm}
\begin{verbatim}
\begin{minipage}{5cm}
This ...
\end{minipage}
\end{verbatim}
\end{minipage}
\end{tabular}
The TEX Code box containing this text is directly after this paragraph. Those of you
reading the manual in LYX will only see the TEX code inset. Those reading a printed
version of the manuals will see the actual results:
2
tex2lyx can also be run from the command line, of course.
4
2.4 LYX and the LATEX Preamble
This is an example of a
minipage environment. You \begin{minipage}{5cm}
can put nearly everything in This ...
it, even (non-floating) fig- \end{minipage}
ures and tables.
In addition to using TEX code, you can also create a separate file containing some
complex LATEX structure and then use Insert ▷ Child Document to include your file
(you should select the type Input). We recommend that you only do this if you have
a .tex file which you know works already. Otherwise, you’ll have a big job tracking
down LATEX errors.
There are a few last points to emphasize:
On that last point, LYX does have quite a few features tucked into it, and more are
coming. Be sure to check the manuals to make sure that LYX doesn’t have such-
and-such feature before you decide you have to do it by hand. Moreover, there are
numerous LATEX packages out there to do all sorts of things, from labels to envelopes
to fancy multipage tables. Check out CTAN for details.
If you do need to do some wild and fancy things within your document, be sure to
check out a good LATEX book for assistance. There are a number of them listed in
the bibliography of the User’s Guide.
5
2 LYX and LATEX
to providing special commands, the inclusion of a package can change the doc-
ument. For example, the package indentfirst forces all paragraphs to be
indented. There are other packages for labels, envelopes, margins, etc.
LYX adds its own set of definitions to the preamble of the .tex file it produces. This
makes LATEX files generated by LYX portable.
2.4.3 Examples
Here are some examples of what you can add to a preamble, and what they do.
6
2.4 LYX and the LATEX Preamble
The default values for \hoffset and \voffset are both 0 points, i. e. the page
isn’t shifted. Unfortunately, some DVI drivers always seem to shift the page. We
have no idea why, or why the sysadmin hasn’t fixed such behavior. If you’re using
LYX on a system that you don’t personally maintain, and your sysadmin is a doofus,
\hoffset and \voffset can save the day. Suppose your left and top margins are
always 0.5 inches too big. You can add this to the preamble:
\setlength{\hoffset}{-0.5 in}
\setlength{\voffset}{-0.5 in}
\usepackage{labels}
\LabelCols=3
\LabelRows=7
\LeftBorder=8mm
\RightBorder=8mm
\TopBorder=9mm
\BottomBorder=2mm
This sets things up for Avery label sheets, stock #5360. You’re now ready to print la-
bels, but you’ll need to insert LATEX code, placing the commands \begin{labels} and
\end{labels} around each label text. This and other special features of labels.sty
are explained in its documentation.
Someday, someone may write a LYX layout file to support this package directly.
Maybe that someone is you.
7
2 LYX and LATEX
Of course, this behavior isn’t standard typography. In books, you typically only
indent the first line of a paragraph if it follows another one. The idea behind indenting
the first line of a paragraph is to distinguish neighboring paragraphs from one another.
If there is no previous paragraph—for example, if it follows a figure or is the first
paragraph in a section—then there is no need for indentation.
If you’re a typical American (we’re still joking!), though, you don’t care about such
esoteric things; you want your indentation! Add this to the preamble:
\usepackage{indentfirst}
If your TEX distribution isn’t braindead, you’ll have this package, and all of your
paragraphs will get the indentation the Founding Fathers intended they should have.
• LaTeX Warning
Anything beginning with these words is a warning message for the purpose of
“debugging” the LATEX code itself. You’ll get messages like this if you added or
changed cross-references or bibliography entries, in which case, LATEX is trying
to tell you that you need to make another run. You can by-and-large ignore
these.
8
2.5 LYX and LATEX Errors
• Overfull \hbox
LATEX absolutely loves to spew these out. It seems to generate at least one
of these messages for just about any document you write. They are warnings
about lines that were too long and run past the right margin. This happens if
LATEX does not find a reasonable way to break the lines (notoriously often with
typewriter font, since this does not allow for automatic break points). In many
cases, this is unnoticeable in the final output. (It can be just a point or two.)
Sometimes, however, the lines run rather visibly into the margin; something
you will not want to have in your final print.
There are several global ways to try to minimize the overfull lines. Clicking En-
able micro-typographic extensions in Document ▷ Settings ▷ Fonts might already
improve things a lot. Furthermore, LATEX code such as the following in Docu-
ment ▷ Settings ▷ Preamble usually reduces the overfull lines drastically (we use
this in the preamble of this document):
\tolerance 1414
\hbadness 1414
\emergencystretch 1.5em
\hfuzz 0.3pt
In some cases, however, you eventually have to rewrite the text to get the line
breaking right.4
In any case, you should check the respective lines, at least for the final version
of your document. Your eyes will tell you if there’s a problem with something
that’s too wide.5
• Underfull \hbox
Not quite as common as its cousin. This happens again if LATEX does not find
a reasonable break point and consequently generates too loose lines. As with
the overfull lines, you should check if this is a visible problem.
9
2 LYX and LATEX
There are other error and warning messages. Some are self-explanatory. These are
usually LATEX messages. Others are downright cryptic. These are usually TEX error
messages, and we really have no clue what they mean or how to decipher them.
No-one does.
There’s a general sequence you should follow if you get error messages:
2. If there are no typos, check that you used the command(s) correctly.
3. If you get a bunch of error boxes piled up at the very top of the document—
and especially if you see a “Missing \begin{document}” error—it means that
there are errors in the preamble. Start debugging your preamble.
4. If you didn’t add anything to the preamble and didn’t add any LATEX code
to the document, the first suspect is your LATEX distribution itself. Check for
missing packages and install them.
5. Okay, so there are no missing packages. Did you use any of the fine-tuning op-
tions in LYX? Specifically, did you misuse any of them, like trying to manually
insert lots of Non-Breaking Spaces, Linebreaks, or Pagebreaks? Did you
try to kludge something together with these instead of using the appropriate
paragraph environment?
6. All right, you didn’t use any of the fine-tuning options, you played by the rules.
Did you try to pull a fancy maneuver? Did you do something funky inside a
table or an equation, like inserting a graphic into a table cell?
7. Do you have long sections of text where LATEX cannot find a place to break
a line? By default, LATEX is rather strict about how much extra inter-word
spacing it will add in order to break a line. Preferably, you should rework the
paragraph to avoid the problem.
10
2.5 LYX and LATEX Errors
8. Did you go overboard with the nesting? LYX (currently) doesn’t check to make
sure you’re in the limits for nesting environments. If you nested a bunch of
environments to the 17th level, that’s the problem. (The limit in LATEX is five.)
9. Okay, you didn’t get any error messages, but your output looks awful. If you
have a table or figure that’s too wide or long for the page, you need to:
a) rescale the figure so it fits.
b) trim down the table so it fits.
10. If something else is wrong with the output, and you didn’t try to pull anything
fancy or kludge the fine-tuning options, we’re not sure what’s wrong.
If all this doesn’t help—well, then perhaps you might have found a bug in LYX. . . .
11
3 Document classes
As explained in the User’s Guide, LATEX originally offered four standard document
classes, article, report, book and letter, but individuals and organizations, most no-
tably the American Mathematical Society in the early days, have made many contri-
butions to extending the range of document classes. In this chapter we summarize the
main externally maintained classes, some of which are marked “Unavailable:” in the
pull-down Document class list in the Document ▷ Settings ▷ Document class dialog and
which you will need to install as described in the Installing New Document Classes
chapter of the Customization manual if you want to use them.
3.1 Collections
3.1.1 AMS-LATEX (American Mathematical Society)
The LYX supported document classes American Mathematical Society (AMS) in cate-
gory Articles and American Mathematical Society (AMS) in category Books are main-
tained by the Society; use of their features is described in the Math manual and
on their website http://www.ams.org/publications/authors/tex/amslatex. The
following summary was originally provided by David Johnson and updated by
Richard Kimberly Heck and the LYX Team.
The AMS LATEX layouts are set up to conform to suggested styles for mathematical
papers to be submitted to American Mathematical Society publications. The layouts
are not tailored to a specific journal, but easily can be. You should refer to the AMS
documentation for specific instructions for each journal (usually it will entail only
changing a single line in the TEX output). That documentation is available on the
Web at http://www.ams.org or by ftp at ftp://ftp.ams.org/pub/tex/amslatex/.
These layouts are appropriate, and useful, for any mathematical writing.
There are three basic AMS LATEX layouts:
• amsart: The standard AMS article format; see File ▷ Open Example ▷ Articles ▷
American Mathematical Society (AMS).
• amsbook: the standard AMS book (really, monograph) format; see File ▷ Open
Example ▷ Books ▷ American Mathematical Society (AMS).
13
3 Document classes
LYX only supports the first two natively; see the Installing New Document Classes
chapter of the Customization manual if you want to use amsproc.
The layouts themselves contain only the minimum necessary to use the AMS
classes. They do not, in particular, contain any of the ‘theorem’ environments used
for setting theorems, lemmas, and the like. These are contained, instead, in the AMS
Theorems module, which is loaded by default when you select one of the AMS classes.
(It can also be used with other classes and can be removed, if you would rather use
something else.) Less commonly used environments are in the AMS Theorems (Ex-
tended) module, which must be loaded manually.
By default, theorems and the like are numbered consecutively throughout the docu-
ment, but this may be modified by loading the module Standard Theorems (Numbered
by Section) or, if you are using book (AMS), the module Standard Theorems (Numbered
by Chapter). These will number the results as n.m, where the first number refers to
the section (or chapter) and the second refers to the total number of results so far in
that section (or chapter). Many environments are also available unnumbered. These
are indicated by an asterisk at the end. If you happen to want only unnumbered
results, the module Standard Theorems (Unnumbered) provides that option.
Note that these modules do not have to be used with the AMS classes. It is per-
fectly possible to use the AMS Theorems module, and the others mentioned, with other
classes, such as Article (Standard Class), Report (Standard Class), KOMA-Script
Book, and so forth.
14
3.1 Collections
Thanks
Dedicatory
Translator
The following environments are provided by both the Standard Theorems and AMS
Theorems modules, in the latter case in both unnumbered and numbered versions.
These same environments are provided only in the starred versions by the Standard
Theorems (Unnumbered) module:
Theorem 1. This is typically used for the statements of major results.
Corollary. This is used for statements which follow fairly directly from previous
statements. Again, these can be major results.
Lemma 2. These are smaller results needed to prove other statements.
Proposition 3. These are less major results which (hopefully) add to the general
theory being discussed.
Conjecture 4. These are statements provided without justification, which the author
does not know how to prove, but which seem to be true (to the author, at least).
Definition. Guess what this is for. The font is different for this environment than
for the previous ones.
Example. Used for examples illustrating proven results.
Problem 5. It’s not really known what this is for. You should figure it out.
Exercise. Write a description for this one.
Remark 6. This environment is also a type of theorem, usually a lesser sort of obser-
vation.
Claim. Often used in the course of giving a proof of a larger result.
Case 1. Generally, these are used to break up long arguments, using specific in-
stances of some condition.
Case 2. The numbering scheme for cases is on its own, not together with other
numbered statements.
Proof. At the end of this environment, a QED symbol (usually a square, but it can
vary with different styles) is placed. If you want to have other environments within
this one—for example, Case environments—and have the QED symbol appear only
after them, then the other environments need to be nested within the proof environ-
ment. See the section Nesting Environments of the User’s Guide for information on
nesting.
15
3 Document classes
Fact 7. Used in a way similar to Proposition, though perhaps lower on the scale.
Axiom. This is a property or statement taken as true within the system being dis-
cussed.
Condition. Sometimes used to state a condition assumed within the present context
of discussion.
Assumption. Assumption
Question. Question
There are ten more Maths modules available including several offering options
ordered on (Numbered by Type . . . ).
In addition, the AMS classes automatically provide the AMS LATEX and AMS
fonts packages. They need to be available on your system in order to use these
environments.
3.1.3 Hebrew
The document classes Hebrew Article and Hebrew Letter use the article.cls and
letter.cls document classes to facilitate the use of Hebrew in LYX.
16
3.1 Collections
17
3 Document classes
and LuaLATEX directly, with the aid of suitable packages that provide capability of
Japanese typesetting.
3.1.8 KOMA-Script
Original by Bernd Rellermeyer; updated by Jürgen Spitzmüller and the
LYX Team
3.1.8.1 Overview
The KOMA-Script collection of document classes is a development of the Script
classes created by Frank Neukam in the early 1990s; it was formally launched with
the addition of a letter class in 1994. Since then, a second letter class has been added.
Frank Neukam’s classes were inspired by the principles of typography and this has
been fully integrated into the design of the KOMA-Script classes.
The LYX document classes KOMA-Script Article, KOMA-Script Report, KOMA-
Script Book, and KOMA-Script Letter correspond to the LATEX document classes
scrartcl.cls, scrreprt.cls, scrbook.cls, and scrlettr.cls, resp. of the Koma-
Script family. They are replacements for the standard document classes article.cls,
report.cls, book.cls and letter.cls, resp., and fit better to European typography
conventions in a number of points.
• The base character sizes when you select a KOMA-Script class are 11pt in
KOMA-Script Article, KOMA-Script Report, and KOMA-Script Book and 12pt
in KOMA-Script Letter.
18
3.1 Collections
• The LATEX document classes of the Koma-Script family define a number of ad-
ditional commands. Those part of it which makes sense in LYX is implemented
in corresponding paragraph types.
Detailed descriptions of the LATEX document classes of the Koma-Script family can be
found in the Koma-Script documentation scrguide (German) and scrguien (English).
19
3 Document classes
having the same functionality. Beside the Labeling-Type there is a number of new
paragraph types added. They are not part of letter (koma-script).
• Captionabove and Captionbelow are special captions which respect the different
space settings needed for captions placed above or below an element (if you
follow strict typographic rules, you might want to place table captions always
above the table). You can also use the class option tablecaptionsabove, which
will switch caption to captionabove for tables and captionbelow for figures. You
need at least Koma-Script version 2.8q to use this.
The following types, together with the standard types Title, Author, and Date, form
the title area of the document. They must be entered ahead of the first “ordinary”
paragraph.3 When such a type is used more than once, the latter usage overwrites the
former one, that means, for every type only the latest usage is valid. The order of the
different types however has, like Title, Author, and Date, no effect on the appearance
of the produced document.
• Subject: produces a centered paragraph above the ordinary title (Title, Author,
Date) for the subject of the document.
• Publishers: produces a centered paragraph below the ordinary title (Title, Au-
thor, Date) for the publishers’ name.
20
3.1 Collections
• Titlehead: produces a left aligned paragraph above the ordinary title (Title,
Author, Date, Subject) for a document‘s head.
• Extratitle: produces a special “dirty” page ahead of the actual document con-
taining a paragraph without special formatting.
KOMA-Script offers a wide range of Custom Class options for the Document ▷ Settings ▷
Document class dialog which you can apply to the whole document, among them
draft=true which produces a PDF with a small black box at the end any line in
which a formatting error occurs; the default setting is false
headings= which may take the values big, normal or small; the first and last adjust
the sizes of the headings to take account of page sizes where the default values
may not be suitable
numbers= which may take the values auto (the default), enddot or noenddot; the
first leaves it up to KOMA-Script to add periods after chapter, section numbers,
etc.; the second forces the addition of periods and third suppresses them
leqno which causes equations to be numbered on the left rather than on the right,
and
It also provides commands to affect the output of the document independently of the
standard LATEX commands and packages; for example, if you want your captions in
bold add
\setkomafont{captionlabel}{\bfseries}
to Document ▷ Settings ▷ LATEX Preamble) and the problem is solved.
If you are writing a book, it is normal to have the preliminary pages numbered in
Roman numerals and the Chapters in this part unnumbered. If you use the Chapter*
environment, your Foreword and Preface will not appear in the Table of Contents; to
make them to appear in the Table of contents, you need to use Chapter environments
and add the TEX code
\frontmatter
at the very start of the book (not in the LATEX Preamble) and
21
3 Document classes
\mainmatter
before the first chapter of the body of the text. Alternatively, you might also use
Chapter* (TOC).
You may also want to have some unnumbered Chapter environments at the end of
the book after the Appendices, if any.4 If you use the Chapter* environment, they
will not appear in the Table of Contents; so add the TEX code
\backmatter
before the first of these headings and use the Chapter environment. These com-
mands will have no effect on the numbering in LYX, only on the PDF output where
the headings will be unnumbered and appear in the Table of Contents.
The layout files for the document classes article (koma-script), report (koma-
script), and book (koma-script) do include the file scrmacros.inc. This is thought
of as a place to define your own types. Copy scrmacros.inc in your personal layout
directory and edit the file!
3.1.8.4 Problems
Visualizing the Koma-Script document classes in LYX, the LYX internals cause some
problems.
• The chapter number of a Chapter type appears on a line of its own above the
chapter heading instead of appearing in the same line ahead of it. The cause
4
Appendices are normally “numbered” with letters.
5
The KOMA package comes with some default *.lco files. There is, for instance, a DIN.lco file
that follows german typesetting rules, or a KOMAold.lco that provides the default layout of the
old scrlettr class. The latter can be loaded with the class option KOMAold, inserted via the
Layout ▷ Document ▷ Extra Options field.
22
3.1 Collections
for that is the LYX internal behavior for the labeltype Counter_Chapter in the
layout file.
• The headings of the types Addchap and Addsec are only put in the “true”
LATEX table of contents, but not in the LYX table of contents (Document ▷
Table of Contents).
• Unnumbered titles (with star, e. g. Section*) are added into table of contents,
• Options
rmheadings serif titles — default,
sfheadings sansserif titles,
authortitle on title page first placed is author next title — default,
titleauthor on title page first placed is title next author,
withmarginpar reserve place on page for margins.
23
3 Document classes
3.2 Articles
See also the document classes in the Collections (section 3.1).
3.2.1.1 Introduction
This section describes how LYX can be used to write articles for submission to the
scientific journal Astronomy & Astrophysics (aa-package) using Version 9.1 of the
document class aa.cls; information about it is available at https://www.aanda.
org/for-authors/latex-issues/texnical-background-information.
A manual comes together with the package and should be consulted before in-
stalling this document class as described in the Installing New Document Classes
section of the Customization manual.
Please note that the publisher of the journal was changed from Springer to EDP
Sciences starting January 1, 2001. That change also involved some slight changes to
the style files, namely the removal of the thesaurus command. If you have an older
version installed, please upgrade. For information about compatibility with the old
(version 4) layout, please refer to the comments in LYXDir/layouts/aapaper.layout.
It is recommended you start from the template in the menu File ▷ New from Tem-
plate ▷ Articles ▷ Astronomy & Astrophysics. If you are not using the template, note
the following settings:
• Don’t change the Headings style in the Page Layout dialog: leave it set to Default.
The whole layout is done by the macros, you shouldn’t change anything.
24
3.2 Articles
25
3 Document classes
• Standard • Description
• Section • Caption
• Subsection • Abstract
• Subsubsection • Acknowledgment
• Itemize • Bibliography
• Enumerate • LaTeX
• \authorrunning
• \object{}
• \titlerunning{}
If you want to use any of these commands, you have to enter them yourself. Do not
forget to use Insert ▷ TEX Code!
26
3.2 Articles
5. Position the cursor after the figure and insert a horizontal fill by using the
menu: Insert ▷ Formatting ▷ Horizontal Space to open the space dialog and select
the Horizontal fill option from the Spacing context menu.
8. Position the cursor behind the caption text, switch to LATEX mode and insert
the closing brace: M-c t }.
Also, refer to the figures in the file in File ▷ Open Example ▷ Articles ▷ Astronomy &
Astrophysics.
3.2.2 AASTEX
by Mike Ressler
3.2.2.1 Introduction
AASTEX is a set of macros produced by the American Astronomical Society to facil-
itate electronic manuscript submission to the three journals they publish: the Astro-
physical Journal (including the Letters and Supplement), the Astronomical Journal,
and the Publications of the Astronomical Society of the Pacific. LYX has proven to
be an excellent tool for generating these documents, especially given its equation, ci-
tation, and figure handling capabilities. LYX requires version 5.0 (or higher) of these
macros; preferably 6.0, which is the version described here, or higher. Versions prior
to 5.0 are intended for use with LATEX2.09 and are fundamentally incompatible with
LYX. The AASTEX package may be downloaded from the AASTEX Web site
https://aas.org/aastex/aastex-downloads
27
3 Document classes
A complete user guide is contained in that package and you should familiarize
yourself with it thoroughly before embarking on writing a paper in LYX. LYX will
not reduce the need to figure out all the AASTEX commands, it will only reduce the
drudgery of typing everything in. It is your responsibility to ensure that the final
exported LATEX document conforms completely to the requirements of the journal to
which you are submitting your paper.
I strongly suggest that you start with the AASTEX template file. Click on File ▷ New
from Template ▷ Articles ▷ American Astronomical Society. This will show the most
common fields found in a manuscript. Simply overwrite the existing text (including
the brackets, <>) with the correct information. Many of the AASTEX commands and
environments can be implemented directly in LYX, but some cannot. For commands
such as these, the LATEX code must be entered directly and marked as such. Such
commands are referred to as TEX code, or Evil Red Text. I tried to minimize the
amount of TEX code needed in an AASTEX document.
When the paper is finished to your satisfaction and previews/prints correctly, there
are a few “postprocessing” actions which need to be done before you submit it to the
journals.
2. Edit the resulting .tex file with your favorite text editor
a) remove the comment lines before the \documentclass command
b) remove the \usepackage...{fontenc} line if it appears (usually just after
\documentclass}; also remove the \secnumdepth line if it appears.
c) remove everything between (and including) the \makeatletter and \makeatother
commands, except for any commands you specifically put into the LATEX
preamble (which should appear immediately after the “User specified LATEX
commands” comment in the .tex file).
3. Run the resulting file through LATEX to make sure it still processes correctly.
4. Reread the journal requirements to make sure your filenames and formats are
correct.
5. Submit it.
28
3.2 Articles
Things that work as expected Because they work as you might expect, I simply list
them and the section they are found in: \documentclass (2.1.1), \begin{document}
(2.2), \title (2.3), \author (2.3), \affil (2.3), \abstract (2.4), \keywords (2.5),
\section (2.7), \subsection (2.7), \subsubsection (2.7), \paragraph (2.7), \facility
(2.10), \begin{displaymath} (2.12), \begin{equation} (2.12), \begin{eqnarray}
(2.12), \begin{mathletters} (2.12), \begin{thebibliography} (2.13.1), \bibitem
(2.13.2), all the cite commands and their variations (2.13.2), the generic graph-
icx figure commands (2.14.1), \begin{table} (2.15.4), \begin{tabular} (2.15.4),
\caption (2.15.4), \label (2.15.4, amongst other places), \tablerefs (2.15.5),
\tablecomments (2.15.5), \url (2.17.4), \end{document} (2.18).
The following style options also work correctly: longabstract (2.4), preprint
(3.2.1), preprint2 (3.2.2), eqsecnum (3.3), flushrt (3.4). Simply put them in the
Options box in Layout ▷ Document.
Things that work, but require more comment The following items work, but
require a little more discussion:
• These items are reserved for use by the journal editors, but you can put them
into the LATEX preamble if you feel compelled to do so: \received, \revised,
\accepted, \ccc, \cpright (all from 2.1.3)
• These items may be placed in the LATEX preamble, and are included as blanks in
the template file: \slugcomment (2.1.4), \shorttitle (2.1.5), \shortauthors
(2.1.5)
• \email (2.3) – can only be used “standalone”, not in the middle of a paragraph.
Use TEX code if you need to embed it.
• \and (2.3) – will have extra {} after it. This should not cause an error.
• \placetable (2.8) – can’t insert a cross-reference tag, you must type the tag
name by hand
• \acknowledgements (2.9) – will have extra {} after it. This should not cause
an error.
29
3 Document classes
• \appendix (2.11) – will have extra {} after it. This should not cause an error.
1. Make certain that LATEX can find AASTEX. Copy sample.tex (and perhaps
table.tex) from the AASTEX distribution into a directory completely unrelated
to LATEX or AASTEX and run LATEX on sample.tex.
4. Open a regular new file, not from a template. Does American Astronomical
Society (AASTeX V. 6.3.1) appear in the class list in Document ▷ Settings?
If you get a warning from an existing AASTEX document about not being able to
find the AASTEX layout or a message about “You should not mix title layouts with
normal ones”, things haven’t been installed correctly.
30
3.2 Articles
LATEX error processing a table LYX, by default, attempts to center the table
caption/title. This seems to produce a bad interaction in AASTEX so you should
click somewhere in the caption/title, then select Edit ▷ Paragraph Settings, then set
the Alignment to Block. This took care of it for me.
1. I have noticed some funny spacing in the reference entries in the text. When
you enter the bibliography item data, make sure their is no space between the
last author and the parenthesis setting off the year; e. g. type Ressler(1992),
not Ressler (1992).
2. Entering the references at all is not obvious. The easiest thing is to start typing
your first reference at the end of the document, then mark it as type References.
That will put a small gray box in front of what you just typed. Click on the
box to fill in the rest of the information. For new references, go to the end of
an existing reference and press return. That will create a new line with its own
box, etc.
Including EPS files Even though AASTEX provides its own figure commands (\plotone,
for example), I much prefer LATEX’s standard figure commands (with the default
graphicx). You can insert the \plotone, etc. commands as TEX code into a Figure
Float box if you desire, but I never have much luck getting the layout right. With
the standard graphics, LYX will insert a \usepackage{graphicx} command into the
LATEX preamble and handle the figures in the standard LATEX 2ε way, interspersing
the figures in the text. I believe ApJ accepts figures exactly this way now; AJ might
still use the “stack everything at the end” technique.
Things I could have done, but didn’t There are a few “pretty” things I could have
implemented, but chose not to. For instance, I saw no point in double-spacing the
text in the LYX window, even though it is double-spaced in the paper manuscript.
Also, I chose not to make separate layouts for the preprint and preprint2 styles. Since
I assume you will spend most of your time in the plain manuscript mode anyway, I
decided not to chew up more disk space with this.
Your mileage may vary. I’ve now had papers published by both ApJ and AJ that
have had 98% of the effort done in LYX; the last 2% was the LATEX post-processing
and a few cleanups. I have had no trouble with the submission process, and I’m sure
the journals were never aware that there might be a difference. So, go forth and
publish!
31
3 Document classes
3.2.3 Chess
The document class Chess uses the standard article document class together with the
package lyxskak to facilitate the description of chess games. See File ▷ Open Example ▷
Articles ▷ Chess where you will find Game 1 and Game 2.
3.2.4 Elsevier
The document class Elsevier provides support for the elsarticle LATEX class for
journals in the Elsevier publishing house. This provides the following additional
environments: Title footnote, Author footnote, Corresponding author, Address, Email
and Keywords.
A template is available in the menu File ▷ New from Template ▷ Articles ▷ Elsevier. It
has been customized with further environments and contains all the information you
may need. However, the documentation is also available from CTAN.
3.2.5 Paper
The document class Paper (Standard Class) provides an alternative to the Article
(Standard Class) document class. It provides similar functionality, but you might
prefer this layout with sans serif sections, headings, and more.
3.2.6 RevTEX4
by Amir Karger
The RevTeX (V. 4) textclass works with the American Physical Sociey’s RevTEX 4.0
(the β release of May, 1999) class.
LYX has a REVTeX (obsolete) textclass, which works with RevTEX 3.1. However,
v3.1 is basically obsolete, as it works with LATEX 2.09. That means that it doesn’t
interact very well with LYX, which requires LATEX 2ε , although it has been kludged to
work. Since RevTEX 4.0 has been designed to work much more cleanly with LATEX 2ε ,
LYX with the Revtex 4TeX (V. 4) textclass should also be pretty easy to use.
These documents are supposed to be used in addition to the RevTEX 4.0 docu-
ments, so we don’t describe any of the special RevTEX macros, and assume you’ll
know what to put in the preamble if necessary.
3.2.6.1 Installation
All you need to do is install RevTEX 4, as described in the package’s README file.
The package can be found at The RevTEX 4 Web Site http://publish.aps.org/
revtex4/. Install it somewhere that LATEX can see it. Test it by trying to LATEX a
short RevTEX 4 document in some random directory (i. e. not the directory where
you installed the class file.) Then, if you reconfigure LYX, it will find the class file
and let you use the RevTEX4 textclass.
32
3.3 Books
Probably the easiest way to get started is either to import a RevTEX 4 document
using tex2lyx, or to use the Revtex 4 template, found in File ▷ New From Templates ▷
Articles.
3.2.6.3 Layouts
The layouts basically correspond to the commands in RevTEX4.0. For example, the
Email layout corresponds to \email{}. Note that (at least as of RevTEX 4.0 Beta),
the Address and Affiliation layouts are exactly equivalent, so you shouldn’t need to
use both.6
3.3 Books
See also the document classes in the Collections (section 3.1).
6
In case you’re curious, both were included so that tex2lyx would be able to translate both
\address and \affiliation.
33
3 Document classes
3.3.1 Memoir
By Jürgen Spitzmüller
3.3.1.1 Overview
Memoir is a very powerful and constantly evolving class. It has been designed with
regard to fictional and non-fictional literature. Its aim is to let the user have maximum
control over the typesetting of his document. Memoir is based on the standard book
class, but it can also emulate the article class (see below).
Peter Wilson, the developer of Memoir, is known as the author of lots of useful
packages in the LATEX world. Most of them have been merged with Memoir. There-
fore, it is much easier to layout the table of contents, appendices, chapter designs
and such. LYX, though, does not support all of these goodies natively. Some of them
might be added to forthcoming releases7 , lots will probably never be supported, due
to the limitations of LYX’s framework. Of course you can still use all features with
the help of some native LATEX commands (TEX code8 ). In this section, we can only
list those features that are natively supported by LYX. For detailed descriptions (and
for the rest of features) we recommend you have a look at the detailed manual of the
Memoir class9 , which is not only a user guide for the class, but also both a compre-
hensive description on good typesetting and a superb example for good typesetting
itself.
Page style: The fancy page style is not supported, due to a command clash between
Memoir and the fancyhdr package (they both define a command with the same
name, which confuses LATEX). Instead, Memoir comes with a number of its own
page styles (see Document ▷ Settings ▷ Page Style). If you want to use these for
the chapter pages, you have to use the command \chapterstyle in the main
text or in preamble (e. g. \chapterstyle{companion}).
34
3.3 Books
variants of a title with this: one for the main text, one for the table of contents,
and one for the headers. LYX makes these available in form of specific Short
Title variants in the Insert menu.
TOC/LOT/LOF: In the standard classes (and in many other classes), the table of
contents, the list of figures and the list of table start a new page automatically.
Memoir does not follow this route. You have to insert a page break yourself, if
you want to have one.
Titlepage: For some unknown reason, Memoir uses pagination on the title page (in
the standard classes, title pages are “empty”). If you want an empty title page,
type \aliaspagestyle{title}{empty} in the preamble.
Article: With the class option article (to be inserted in Document ▷ Settings ▷ Class
Settings ▷ Custom Options), you can emulate article style. That is, counters
(footnotes, figures, tables etc.) will not be reset on new chapters, chapters
don’t start a new page (but are—in contrary to “real” article classes—still
allowed), parts, though, use their own page, as in book.
Oldfontcommands: By default, Memoir does not allow the use of the deprecated font
commands, which have been used in the old LATEX version 2.09 (e. g. \rm, \it).
It produces an error and stops LATEX whenever such a command appears. The
class option oldfontcommands reallows the commands and spits out warnings
instead (which does at least not stop LATEX). Since a lot of packages and
particularly BibTEX style files are still using those commands, we have decided
to use this option by default.
Abstract: You may wonder why an abstract is an extra feature. Well, it is in book
class. Usually books don’t have abstracts. Memoir, however, has. You can use
it wherever and how often you like.
Chapterprecis: You may know this older typesetting style: The contents of a chapter
are summarized below the title and also in the table of contents (e. g. Our hero
arrives in Troia; he loses some friends; he finds others). Chapterprecis does
exactly this. It is therefore only sensible below a chapter.
35
3 Document classes
Poemtitle: Memoir has lots of possibilities to typeset poetry (up to very complex
figurative poems). LYX can only support a few of them. One is poemtitle, which
is a centered title for poems, which will also be added to the table of contents
(verse is the standard environment for poems. Memoir has some enhanced
versions of verse, but you need to use TEX code, because they have to be
nested inside regular verse environments, which is not possible with LYX).
3.4.2 Europe CV
The document class Europe CV provides the europecv.cls document class, an un-
official implementation of the “Europass CV” recommended by the European Com-
mission in 2002. File ▷ Open Example ▷ Curricula Vitae ▷ Europe CV offers guidance on
its use. Its documentation is available from CTAN.
3.4.3 Modern CV
The document class Modern CV provides the moderncv.cls document class. This al-
lows the creation of customizable CVs. File ▷ Open Example ▷ Curricula Vitae ▷ Modern
CV offers guidance on its use. Its documentation is available from CTAN.
36
3.5 Letters
3.4.4 Simple CV
The document class Simple CV provides the simplecv.cls document class, originally
developed for use with LYX. File ▷ Open Example ▷ Curricula Vitae ▷ Simple CV offers
guidance on its use. Its documentation is available from CTAN
3.5 Letters
See also the KOMA-Script Letter (V. 2) (section 3.1.8.3), the Letter (Standard Class
with Extra Font Sizes) (section 3.1.2) and the Hebrew Letter (section 3.1.3) document
classes .
3.5.1 DIN-Brief
The document class DIN-Brief provides support for the dinbrief.cls LATEX class
for writing letters according to the standards of the German Standards Institute
(Deutsches Institut für Normung, DIN). The file in the menu File ▷ New from Tem-
plate ▷ Letters ▷ DIN-Brief offers guidance on its use. The documentation is available
from CTAN.
37
3 Document classes
3.6 Presentations
3.6.1 Beamer
The document class Beamer uses the beamer.cls LATEX class for creating presenta-
tions. The file in the menu File ▷ New from Template ▷ Presentations ▷ Beamer or Help ▷
Specific Manuals ▷ Beamer Presentations offers guidance on its use. The documentation
is available from CTAN.
3.6.2 FoilTEX
Original by Allan Rae; updated by the LYX Team
3.6.2.1 Introduction
The document class FoilTEX uses the foils.cls document class to make slides for
overhead projectors. There are two document classes that can do this: the Slides
document class (section 3.6.5) and the FoilTEX slides class. As of 2023 the former
has continued to be maintained whereas FoilTEX has not been maintained since 2008.
This section documents the latter. If your machine doesn’t have the FoilTEX document
class installed, you’ll probably have to use the Slides document class. If you want to
install the foils.cls document class, it is available from CTAN. You should also
read the Installing New Document Classes chapter of the Customization manual.
• Don’t change the options Sides and Columns on the Document Layout dialog.
They’re ignored by the foils class.
• The default font size is 20 pt with the other options being 17 pt, 25 pt and 30 pt.
• The default font is sans serif but all math equations are still typeset in the usual
roman font.
• FoilTEX supports A4 and Letter paper sizes as well as a special size for working
with 35 mm slides. It doesn’t support A5, B5, legal or executive paper sizes.
• Don’t bother changing the Float Placement settings because they are ignored
anyway. All floats appear where they are defined in the text.
• The Pagestyle setting behaves a bit differently for this class. FoilTEX provides
extensive footer and header capabilities including a user-defined logo. See sec-
tion 3.6.2.4 for more details. The title page is treated differently to all other
38
3.6 Presentations
pages in the document and is always unnumbered and always has the logo cen-
tered at the bottom of the page (if one is defined). The possible page style
choices and what they do are as follows:
empty The final output contains no page numbers, or other headers or
footers (except footnotes of course).
plain The final output contains page numbers centered at the bottom
of the page. No other headings or footers (other than footnotes).
foilheadings Page numbers in lower right corner. Additional headers and
footers are also shown. This is also the default.
fancy Gives you access to the fancyheadings package although its use
with FoilTEX is discouraged by the writer of the FoilTEX package
because of some potential page layout clashes.
Extra Options The following options may be used in the extra class options in the
Document ▷ Settings dialog.
35mmSlide This sets up the page layout for 7.33 in by 11 in paper, which is about
the same aspect ratio as a 35 mm slide, making it a bit easier to work
with this medium.
headrule Places a rule across the page below the header on every page except
the title page.
footrule Places a rule across the page above the footer on every page except the
title page.
dvips This is automatically set each time you create a new foils document.
This option tells FoilTEX to use the dvips driver to rotate those pages
that are set as landscape foils.
landscape Simply changes the page dimensions to those of a landscape page but
doesn’t do any rotation. Thus if you use this option you need to use an
external program to rotate each page or feed your paper through your
printer as landscape. Note that this option effectively reverses the roles
of the Foilhead and Rotatefoilhead environments (don’t worry these are
described in the next section).
39
3 Document classes
• Standard • Quotation
• Itemize • Title
• Enumerate • Author
• Description • Date
• List • Abstract
• LYX-Code • Bibliography
• Verse • Address
• Quote • RightAddress
That is, all the major environments apart from the sectioning environments. Since
foils are essentially self-contained sections, with a title and body, FoilTEX provides
specific commands for starting new foils and these are:
• Foilhead
• Rotatefoilhead
LYX also provides slightly modified versions of these two environments called:
• ShortFoilhead
• ShortRotatefoilhead
• Theorem • Theorem*
• Lemma • Lemma*
• Corollary • Corollary*
• Proposition
• Proposition*
• Definition
• Definition*
• Proof
40
3.6 Presentations
The starred versions are unnumbered while the unstarred versions are numbered.
There are also two list environments added by LYX and these are:
• TickList
• CrossList
FoilTEX provides some powerful header and footer capabilities that are best set in
the preamble although they may be set at any point in a document. If you want to
change these settings in your document the best place to do so is at the very top of
a foil, i. e. straight after the foilhead.
For this purpose, the following command styles are provided [Martin Vermeer]:
There are also a few commands provided by FoilTEX that aren’t directly supported
by LYX but I’ll tell you what they do and how to use them in section 3.6.2.5.
Give It a Title Page Unlike other classes that provide Title, Author, Date and
Abstract environments, FoilTeX creates the title on a page of its own. If you leave
out the Date environment LATEX will substitute the current date (every time you
regenerate the output).
Start a New Foil As I mentioned earlier, there are four ways of starting a new foil.
For portrait foils you should use Foilhead or ShortFoilhead. The difference between
these two environments is the amount of space between the title of the foil (the
foilhead) and the body of the foil.
Landscape foils are generated using the Rotatefoilhead and ShortRotatefoilhead en-
vironments. Again the only difference is the spacing between foilhead and body.
Both of the short versions have 0.5 inches less separation between the foilhead and
the body.
One problem with the support for landscape foils is the requirement that you have
to use the dvips driver to generate the PostScript output otherwise the foils won’t
be rotated. It is possible to get landscape foils even if you haven’t got the dvips
driver provided you can feed your foils sideways through your printer ;-)
41
3 Document classes
Theorems, Lemmas, Proofs and more You can’t have two of the same type of
these environments directly following each other. If you use a normal paragraph
break, , you will just be extending the previous environment as if you had merged
the two environments together. Rather than that, you need to insert a so-called
separator. Please refer to the section entitled Separate Nestings in the User’s Guide.
Lists You get all the commonly supported list styles found in other classes as well
as two new ones. I’ll only describe the new ones here. If you want to find out more
about the other list environments check out the User’s Guide. If you intend to use
itemized lists you might also want to read about the Itemize Bullet Selection dialog
described above in section 6.
The two new list styles, TickList and CrossList, are designed to make it easier for
you to create lists of do’s and don’ts or right and wrong by providing dedicated
environments that use a tick or a cross as the label of the list. These lists are in fact
dedicated variants of the Itemize environment. They do however require that you
have the psnfss packages installed.
Figures and Tables FoilTEX redefines the floating tables and figures so that they
appear exactly where they are in the text rather than pushing them to the top of
the page or to some user specified location. In fact if you change the float placement
settings they are simply ignored.
Page Headers and Footers My Logo and Restriction are two commands used to
control the left-footer text string. The first is meant to allow you to include a graphic
logo on your foils and defaults to “-Typeset by FoilTEX-”. While the second is meant
to provide a classification for the audience, e. g. Confidential. It is empty by default.
The remaining page corners can be filled by Right Footer (which defaults to page
numbers), Right Header (top right) and Left Header (top left).
42
3.6 Presentations
\abovefloatskip Separation between the text and the top of the float
\abovecaptionskip Separation between the float and the caption
\belowcaptionskip Separation between the caption and the following text
\captionwidth You can make the captions narrower than the surrounding
text by adjusting this length. Best done relative to \textwidth.
There are also several title page related lengths that you may find useful if you have
a long title or several authors:
\abovetitleskip Separation from headers to Title
\titleauthorskip between Title and Author environments
\authorauthorskip between multiple Author lines
\authordateskip between the Author and the Date
\dateabstractskip between the Date and the Abstract
The last length related command affects all the list environments. If you place
\zerolistvertdimens inside a list environment then all the vertical spacing be-
tween the list items is removed. Note that this is a command not a length so it
doesn’t require \setlength like the stuff mentioned above.
Headers and Footers The \LogoOn and \LogoOff commands control whether the
logo in the MyLogo definition appear on a given page. If you put \LogoOff in the
preamble then none of the foils will have the logo on them. If you don’t want the
logo on a particular page place the \LogoOff directly after the foilhead of that page
and the \LogoOn directly after the next foilhead.
If you decide to use the fancy page style setting in the Document Layout dialog
you should probably add \let\headwidth\textwidth to your preamble so headers
and footers on landscape pages are correctly placed when rotated. This is due to
some clashes between the page layouts provided by the fancyheadings package and
the FoilTeX class.
3.6.3 Powerdot
The document class Powerdot uses the powerdot.cls LATEX class for creating pre-
sentations. File ▷ Open Example ▷ Presentations ▷ Powerdot offers guidance on its use.
The documentation is available from CTAN.
3.6.4 Seminar
The document class Seminar uses the seminar.cls document class for creating pre-
sentations. File ▷ Open Example ▷ Presentations ▷ Seminar offers guidance on its use.
The documentation is available from CTAN.
43
3 Document classes
3.6.5.1 Introduction
This section describes how to use LYX to make slides for overhead projectors. There
are two document classes that can do this: the Slides document class and the FoilTEX
document class. This section documents the former. If you’re looking for the docu-
mentation for FoilTEX, check out section 3.6.2. As of 2023 Slides has continued to be
maintained whereas FoilTEX has not been maintained since 2008.
• Don’t bother changing the options Sides and Columns. They’re not supported
by the Slides class, anyways.
• The option Page style behaves a bit differently for this class. The possible
choices and what they do are as follows:
plain The final output contains page numbers in the lower right corner.
headings Like plain, but also prints out any time markers you’ve put in. This
is the default.
empty The final output contains no page numbers, time markers, or alignment
markers.
• The Slides class has an extra option: clock. To use it, put “clock” in the extra
class options.
Using this options allows you to add time markers to Notes. See section 3.6.5.4
for more details.
You can also use the template file to automatically set up a document to use the
slides class using File ▷ New from Template ▷ Presentations ▷ Slides to open your new
document. The template file also contains some examples of the special paragraph
environments used by this class. I’ll describe those next.
44
3.6 Presentations
you’ll have less space. Of course, the larger default screen font isn’t WYSIWYG,
only a reminder.
The next thing that becomes obvious is the changes to the paragraph environment
pull-down box [at the far-left end of the toolbar]. Most of the paragraph environments
you’re used to seeing are missing. There are also five new ones. That’s because the
Slides class itself only supports certain paragraph environments:
• Standard • Quotation
• Itemize • Quote
• Enumerate • Verse
• Description • Caption
• List • LYX-Code
• Slide • InvisibleText
• Overlay • VisibleText
• Note
These five are kind of quirky, due to a “feature” in LYX. You see, LYX doesn’t
permit you to nest any other paragraph environment into an empty environment.
Now, that’s fine and dandy, but it means that you wouldn’t be able to start a slide
with anything except plain text. To deal with this, I’ve performed a little “LATEX
magic.”
Quirks of the New Environments All five of the new paragraph environments are
somewhat quirky due to inherent limitations in the current version of LYX. As I just
mentioned, LYX forbids environments that begin with another environment. To get
around this, the Slide environment isn’t a paragraph environment as described in the
User’s Guide.
You should consider Slide, Overlay, and Note to be “pseudo-environments.” They
look like a section heading or a “Caption,” but really begin a [and, if necessary, end
the previous] paragraph environment. Likewise, treat InvisibleText and VisibleText as
“pseudo-commands.” These two perform some action.
A common feature of all five environments, Slide, Overlay, Note, InvisibleText and
VisibleText, is a rather long-ish label. The text following this label — ordinarily the
contents of the paragraph environment — is utterly irrelevant for Slide, Overlay, Note,
InvisibleText and VisibleText. LYX completely ignores it. In fact, you can leave these
five environments completely empty.
45
3 Document classes
While you don’t have to put any text after the rather long-ish label, you might
want to. This could be a short description of the contents of the Slide, for example.
In that case, enter your descriptive comment and hit Return as you normally would.
Using Overlay with Slide The idea behind an Overlay is a slide that sits atop
another slide. Perhaps you wish to discuss a figure on the main Slide before displaying
the text associated with it. One way to accomplish this is tape a flap of dark paper
over the part of the Slide you want to display later. This method fails, however, if
you wish to overlap one graph with another, for example. You would then have to
fumble while speaking to align the two separate, overlapping Slides to align the two
graphs. The use of an Overlay environment in both cases makes life much easier.
Each Overlay receives the page number of its “parent” Slide, appended by “-a”.11
Clearly, you want the contents of both the Slide and the Overlay to each fit on a
single physical slide! You should probably consider an Overlay as “part of” a Slide.
Indeed, the LYX slides class provides a visual cue for this: the label at the start of
11
Presumably, mutliple Overlays would have “-a”, “-b”, “-c”, etc. appended to the page number of
the parent Slide.
46
3.6 Presentations
an Overlay is shorter than that at the start of a Slide. Lastly, when you generate
printable output, you’ll find alignment markers in all four corners of both the Overlay
page and its parent Slide. These will assist you in lining up the two physical slides.
The major problem in overlaying two slides is aligning the contents of the two
transparencies. How much space should you leave for that graph on the second slide?
Worse still, what if you want a graph and a sentence on second slide, but there is
text on the main transparency that goes in between them? You could try and insert
vertical space of the right size. The better way is to use InvisibleText and VisibleText.
As their names imply, InvisibleText and VisibleText are two command-like para-
graph environments that make all subsequent text invisible and visible, respectively.
Note from section 3.6.5.3 that you don’t place anything into these two environments,
however. When you create an InvisibleText, it inserts a centered, sky-blue label into
the page reading “<Invisible Text Follows>”. For paragraphs following this label, the
parts of the Slide [or Overlay; it doesn’t matter which] where they would be contain
instead blank space.
For VisibleText, the corresponding centered label is “<Visible Text Follows>” in
blazing green. Paragraphs following this label behave normally. Note that the be-
ginning of a new Slide, Overlay, or Note automatically shuts off an InvisibleText. It’s
therefore not necessary to use VisibleText at the end of a Slide.
By now, it should be obvious how to create overlay transparencies using the proper
combination of InvisibleText and VisibleText on a Slide and Overlay:
1. Create a Slide, including everything that will appear on it, whether on the main
slide or on the Overlay.
2. Before each figure or paragraph that will appear only on the Overlay, insert an
InvisibleText environment. If necessary, insert a VisibleText environment after
the Overlay-only text.
5. Within the Overlay, change all of the InvisibleText lines to VisibleText and vice-
versa.
That’s it. You’ve just made an Overlay.
There’s one problem with the way I’ve designed the LYX slides class: you can’t
make text in the middle of a paragraph invisible, nor make text in the middle of an
invisible paragraph visible again. To accomplish this feat, you’ll need to use some
inlined LATEX codes.12
12
The commands of interest are:
• {\invisible ... }
• {\visible ... }
. . . and need to be marked as TEX. The text whose “visibility” you wish to change goes in
47
3 Document classes
Using Note with Slide Like an Overlay, a Note is associated with a “parent” Slide.
Here, too, the LYX slides class provides visual cues. The label for a Note is shorter
than that of a Slide [yet longer than that of an Overlay] and, like the label of an
Overlay is shockingly magenta. Additionally, the printed Note has the page number
of its “parent” Slide, appended by “-1”, “-2”, “-3”, etc. You can have multiple Notes
associated with a single Slide, and, as with Slide and Overlay, you’ll probably want to
break up long Notes so that they fit on a single sheet of paper.
The purpose of a Note is obvious: it contains anything additional you might want
to say about a Slide. It could also be used as a sheet of reminders for a particular Slide.
In the case of the latter, you might want to make use of time markers. Currently,
the LYX slides class has no “native” support for time markers, a SliTEX feature. So,
you’ll have to resort to using the LATEX codes.
To use time markers, you’ll need to specify the extra class option “clock” [see
section 3.6.5.2]. This option turns on timing marks, which will appear in the lower-
left-hand corner of every Note you generate. To set what appears in the time marker,
you use the LATEX commands “\settime{}” and “\addtime{}”. The arguments of
both commands are time measured in seconds. “\settime{}” sets the time marker
to a given time. “\addtime{}” increments the time marker by the specified amount.
Using time markers and Notes in this fashion, you can remind yourself how much
time to spend on a particular Slide.
There’s one last feature to describe. Clearly, you’d like to print out all of your
Slides and Overlays on transparencies while printing all of your Notes on plain paper.
However, a Note must follow the Slide with which it is associated. What’s a person
to do?
Luckily, there are two LATEX commands that allow you to select what to print
out. Both must be placed into the preamble of your document. The command
“\onlyslides{\slides}” will cause the output to contain only the Slides and Over-
lays. Correspondingly, the command “\onlynotes{\notes}” prevents the output
of anything but Notes. I’d advise placing both commands in the preamble and ini-
tially comment both out. You can then preview your entire presentation as you
write. When you’re done writing, you can then uncomment one of the two to
select what you want to print. I like to uncomment “\onlyslides{\slides}” ,
print to a file with “-slides” in its name, comment it back out, then uncomment
“\onlynotes{\notes}” and print to a “*-notes.ps” file. I can then send either file
to a printer, loading transparencies or plain paper as appropriate.
You can also provide other arguments to the “\onlyslides{}” and “\onlynotes{}”
commands. See a good LATEX book for details.
48
3.7 Reports
presentation file will contain an example Slide – Overlay – Note triplet. The Slide and
Overlay additionally contain an example of the use of InvisibleText and VisibleText.
Lastly, the preamble will contain:
One final thing: I created this class to support the LATEX 2ε “SliTEX emulation”
class, one of the built-in LATEX 2ε classes. Neither I nor the rest of the LYX Team
endorse or oppose the use of this built-in slide class. It’s here if you want it or
need it. There exist other LATEX 2ε classes for creating presentations, such Foils
(see section 3.6.2) or Seminar (see section 3.6.4). Try them out to see what sort of
alternative they provide.
3.7 Reports
3.7.1 report
Report classes are sort of a hybrid between book and article classes: like book classes,
they provide parts, chapters and sections but does not provide frontmatter, main-
matter, and backmatter; like article classes, they provide abstract paragraph styles
and are one-sided by default. Also, they do not start a new chapter on the right hand
page (even in two-side mode).
All externally maintained report document classes that are officially supported by
LYX are described in the Collections (section 3.1):
• For Japanese Report (Standard Class, vertical Writing) and Japanese Report (Stan-
dard Class), see section 3.1.4.
• For Report (Standard Class with Extra Font Sizes), see section 3.1.2.
3.8 Scripts
In the Scripts category, we assemble document classes that help to write drama or
movie scripts. The category is also open for other scripts, such as lecture scripts, for
which no classes are officially supported yet by LYX though.
49
3 Document classes
3.8.1 Broadway
by Garst Reese
3.8.1.1 Introduction
Broadway is for writing plays. The format is more decorative than Hollywood (see
sec. 3.8.2), and much less standardized. This format should be suitable for workshops.
3.8.1.5 Environments
The following environments are available. You can use broadway.bind to get the
bind keys shown at the right.
• Standard
You should not have to use this, but it is here for anything that does not fit
otherwise.
• Narrative M-z n
Used to describe stage setting and the action. First use of speaker names in all
CAPs.
• ACT M-z a
Automatically numbered. On screen it will be arabic, but will print as Roman.
• ACT* M-z S at
Subtitle for ACT. It is just centered text.
50
3.8 Scripts
• Speaker M-z s
The speaker’s (actor’s) title, centered in all CAPS.
• Parenthetical M-z p
Instructions to the speaker. The parentheses are automatically inserted. The (
will appear on screen, but both will be in the printed play. This environment
is only used within Dialogue.
• Dialogue M-z d
What the Speaker says.
• CURTAIN M-z S-C
The curtain comes down.
• Title M-z S-T
• Author M-z S-A
• Right_Address M-z r
Hello there.
3.8.2.1 Introduction
Getting the format of a Hollywood script right is a “rite of passage.” It is designed to
make the readers focus on content and to be easy and familiar for the actors to read.
Each page of a script should be one minute of film. Nothing goes in a script that you
cannot see or hear on screen. The courier 12 pt font should be used throughout. No
italics.
51
3 Document classes
3.8.2.5 Environments
The following environments are available. You can use hollywood.bind to get the
bind keys shown at the right.
• Standard
Used where nothing else works. Try to avoid it.
• FADE_IN: M-z S-I
Usually followed by something like “on Sally waking up.”
• INT: M-z i
Introduces a new INTERIOR camera set-up. Always followed by DAY or
NIGHT, or something similar to define the lighting required. Everthing on
this line in CAPS.
• EXT: M-z e
Introduces a new EXTERIOR camera set-up. Everthing on this line in CAPS.
• Speaker M-z s
The character speaking.
• Parenthetical M-z p
Instructions to the speaker. The () are automatically inserted.
• Dialogue M-z d
What the Speaker says.
• Transition M-z t
Camera movement instruction. e. g. CUT TO:
• FADE OUT: M-z S-I
• Author M-z S-A
• Title M-z S-T
• Right_Address M-z r
52
4 Modules
4.1 Academic Field Specifics
4.1.1 Chemistry: Hazard and Precautionary Statements
This module provides two insets and a paragraph style to typeset numbers and
phrases of chemical hazard and precautionary statements. For a description see File ▷
Open Example ▷ Modules ▷ Hazard and Precautionary Statements and Help ▷ Specific Man-
uals ▷ Hazard and Precautionary Statements.
4.1.3 Linguistics
This module provides specific environments useful for linguistics (numbered exam-
ples, glosses, semantic markup, OT tableau floats, Discourse Representation Struc-
tures, phonetic symbols). You can obtain information about this module in Help ▷
Specific Manuals ▷ Linguistics and File ▷ Open Example ▷ Modules ▷ Linguistics.
4.2 Accessibility
4.2.1 Braille
This module supports the Braille script. It requires the LATEX package braille.sty.
This and its documentation can be obtained from CTAN. See Help ▷ Specific Manuals ▷
Braille and File ▷ Open Example ▷ Modules ▷ Braille.
53
4 Modules
outline panel. The annotations are customizable via the LaTeX preamble. See the
fixme documentation which can be obtained from CTAN.
Note: by default, the notes are only displayed in “draft” mode (if the option
“draft” has been inserted in Document ▷ Settings ▷ Document Class ▷ Class Options ▷
Custom). To display them always, insert \fxsetup{draft} in Document ▷ Settings ▷
LATEX Preamble.
4.4 Bibliography
4.4.1 APA Style with Natbib
This module adds support for using natbib together with apacite (the bibliography
style need not be apacite — it could be apacite, apacitex, or any bibliography
that works with both the natbib and apacite packages.)
54
4.5 Boxes
4.5 Boxes
55
4 Modules
1. In Preamble which puts whatever is entered into it into the preamble. This can
be used, if one wishes, to include preamble code in the body of a LyX document.
2. In Title which that will put its contents into the body of the LaTeX document,
but before \maketitle is issued. This is useful for making branches and notes
in title-related material. (However, if you put these in a Standard layout, this
signals to LyX to output \maketitle, which may then come too early.)
56
4.7 Floats & captions
57
4 Modules
insert the endnotes list where you want the endnotes to appear. See also Help ▷
Embedded Objects, section 4.2 Footnotes..
58
4.10 List enhancements
59
4 Modules
4.10.3 I have ignored the subsection heading in this example because, with paragraphs
numbered in this way, subsections are less likely to be used.
1. first
2. second
regular text
3 resumed
1 first item
2 second item
• A bullet list
You can decrease the space by adding an optional argument to the first item of the
list. Add there the command nolistsep to get no additional list space like in this
example:
• A bullet list
• without additional
• vertical space
60
4.10 List enhancements
To add space you can use several other commands provided by the enumitem package.
For more information see the enumitem documentation.
There are also many commands available to change the horizontal spacing and
indentation. Here is an example where the indentation was changed to that of the
paragraphs in the document and the label separation was set to 2 cm so that the
number is in the page margin:
1 An enumeration
Ionizing radiation:
Ionizing radiation consists of particles or electromagnetic waves that are ener-
getic enough to detach electrons from atoms or molecules, therefore ionizing
them.
Reference counting:
In computer science, reference counting is a technique of storing the number
of references, pointers, or handles to a resource such as an object, block of
memory, disk space or other resource.
There are many more commands and features provided by the enumitem package.
For more information see the enumitem documentation.
61
4 Modules
See Help ▷ Specific Manuals ▷ Knitr, File ▷ Open Example ▷ Modules ▷ Rnw (knitr) and sec-
tion 11.3 for information about literate programming.
4.11.3 Sweave
This module allows the use of the statistical language S/R as a literate programming
tool. It requires the includernw and fancyvrb packages. Both includernw and fancyvrb
are available from CTAN. It cannot be used if the module LilyPond Book has been
loaded. See Help ▷ Specific Manuals ▷ Sweave, File ▷ Open Example ▷ Modules ▷ Sweave
and section 11.3 for information about literate programming.
4.12 Maths
4.12.1 AMS Theorems
This modules defines theorem environments and the proof environment using the
extended AMS machinery. Both numbered and unnumbered types are provided. By
default, the theorems are numbered consecutively throughout the document. This
can be changed by loading one of the AMS Theorems (Numbered by . . . ) modules. It
cannot be used if the modules Standard Theorems or Standard Theorems (Unnumbered)
have been loaded.
62
4.12 Maths
63
4 Modules
64
4.12 Maths
65
4 Modules
4.12.16 Subequations
This module provides a straightforward way to segregate subequations in LyX. See
Help ▷ Math ▷ Subnumbering.
• Left Header
• Center Header
• Right Header
• Left Footer
• Center Footer
• Right Footer
\lhead{John Q. DocWriter}
You will now see your name in the upper left. If a field has a default entry that you
would like to get rid of (often the page number appears in the central footer) simply
include a command with a blank argument, e. g.:
\cfoot{}
66
4.13 Page Layout
There is, however, an easier way to make simple changes. If you load the Document ▷
Settings ▷ Modules ▷ Page Layout ▷ Custom Header/Footer Text module, you will find
you have six new environments corresponding to the six fields described above.
Let’s get really fancy: lets put the section number with the word “Section” (e. g.
Section 3) in the upper left, the page number (e. g. Page 4) in the upper right, your
name in the lower left, and the date in the lower right. Use your newly enabled
environments to add these entries:
Make sure you enter the commands \thesection, \thepage and \today as TEX Code
commands. The commands \thesection and \thepage access LATEX’s section and
page counters, and so print out the current section and page numbers. \today simply
prints out today’s date.
The thicknesses of the horizontal rules drawn beneath the header and above the
footer can also be modified. If you don’t want one of the rules, set its thickness to 0.
The header rule has a default thickness of 0.4pt, the footer rule is 0pt. For this you
will need to use TEX Code commands like
\renewcommand{\headrulewidth}{0.4pt} and
\renewcommand{\footrulewidth}{0.4pt} to set the thicknesses.
You can switch the header/footer settings on and off for individual pages using
TEX Code commands like \thispagestyle{empty}, \thispagestyle{plain}, and
\thispagestyle{fancy}. Simply insert them in the text on the page you want
changed and mark them as TEX code. In fact, title pages are marked as plain by
default, while following pages are marked fancy when using the global fancy setting.
If you want a header or footer to be on the outer side of a two sided document,
you need to use something like:
\fancyfoot{}
\fancyfoot[LE,RO]{\thepage}
The first command clears all existing footers avoiding any conflicts with your new
command.
You can enter any of these commands, the simpler ones in any of your new en-
vironments, the more complex ones as TEX Code commands, at any point in your
document and they will take effect on the next page.
As a final example, it is possible to include an image in the header or footer.
Suppose you want to put a company logo in the upper left hand corner. You might
try something like this in Document ▷ Settings ▷ LaTeX Preamble:
67
4 Modules
\lhead{\resizebox{1in}{!}{\includegraphics{logo.png}}}
You may need to preface this with \usepackage{graphics} if you don’t include
graphics elsewhere in your document.
For more information on fancy headers, you can get the fancyhdr documentation
from CTAN.
4.13.3.1 Basics
If you want to have two columns in your text, insert a multicolumn inset via the
menu Insert ▷ Custom Insets ▷ Multiple Columns where the columns should start. Write
all text that should be printed in 2 columns into this inset.
Here is an example:
The Adventure of the Empty House ing links which make up the whole of that
by Sir Arthur Conan Doyle remarkable chain. The crime was of inter-
est in itself, but that interest was as noth-
It was in the spring of the year 1894 that ing to me compared to the inconceivable se-
all London was interested, and the fashion- quel, which afforded me the greatest shock
able world dismayed, by the murder of the and surprise of any event in my adventur-
Honourable Ronald Adair under most un- ous life. Even now, after this long inter-
usual and inexplicable circumstances. The val, I find myself thrilling as I think of it,
public has already learned those particulars and feeling once more that sudden flood of
of the crime which came out in the police in- joy, amazement, and incredulity which ut-
vestigation, but a good deal was suppressed terly submerged my mind. Let me say to
upon that occasion, since the case for the that public, which has shown some interest
prosecution was so overwhelmingly strong in those glimpses which I have occasionally
that it was not necessary to bring forward given them of the thoughts and actions of a
all the facts. Only now, at the end of nearly very remarkable man, that they are not to
ten years, am I allowed to supply those miss-
68
4.13 Page Layout
blame me if I have not shared my knowledge by a positive prohibition from his own lips,
with them, for I should have considered it which was only withdrawn upon the third of
my first duty to do so, had I not been barred last month.
To get 3 or more columns, set the cursor into the multicolumn inset and use the
menu Insert ▷ Number of Columns. The number of the desired columns is written into
that inset (for 3 columns write “3”).
Here is an example with 3 columns:
It can be imagined that of Ronald Adair. As I read the or more probably anticipated,
my close intimacy with Sher- evidence at the inquest, which by the trained observation and
lock Holmes had interested me led up to a verdict of will- the alert mind of the first crimi-
deeply in crime, and that after ful murder against some person nal agent in Europe. All day, as
his disappearance I never failed or persons unknown, I realized I drove upon my round, I turned
to read with care the various more clearly than I had ever over the case in my mind and
problems which came before the done the loss which the commu- found no explanation which ap-
public. And I even attempted, nity had sustained by the death peared to me to be adequate.
more than once, for my own of Sherlock Holmes. There were At the risk of telling a twice-
private satisfaction, to employ points about this strange busi- told tale, I will recapitulate the
his methods in their solution, ness which would, I was sure, facts as they were known to the
though with indifferent success. have specially appealed to him, public at the conclusion of the
There was none, however, which and the efforts of the police inquest.
appealed to me like this tragedy would have been supplemented,
You can have up to 10 columns if you want to, but that might not be very pleasant
for the readers of your document.
The Honourable Ronald Adair was the second The youth moved rest {sic} the man’s life
son of the Earl of Maynooth, at that time gov- in the best society – moved in a narrow and
ernor of one of the Australian colonies. Adair’s
had, so far as was conventional circle, for
mother had returned from Australia to undergo
the operation for cataract, and she, her son known, no enemies and his habits were quiet
Ronald, and her daughter Hilda were living to- no particular vices. He and his nature unemo-
gether at 427 Park Lane. had been engaged to tional. Yet it was upon
Miss Edith Woodley, this easy-going young
of Carstairs, but the aristocrat that death
engagement had been came, in most strange
broken off by mutual and unexpected form,
consent some months between the hours of
before, and there was ten and eleven-twenty
no sign that it had left on the night of March
any very profound feel- 30, 1894.
ing behind it. For the
69
4 Modules
Ronald Adair was fond of cards – playing con- have lost five pounds, but not more. His fortune
tinually, but never for such stakes as would hurt was a considerable one, and such a loss could
him. He was a member of the Baldwin, the not in any way affect him. He had played nearly
Cavendish, and the Bagatelle card clubs. It was every day at one club or other, but he was a cau-
shown that, after dinner on the day of his death, tious player, and usually rose a winner. It came
he had played a rubber of whist at the latter club. out in evidence that, in partnership with Colonel
He had also played there in the afternoon. The Moran, he had actually won as much as four hun-
evidence of those who had played with him – Mr. dred and twenty pounds in a sitting, some weeks
Murray, Sir John Hardy, and Colonel Moran – before, from Godfrey Milner and Lord Balmoral.
showed that the game was whist, and that there So much for his recent history as it came out at
was a fairly equal fall of the cards. Adair might the inquest.
Preface To add a preface text for multiple columns, set the cursor into the mul-
ticolumn inset and use the menu Insert ▷ Preface. Write your preface text into that
inset.
This is an example with some preface text:
And the story continues and continues and continues and continues. . .
On the evening of the crime, he returned her daughter. Desiring to say good-night,
from the club exactly at ten. His mother and she attempted to enter her son’s room. The
sister were out spending the evening with door was locked on the inside, and no an-
a relation. The servant deposed that she swer could be got to their cries and knock-
heard him enter the front room on the sec- ing. Help was obtained, and the door forced.
ond floor, generally used as his sitting-room. The unfortunate young man was found lying
She had lit a fire there, and as it smoked near the table. His head had been horribly
she had opened the window. No sound was mutilated by an expanding revolver bullet,
heard from the room until eleven-twenty, the but no weapon of any sort was to be found
hour of the return of Lady Maynooth and in the room.
You can also use a section heading as the preface if you use a section command as
TEX Code. For example the command
\subsection{subsection title}
A minute examination of the circumstances served only to make the case more complex.
70
4.13 Page Layout
In the first place, no reason could be given Apparently, therefore, it was the young man
why the young man should have fastened the himself who had fastened the door. But how
door upon the inside. There was the possi- did he come by his death? No one could
bility that the murderer had done this, and have climbed up to the window without leav-
had afterwards escaped by the window. The ing traces. Suppose a man had fired through
drop was at least twenty feet, however, and the window, he would indeed be a remark-
a bed of crocuses in full bloom lay beneath. able shot who could with a revolver inflict so
Neither the flowers nor the earth showed any deadly a wound. Again, Park Lane is a fre-
sign of having been disturbed, nor were there quented thoroughfare; there is a cab stand
any marks upon the narrow strip of grass within a hundred yards of the house. No one
which separated the house from the road. had heard a shot.
If there is less vertical space than six text lines is left on the page at the beginning
of the multiple columns, a page break will be inserted before the multiple columns.
Depending on the number of lines of the preface text, you might want to change
this space. This is done by setting the cursor into the mulitcolumn inset behind the
preface (if there is any) and using the menu Insert ▷ Space Before Page Break. Insert
into that inset the amount of space like e. g. “5cm”.
In this example the space is set to 7 text lines by using 7\baselineskip (where the
command \baselineskip needs to be inserted as TEX code):
On the evening of the crime, he returned her daughter. Desiring to say good-night,
from the club exactly at ten. His mother and she attempted to enter her son’s room. The
sister were out spending the evening with door was locked on the inside, and no an-
a relation. The servant deposed that she swer could be got to their cries and knock-
heard him enter the front room on the sec- ing. Help was obtained, and the door forced.
ond floor, generally used as his sitting-room. The unfortunate young man was found lying
She had lit a fire there, and as it smoked near the table. His head had been horribly
she had opened the window. No sound was mutilated by an expanding revolver bullet,
heard from the room until eleven-twenty, the but no weapon of any sort was to be found
hour of the return of Lady Maynooth and in the room.
Surrounding Space The amount of space before and after multiple columns can be
changed by changing the length \multicolsep. For example the command
\setlength{\multicolsep}{3cm}
in TEX Code changes its value to 3 cm. The change must be made before the multiple
columns’ start. The predefined value is 13 pt.
For this example \multicolsep was set to 2.5 cm:
71
4 Modules
mind, endeavouring to hit upon some the- see. A tall, thin man with coloured glasses,
ory which could reconcile them all, and to whom I strongly suspected of being a plain-
find that line of least resistance which my clothes detective, was pointing out some the-
poor friend had declared to be the starting- ory of his own, while the others crowded
point of every investigation. I confess that I round to listen to what he said. I got as near
made little progress. In the evening I strolled him as I could, but his observations seemed
across the Park, and found myself about six to me to be absurd, so I withdrew again in
o’clock at the Oxford Street end of Park some disgust. As I did so I struck against an
Lane. A group of loafers upon the pave- elderly, deformed man, who had been behind
ments, all staring up at a particular window, me, and I knocked down several books which
directed me to the house which I had come to he was carrying.
Note: The values you set with \setlength will be used for all following multiple
columns until you change them again.
Column Breaks A column break can be forced by inserting the command \columnbreak{}
as TEX Code to that position in the text where the column should be broken. Note
that this leads in most cases to whitespace in the text.
Here is an example:
“You’re surprised to see me, sir,” said he, “Well, sir, if it isn’t too great a liberty,
in a strange, croaking voice. I am a neighbour of yours, for you’ll find
I acknowledged that I was. my little bookshop at the corner of Church
“Well, I’ve a conscience, sir, and when I Street, and very happy to see you, I am
chanced to see you go into this house, as I sure. Maybe you collect yourself, sir. Here’s
came hobbling after you, I thought to myself, British Birds, and Catullus, and The
I’ll just step in and see that kind gentleman, Holy War – a bargain, every one of them.
and tell him that if I was a bit gruff in my With five volumes you could just fill that gap
manner there was not any harm meant, and on that second shelf. It looks untidy, does it
that I am much obliged to him for picking not, sir?”
up my books.”
“You make too much of a trifle,” said
I. “May I ask how you knew who I was?”
AFTER THIS SENTENCE THE COLUMN
BREAK IS FORCED.
Column Separation The width of the columns is automatically calculated, but you
can modify the space between the columns. This is done by changing the length
\columnsep. Its predefined value is 10 pt. Here is an example where \columnsep is
set to 3 cm:
72
4.13 Page Layout
Vertical Lines Between the columns a rule with a width of the length \columnseprule
is placed. If this rule width is set to 0 pt (this is the default), the rule is suppressed.
In the following example the rule is 2 pt wide:
“You’re surprised to see me, sir,” said he, “You make too much of a trifle,” said I.
in a strange, croaking voice. “May I ask how you knew who I was?”
“Well, sir, if it isn’t too great a liberty,
I acknowledged that I was.
I am a neighbour of yours, for you’ll find
“Well, I’ve a conscience, sir, and when I my little bookshop at the corner of Church
chanced to see you go into this house, as I Street, and very happy to see you, I am
came hobbling after you, I thought to myself, sure. Maybe you collect yourself, sir. Here’s
I’ll just step in and see that kind gentleman, British Birds, and Catullus, and The
and tell him that if I was a bit gruff in my Holy War – a bargain, every one of them.
manner there was not any harm meant, and With five volumes you could just fill that gap
that I am much obliged to him for picking on that second shelf. It looks untidy, does it
up my books.” not, sir?”
\renewcommand{\columnseprulecolor}{\color{red}}
as TEX Code before the multicolumn inset. Replace red in this command by a color
of your choice. You can use all pre- and self-defined colors. See the EmbeddedOb-
jects manual, section Colored Tables for more information about pre- and self-defined
colors. To go back to the default color insert the command
\renewcommand{\columnseprulecolor}{\normalcolor}
73
4 Modules
“You’re surprised to see me, sir,” said “May I ask how you knew who I was?”
he, in a strange, croaking voice. “Well, sir, if it isn’t too great a lib-
I acknowledged that I was. erty, I am a neighbour of yours, for you’ll
“Well, I’ve a conscience, sir, and when find my little bookshop at the corner of
I chanced to see you go into this house, Church Street, and very happy to see you,
as I came hobbling after you, I thought to I am sure. Maybe you collect yourself,
myself, I’ll just step in and see that kind sir. Here’s British Birds, and Catul-
gentleman, and tell him that if I was a bit lus, and The Holy War – a bargain, ev-
gruff in my manner there was not any harm ery one of them. With five volumes you
meant, and that I am much obliged to him could just fill that gap on that second shelf.
for picking up my books.” It looks untidy, does it not, sir?”
“You make too much of a trifle,” said I.
74
4.14 Paragraph Styles
Drop
Normal/reversed rain drop Fragile, calculation might fail
down/up
TEX The TEX logo -
Triangle
up/down/ Triangles in different orientations -
left/right
To use a shape for your paragraph, simply select it in LYX’s pull-down box for
environments in the toolbar.
75
4 Modules
The package shapepar takes care that the shape will always be preserved, no
matter how much text is in the paragraph. Therefore the paragraph size changes
with the amount of contained text. This can lead to paragraph sizes exceeding the
page margins. To demonstrate the size scaling, here is the same example paragraph
but with twice as much text:
76
4.14 Paragraph Styles
An exception is the shape CDlabel. It cannot be scaled because it must fit the size
of a CD/DVD. Therefore the amount of text that fits into the shape is limited.
The drop shapes and the circle shape are fragile, meaning that the calculation of
their size can fail, depending on the amount of text. You will then get the LATEX
error “Arithmetic overflow”. In this case one can try to remove or add some text; if
nothing works one has to use another shape.
For shapes with tips you will maybe see that LATEX’s hyphenation routine fails for
text in the tips. Therefore it is often necessary to add hyphenation points () to the
corresponding text parts.
Shapepar paragraphs are either always centered or placed on the page so that their
left border touches the left page margin. You can therefore not use the paragraph
dialog to align such paragraphs. A solution is to put the paragraph into a minipage
or parbox and align the box. The problem is hereby to find the right width for the
box. Because if it is too wide and you center the box, the paragraph is not centered
too because it sticks at the left side of the box. So you might have to play a bit with
the width until it fits. Here are two heart-shaped paragraphs, the first one is not
aligned, the second one is right-aligned:
77
4 Modules
Lorem ipsum
dolor sit amet, consetetur sa-
dipscing elitr, sed diam nonumy eir-
mod tempor invidunt ut labore et do-
lore magna aliquyam erat, sed diam
voluptua. At vero eos et accusam
et justo duo dolores et ea rebum.
Stet clita kasd gubergren, no
sea takimata sanctus est
Lorem ipsum dolor
sit amet.
♡
Lorem ipsum
dolor sit amet, consetetur sa-
dipscing elitr, sed diam nonumy eir-
mod tempor invidunt ut labore et do-
lore magna aliquyam erat, sed diam
voluptua. At vero eos et accusam
et justo duo dolores et ea rebum.
Stet clita kasd gubergren, no
sea takimata sanctus est
Lorem ipsum dolor
sit amet.
♡
2 In Jpgfdraw go to the menu TeX/LaTeX ▷ Settings ▷ Set Normal Size and select
the font size you are using in your document. For example this document uses
the size 12 pt.
3 Draw a shape.
4 Use the menu TeX/LaTeX ▷ Shapepar to export the shape to coordinates. In the
appearing dialog use either the outline of your shape for the coordinates or the
path itself.1
1
For more information see http://www.dickimaw-books.com/apps/jpgfdraw/manual/shapepar.html
78
4.14 Paragraph Styles
The coordinates are written into a TEX file. To use it for your LYX document
1 Place the cursor before the first character of your paragraph (or into a new
empty one).
2 Open in LYX the menu Insert ▷ File ▷ Child Document, select the file and use Input
as Include Type.
Note: The changed shape only applies to the current paragraph; everything is
reset to normal for the next paragraph. Therefore the shape definition file must be
input into every paragraph with the desired shape.
Here is an example:
A tip: to draw complexer shapes in Jpgfdraw you can draw the shape in a program
of your choice and import the resulting image to Jpgfdraw. Then you only need to
draw a line or spline along the outline of the image.
The module Custom paragraph shapes also provides the two commands shapepar and
Shapepar which can be used to define custom shapes coordinate by coordinate.2 For
information how these styles are used and about further customization possibilities,
have a look at the documentation of the package shapepar.
79
4 Modules
• Rest of initial which creates an inset for the rest of the word
• Options which allow you configure the formatting of the drop capital.
To customize the appearance of the style, see Help ▷ Embedded Objects ▷ Objects
Surrounded by Text ▷ Initials.
80
5 Bibliography
The most basic information about how to use BibTEX or Biblatex with LYX is con-
tained in the section Bibliography databases of the User’s Guide. The following sub-
sections explain special bibliography features supported by LYX.
81
5 Bibliography
this. But with the help of some LATEX packages, BibTEX can be extended to fit your
needs.
LYX provides native support for one of these packages, bibtopic.2 The advantage
of this package (compared to other packages such as multibib) is that you don’t need
to define new citation commands. Instead, you need to prepare different bibliographic
databases which include the entries for the different sections of the bibliography.
For example: If you want to divide your bibliography into the sections “Sources”
and “Scientific works”, you first need to create two bibliographic databases, e. g.
sources.bib and scientific.bib.
Go to Document ▷ Settings and check under Bibliography the option Subdivided bib-
liography. Now you can insert multiple BibTEX bibliographies, one for each section
of your bibliography. Returning to our example: Insert the BibTEX bibliography
sources.bib and a second one for the database scientific.bib. You are free to
use the same or different styles for each section. Additionally, you can choose if the
bibliography section should contain “all cited references” of the specified database(s)
(which is the default), “all uncited references” or even “all references”. This might
be useful if you would like to separate your bibliography into three sections: “Cited
sources”, “Uncited sources”, and “Scientific works”. The titles for the sections can be
added as ordinary sections or subsections. Since bibtopic removes the bibliography
title, you have to manually re-add that, too (as a chapter* or section*, for instance).
With Biblatex, the procedure is a bit different. Since bibtopic does not work
with Biblatex, the aforementioned Subdivided bibliography option is disabled
if you use Biblatex. However, Biblatex provides its own means to generate subdi-
vided bibliographies. You can either add keywords to bibliography entries via the
keywords entry option and then filter bibliography sections by keyword (by adding
keyword=mykeyword to the Options field of the dialog that opens if you left-click on
the Biblatex Generated Bibliography button), or you can filter by entry types
(such as book or article) by entering e. g. type=book or nottype=collection to the
mentioned Options field, or you can create so-called “Bibliography Categories” to
which you can assign individual entries. Please refer to the Biblatex manual, section
Subdivided Bibliographies, for details.
82
5.3 Multiple Bibliographies
and do not check Sectioned Bibliography. In all other cases, bibtopic is used.3
If bibtopic is used, LYX encloses the specified units in bibtopic’s \begin{btUnit}
and \end{btUnit} in order to create the units. Note that this approach has some
limitations. First, every citation reference has to be inside some btUnit. So citations
outside a defined unit (e. g., before the first section if you use “by section”) will
appear as “???”. You can also create your own units by entering \begin{btUnit} and
\end{btUnit} as TEX code (for instance to work around the mentioned limitation).
Note, though, that btUnits cannot be nested. A second limitation is that bibtopic
always processes all references of a bibliography database, even if they are not cited.
This can result in odd labels (e. g. “Miller 2014b” if two works of this author from
2014 are in the database, even if only one is cited).
If you use Biblatex, the refsection option is used instead. If you need specific
units, you can start them with the TEX code \newrefsection or \newrefsegment,
respectively. If you also want to control the end of the unit, use the environ-
ment \begin{refsection} . . . \end{refsection} instead. Note, though, that
refsections cannot be nested. In addition to the individual bibliography of the
current unit, Biblatex also provides an easy way to output all bibliographies, subse-
quently, at one place (e. g., at the end of the document). Select “all reference units”
from the Content combo box of the Bib(la)TeX inset dialog in order to achieve this.
Please refer to the Biblatex manual for more information on this topic.
3
An alternative approach, if you are willing to use some TEX Code (see section 2.3), is to use the
bibunits package.
83
6 Bullets
by Allan Rae
6.1 Introduction
LYX provides 216 bullet shapes that can be accessed from a simple dialog. Using this
dialog you can easily specify what bullet shape to use at each level of an itemized
list. These settings are document-wide so you won’t be able to specify different sets
of bullets for different paragraphs.1
LYX doesn’t stop you using bullets from packages you don’t have. If you get errors
from LATEX when you try to view or print the file, then it is likely you are missing a
package.2
1
Well, actually you can but you’ll have to do it by hand.
2
LYX doesn’t restrict your use since you may be editing locally and exporting elsewhere.
85
6 Bullets
♯ Use the LATEX command \renewcommand to specify a new bullet shape for a
given depth. You’ll also need to save the current bullet shape so you can restore
it again afterwards. In this itemized list the following LATEX code was used to
change the bullet used for the first depth.
\let\savelabelitemi=\labelitemi
\renewcommand\labelitemi[0]{\small\(\sharp\)}
♯ Note that the itemize depth is specified in Roman numerals as part of the
\labelitem command.
⋆ Specify each individual entry by starting each item with the bullet shape en-
closed in a “Custom Item” inset (available at Insert ▷ Custom Item) and set as
TEX Code. For example, this item was started with \(\star\).
You’ll also need to revert the labelitem back to its previous setting for the global
bullet shape settings to remain in effect. The way used here was:
\renewcommand\labelitemi[0]{\savelabelitemi}
86
7 Supplemental Tools
7.1 Multipart Documents
7.1.1 General Operation
When you are working on a large file with many sections, it is often convenient to
break up the document into several files, or perhaps you have something where a table
may change from time to time, but the preceding text does not. In these cases, you
should seriously consider using multipart documents. For example, scientific papers
often have five major sections: the introduction, observations, results, discussion, and
conclusion. Each of these could be its own separate LYX file, with one “master” file
which contains the title, authors, abstract, references, etc., plus the five included files.
It is important to note that each of these files is a full LYX file which can be formatted
and printed on its own, as well as included in a master file. Each of these files must
have the same document class, however—don’t attempt to mix book classes with
article classes. You may also include LATEX files; however, these files must not have
their own preamble (i. e. everything up to and including the \begin{document} line
as well as the \end{document} line must be deleted) or else errors will be generated
when you try to make a DVI file.
LYX allows you to include files quite easily with Insert ▷ Child Document. When
you click on this selection a small box is inserted into the file at the current cursor
location. Clicking on the box raises a dialog which allows you to select the file to be
included, and the method of its inclusion.
The file selection box should by now be obvious. The three inclusion methods are
“include”, “input”, and “verbatim”. The methods “include” and “input” are similar
in many ways, but there are also some notable differences:
1 Files that are “included” are typeset beginning on a new page, while files that
are “inputted” are typeset starting on the current page.
3 “Include” allow for the output of only selected “included” files, while maintain-
ing the actual counters (pagination etc.) and references (please refer to the
section Child Documents of the Embedded Objects manual for details).
Hence, “include” is the preferred method for chapters that are outsourced to child
documents, while “input” is more suitable for arbitrary file inheritance.
87
7 Supplemental Tools
A “verbatim” included file allows you to include a file typeset exactly as it ap-
pears in the file, i. e. in verbatim mode, with the characters set in a fixed-width
typewriter font. Normally, spaces in this file are invisible, though two consecutive
spaces are conserved, unlike LYX’s normal treatment of spaces. However, setting the
Mark spaces in output checkbox typesets a mark to unambiguously define the
presence of a space.
Generally, the master file is converted into a full LATEX file before typesetting,
while the included files are converted to LATEX files that do not have all the preamble
information.
88
7.2 LYX Archives
with a co-author. LYX includes a Python script (lyxpak.py) that automates this
process. To use it, you must have either the zipfile or tarfile python modules
installed on your system. By default, the script prefers the gzip-compressed tar
format on Unix-like systems and the zip format on Windows.
LYX’s configuration process will set the script up to export a ‘LYX Archive’, and
this format will then be available under File ▷ Export.
Independently of the platform, the generation of a particular archive format can be
forced by adding either the -t (for the tar format) or -z (for the zip format) switch
to the LYX->LYX Archive converter in Tools ▷ Preferences ▷ File Handling ▷ Converters.
(Make sure you add the switch after the script name, not before it.)
89
8 LYX and the World Wide Web
LYX has long supported the export of documents to various web-friendly formats, such
as HTML. Before version 2.0, however, HTML export was always accomplished by the
use of external converters.1 These fall into two large groups: there are converters that
use LATEX as an intermediate format, such as htlatex, html2latex, and plastex,
relying upon LYX to produce the LATEX; and there is a converter that works directly
on LYX files, eLYXer. All of these have different advantages and disadvantages.
The LATEX-based converters have the advantage that, in principle, they know ev-
erything about the exported document that LATEX does. Such converters do not care,
for example, if a certain block of code was produced by LYX or was Evil Red Text.
These converters know about aux files, counters, and references, and can often make
use of the bbl files generated by BibTEX. On the other hand, LATEX is a very hard
language to parse—it is sometimes said that only TEX itself understands TEX—and
LATEX-based converters will often choke on what seem to be quite simple constructs;
complex ones can throw them completely, and as of this writing, for example, the
Embedded Objects manual will not export with htlatex, though the others will. The
other issue concerns how math is handled. These converters typically convert the for-
mulae into little pictures that are then linked from the HTML document. Since these
are actually generated by LATEX, they are accurate. But they do not scale well, and
just getting them to look as if they are actually meant to be in your document—so
that the font sizes seem to be roughly the same—can be a challenge.
Alex Fernandez’s eLYXer (http://pinchito.es/elyxer/) solves some of these prob-
lems. In particular, the formulae it produces scale perfectly, since it renders math
using a combination of HTML and CSS rather than converting the formulae to images.
But even moderately complex formula are rendered less well than with htlatex; this
reflects the limitations of HTML.2 More importantly (as of version 1.1.1, at least),
eLYXer has limited support for math macros and no support for user-defined para-
graph or character styles. These limitations make eLYXer unsuitable for many of the
documents LYX users produce. In principle, of course, these problems could be solved,
but the LYX developers have decided to follow a different path and have made LYX
itself capable of writing XHTML, just as it is capable of writing LATEX, DocBook,
and plaintext.
As of this writing, XHTML output remains under development and should prob-
1
For details on the use of external converters with LYX, see the Converters section of the Cus-
tomization manual.
2
That said, eLYXer can also use jsMath and MathJax for equations, but this setting is only available
globally and requires one to have access to a server that runs the backend.
91
8 LYX and the World Wide Web
ably be regarded as “experimental”.3 Still, the developers have chosen this approach
because it has several potential advantages over the other two.
These advantages are primarily due to the fact that the XHTML output routines,
since they are part of LYX, know everything LYX knows about the document being ex-
ported.4 So they know about the table of contents (as displayed in the outline), about
the counters associated with different paragraph styles, and about user-defined styles.
The XHTML output routines know what LYX knows about internationalization, too,
so they will output “Chapter 1” or “Kapitel 1”, depending upon the language in effect
at the time.
Quite generally, the output routines know what LYX knows about document layout,
that is, about how the document is to be rendered on screen. We use this information
when we output the document as XHTML. In particular, LYX automatically generates
CSS style information corresponding to the layout information it uses to render the
document on screen: if section headings are supposed to be sans-serif and bold as
seen in LYX, then (by default) they will be sans-serif and bold when viewed in a web
browser, too. And this is true not just for pre-defined styles, like Section, but for
any style, including user-defined styles. Indeed, the XHTML output routines make
no distinction between user-defined paragraph and text styles and LYX’s own pre-
defined styles: in each case, everything LYX knows about the styles is contained in
the layout files. And much the same is true as regards pre-defined textual insets,
such as footnotes, and various custom insets.
The result is that XHTML output can be customized and extended in exactly the
same way LATEX output can be customized and extended: through layout files and
modules. See chapter five of the Customization manual for the details.
The remainder of this chapter contains more detailed information on XHTML
output, its limitations, and ways to work around those limitations.
• MathML
MathML is a dialect of XML designed specifically for mathematics on the web,
and it typically renders very well in browsers that support it. The disadvantage
is that not all browsers support MathML, and support is not complete even in
the Gecko-based browsers, such as Firefox.
If LYX is unable to render a formula as MathML—for example, if the formula
3
The file development/HTML/HTML.notes, which can be found in the LYX source tree or accessed
online, usually contains up-to-date information about the state of XHTML output. See also the
list of XHTML bugs on the bug tracker.
4
Another advantage is that, since these routines are internal to LYX, they are immune to changes
in LYX’s file format, or to changes in the semantics of existing insets.
92
8.2 Bibliography and Citations
uses the xymatrix package or ERT—then it will instead output the formula as
an image.
• HTML
As mentioned above, elyxer outputs math as HTML, styled by CSS.5 For sim-
ple formulae, this can work quite well, though with more complicated formulae
it tends to break down. Still, this method has the advantage that it is very
widely supported and so it may be appropriate for documents that contain
only a little, fairly simple math.
If Lyx is unable to render a formula as HTML—for example, if the formula uses
the xymatrix package or ERT—then it will instead output the formula as an
image.
• Images
Like htlatex, LYX will output formulae as images, the very same images, in
fact, that are used for instant preview.6 The advantage to this method is that
the images are simply generated by LATEX, so they are very accurate. The
disadvantage, as mentioned earlier, is that these are bitmapped images, so they
do not scale terribly well, and one cannot copy them, etc.
The size of the images can be controlled by setting the “Math Images Scaling”
parameter under Document ▷ Settings ▷ Output ▷ HTML.7
If LYX for some reason fails to create an image for a formula (e.g., if a required
LATEX package is not installed), then it will fall back to outputing the raw LATEX.
• LATEX
Finally, LYX will happily output math as LATEX. As well as being the output
of last resort, this method can be used with such tools as jsMath, which uses
JavaScript to render LATEX embedded in HTML documents. LYX wraps the
LATEX in either a span (for inline formulas) or div (for displayed formulas)
with class=’math’, as is required for jsMath.
One of these output methods must be selected under Document ▷ Settings ▷ Formats.
By default, LYX outputs MathML. This is a document-wide setting, therefore.
Eventually, LYX will offer the user the option to select an alternate output method
for a particular inset, say, one that isn’t being rendered very well by MathML.8
93
8 LYX and the World Wide Web
Citation labels are generated by the same machinery that generates LYX’s on-
screen labels, so the labels will look in the output much as they do in LYX, though
better. If you are using numerical citations, then LYX will output numerical labels,
such as [1] or [17], rather than simply showing the citation key in square brackets, as
it does on-screen. If you are using author-year citations, then LYX will add lowercase
letters to the years, just as BibTEX does, if it finds more than one citation for a given
author-year combination. The labels will be printed with the bibliography entries.
Note that there is, at present, no way to customize the appearance of the labels, for
example, to choose between square brackets and parentheses.
Bibliography output is handled by the same machinery that handles the presenta-
tion of reference information in the citation dialog, so you will see in the XHTML
output pretty much what you would see if you were to look at a given entry in the
citation dialog. The formatting can be customized in your layout file or, preferably,
in a module. See the Customization manual for the details.
The main defect at present is that cross-referenced information is printed with
every entry with which it is associated. So you can see things like this:
8.3 Indexes
LYX will happily export indexes as XHTML, but with certain limitations at the
moment.
Index export will be most reliable when you do not attempt to use the fancy
constructs that are described in the section on indexes in the User’s Guide.9 We’ll
describe how they are handled using the subsection headings from that section.
• Page Ranges: There is no support at all for page ranges, since these make no
sense with XHMTL. Instead, you will just get two index entries, one at either
end.
9
The main issue here is that LYX itself does not really handle these. It just lets you enter what
you would have to enter in raw LATEX.
94
8.4 Nomenclature and Glossary
• Index Entry Order: LYX does support attempts to fix the sorting order. It will
take what is before the first ‘@’ it finds and use that for sorting, taking what
follows the first ‘@’ to be the actual entry. At present, LYX does not check for
escaped ‘@’, so do not try to index email addresses.
• Index Entry Layout: You can format entries by using the text style dialog, or
by using any other method available within LYX itself. There is no support for
constructs like: “entry|textbf”. Indeed, if LYX finds a pipe symbol, ‘|’, in an
entry, it will delete it and everything that follows it.
• Multiple Indexes: There is no support for multiple indexes. Rather, all index
entries will be printed as one large index. To avoid our printing several versions
of the index, we print only the main index, so make sure you have one.
95
9 DocBook Output
Apart from HTML, LYX can generate documents in the DocBook XML vocabulary.
With versions 2.3 and before, only select templates could be used to generate Doc-
Book documents (only version 4). Starting with LYX 2.4, most LYX layouts can
generate valid DocBook documents (only version 5). This feature is built into LYX
and does not require the use of external tools.
The result is that the DocBook output can be customized and extended in exactly
the same way LATEX output can be customized and extended: through layout files
and modules. See chapter five of the Customization manual for the details.
Most LYX features are supported with DocBook, like math output.
• Math output is performed mostly in MathML (the major exception being con-
structions not supported by LYX, i.e. ERTs). All formulae are also available in
raw TEX in the DocBook output for further processing.
• Indexes are supported, including multiple indices. Grouping (with !), page
ranges, and cross-references (|see) are supported, with the exception of the
same symbols escaped. Entry order (@) and layout (|mathbf) are not supported.
There is no support for escaping of index entries.
• Format for tables: LYX can generate tables either as HTML (default value) or
CALS, depending on the user’s requirements. Most DocBook processors accept
both formats.
• MathML prefix: in DocBook, MathML is included within its own name space,
unlike HTML. The implication is that there must be an indication of the tags
belonging to the MathML standard. Three choices are offered:
– Inline: the MathML name space is defined for each formula (using the
xmlns attribute on each formula)
97
9 DocBook Output
– With the m prefix (default): the MathML name space is defined at the
document level (using the xmlns:m attribute on the root element). Each
MathML is prefixed with m: for instance, m:math
– With the mml prefix: similar to the m option, but with mml
This option is especially useful if you want LYX to match your personal style
or to work with buggy software that only accepts one prefix for MathML.
98
10 The LYX Server
10.1 Introduction
The ‘LYX server’ allows other programs to talk to LYX, invoke LYX commands, and
retrieve information about the LYX internal state. This is only intended for advanced
users, but they should find it useful. It is by writing to the LYX server, for example,
that bibliography managers, such as JabRef, are able to “push” citations to LYX.
99
10 The LYX Server
LYXCMD:clientname:function:argument
clientname is a name that the client can choose arbitrarily. Its only use is that LYX
will echo it if it sends an answer—so a client can dispatch results from different
requesters.
function is the function you want LYX to perform. It is the same as the commands
you’d use in the minibuffer.
The answer from LYX will arrive in the output pipe and be of the form
INFO:clientname:function:data
where clientname and function are just echoed from the command request, while data
is more or less useful information filled according to how the command execution
worked out. Some commands, such as “font-state”, will return information about the
internal state of LYX, while other will return an empty data-response. This means
that the command execution went fine.
In case of errors, the response from LYX will have this form
ERROR:clientname:function:error message
where the error message should contain an explanation of why the command failed.
Examples:
100
10.4 Notification
10.4 Notification
LYX can notify clients of events going on asynchronously. Currently it will only do
this if the user binds a key sequence with the function “notify”. The format of the
string LYX sends is as follows:
NOTIFY:key-sequence
where key-sequence is the printed representation of the key sequence that was actually
typed by the user.
This mechanism can be used to extend LYX’s command set and implement macros.
Bind some key sequence to “notify”. Then start a client that listens on the output
pipe, dispatches the command according to the sequence, and starts a function that
may use LYX calls and LYX requests to issue a command or a series of commands to
LYX.
LYXSRV:clientname:protocol message
where protocol message can be “hello” or “bye”. If “hello” is received from a client,
LYX will report back to inform the client that it’s listening to it’s messages, while
“bye” sent from LYX will inform clients that LYX is closing.
101
10 The LYX Server
by clicking at the respective position in the DVI/PDF output. To achieve this, the
viewer must be able to communicate with LYX. This is done via the LYX server either
by using the named pipe (lyxpipe), or the UNIX domain socket (lyxsocket) that LYX
creates in its temporary directory (this is the way the lyxclient program commu-
nicates with LYX). In some cases, you need a helper script that mediates between
the viewer and LYX, in others, the viewer can communicate with LYX directly. This
depends on the selected viewer and on your operating system. The same applies to
the way viewers need to be configured and the way the reverse search is actually
performed. In what follows, we will thus describe how to setup reverse search for
specific viewers. Before we turn to this, though, we will explain what needs to be
done generally to enable reverse search in the DVI/PDF output.
102
10.6 Reverse DVI/PDF search
should include it), and it works reliably. To enable it, change the LaTeX (plain)-
>DVI or LaTeX (plain)->DraftDVI converter in Preferences ▷ File Handling ▷
Converters to latex -src-specials $$i. If this doesn’t work, check if your TEX
engine needs different options (the syntax might differ in some distributions).
If you want to be able to perform both DVI and PDF reverse searches, you can also
insert in the preamble the following lines
\usepackage{ifpdf}
\ifpdf
\usepackage{pdfsync}
\else
\usepackage[active]{srcltx}
\fi
This way, you can preview the file as either DVI or PDF (pdflatex) and the right
package will be used.
Note that PDFSync might affect the output layout of your document. It is therefore
advised to disable PDFsync for final documents.
103
10 The LYX Server
To enable SyncTEX for DVI output, change the LaTeX (plain) -> DVI or
LaTeX (plain) -> DraftDVI converter in Preferences ▷ File Handling ▷ Converters
to latex -synctex=1 $$i, and for PDF output, change the LaTeX (pdflatex)
-> PDF (pdflatex) converter to pdflatex -synctex=1 $$i. Should your viewer
not be considered in the following description, or in case of missing success, please
check the documentation of your viewer whether the viewer needs to be configured
for the use with SyncTEX.3
#!/bin/sh
LYXPIPE="/path/to/lyxpipe"
COMMAND="LYXCMD:revdvi:server-goto-file-row:$1 $2"
echo "$COMMAND" > "${LYXPIPE}".in || exit
read TMP < "${LYXPIPE}".out || exit
/Applications/LyX.app/Contents/MacOS/lyxeditor "$2" $1
exit 1
Modify the lines accordingly if you install LYX somewhere else than in the Applica-
tions folder.
Reverse search is triggered by Alt-click (OPTION-click).
3
Note that the option -synctex=1 option enables gzip compression. If your viewer does not support
it, you should instead use -synctex=-1.
4
On Mac OSX you have to use DISPLAY=:0.0 xdvi -editor "lyxeditor.sh %f %l"
5
In the development/tools folder of a source distribution you can find a lyxeditor script which
is able to locate the lyxpipe based on your preferences.
104
10.6 Reverse DVI/PDF search
Evince (GNOME)
Reverse search with evince does not work out of the box, but it can be achieved by
means of some third party helper scripts. Please refer to https://wiki.lyx.org/LyX/SyncTeX
for details.
Okular (KDE)
Go to Settings ▷ Configure Okular ▷ Editor and select LyX” as editor. This inserts the
appropriate command (lyxclient -g %f %l).
Reverse search is triggered by SHIFT-click. Note that this only works if Okular is
in “Browse” mode (i. e., the hand symbol is clicked).
Qpdfview (Unix)
Qpdfview supports SyncTEX since version 0.3.5. Go to Edit ▷ Settings ▷ Behavior, click
on the input field of the “Source editor” item and add the command lyxclient -g
%1 %2.
Reverse search is triggered by double-click or, in more recent versions, by context
menu.
YAP (Windows)
Launch yap, choose its View ▷ Options menu and select the “Inverse DVI Search” tab.
Click on the “New. . . ” button and, in the window that opens, enter “LYX Editor”
(or any other name you like) in the “Name:” field. Now click on the button labeled
“. . . ” to open a file dialog and navigate to the directory containing the batch file
lyxeditor.bat (see below). Select lyxeditor.bat and then specify the program
arguments as %f %l. The lyxeditor.bat wrapper is used for communicating with
LYX through the lyxpipe and is as follows:
@echo off
echo LYXCMD:revdvi:server-goto-file-row:%~1 %2> \\.\pipe\lyxpipe.in
type \\.\pipe\lyxpipe.out
Make sure that the LYXServer pipe path you specified in LYX is \\.\pipe\lyxpipe,
otherwise change the lyxeditor.bat wrapper accordingly.
In yap, reverse search is triggered by double-click.
105
10 The LYX Server
SumatraPDF (Windows)
In order to use SumatraPDF for inverse search, enter SumatraPDF -inverse-search
"lyxeditor.bat "%f" %l" in the viewer setting in Preferences ▷ File Handling ▷ File
formats ▷ PDF (pdflatex), where lyxeditor.bat is the previous wrapper. If Suma-
traPDF.exe is not in your command PATH, use its full file name.
Reverse search is triggered by double-click.
YAP (Cygwin)
First of all, make sure that yap is your default DVI viewer in the Windows envi-
ronment, then launch it, choose its View ▷ Options menu and select the “Inverse DVI
Search” tab. Click on the “New. . . ” button and, in the window that opens, enter
“LYX Editor” (or any other name you like) in the “Name:” field. Now click on the
button labeled “. . . ” to open a file dialog and navigate to the directory containing
the lyxeditor.exe program (which is installed by default on Cygwin along with the
LYX executable). Select lyxeditor.exe and then specify the program arguments as
-g %f %l. In this way, you will be using the lyxsocket for communicating with LYX.
If, for whatever reason, you want to use the lyxpipe, omit the -g option and be sure
to specify the LYXServer pipe path in the LYX preferences.
In yap, reverse search is triggered by double-click.
SumatraPDF (Cygwin)
In order to use SumatraPDF for inverse search, enter SumatraPDF -inverse-search
"lyxeditor -g %f %l" in the viewer setting in Preferences ▷ File Handling ▷ File for-
mats ▷ PDF (pdflatex). If SumatraPDF.exe is not in your command PATH, use its
full posix path. The -g enables communication via the lyxsocket. Again, omit the
-g option if you want to use the lyxpipe, and be sure to specify the LYXServer pipe
path in the LYX preferences.
Reverse search is triggered by double-click.
106
10.7 Forward search
Additionally, you need to configure LYX for using your viewers in Tools ▷ Preferences ▷
Output ▷ General. We provide a range of tested configurations for some viewers, which
you can select from the drop down list. If none of these configurations suits you, you
have to find out and enter a suitable configuration yourself. The definition syntax
uses the following placeholders:
• $$o: name of the exported output file (either dvi or pdf, depending on which
one exists in the temporary directory)
Note that only some of the viewers provide full and usable forward search functionality
out of the box, among them yap, xdvi, okular6 , qpdfview, and SumatraPDF7 . Others,
such as evince8 , require some extra tools in order to use forward search. While many
of the widespread PDF viewers (most notably Adobe Reader) do not support forward
search at all, some other viewers – e. g. xpdf – allow at least to reload the document
and jump to a specific page of the file, so you can at least navigate “near”. This latter
functionality is provided by an external call of synctex (see the predefined example
configurations).
Forward search works both with DVI and PDF output. LYX simply checks which
preview format you have used before (i. e., which format is already there in the
temporary directory) and chooses the appropriate configuration for the respective
format.
6
You might want to set okular --unique in Tools ▷ Preferences ▷ File Handling ▷ File Formats
7
SumatraPDF can also use DDE commands through the external program CMCDDE — down-
loadable from http://www.istri.fr/spip/zip/CMCDDE.zip
8
Forward search with evince can be achieved by means of third party helper scripts. Please refer
to https://wiki.lyx.org/LyX/SyncTeX for details.
107
11 LYX Features needing Extra
Software
11.1 Checking TEX
by Asger Alstrup
11.1.1 Introduction
If you have the chktex program installed1 , you’ll find in the Tools menu the entry:
Check TeX. You can get chktex from CTAN,
https://www.ctan.org/tex-archive/help/Catalogue/entries/chktex.html.
The ChkTEX package is a program that was written by Jens T. Berger Thiele-
mann in frustration because some constructs in LATEX are sometimes non-intuitive,
and easy to forget. The program runs over your LATEX file, checks the integrity of the
file, and flags some common errors. In other technical words, it is lint for LATEX.
Well, what is a syntax checker doing in LYX which is supposed to produce correct
L TEX anyways? The answer is simple: Just as Lint not only checks the syntax of
A
C programs, but also does semantic checks for type-errors, ChkTEX catches some
common typographic errors, in addition to the syntactical ones. Specifically, ChkTEX
is capable of detecting several common errors, such as
• Ellipsis detection:
Use . . . instead of ...
• No space in front of/after parenthesis:
( wrong spacing )
• Enforcement of normal space after common abbreviations:
e. g. is too wide spacing.
• Enforcement of end-of-sentence space when the last sentence ends with a capital
letter:
This is a TEST. And this is wrong spacing.
• Space in front of labels and similar commands:
2
The label should stick right up to the text to avoid falling to a wrong page.
The label is separated too much.
1
chktex is not yet available when you are using the LATEX distribution MiKTEX.
2
This footnote is in danger of falling off to a wrong page
109
11 LYX Features needing Extra Software
and more . . . It is an invaluable tool when you are “finishing up” your document
before printing, and you should run it right after the obligatory spelling check, and
before you go fine tuning the typesetting.
• Fine tune the ChkTEX invocation command line in Tools ▷ Preferences ▷ Output ▷
LaTeX ▷ CheckTeX command, or the global ChkTEX installation configuration file
3
You can inspect the specific output from chktex by using Document ▷ LATEX Log right after a chktex
run.
110
11.1 Checking TEX
(usually with the file chktexrc). See below to learn what warnings can be
enabled and disabled on the command line.
• Export your document as a raw LATEX file using File ▷ Export ▷ LATEX and run
chktex manually on that. Invoked in this way, it can be a hassle to find the
corresponding place in the document inside LYX, but with a little patience, you
should be able to do it.
Here follows the warning messages that can be enabled and disabled in Preferences.
Use -n# to disable a warning, and -w# to enable a warning. The emphasized entries
are disabled by default, because the default is "chktex -n1 -n3 -n6 -n9 -n22 -n25
-n30 -n38".
Notice that you should only use the options that enable and disable warnings,
because LYX relies on some of the other command line parameters to be set in a
specific way to have a chance to communicate with chktex.
1 Command terminated with space.
2 Non-breaking space (“~”) should have been used.
3 You should enclose the previous parenthesis with “{} ”.
4 Italic correction (“\/”) found in non-italic buffer.
5 Italic correction (“\/”) found more than once.
6 No italic correction (“\/ ”) found.
7 Accent command “cmd” needs use of “cmd”.
8 Wrong length of dash may have been used.
9 “%s ” expected, found “%s ”.
10 Solo “%s” found.
11 You should use “%s” to achieve an ellipsis.
12 Inter-word spacing (“\ “) should perhaps be used.
13 Inter-sentence spacing (“\@”) should perhaps be used.
14 Could not find argument for command.
15 No match found for “%s”.
16 Math mode still on at end of LATEX file.
17 Number of “char” doesn’t match the number of “char”.
18 You should use either “ or ” as an alternative to “"”.
111
11 LYX Features needing Extra Software
19 You should use "’" (ASCII 39) instead of "´" (ASCII 180).
20 User-specified pattern found.
21 This command might not be intended.
22 Comment displayed.
23 Either ”\,’ or ’\,” will look better.
24 Delete this space to maintain correct page references.
25 You might wish to put this between a pair of “{} ”.
26 You ought to remove spaces in front of punctuation.
27 Could not execute LATEX command.
28 Don’t use \/ in front of small punctuation.
29 $\times$ may look prettier here.
30 Multiple spaces detected in output.
31 This text may be ignored.
32 Use “ to begin quotation, not ’.
33 Use ’ to end quotation, not “.
34 Don’t mix quotes.
35 You should perhaps use “cmd” instead.
36 You should put a space in front of/after parenthesis.
37 You should avoid spaces in front of/after parenthesis.
38 You should not use punctuation in front of/after quotes.
39 Double space found.
40 You should put punctuation outside inner/inside display math mode.
41 You ought to not use primitive TEX in LATEX code.
42 You should remove spaces in front of “%s”
43 “%s” is normally not followed by “%c”.
In later versions of LYX, we hope to provide a more complete interface to this tool
(and it’s smaller cousin lacheck) to exploit the full power of it. But it’s not exactly
useless as it is now: go try it on one of your existing documents of a certain length
and be surprised.
112
11.2 Version Control in LYX
11.2.1 Introduction
LYX supports some of the most basic RCS/CVS/SVN/GIT commands. If you need
something a bit more sophisticated you will have to do that manually in a terminal
or your favourite client.
Also note that CVS support is not as good as subversion support, so we advise
using SVN instead. A good place to start learning Subversion is the SVN Book4 . In
the case of RCS you should read “rcsintro” (a man file, read it with man rcsintro).
This file describes all the basic features of RCS. You should especially notice the
comment about a RCS directory, and the notion of a master RCS file (the file ending
in ,v).
Before you begin to use the version control features in LYX, you should be familiar
with RCS/CVS/SVN/GIT usage. The implementation in LYX assumes a recent
version of the GNU RCS or CVS/SVN package — no guarantees are made for older
versions. Most of the log messages are not currently displayed after operations —
you can check them in the Messages pane if you are unsure. Regular users of version
control will appreciate the VC toolbar, which can be enabled via View ▷ Toolbars ▷
Version Control.
For introducing your own external commands consult vc-command in the manual
LYX Functions.
It is strongly recommended to store documents in uncompressed format if using
version control (uncheck Document ▷ Compressed if it is checked): Uncompressed LyX
documents are text files and therefore for merging two different versions by ver-
sion control systems. Compressed LyX documents are binary files, which cannot be
merged by version control systems. Also to avoid unnecessary merge conflicts we
advise to disable Document ▷ Settings ▷ Output ▷ Save transient properties when more
users work on the same document.
11.2.2.1 Register
If your document is not under revision control, this is the only item shown in the
menu. And if it is under revision control, the Register item is not visible.
4
http://svnbook.red-bean.com/
113
11 LYX Features needing Extra Software
This command registers your document with RCS (unless you are under the di-
rectory managed by CVS). You are asked interactively to supply an initial descrip-
tion of the document. The document is now set in Read-Only mode and you have
to Check Out For Edit, before making any changes to it. A document under revi-
sion control has a “[RCS:<version> <locker>]” item tagged to the filename in the
minibuffer.
RCS command that is run:
11.2.2.5 Copy
This will create a copy of the current document. Since RCS does not support copy
operations natively, the version history is not preserved, and the copy is added as a
new file. It requires a clean document without any changes since the last checkin.
You are asked for a file name and a description of the copy operation. After that the
copy is created, both locally and in the repository. If the parent directories of the
copied and original document differ, all relative paths of included files of the copy are
adjusted (like in File ▷ Save As. . . ). Finally, the copy is loaded instead of the original
document.
114
11.2 Version Control in LYX
RCS commands:
Copy "<file-name>" to "<new-file-name>"
ci -q -u -i "<new-file-name>"
115
11 LYX Features needing Extra Software
11.2.3.2 Register
If your document is not under revision control, this is the only item shown in the
menu. And if it is under revision control, the Register item is not visible.
This command registers in CVS your document only in the case you have already
the documents directory under CVS control (in particular CVS/Entries file exists).
This means you have to create or checkout the archive by yourself using external
tools. (In case you forget that step LYX registers the document with RCS.)
Then you are asked interactively to supply an initial description of the document.
Don’t forget that registered file is not yet checked in.
CVS command that is run: cvs -q add -m"<entered message>" "<file-name>"
The term "<file-name>" above and for all other CVS commands is an abbreviation
for “change the current working directory to file location and use the file name without
path component as argument”.
CVS command:
cvs -q commit -m"<description>" "<file-name>" or
cvs -q unedit "<file-name>"
116
11.2 Version Control in LYX
11.2.3.6 Copy
This will create a copy of the current document. Since CVS does not support copy
operations natively, the version history is not preserved, and the copy is added as a
new file. It requires a clean document without any changes since the last checkin.
You are asked for a file name and a description of the copy operation. After that the
copy is created, both locally and in the repository. If the parent directories of the
copied and original document differ, all relative paths of included files of the copy are
adjusted (like in File ▷ Save As. . . ). Finally, the copy is loaded instead of the original
document.
CVS commands:
Copy "<file-name>" to "<new-file-name>"
cvs -q add "<new-file-name>"
11.2.3.7 Rename
This will rename the current document. Since CVS does not support rename opera-
tions natively, the version history is not preserved, the renamed document is added as
a new file, and the original document is deleted. It requires a clean document without
any changes since the last checkin. You are asked for a file name and a description of
the rename operation. After that the document is renamed, both locally and in the
repository. If the parent directories of the new and old file names differ, all relative
paths of included files are adjusted (like in File ▷ Save As. . . ). Finally, the document
is reloaded using the new name.
CVS commands:
Rename "<file-name>" to "<new-file-name>"
cvs -q add "<new-file-name>"
cvs -q remove "<file-name>"
117
11 LYX Features needing Extra Software
become especially useful once you cooperate with people which neither have detailed
knowledge about CVS usage nor they have ambition to commit additional material
to the repository. You have to organize the files structure so that all external files are
in the same directory or subdirectories of the document. It’s good practice anyway
to store multipart documents in an extra directory.
The Update local directory from repository command updates the whole di-
rectory. If local changes are detected user is warned before update starts. In case
of merge conflicts both versions of the conflicting document parts are placed in the
final document. You have to review and correct the result of the merge. You’ll find
the conflicts enclosed in pairs of <<<<<<< and >>>>>>> separated by =======. The
first part is your version as before the update operation with the document name
prepended. The second one is the repository version with the version number after
the sequence of > signs.
CVS commands:
cd $path; cvs diff "." (Ask if changes are detected.)
cd $path; cvs -q update "."
where $path stands for the path to the document.
11.2.4.1 Register
If your document is not under revision control, this is the only item shown in the
menu. And if it is under revision control, the Register item is not visible.
This command registers in SVN your document ONLY in case you have already
the documents directory under SVN control (in particular .svn/entries file exists).
This means you have to checkout the archive by yourself.
5
Most of the commands will work with 1.4 too, see 11.2.4.7. There seems to be currently unresolved
permissions problem under SVN 1.8 with reverting changes when file is locked.
118
11.2 Version Control in LYX
Then you are asked interactively to supply an initial description of the document.
Don’t forget that registered file is not yet commited.
SVN command that is run: svn add -q "<file-name>"
Read man svn to understand the switches.
11.2.4.5 Copy
This will create a copy of the current document including the version history. It
requires a clean document without any changes since the last checkin. You are asked
for a file name and a description of the copy operation. After that the copy is created,
both locally and in the repository. If the parent directories of the copied and original
document differ, all relative paths of included files of the copy are adjusted (like in
File ▷ Save As. . . ). Finally, the copy is loaded instead of the original document.
SVN commands:
svn copy -q "<file-name>" "<new-file-name>"
svn commit
11.2.4.6 Rename
This will rename the current document including the version history. It requires a
clean document without any changes since the last checkin. You are asked for a
file name and a description of the rename operation. After that the document is
renamed, both locally and in the repository. If the parent directories of the new and
6
In case locking is not enabled. See Section 11.2.4.9.
7
Ditto.
119
11 LYX Features needing Extra Software
old file names differ, all relative paths of included files are adjusted (like in File ▷ Save
As. . . ). Finally, the document is reloaded using the new name.
SVN commands:
svn move -q "<file-name>" "<new-file-name>"
svn commit
120
11.2 Version Control in LYX
• Unlocked state. The loaded file is in the read-only mode. For editing on needs
to check-out. Check-out consists of updating from the repository and gaining
write lock. If the lock is not possible to obtain, we remain in unlocked state.
• Locked state. The loaded file is in the ‘normal’ edit mode. No other user is
allowed to edit the file. Check-in consists of commiting changes and releasing
write-lock. If no changes have been made to the document, no commit will be
produced11 and only the write-lock will be released.
SVN commands:
SVN commands:
121
11 LYX Features needing Extra Software
– file revision information. The result comes from parsing the output of
svn info --xml file.lyx. Supported flags are:
∗ version number of the last commit (vcs-revision)
∗ author of the last commit (vcs-author)
∗ date of the last commit (vcs-date)
∗ time of the last commit (vcs-time)
You can obtain this info via InsetInfo (Insert ▷ Field ▷ Version Control Revision).
The information will be available only when you have the file stored under svn
managment (i.e. the .svn directory is available with your document).
11.2.5.1 Preparation
In addition to installing LYX, and having access to a Subversion repository, the user
will need to install the Subversion client program. A Windows installer for the client
program is available from CollabNet. The user may also want to install TortoiseSVN,
which integrates Subversion operations into the context (rightclick) menu of Windows
Explorer. Operations done outside LYX will typically be more convenient using the
Explorer context menu. Note that TortoiseSVN is not a replacement for the client
program, which is what LYX itself will use.
12
http://svnbook.red-bean.com/en/1.4/svn.advanced.props.special.keywords.html
13
This is an easy way how to ensure that LYX won’t break the line in the middle of keyword tag.
122
11.2 Version Control in LYX
1 Locate C:\new project in Windows Explorer, right click it, and select Tor-
toiseSVN ▷ Repo-browser. If necessary, adjust the URL for the repository, then
click OK.
2 Right click the level of the repository under which you want to place the new
project folder (typically the top level) and click Create folder Supply a name
for the project folder and click OK. Add a message for the log file if desired,
then click OK again. The new project folder should appear in the repository.
Finally, click OK again to exit the repository browser.
3 Once again right click C:\new project, this time selecting SVN Checkout. . .
Select the URL of the project folder you just created in the repository, and
set the checkout directory to C:\new project. Click OK. You will be warned
about a non-empty folder; click OK to proceed. You should now have a .svn
directory under C:\new project.
4 Create or open your document in LYX and click File ▷ Version Control ▷ Register.
Add a log message and click OK to commit the document to version control.
From this point onward, you should have full functionality in the File ▷ Version Control
menu. You also have the option of checking the document in and out, viewing
its history, etc. using the TortoiseSVN context menu in Windows Explorer or the
Subversion client program from a command prompt.
123
11 LYX Features needing Extra Software
1 Get an svn client for windows, as described in the previous sections. When it
is a fresh install run some svn command (e.g. svn --version) to create config
files, which you will need to change later on.
2 Choose an ssh client for Windows. There are several possibilities, we will use
the one from Putty tools14 . You will need to set the connection up so that the
client doesn’t ask for any password from you. To keep things easy we will use
only keys without any additional password protection etc.
a) Generate keys by puttygen. Save your private .ppk key file and put the
public one on the server side. If the SVN server runs on Linux, note
that the format of the public key is not compatible with Linux openssh
and you will need to direcly copy-paste the key from the “Public key for
pasting into OpenSSH authorized_keys file:” edit field into the server’s
~/.ssh/authorized_keys / authorized_keys2 file.
b) Get the Putty’s plink. In the SVN config file15 , section [tunnels], setup ssh
command, e.g. ssh=c:/path/plink.exe -i c:/path/private_key.ppk.16
124
11.2 Version Control in LYX
One big difference of GIT and the other supported version control systems is the
distributed nature of GIT: With traditional version control systems there is one cen-
tral server which hosts the repository. Users commit their changes to the server, and
get updates made by other users from it. With GIT, users commit to a local reposi-
tory. The local repository can be synchronized with one or more remote repositories
using the pull and push GIT commands. LYX does not interact in any way with
remote GIT repositories. It works exclusively with the local repository in a very sim-
ilar way as with a central CVS or SVN repository. If you use remote GIT repositories
you need to do the pull and push operations with your favourite GIT client.
11.2.6.1 Register
If your document is not under revision control, this is the only item shown in the
menu. And if it is under revision control, the Register item is not visible.
This command registers in GIT your document ONLY in case you have already
the documents directory under GIT control (in particular .git/index file exists20 ).
This means you have to checkout the archive by yourself.
Then you are asked interactively to supply an initial description of the document.
Don’t forget that registered file is not yet committed.
GIT command that is run: git add "<file-name>"
Read man git to understand the switches.
11.2.6.4 Rename
This will rename the current document including the version history. It requires a
clean document without any changes since the last checkin. You are asked for a
file name and a description of the rename operation. After that the document is
renamed, both locally and in the repository. If the parent directories of the new and
old file names differ, all relative paths of included files are adjusted (like in File ▷ Save
As. . . ). Finally, the document is reloaded using the new name.
20
For that both git init *and* initial repository commit (or at least git add) needs to be man-
ually done.
125
11 LYX Features needing Extra Software
GIT commands:
git mv "<file-name>" "<new-file-name>"
git commit
126
11.3 Literate Programming
11.3.1 Introduction
The main purpose of this documentation is to show you how to use LYX for liter-
ate programming, where it is assumed that you are familiar with this programming
technique, and know what “tangling” and “weaving” means. If that is not the case,
please follow the web links provided in the following sections. There is a lot of good
documentation out there covering old development history to the latest tools tips.
It is also assumed that you are familiar with LYX itself to a point that you are
comfortable changing your LYX preferences, and X resources file. If that is not the
case please refer to other LYX documentation to cover your specific needs.
11.3.2.1 References
The complete Literate Programming FAQ can be found at:
Literate Programming FAQ http://www.literateprogramming.com/lpfaq.
pdf
127
11 LYX Features needing Extra Software
The FAQ lists 23 (twenty three!) different literate programming tools. Where some
are specialized or “tailored” for particular programming languages, while other have
general scope. I selected Noweb for my own use for several reasons:
• There is a good selection of filters available already (the HTML is one of them).
• It is free.
Starting from there you can reach many other interesting links and even some literate
program examples.
Typing code in LYX enables you to write code with a custom inset named Chunk.
Noweb delimits chunks like this:
<<My code>>=
code
more code
even more code
@
21
Filters are programs that read a given data stream and output a manipulated data stream. That
way, a WEB file (consisting of literate code) can be turned into a file consisting only of C program
code or LATEX code.
128
11.3 Literate Programming
The problem is that whatever is written in between the << and the @ must be taken
literally, i. e. LYX should be prevented from making any special interpretation of what
has been written. This is also handled by Chunk, that works like a normal text inset
but has a free spacing capability.
As a special note, you can also use the “%def” construct of Noweb in your chunks
to add items to Noweb’s identifier cross-reference:
<<My chunk>>=
def some_function(args):
"This is the doc string for this function."
print "My args: ", args
@ %def some_function
For an example of this usage and the resulting cross-reference output, look at the
Literate python program in LIBDIR/examples/listerrors.lyx which should make this
all clear.
Generating the documentation At this point you already have a new document
file with a proper document class, and with some code and text on it. How do I print
it? The answer is simple, you select View ▷ DVI, etc. Just like you would do for a
plain document. No special procedure is required.
To help orientate you, I will now explain what happens inside LYX:
1 When the Update ▷ DVI menu option is chosen, a LATEX file is generated.
If the document is of any literate class the generated file will be named with
an extension name defined by the “literate” format (defined in the Preferences
panel), otherwise the file will have the usual .tex extension.
2 Note that the only difference so far is in the name of the file, no special process-
ing is required by LYX. Given that you formatted the code using the Chunk
inset that, by itself, takes care of the business.
3 If the document is of any literate class LYX will then use the internal LYX to
Noweb converter, followed by the Noweb to LATEX converter22 to generate the
LATEX file.
Otherwise it will just skip this step.
4 Finally, LATEX is invoked and the regular post processing continues as in a plain
document.
129
11 LYX Features needing Extra Software
Generating the code When the build menu option is chosen or the corresponding
button in the toolbar is pressed, a LATEX file is generated just like step 1 above. Next,
LYX invokes the Noweb->Program converter. This converter needs to be defined by
the user and is not installed by default, though the Program format is. This converter
(like any other converter) will have two parts:
1 The converter program itself. This program performs the conversion from the
one format to the other (in this case, from the Noweb format to the Program
pseudo-format).
2 The error log parser. This is a program whose sole purpose is to rewrite error
messages in a format that LYX understands. This makes it possible for LYX to
place error boxes in the right places in the file buffer.
This basically means that LYX will call “build-script” (a program or script) with the
name of the Noweb file (normally a file in the LYX temp directory) and the directory
path of the original LYX file.
This is an implementation of “build-script” that you can place in a directory on
your path:
#!/bin/sh
#
notangle -Rbuild-
script $1 | env NOWEB_SOURCE=$1 NOWEB_OUTPUT_DIR=$2 sh
The next part of the converter setting is the “Flags” which is to be set to
parselog=$$s/scripts/listerrors
This will run any errors that are generated by the “build-script” process through the
“listerrors” program.
The build will normally take place in LYX’s temporary directory, so the files pro-
duced by the conversion will be in that directory. LYX will copy out what it regards
as the ‘main’ file, but the Noweb->Program conversion may produce several files, and
so most of these would then be deleted when LYX was closed. This is why we pass in
the NOWEB_OUTPUT_DIR environment variable so that the build-script chunk
can place the generated files in that location.
130
11.3 Literate Programming
Build instructions in the document The last piece of the integration between LYX
and noweb is the “build-script” chunk. Generally, the instructions for building your
program should be embedded in a chunk of its own. The noweb-specific “build-script”
above uses the notangle command to look for this chunk (called “build-script”) and
runs its contents through “sh”.
Typically, such a chunk would look something like this:
<<build-script>>=
#!/bin/sh
if [ -z "${NOWEB_SOURCE}" ]
then
NOWEB_SOURCE=myfile.nw
fi
[... code to extract files ... use NOWEB_OUTPUT_DIR here ...]
[... code to compile files ...]
@
Look in File ▷ Open Example ▷ Modules ▷ Noweb Listerrors or in File ▷ Open Example ▷
Modules ▷ Noweb2LyX which implement versions of the “listerrors” program for some
illustrations of how all of these pieces go together . Interestingly, these files show off
the language independency of the LYX literate programming support since they are
written in Python and Perl respectively.
All the Literate Programming support is configured by the Tools ▷ Preferences panel
in the “File Handling” tab. The important parts are:
the “NoWeb” format Set up via the File Formats tab, this is where the Noweb-
specific pieces are set up. The GUI Name is set to NoWeb, the file extension is
set to .nw. This tells LYX to create a file with a .nw extension in the first step
of the conversion process.
the Program format This is an empty format whose sole purpose is to be the end-
point of a conversion (which then allows us to set up a converter for it).
NoWeb->Program This performs the “tangling step”. As stated above, the Con-
verter is set to “build-script $$i $$r”, with Flags set to
“parselog=$$s/scripts/listerrors”.
131
11 LYX Features needing Extra Software
With this, whenever you are using ddd and find a point in the program that you
want to edit, you just press shift-ctrl-V (in the ddd window), and ddd will forward
this information to LYX through the LYX server and then the LYX window will show
the same file with the cursor at the same position ddd was pointing to. No more
guessing or long scrolling to locate a point in the program back from debugging !
Note however that you must enable the LYX server to get this feature working (it
is disabled by default). Sec. 10.2 explains how to do that.
Toolbar
Layouts
Icon "layout Standard"
Icon "layout Section"
Icon "layout LATEX"
Icon "layout LYX-Code"
Icon "flex.insert Chunk"
Separator
Icon "buffer-view"
Icon "buffer-typeset"
Icon "build-program"
132
11.3 Literate Programming
Separator
.
.
.
End
133
Index
L
LATEX-packages
enumitem, 61
multicol, 68
Lists
Customization, 61
Spacing, 60
135