The LYX Tutorial: by Amir Karger and The LYX Team 16th September 2002
The LYX Tutorial: by Amir Karger and The LYX Team 16th September 2002
1 Introduction 5
1.1 Welcome to LYX! . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2 What the Tutorial is and What it isn’t . . . . . . . . . . . . . . . 5
1.2.1 Getting the Most out of the Tutorial . . . . . . . . . . . . 6
1.2.2 What You Won’t Find: . . . . . . . . . . . . . . . . . . . 6
3 Writing Documents 15
3.1 Textclasses and Templates: Writing Letters . . . . . . . . . . . . 15
3.2 Templates: Writing a Letter . . . . . . . . . . . . . . . . . . . . . 16
3.3 Document Titles . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.4 Labels and Cross-References . . . . . . . . . . . . . . . . . . . . . 17
3.5 Footnotes and Margin Notes . . . . . . . . . . . . . . . . . . . . . 19
3.6 Bibliographies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.7 Table of Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4 Using Math 23
4.1 Math Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.2 Navigating an Equation . . . . . . . . . . . . . . . . . . . . . . . 24
4.3 Exponents and Indices . . . . . . . . . . . . . . . . . . . . . . . . 25
4.4 The Math Panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.4.1 Greek and symbols . . . . . . . . . . . . . . . . . . . . . . 26
4.4.2 Square roots, accents, and delimiters . . . . . . . . . . . . 26
4.4.3 Fractions . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.4.4 TEX mode: Limits, log, sin and others . . . . . . . . . . . 27
3
4 CONTENTS
4.4.5 Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.4.6 Display mode . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.5 Multi-Line Equations . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.6 More Math Stuff . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5 Miscellaneous 33
5.1 Other Major LYX Features . . . . . . . . . . . . . . . . . . . . . . 33
5.2 LYX for LATEX Users . . . . . . . . . . . . . . . . . . . . . . . . . 34
5.2.1 TEX Mode . . . . . . . . . . . . . . . . . . . . . . . . . . 34
5.2.2 Importing LATEX Documents— reLyX . . . . . . . . . . . 35
5.2.3 Converting LYX Documents to LATEX . . . . . . . . . . . . 35
5.2.4 LATEX Preamble . . . . . . . . . . . . . . . . . . . . . . . 35
5.2.5 BibTEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.2.6 Miscellaneous . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.3 Errors! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Chapter 1
Introduction
5
6 CHAPTER 1. INTRODUCTION
So, brave soul, it’s time to move onward. Time for your first document . . .
1 or,
more optimistically, “features”
2 Notefrom John Weiss: . . . well, at least in America, where we dumb everything down to
the lowest common denominator. . .
3 Besides which, if you’re using L X to begin with, you’ll probably have more than half a
Y
brain in your head.
Chapter 2
7
8 CHAPTER 2. GETTING STARTED WITH LYX
• Run LATEX to create a dvi file, with View . DVI. You may see things being
printed in the window you ran the lyx command from. These are messages
from LATEX, which you can ignore for now. LYX will run xdvi (or some
other dvi viewer), which will pop up a new window displaying what your
document will look like when printed.4
Congratulations! You’ve written and printed your first LYX document. All of
the rest is just details, which is covered in the rest of the Tutorial, the User’s
Guide, and the Extended Features.
apologize here for the inanity of this sentence, as well as anything we ask you to type in the
future.
4 You can save time by leaving xdvi running in the background. Then, you can use View .
Update . DVI and just click on the xdvi window (or unminimize it) after LATEX finishes running.
5 If you’re like many unix users, you did so long before starting to read the Tutorial.
2.1. YOUR FIRST LYX DOCUMENT 9
Undo LYX has capacity for “infinite undo”, which means you can undo every-
thing you’ve done since your current editing session started, by selecting
Edit . Undo over and over again. If you undo too much, just select Edit .
Redo to get it back.
[Currently, undo is limited to 100 steps. Undo also doesn’t work for ev-
erything, not for changes to the document layout for instance.]
Cut/Paste/Copy Use Edit . Cut, Edit . Paste, and Edit . Copy to cut, paste,
and copy. Or automatically paste selected text with the middle button.
Find/Replace Use Edit . Find & Replace for a search. In the resulting dialog
box, search with the Forwards> and <Backwards buttons, and use the
Replace button to replace a word you’ve found.6 If you like, you can
specify whether to make the search case-sensitive, or to search for only
complete words.
Character Formatting You can emphasize text (which will generally put
characters in italics), put it in bold face, or in Noun Style (usually small
caps, used for people’s names) from the toggle buttons in the Layout .
Character menu.
Toolbar There are buttons on the toolbar (just below the menus) which allow
you to do some of the more popular functions, such as Paste and Print.
If you hold the mouse above one of the buttons on the toolbar, a little
yellow note will tell you that button’s function.
Minibuffer The gray line at the very bottom of the LYX window is called
the minibuffer. This line will show all sorts of useful information. For
example, when you save, it will tell you the name of the file you just
saved. Some error messages may show up here, too. Note that you can
type in the minibuffer too. This gives you access to all sorts of interesting
functionality, including functionality which could break your document.
In other words, don’t type in the minibuffer unless you know what you’re
doing.
Of course, you haven’t yet written enough to make most of these functions
useful. As you write more, though, try undoing, pasting, etc.
dialog boxes in LYX — including the Find & Replace, Table of Contents, and Layout dialogs,
as well as the various math dialogs — are windows that may be lowered, rather than closed.
A few dialogs, like File . Open, won’t let you type anything in the main LYX window until you
actually close the dialog. Just be sure you have the right window focus when you’re trying to
type in the main LYX window or give a command in some other LYX dialog.
10 CHAPTER 2. GETTING STARTED WITH LYX
line. As many times as you hit Space, you’ll only get one space. On a blank line,
LYX won’t let you type even one space. The Tab key won’t move you forward
one tab stop; in fact there are no tab stops! There’s no ruler at the top of the
page to let you set tabs or margins, either.
Many commercial word processors are based on the WYSIWYG principle:
“What You See Is What You Get.” LYX, on the other hand, is based on the
principle that “What You See Is What You Mean.” You type what you mean,
and LYX will take care of typesetting it for you, so that the output looks nice.
A Return grammatically separates paragraphs, and a Space grammatically sep-
arates words, so there is no reason to have several of them in a row; a Tab has
no grammatical function at all, so LYX does not support it. Using LYX, you’ll
spend more of your time worrying about the content of your document, and less
time worrying about the format. See the Introduction for more information on
the WYSIWYM concept.
LYX does have (many) ways to fine-tune the formatting of your document.
After all, LYX might not typeset exactly what you mean. The User’s Guide has
information about all that. It includes HFills and vertical space — which are
more powerful and versatile than multiple spaces or blank lines — and ways to
change font sizes, character styles, and paragraph alignments by hand. The idea,
though, is that you can write your whole document, focusing on content, and
just worry about that fine-tuning at the end. With standard word processors,
you’ll be distracted by document formatting throughout the writing process.
Another special kind of whitespace is the Protected Blank, which is made by
typing C-Space (or Insert . Special Character . Protected Blank) and shows up as
a small blue “u” on the screen7 . If you put a Protected Blank between two words,
it prints out just like a regular space on paper. However, a Protected Blank tells
LATEX not to put a linebreak in between those two words. A popular usage is
when writing something like, “see Section 1,” where you want to make sure that
“Section” and “1” are on the same line8 .
2.2 Environments
Different parts of a document have different purposes; we call these parts en-
vironments. Most of a document is made up of regular text. Section (chapter,
subsection, etc.) titles let the reader know that a new topic or subtopic will be
discussed. Certain types of documents have special environments. A journal
article will have an abstract, and a title. A letter will have neither of these, but
will probably have an environment that gives the writer’s address.
Environments are a major part of the “What You See Is What You Mean”
philosophy of LYX. A given environment may require a certain font style, font
size, indenting, line spacing, and more. This problem is aggravated, because
the exact formatting for a given environment may change: one journal may use
7 If you’ve been reading this online, you probably noticed and wondered about these.
8 In the Tutorial, we also use them when describing menu names, or special characters
like. . . Protected Blanks!
2.2. ENVIRONMENTS 11
boldface, 18 point, centered type for section titles while another uses italicized,
15 point, left justified type; different languages may have different standards
for indenting; and bibliography formats can vary widely. LYX lets you avoid
learning all the different formatting styles.
The Environment box is located on the left end of the toolbar (just under the
File menu). It indicates which environment you’re currently writing in. While
you were writing your first document, it said “Standard,” which is the default
environment for text. Now you will put a number of environments in your new
document so that you can see how they work. You’ll do so with the Environment
menu, which you open by clicking on the “down arrow” icon just to the right of
the Environment box.
Hit Return again, and select Section from the Environment menu again. LYX
writes a “2” and waits for you to type a title. Type More Stuff, and you’ll see
that LYX again sets it as a section title.
It gets better. Go to the end of Section 1 again (after “my first LYX doc-
ument”) and hit Return again, and select Section from the Environment menu
again. Again, LYX writes “2” and waits for you to type a title. Type About
This Document. Section “More Stuff”, which used to be Section 2, has been
automatically renumbered to Section 3! In true WYSIWYM fashion, you just
need to identify the text that makes up the section titles, and LYX takes care
of numbering the sections and typesetting them.
Hit Return to get back to the Standard environment, and type the following
five lines:
environment can of course continue for several paragraphs. The various list environments (see
below) also don’t end when you hit Return. You can always tell what environment you’re
currently in by looking at the Environment box.
12 CHAPTER 2. GETTING STARTED WITH LYX
Subsection description
Subsections are smaller than sections.
Click on the second line and select Subsection from the Environment menu. LYX
numbers the subsection “2.1”, and typesets it in a font which is bigger than
regular text but smaller than the section title. Change the fourth line Subsection
environment as well. As you probably expected, LYX automatically numbered
the section “2.2”. If you put yet another section before Section 2, Section 2 will
be renumbered as Section 3, and the subsections will be renumbered to “3.1”
and “3.2”.
Further levels of sectioning include Subsubsection, Paragraph, and Subpara-
graph. We’ll let you play with these on your own. You may notice that paragraph
and subparagraph headings are not numbered by default, and that subpara-
graphs are indented; see the User’s Guide to change this. Chapter headings are
actually the highest level of sectioning, above Sections, but you’re only allowed
to use them in certain types (textclasses) of LYX documents (see Section 3.1).
Finally, you may want to have sections or subsections that are not num-
bered. There are environments for this as well. If you change one of your
section headings to the Section* environment (you may have to scroll down in
the Environment menu to find it), LYX will use the same font size for the head-
ing as it uses for a regular section, but it won’t number that section. There are
corresponding “starred” heading environments for Subsection and Subsubsection.
Try changing some of your sections or subsections to the starred environments,
and note how the other sections’ numbers are updated.
Exercise: Fix the section and subsection headings in example_raw.lyx.
Let’s write a list of reasons why LYX is better than other word processors.
Somewhere in your document, type:
Lyx is better than other word processors because:
and hit Return. Now select Itemize from the Environment menu. LYX writes
a “bullet” (actually, an asterisk, which will be converted to a round circle on
output) on the line. Type in your reasons:
List environments, unlike headings, do not end when you type Return. Instead,
LYX assumes you’re going on to the next item in the list. The above will
therefore result in a three-item list. If you want more than one paragraph
within one list item, one way is to use the Protected Return, which you get by
typing C-Return. In order to get out of the list, you need to reselect the Standard
environment (or just use the keybinding, M-p s).
You’ve got a beautiful itemized list. You might want to run LATEX to see how
the list looks when printed out. But what if you wanted to number the reasons?
Well, just select the whole list12 and choose Enumerate from the Environment
menu. Pow! As we mentioned, if you add or delete a list item, LYX will fix the
numbering.
While the list is still selected, you can change to the other two list envi-
ronments, Description and List, in order to see what they look like. For those
two environments, each list item is made up of a term, which is the item’s first
word, followed by a definition, which is the rest of the paragraph (until you hit
Return.) The term is either typeset in boldface (Description) or separated by a
“Tab”13 (List) from the rest of the paragraph. If you want to have more than
one word in the definition, then separate the words with Protected Blanks.
Exercise: Typeset the list in example_raw.lyx
You can nest lists within each other in all sorts of interesting ways. An
obvious example would be writing outlines. Numbered and bulleted lists will
have different numbering and bulleting schemes for sublists. See the User’s
Guide for details on the different sorts of lists, as well as examples which use a
lot of nesting.
you’re allowed to use multiple spaces to allow code indenting. You can even
write poetry14 using the Verse style, using Return to separate stanzas, and C-
Return to separate lines within a stanza. See the User’s Guide for more complete
descriptions of all of the available LYX environments.
Exercise: Correctly typeset the Quote, LYX-Code, and Verse in
example_raw.lyx
14 . . . assuming you’re creative enough to come up with poetry in the first place.
Chapter 3
Writing Documents
The previous chapter hopefully allowed you to get used to writing in LYX. It
introduced you to the basic editing operations in LYX, as well as the powerful
method of writing with environments. Most people who use LYX, though, will
want to write documents: papers, articles, books, manuals, or letters. This
chapter is meant to take you from simply writing text with LYX to writing a
complete document. It will introduce you to textclasses, which allow you to
write different sorts of documents. It will then describe many of the additions
that turn text into a document, such as titles, footnotes, cross references, bibli-
ographies, and tables of contents.
15
16 CHAPTER 3. WRITING DOCUMENTS
Font sizes, one- or two-column printing, and page headings are just some
of the ways journals’ typesettings differ from one another. As the Computer
Age continues to mature, journals have begun accepting electronic submissions,
creating LATEX “style files” so that authors can submit correctly typeset articles.
LYX is set up to support this as well. For example, LYX supports typesetting
(and extra environments) for the American Mathematics Society journals using
the Article (AMS) textclass.
Here’s a very quick reference to some of the textclasses. See the Special Doc-
ument Classes section of the Extended Features manual for many more details.
Name Notes
article one-sided, no chapters
article (AMS) layout & environments for American Math Society
report longer than article, two-sided
book report + front and back matter
slides transparencies (also including FoilTEX)
letter lots of extra environments for address, signature. . .
A template is just a regular LYX file. This means you can fill in your address
and signature and save the file as a new template. From now on, any time you
want to write a letter, you can use the new template to save time. We probably
don’t have to suggest an actual “exercise” here; just write a letter to someone3 !
Templates can be a huge time-saver, and we urge you to use them whenever
possible. In addition, they can help a person learn how to use some of the
fancier textclasses. Finally, they may be useful for a person who is configuring
LYX for a bunch of less computer-aware users. When they’re first learning LYX,
it will be much less intimidating if they have a letter template customized for
their company, for example.
ment — for example, if you erase the whole My Address field so that you can replace it with
your own — and then you move the cursor without writing any text, the environment may
disappear. This is because most environments cannot exist without any text in them. Just
reselect the environment from the Environment menu to get it back.
4 You should not be using the letter any more, since the Letter textclass doesn’t allow titles.
18 CHAPTER 3. WRITING DOCUMENTS
descriptive label that won’t get confused with other labels we might add.5 When
you click on OK, the label name will be placed in a box next to the section title.
By the way, you could have put the label right anywhere within the section as
well; section references will refer to the last section or subsection whose heading
comes before the label. However, putting it on the same line as the section title
(or, perhaps, on the first line of the section’s text) ensures that page references
will reference the beginning of the section.
So far you haven’t done anything — the dvi file will look exactly the same,
since labels don’t show up in the printed document. However, now that you’ve
added a label, you can refer to that label with cross-references. We’ll do that
next.
Now — with the cursor after the word“section” — choose Insert . Cross Reference.
The Reference dialog pops up. It shows a list of the possible labels you can
reference. At the moment, there should be only one, “sec:aboutdocument”.
Select it (it may be selected by default), then set the Reference type to Standard
(the default), and click Apply. Now put the cursor after the word “page”, and
change the Reference type to Page Number, then click Apply. (To be really
correct, you should put a Protected Blank in between the word “Section” and
the reference. Same for the page reference.)
LYX puts the references in a box right where the cursor was. In the printed
document, this reference marker will be replaced with either the page or section
number (depending on what you selected in the Insert Reference dialog). Con-
veniently, a cross-reference acts a hyperlink when you’re editing a document in
LYX; clicking on it will pop up the Reference dialog, clicking Goto reference will
move the cursor to the referenced label, and C-< will then move the cursor back
to the reference. Use View . Update . DVI, and you’ll see that on the last page
we refer to “Section 2” and “Page 1” (or whatever page Section 2’s title is on).
If you want some more practice with labels, then try putting a new label,
“sec:myfirstlabel”, where your first cross-reference was, and refer to that label
from elsewhere in the document. If you’ll be inserting cross-references often (if,
for example, you’re writing a journal article), it may be convenient to leave the
Insert Reference window open.
If you want to make sure that the cross-referencing gets the pages right even
for larger documents, Copy a couple pages of text from the User’s Guide to the
clipboard, and Paste the stolen text into your document6 .
Exercise: Fix the references in example_raw.lyx
Now click on the word “foot.” The footnote line disappears, leaving the word
“foot”, superscripted in red, showing where the footnote marker will be in the
printed text; this is called “folding” the footnote. You can unfold the footnote
at any time — and re-edit its text, if you want — by clicking on the red “foot”
marker.
You may wonder why the footnote marker is a word instead of a number.
The answer is that LYX worries about the footnote numbering for you in the
printed text. You can see this yourself by looking at the dvi file (or printout).
If you add other footnotes, LYX will renumber the footnotes. Since LYX (well,
LATEX, actually) takes care of the footnote numbering, there’s really no need to
put the numbers in the LYX file.
A footnote can be cut and pasted like normal text. Go ahead; try it! All you
need to do is select the footnote marker8 and Cut and Paste it. In addition, you
can change regular text to a footnote, by selecting it and hitting the Insert Foot-
note button; change a footnote to regular text by clicking the Insert Footnote
button when the cursor is in a footnote.
6 By the way, copying a chapter title may cause an error, because chapters aren’t allowed
in the article class. If this happens, just delete the chapter title. If you want to know why
this happens, see Section 3.1.
7 The button shows an arrow pointing to red text, which is just below some black text.
8 It may be easier to select it using the keyboard. You might accidentally open the footnote
Margin notes can be added using the Insert Marginal Note button9 or Insert .
Marginal Note. Margin notes are like footnotes, except that:
Change your LYX footnote back to text, then select and change it to a margin
note. Run LATEX again to see what the margin note looks like.
Exercise: Fix the footnote in example_raw.lyx
3.6 Bibliographies
Bibliographies (at least in the exact sciences) are similar to cross references10 .
The bibliography contains a list of references at the end of the document, and
they can be referenced from within the document. Like section titles, LYX and
LATEX make your job easier by automatically numbering the bibliography items
and changing citations when the items’ numbers change.
Go to the end of the document and switch to the Bibliography environment.
Now, each paragraph you type will be a reference. Type The Lyx Tutorial,
by the LyX DocTeam as your first reference. Note that LYX automatically puts
a number in a box before each reference. Click on the boxed reference number,
and a Bibliography item dialog box appears. You use the first field, the Key, to
refer to this reference within the LYX document. By default, it is a number.
Change the Key field to “lyxtutorial” to make it easy to remember.
Now pick somewhere in your document that you would like to insert a ref-
erence. Do so with Insert . Citation Reference. A Citation dialog appears. The
right panel in this dialog lists all the bibliography entries, and this field allows
you to choose which bibliography item you want to cite11 . Select “lyxtutorial”
(right now, that’s the only item in the bibliography), then use the left arrow in
the center to insert it in the Inset keys box. (You can have multiple citations
in the same place by transferring a number of keys this way.) Now run LATEX,
and you’ll see that the citation appears in brackets in the text, referring to the
bibliography at the end of the document.
How are the other fields used? The After field in the Citation dialog will put
a remark (such as a reference to a page or chapter within the referenced book
or article) in the brackets after the reference. If you want the references to have
labels instead of numbers in the printed output (for example, some journals
would use “[Smi95]” to refer to a paper written by Smith in 1995), use the Label
9 The button shows an arrow pointing to red text next to (i.e., in the margin of) black text,
field in the Bibliography item dialog. As usual, you can see the User’s Guide for
details.
Exercise: Fix the bibliography and citation in example_raw.lyx
12 Don’t frustrate yourself trying to click or backspace before the section number. It won’t
work. You’re not allowed to edit the section number anyway, since LYX takes care of section
numbering.
13 The menu command will work even if you don’t have a table of contents inset in your
document.
22 CHAPTER 3. WRITING DOCUMENTS
Chapter 4
Using Math
Now, that equation doesn’t look very good, even in the dvi file; there’s no
space between the letters and the equals sign, and you’d like to write an actual
superscript for the “2”. That bad typesetting happened because we didn’t tell
LYX that we were writing a mathematical expression, so it typeset the equation
like regular old text.
Math is written in Mathed, otherwise known as math mode. In order to
enter math mode, just click the toolbar button with a+b c written on it in blue.
LYX will open a little blue square, with a purple rectangle around it. The blue
square is an insertion point, telling you that Mathed is waiting for you to insert
something, and the rectangle indicates that you are in Mathed. LYX has placed
the cursor in the blue square, so just type E=mc^2 again. The expression is
typed in blue, and the blue square disappears as soon as the insertion point is
1L
YX can’t check if the math you’re writing is actually correct. Sorry.
23
24 CHAPTER 4. USING MATH
not empty. Now type Esc to leave Mathed (Note: clicking on the math button
again will not get you out of Mathed). The purple rectangle disappears, leaving
the cursor to the right of the expression, and now if you type something, it will
be regular text.
Run LATEX and look at the dvi file. Notice that the expression was typeset
nicely, with spaces between the letters and the equals sign, and a superscript
“2”. Letters in math mode are assumed to be variables, and come out in italics.
Numbers are just numbers.
Mathed is another example of the WYSIWYM philosophy. In LATEX, you
write a mathematical expression using text and commands like \sqrt; this can
be frustrating, because you can’t see what an expression looks like until you
LATEX the file, and may have to spend time to find missing brackets or other
“bugs”. On the other hand, LYX doesn’t attempt to get the expression to look
perfect (WYSIWYG), but it gives you an extremely good idea of what the
expression will look like. LATEX then takes care of the professional typesetting.
99% of the time, you won’t have to make any changes to the font sizes or spacing
that LATEX outputs. This way (sorry to be so repetitive) you can focus on the
content of your mathematical expressions, not their format.
Space will move the cursor past that structure, but will stay within Mathed.
So, if the cursor is anywhere in the superscript, typing Space will move the
cursor down to the regular level and just after the superscript. This means you
can type E = mc1+x − 2 without using the mouse or the arrow keys, a method
you’ll probably prefer once you’re more experienced. Just be careful not to type
Space between the one and the plus sign, or you will exit the superscript. In
places where these actions don’t make sense (say, between the “m” and the “c”),
Space will do nothing2 .
Note that if you type your expression and exit with Esc, there will be no
space after the expression. This is fine if you’re typing a period or comma, but
if you want to type a word after the formula, you need to explicitly type Space
after you exit Mathed. As a shortcut, though, if you are at the very end of
a Mathed expression, then pressing Space will exit Mathed and print a space
after the expression. That way you can write “f = ma is my favorite equation”
instead of “f = mais my favorite equation.”
2 Space and Tab are not used for making extra space between parts of an equation. That
spacing is a typesetting issue, which means that you should let LYX (LATEX) take care of it
(see Sec. 2.1.3). If you’re not entirely satisfied, there are ways to fine-tune spacing, for which
you can see the User’s Guide — but don’t bother with fine-tuning until you’re done putting
all the content into your document.
26 CHAPTER 4. USING MATH
the Delimiter window. However, those parentheses will be the same size as
regular text, which will look bad if you have a big fraction or matrix inside the
parentheses. Using the Delimiter window will guarantee that the delimiters are
sized based on what’s inside them.
You can also put delimiters or a square root sign or a decoration on already
existing text. Select the portion of the formula that you want to adjust, and
then click on the button you want from the Math Panel. Try using this to change
→
−
Newton’s second law from scalar to vector form (f = ma to f = m− →a ). Once
you’ve learned about matrices, this is how you’ll put parentheses or brackets
around them.
4.4.3 Fractions
Fractions are very simple in Mathed. Just click on the fraction button in the
Math Panel, which shows a fraction with blue squares in the numerator and
the denominator. LYX writes two insertion points in a fraction. As you would
expect, you can use arrow keys or the mouse to move around a fraction. Click
on the top square and type “1”. Now hit Down and type “2”. You’ve made
a fraction! Of course you can type anything within each of the two boxes:
variables with exponents, square roots, other fractions, whatever.
Exercise: Put equation 2 of example_raw.lyx into math mode.
4.4.5 Matrices
Click on the matrix button in the Math Panel. The Matrix dialog box has two
sliding bars which allow you to choose how many rows and columns you want
in your matrix. Choose 2 rows and 3 columns and hit Apply or OK. LYX prints
28 CHAPTER 4. USING MATH
6 insertion points in a 2 × 3 matrix. As usual, you can put any sort of Mathed
expression (a square root, another matrix, etc.) in each insertion point. You
can also leave some of the insertion points empty if you want.
Tab can be used to move horizontally between the columns of a matrix.
Alternatively, you can use the arrow keys to move around - hitting Right at the
end of one box will move to the next box, Down will move to the next row, etc.
If you suddenly need more rows or columns, use Edit . Math . Add Row and
Add Column. They add a row or column just after the current position. Overdid
it? Use Delete Row and Delete Column from the same menu.
See the User’s Guide for information on how to change the horizontal align-
ment of each column, and how to change the vertical position of the whole
matrix. Note that if you want to write a table containing text, you should use
LYX’ wonderful table support, rather than trying to write text in a matrix.
• Subscripts and superscripts for limits and sums (but not integrals) are
written under rather than next to the symbols
• Text is centered
Other than these differences, though, displayed expressions and inline expres-
sions are very similar.
One final note about the way displayed equations are typeset: be careful
about whether you’re putting your equation into a new paragraph or not. If your
equation is in the middle of a sentence or paragraph, then don’t press Return.
Doing so will cause the text after the equation to start a new paragraph. That
text will therefore be indented, which is probably not what you want.
Exercise: Put the various equations in example_raw.lyx into display mode,
and see how they’re typeset differently.
4.5. MULTI-LINE EQUATIONS 29
Exercise: Using various tools you’ve learned in this section, you should be
able to write an equation like4 :
log8 x x>0
f (x) = 0 q x=0
P5 αi + − 1
x<0
i=1 x
x=y+y+y+y+y
= 5y
This doesn’t look good at all! If you write two or more equations in succes-
sion, they look much better if their equals signs are aligned; this is especially
true if the second equation has no left side. LYX allows you to write multi-line
equations with some control over the alignment.
x = y+y+y+y+y
= 5y
This looks much better! The equals signs are aligned, and there is less
vertical space between the equations.
In order to start a multi-line equation, open a displayed Mathed expression
and type C-Return, or choose Insert . Math . Eqnarray environment. LYX will print
a line with three empty insertion points. This is a multi-line equation with just
one line. Disappointed? Use Edit . Math . Add Row or type C-Return again to
get two such lines. Try to reproduce the above multi-line equation. Note that
it’s legal to leave one or more insertion points empty in a multi-line equation.
This can be useful either for examples like the one above, or for splitting very
long equations, like5 :
x = a+b+c+d
+e + f + g
LYX will line up the second (central) field of each line, so usually you’ll put
equals signs or other relational operators in that field; in fact, though, you can
4 After you’ve done it the hard way, why don’t you give Insert . Math . Cases environment a
try?
5 Note that the spacing after the first plus in the second row is too short. This is one of
the rare cases where LATEX fails and you have to tweak the spacing yourself. Read more in
the User’s Guide.
30 CHAPTER 4. USING MATH
put whatever you want in there. But don’t use a multi-line equation to print
an array; use a matrix for that (see Sec. 4.4.5).
If you want an even longer set of equations, use C-Return to get a new line
with three empty insertion points. If you aren’t at the end of the line when you
do it, the remaining stuff on the current line will be carried to the new line. If
you hit C-Return when you’ve already written a (one-line) equation, the whole
equation will be in the first field. Place the cursor before the equals sign and hit
C-Tab to move it to the second field. Then move past the equals sign, and C-Tab
again to move the right side of the equation to the third field. Try changing
your E = mc2 equation to
E = mc2
= mc × c
If you’ve written too many lines, use Edit . Math . Delete Row. Alternatively,
put the cursor at the end of a line and use C-k to delete the following line.
It will delete the linefeed and concatenate (all three insertion points of) the
next line onto the end of the current one. If the following line is empty, it will
effectively just delete it. Using C-k when you’re not at the end of the line will
erase everything until the end of the line. In effect C-k is not Mathed specific,
it simply erases until the end of the line in any mode and in any situation.
A final note: there is much more to multi-line equations. In particular we
failed to explain all these mysterious entries in the Insert . Math menu that start
with AMS! The American Mathematical Society, being displeased with certain
issues about regular multi-line equations have created their own family of LATEX
constructs for doing the same thing. Why would you want to use them? Read
about all this in the User’s Guide.
Miscellaneous
• LYX has WYSIWYM support for tables. Use the Insert . Tabular Material
to get a table. (We chose to use the LATEX naming convention—tabular vs
table—to distinguish between the tabular material itself from a floating
table, which include the tabular material, a caption, etc.) Click on the
table with the right button to get a Tabular Layout dialog box which allows
extensive table editing.
• Version control is supported, using RCS (man rcsintro for more info).
• LYX is heavily configurable. Everything from how the LYX window looks
to how the output comes out can be configured in a number of ways. Much
configuration is done through Edit . Preferences. For more information on
this, check out Help . Customization.
33
34 CHAPTER 5. MISCELLANEOUS
supported. You can write documents in other languages, but you can also
configure LYX to show its menus and error messages in other languages.
• The LYX menus feature keybindings. This means that you can do File .
Open by typing M-F followed by O or by using the binding which is shown
next to it in the menu (C-O by default). Keybindings are also configurable.
For information on this, check out Help . Customization.
As a special case, if you type a brace in Mathed’s TEX mode, then Mathed
will type the beginning and ending braces in red, then take you out of TEX
mode and place the cursor between the braces. This makes it more convenient
to type commands that Mathed doesn’t know which take an argument.
LYX can’t do absolutely everything that LATEX can do (yet?). Some fancy
functions are not supported at all, while some work but aren’t WYSIWYM. TEX
mode allows users to get the full flexibility of LATEX, while having all the con-
venient features of LYX, like WYSIWYM math, tables, and editing. LYX could
never support every LATEX package. However, by typing \usepackage{foo}
in the preamble (see Section 5.2.4.2), you can use any package you want —
although you won’t have WYSIWYM support for that package’s features.
5.2.5 BibTEX
LYX has support for BibTEX, which allows you to build databases of bibliograph-
ical references to be used in multiple documents. Select Insert . Lists & TOC .
BibTEX Reference to include a bib file. Click on the resulting “BibTEX Gener-
ated References” button, and you will get a BibTEX dialog. In the Database field,
type what you would type inside the braces of a \bibliography{} command3 .
Similarly, in the Style field, type what you would type inside the braces of a
\bibliographystyle{} command.
After you’ve done this, you can use citations from any bibliographies you’re
including with Insert . Citation Reference (see Section 3.6). LYX will take care of
running BibTEX. The combobox in the Citation dialog will show a list of all the
references in your bib file.
5.2.6 Miscellaneous
See the Insert . Special Character menu for other special characters, including
ellipsis, forced linebreak, and hyphenation point.
5.3 Errors!
Sometimes when you LATEX a document, there will be errors, things that LYX
or LATEX can’t understand. When this happens, LYX will create an error box
(a box with the word “error” in it). Clicking on this box will pop up a window
showing what the error was. If it was something you did wrong with LYX, it
will be a LYX error. These should be very rare. If LATEX had a problem (most
often, this happens with things you typed in TEX mode) then LYX will just
quote LATEX’s error message.
3 Like in regular L
AT X, multiple bibliographies should be separated by commas, with no
E
whitespace.