\batchmode
\makeatletter
\def\input@path{{/home/jay/tut//}}
\makeatother
\documentclass[english]{book}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\pagestyle{headings}
\setcounter{secnumdepth}{3}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\providecommand{\LyX}{L\kern-.1667em\lower.25em\hbox{Y}\kern-.125emX\@}
\newcommand{\noun}[1]{\textsc{#1}}
\newcommand{\lyxarrow}{\leavevmode\,$\triangleright$\,\allowbreak}
%% Bold symbol macro for standard LaTeX users
\newcommand{\boldsymbol}[1]{\mbox{\boldmath $#1$}}

%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
 \newenvironment{lyxcode}
   {\begin{list}{}{
     \setlength{\rightmargin}{\leftmargin}
     \setlength{\listparindent}{0pt}% needed for AMS classes
     \raggedright
     \setlength{\itemsep}{0pt}
     \setlength{\parsep}{0pt}
     \normalfont\ttfamily}%
    \item[]}
   {\end{list}}

\usepackage{babel}
\makeatother
\begin{document}

\title{The \LyX{} Tutorial}


\author{by the \LyX{} Team%
\footnote{Principal maintainer of this file is \noun{Amir Karger}. If you
have comments or error corrections, please send them to the \LyX{}
Documentation mailing list, <lyx-docs@lists.lyx.org>.%
}}

\maketitle
\tableofcontents{}


\chapter{Introduction}


\section{Welcome to \LyX{}!}

This file is designed for all of you who have never heard of \LaTeX{},
or don't know it very well. Now, don't panic - you won't need to learn
\LaTeX{} to use \LyX{}. That is, after all, the whole point of \LyX{}:
to provide an almost-WYSIWYG interface to \LaTeX{}. There are some
things you will need to learn, however, in order to use \LyX{} effectively.

Some of you probably found your way to this document because you tried
to put two spaces after a {}``.'' or tried to put 3 blank lines
between paragraphs. After much frustration, you found you couldn't.
In fact, you'll find that most of the little tricks you're accustomed
to using in other word processors just won't work in \LyX{}. That's
because most word processors you've used before allow you to manually
enter all spacings, font changes, and so on. So you end up not only
writing a document but typesetting it, too. \LyX{} does the typesetting
for you, in a consistent fashion, letting you focus on the important
things, like the content of your writing.

So, bear with us and read on. Reading this tutorial is definitely
worth the time.


\section{What the Tutorial \emph{is} and What it \emph{isn't}}

Before we get started with this section, we want to make a quick note
of something. The \emph{Tutorial} uses the notation outlined in the
\emph{Introduction}\@. If you came to this manual first, go read
the \emph{Introduction}\@. Yes, we mean now.

Now that you know which fonts mean what, we want to talk a bit about
what this \emph{Tutorial} is for.


\subsection{Getting the Most out of the Tutorial}

This tutorial consists of examples and exercises. To get the most
out of this document, you should read through the document, typing
all the silly little things we're telling you to type and trying out
all of the exercises to see if you get them right. For convenience,
you might want to print out the PostScript® version of this document.

If you are familiar with \LaTeX{}, you'll probably be able to read
the \emph{Tutorial} somewhat faster, since many \LyX{} ideas are just
\LaTeX{} ideas in disguise. However, \LyX{} does have idiosyncrasies%
\footnote{or, more optimistically, {}``features''%
} you'll want to learn about. Even if you don't feel like reading the
rest of the \emph{Tutorial}, you should definitely check out Section~\ref{sec:latexusers},
which is specifically written for experienced \LaTeX{} users.


\subsection{What You \emph{Won't} Find:}

\begin{itemize}
\item Detailed explanations of all of \LyX{}'s features.


What, you want the \emph{User's Guide} twice?

Seriously, though, we're here to get you up and running so that all
you need is the \emph{User's Guide}. If we tried to duplicate all
of the information about all of \LyX{}'s features in here, the \emph{Tutorial}
would be redundant, too long, and forever out of date. All we do here
is introduce things; imagine there is a {}``see the \emph{User's
Guide}'' at the end of every section.

\item Detailed explanations of \LaTeX{}.


Unnecessary. If you're really curious about learning some of the neat
tricks you can do with \LaTeX{}, you can always go get a \LaTeX{}
book. There are several good ones on the market. No need to reinvent
the wheel, after all\ldots{}

\end{itemize}
So, brave soul, it's time to move onwards. Time for your first document
\ldots{}


\chapter{Getting Started with \LyX{}}


\section{Your First \LyX{} Document }

\label{sec:first-doc-ex} OK\@. You're ready to start writing. Before
you do, though, there are a few things we need to mention, which will
hopefully make the \emph{Tutorial} more instructive, useful, and fun. 

Because there's lots of information that we won't be giving you, the
\emph{first} thing that you need to do is find the other help files.
Luckily, this is very simple. Start up \LyX{}. Choose the \emph{User's
Guide} from the \textsf{\underbar{H}}\textsf{elp} menu. You may want
to load the \emph{Tutorial} as well (if you're not reading it on screen
already). This way, you can read them while you're writing your own
file%
\footnote{They can also serve as good examples of how to use the many features
of \LyX{}.%
}. Note that once you've got more than one document open, you can use
the \textsf{\underbar{D}}\textsf{ocuments} menu to switch between
them. The \emph{Tutorial} will not cover in detail subjects which
are described in the other \LyX{} manuals. This may make life a bit
harder for you at the beginning, but it will keep the \emph{Tutorial}
short. It will also get you in the habit of using the other manuals,
which --- in the long run --- will save you a lot of time.

In this \emph{Tutorial}, we're going to assume that you have a fully
working version of \LyX{}, as well as \LaTeX{}, \texttt{xdvi} or some
other dvi viewer, \texttt{dvips} or some other way of converting \texttt{dvi}
documents to PostScript® documents, and a working printer. This is
a lot to assume. If any of this is not true, you (or a friendly system
administrator) will need to set up your system. You can find information
on setup in other manuals.

Finally, we've written a file to let you practice your \LyX{} skills
on. It's called \texttt{example\_raw.lyx}. Imagine that it was typed
by someone who didn't know about any of \LyX{}'s great features. As
you learn new \LyX{} functions, we'll suggest that you fix those parts
of \texttt{example\_raw.lyx}. It also contains {}``subtle'' hints
about how to fix things%
\footnote{The hints are located in yellow {}``Notes''. Access the text in
a note by clicking on it.%
}. If you want to cheat (or check what you've done), there's also a
file called \texttt{example\_lyxified.lyx} which contains the same
text as written and typeset by a \LyX{} master.

The example files can be found in the \texttt{examples/} directory,
which you can get to by selecting \textsf{\underbar{F}}\textsf{ile\lyxarrow{}}\textsf{\underbar{O}}\textsf{pen}
and then clicking on the \textsf{\underbar{E}}\textsf{xamples} button.
Open the raw document, and use \textsf{\underbar{F}}\textsf{ile\lyxarrow{}Save}
\textsf{\underbar{A}}\textsf{s} to save a copy in your own directory
for you to work on. As you fix parts of the raw document, check to
see how those changes affect the dvi output.

By the way, the \texttt{examples/} directory contains lots of other
examples files. They will show you how to do various fancy things
with \LyX{}. They are especially useful to display things that (due
to length or other reasons) won't fit in the documentation. After
you read the \emph{Tutorial}, or when you're confused about how to
do something fancy in \LyX{}, take a look at these files.


\subsection{Typing, Viewing, and Printing}

\begin{itemize}
\item Open a new file with \textsf{\underbar{F}}\textsf{ile\lyxarrow{}}\textsf{\underbar{N}}\textsf{ew}
\item Type a sentence like: \texttt{This is my first LyX document!}
\item Save your document with \textsf{\underbar{F}}\textsf{ile\lyxarrow{}Save~}\textsf{\underbar{A}}\textsf{s\@.}
\item Run \LaTeX{} to create a \texttt{dvi} file, with \textsf{\underbar{V}}\textsf{iew\lyxarrow{}}\textsf{\underbar{D}}\textsf{VI}\@.
You may see things being printed in the window you ran the \texttt{lyx}
command from. These are messages from \LaTeX{}, which you can ignore
for now. \LyX{} will run \texttt{xdvi} (or some other \texttt{dvi}
viewer), which will pop up a new window displaying what your document
will look like when printed.%
\footnote{You can save time by leaving \texttt{xdvi} running in the background.
Then, you can use \textsf{\underbar{V}}\textsf{iew\lyxarrow{}}\textsf{\underbar{U}}\textsf{pdate\lyxarrow{}}\textsf{\underbar{D}}\textsf{VI}
and just click on the \texttt{xdvi} window (or unminimize it) after
\LaTeX{} finishes running.%
}
\item Print by using \textsf{\underbar{F}}\textsf{ile\lyxarrow{}}\textsf{\underbar{P}}\textsf{rint}
and hitting \textsf{OK\@.}
\end{itemize}
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
\emph{Tutorial}, the \emph{User's Guide}, and the \emph{Extended}
\emph{Features}.


\subsection{Simple Operations}

\LyX{} can of course do most of the things you're used to doing with
a word processor. It will word-wrap and indent paragraphs automatically.
Here's a quick description of how to do some simple actions.

\begin{description}
\item [Undo]\LyX{} has multiple levels of undo, which means you can undo
everything you've done since your current editing session started,
by selecting \textsf{\underbar{E}}\textsf{dit\lyxarrow{}}\textsf{\underbar{U}}\textsf{ndo}
over and over again. If you undo too much, just select \textsf{\underbar{E}}\textsf{dit\lyxarrow{}}\textsf{\underbar{R}}\textsf{edo}
to get it back. 


Currently, undo is limited to 100 steps. Undo also doesn't work for
\emph{everything}; for instance, changes to the document layout. Each
of these is really a \LyX{} bug.

\item [Cut/Paste/Copy]Use \textsf{\underbar{E}}\textsf{dit\lyxarrow{}}\textsf{\underbar{C}}\textsf{ut},
\textsf{\underbar{E}}\textsf{dit\lyxarrow{}C}\textsf{\underbar{o}}\textsf{py},
and \textsf{\underbar{E}}\textsf{dit\lyxarrow{}}\textsf{\underbar{P}}\textsf{aste}
to cut, copy, and paste. Or automatically paste selected text (including
selections from other programs) with the \emph{middle mouse button}.
\item [Find/Replace]Use \textsf{\underbar{E}}\textsf{dit\lyxarrow{}}\textsf{\underbar{F}}\textsf{ind~\&~Replace}
for a search. In the dialog, search with the \textsf{\underbar{F}}\textsf{ind}
button, and use the \textsf{\underbar{R}}\textsf{eplace} button to
replace a word you've found%
\footnote{Close the window when you're done. Or leave it open if you find it
more convenient. Most dialog boxes in \LyX{} --- including the \textsf{Find~\&~Replace},
\textsf{Table~of~Contents}, and \textsf{Layout} dialogs, as well
as the various math dialogs can operate like this. A few dialogs,
like \textsf{\underbar{F}}\textsf{ile\lyxarrow{}}\textsf{\underbar{O}}\textsf{pen},
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.%
}. If you like, you can specify whether to make the search case-sensitive,
or to search for only complete words; you can also search backwards
through the document.
\item [Character~Formatting]You can \emph{emphasize} text (which will
generally put characters in italics), put it in \textbf{bold face},
or in \noun{Noun Style} (usually small caps, used for people's names)
from the toggle buttons in the \textsf{\underbar{L}}\textsf{ayout\lyxarrow{}}\textsf{\underbar{C}}\textsf{haracter}
menu.
\item [Toolbar]There are buttons on the toolbar (just below the menus)
which allow you to do some of the more popular functions, such as
\textsf{Paste} and \textsf{Print}.
\end{description}
Of course, you haven't yet written enough to make most of these functions
useful. As you write more, though, try undoing, pasting, etc.


\subsection{WYSIWYM: Whitespace in \LyX{}}

\label{sec:whitespace}One of the hardest things for new users to
get used to is the way that \LyX{} handles whitespace. As many times
as you hit \textsf{Return}, you'll only get one blank line. As many
times as you hit \textsf{Space}, you'll only get one space. On a blank
line, \LyX{} won't let you type even one space. The \textsf{Tab} key
won't move you forward one tab stop; in fact there \emph{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 \emph{Mean}.''
You type what you mean, and \LyX{} will take care of typesetting it
for you, so that the output looks nice. A \textsf{Return} grammatically
separates paragraphs, and a \textsf{Space} grammatically separates
words, so there is no reason to have several of them in a row; a \textsf{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 \emph{content}
of your document, and less time worrying about the \emph{format.}
See the \emph{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 \emph{exactly} what you mean.
The \emph{User's Guide} has information about all that. It includes
\textsf{HFill}s 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.


\section{Environments}

Different parts of a document have different purposes; we call these
parts \emph{environments}. 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 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 \textsf{Environment} box is located on the left end of the toolbar
(just under the \textsf{\underbar{F}}\textsf{ile} 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 \textsf{Environment} menu, which you open by clicking on
the {}``down arrow'' icon just to the right of the \textsf{Environment}
box.


\subsection{Sections and Subsections}

Type the word \texttt{Introduction} on the first line of your \LyX{}
file, and select \textsf{Section} from the \textsf{Environment} menu%
\footnote{You don't have to \emph{select} the line. If nothing is selected,
\LyX{} changes the paragraph you are currently in to the selected
environment. Alternatively, you can change several paragraphs to a
different environment by selecting them before picking an environment.%
}. Be sure to use \textsf{Section} and \emph{not} \textsf{Section{*}},
which will be covered below. \LyX{} numbers the section {}``1''
and typesets the section heading (title) in a larger font. Now hit
\textsf{Return}\@. Note that the \textsf{Environment} box changes
from {}``Section'' back to {}``Standard''. Section headings, like
most environments, are assumed to end when you type \textsf{Return}\@.
Type the document introduction: 

\begin{lyxcode}
This~is~an~introduction~to~my~first~LyX~document.
\end{lyxcode}
Hit \textsf{Return} again, and select \textsf{Section} from the \textsf{Environment}
menu again. \LyX{} writes a {}``2'' and waits for you to type a
title. Type \texttt{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{} document'') and hit \textsf{Return} again, and select \textsf{Section}
from the \textsf{Environment} menu again. Again, \LyX{} writes {}``2''
and waits for you to type a title. Type \texttt{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 \textsf{Return} to get back to the \textsf{Standard} environment,
and type the following five lines:

\begin{lyxcode}
Sections~and~subsections~are~described~below.

Section~Description

Sections~are~bigger~than~subsections.

Subsection~description

Subsections~are~smaller~than~sections.
\end{lyxcode}
Click on the second line and select \textsf{Subsection} from the \textsf{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 \textsf{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 \textsf{Subsubsection}, \textsf{Paragraph},
and \textsf{Subparagraph}. 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 subparagraphs are indented; see the \emph{User's
Guide} to change this. \textsf{Chapter} headings are actually the
highest level of sectioning, above \textsf{Section}s, but you're only
allowed to use them in certain types (text classes) of \LyX{} documents
(see Section~\ref{sec:textclasses}). 

Finally, you may want to have sections or subsections that are not
numbered. There are environments for this as well. If you change one
of your section headings to the \textsf{Section{*}} environment (you
may have to scroll down in the \textsf{Environment} menu to find it),
\LyX{} will use the same font size for the heading as it uses for
a regular section, but it won't number that section. There are corresponding
{}``starred'' heading environments for \textsf{Subsection} and \textsf{Subsubsection}.
Try changing some of your sections or subsections to the starred environments,
and note how the other sections' numbers are updated.

\textbf{Exercise}: Fix the section and subsection headings in \texttt{example\_raw.lyx}. 


\subsection{Lists and sublists}

\LyX{} has several different environments for typesetting lists. The
various list environments free you from hitting \textsf{Tab} a million
times when writing an outline, or from renumbering a whole list when
you want to add a point in the middle of the list, and lets you concentrate
on the list content.%
\footnote{Yes, we're overemphasizing this point throughout the \emph{Tutorial}.
But it \emph{is} the main philosophy of \LyX{}, so please forgive
us.%
} Different types of documents logically require different list environments:

\begin{itemize}
\item A slide presentation might use the \textsf{Itemize} environment's
bulleted lists to describe different points. 
\item An outline would use the \textsf{Enumerate} environment's numbered
lists (and lettered sublists). 
\item A document describing several software packages could use the \textsf{Description}
environment, where each item in the list begins with a bold-faced
word. 
\item The \textsf{List} environment --- not found in \LaTeX{} --- is a slightly
different form of \textsf{Description}.
\end{itemize}
Let's write a list of reasons why \LyX{} is better than other word
processors. Somewhere in your document, type:

\texttt{Lyx is better than other word processors because: }

and hit \textsf{Return}. Now select \textsf{Itemize} from the \textsf{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: 

\begin{lyxcode}
Typesetting~is~done~for~you.

Math~is~WYSIWYG

Lists~are~very~easy~to~create!
\end{lyxcode}
List environments, unlike headings, do not end when you type \textsf{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 \emph{item}, one way is to
use the \textsf{Protected~Break}, which you get by typing \textsf{C-Return}.
In order to get out of the list, you need to reselect the \textsf{Standard}
environment (or just use the keybinding, \textsf{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 list%
\footnote{\LyX{} won't let you select the first bullet unless you also select
the paragraph \emph{before} the list, which you probably don't want
to do. Similarly, you can't select the actual number in a numbered
section title. Don't worry about it.%
} and choose \textsf{Enumerate} from the \textsf{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 environments, \textsf{Description} and \textsf{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
\textsf{Return}.) The term is either typeset in boldface (\textsf{Description})
or separated by a {}``Tab''%
\footnote{But a typesetter's tab, which will change to fit the size of the largest
term, not a pathetic, rigid, unchangeable typewriter \textsf{Tab}.%
} (\textsf{List}) from the rest of the paragraph. If you want to have
more than one word in the definition, then separate the words with
\textsf{Protected~Blank}s.

\textbf{Exercise}: Typeset the list in \texttt{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 \emph{User's Guide} for details on the different sorts of
lists, as well as examples which use \emph{a lot} of nesting.


\subsection{Other Environments: Verses, Quotations, and More}

There are two environments for setting quotations apart from surrounding
text: \textsf{Quote} for short quotes and \textsf{Quotation} for longer
ones. Computer code (the \textsf{\LyX{}-Code} environment, also used
in the \emph{Tutorial} for the long typing examples) is written in
a \texttt{typewriter} font; this environment is the only place in
\LyX{} where you're allowed to use multiple spaces to allow code indenting.
You can even write poetry using the \textsf{Verse} style, using \textsf{Return}
to separate stanzas, and \textsf{C-Return} to separate lines within
a stanza. See the \emph{User's Guide} for more complete descriptions
of all of the available \LyX{} environments.

\textbf{Exercise}: Correctly typeset the \textsf{Quote, \LyX{}-Code,}
and \textsf{Verse} in\linebreak \texttt{example\_raw.lyx}


\chapter{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 text classes, 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,
bibliographies, and tables of contents.


\section{Text classes}

\label{sec:textclasses}Different sorts of documents should be typeset
differently. For example, books are generally printed double-sided,
while articles are single-sided. In addition, many documents contain
special environments: letters contain some environments --- such as
the sender's address and the signature --- which do not make sense
in a book or article. The \LyX{} \emph{text class}%
\footnote{\LaTeX{} users: this is equivalent to the \LaTeX{} document class%
} \emph{}takes care of these large scale differences between different
sorts of documents. This \emph{Tutorial}, for example, was written
in the \textsf{Book} text class. Text classes are another major part
of the WYSIWYM philosophy; they tell \LyX{} how to typeset the document,
so you don't need to know how.

Your document is probably being written in the \textsf{Article} text
class%
\footnote{That's usually the default text class%
}. Try changing to other text classes (using the \textsf{\underbar{L}}\textsf{ayout\lyxarrow{}}\textsf{\underbar{D}}\textsf{ocument}
dialog) to see how they are typeset differently. If you change your
document to the \textsf{Book} text class and look at the \textsf{Environment}
menu, you'll see that most of the allowed environments are the same.
However, you can now use the \textsf{Chapter} environment. If you're
ever unsure about which environments you can use in a given text class,
just consult the \textsf{Environment} menu.

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 \textsf{Article~(AMS)} text class.

Here's a very quick reference to some of the text classes. See the
\emph{Special Document Classes} section of the \emph{Extended Features}
manual for many more details.

\begin{center}\begin{tabular}{|c|c|}
\hline 
Name&
Notes\tabularnewline
\hline
\hline 
article&
one-sided, no chapters\tabularnewline
\hline 
article (AMS)&
layout \& environments for American Math Society\tabularnewline
\hline 
report&
longer than article, two-sided\tabularnewline
\hline 
book&
report + front and back matter\tabularnewline
\hline
slides&
transparencies (also including Foil\TeX{})\tabularnewline
\hline
letter&
lots of extra environments for address, signature\ldots{}\tabularnewline
\hline
\end{tabular}\end{center}


\section{Templates: Writing a Letter}

One of the most popular text classes is \textsf{Letter}\@. One way
to write a letter would be to open a new \textsf{}file, and choose
\textsf{Letter} from the \textsf{\underbar{C}}\textsf{lass} menu in
the \textsf{\underbar{L}}\textsf{ayout\lyxarrow{}}\textsf{\underbar{D}}\textsf{ocument}
dialog. While this is the most obvious way to write a letter, it seems
like extra work. Every time you write a business letter, you want
to have your address, the address you're sending to, a body, a signature,
etc. \LyX{} therefore has a \emph{template} for letters, which contains
a sample letter; once you have a template, you can just replace a
couple parts of the letter with your text each time you write a letter.

Open a new file with \textsf{\underbar{F}}\textsf{ile\lyxarrow{}New~from~}\textsf{\underbar{T}}\textsf{emplate}.
Select \texttt{letter.lyx} as the template. Save and print the file
to see how the various environments are typeset.

When you look at the \textsf{Environment} menu, you'll see several
environments, like the \textsf{My~Address} environment, which don't
even exist in most other text classes. Others, like \textsf{Quote}
and \textsf{Description}, are familiar. You can play around for a
while to figure out how the various environments work. You'll notice
for example that the \textsf{Signature} environment has the word {}``Signature:{}``
in red before the actual text of the signature. This word doesn't
show up in the actual letter, as you'll see if you try printing the
file. It's just there to let you know where the signature goes. Also,
note that it doesn't matter where in the file the \textsf{Signature}
line is placed. Remember, \LyX{} is WYSIWYM; you can put the \textsf{Signature}
environment anywhere you want, but \LyX{} knows that in the printout,
the signature should be at the end.

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 someone%
\footnote{One warning, if you're writing from a template. If you erase all of
the text in an environment --- for example, if you erase the whole
\textsf{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 \textsf{Environment}
menu to get it back.%
}!

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 text classes. 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.


\section{Document Titles}

\LyX{} (like \LaTeX{}) considers the title --- which may contain the
actual title, the author, the date, and even an abstract of a paper
--- to be a separate part of the document.

Go back to your \texttt{newfile.lyx} document and make sure it's using
the \textsf{Article} text class.%
\footnote{You should not be using the letter any more, since the \textsf{Letter}
textclass doesn't allow titles.%
} Type a title on the first line, and change the line to the \textsf{Title}
environment. On the next line, type your name and change it to the
\textsf{Author} environment. On the next line, write the date in the
\textsf{Date} environment. Type a paragraph or two summarizing your
document using the \textsf{Abstract} environment. Now see how it looks
when printed.

\textbf{Exercise}: Fix the title, date, and author in \texttt{example\_raw.lyx}


\section{Labels and Cross-References}

\label{sec:labels}You can label a section (or subsubsection, or,
more rarely, just a random piece of text) in your document. Once you
do so, you can refer to this section in other parts of the document,
using cross-references. You can refer either to the section's number,
or to the page that the section appears on. As with sections and footnotes,
\LyX{} worries about the cross-references for you. Automatic labels
and cross-references are one of the best advantages of \LyX{} (and
\LaTeX{}) over conventional word processors.


\subsection*{Your first label}

Let's mark our second section, whose title is {}``About This Document''.
Click at the end of the section title line, and select \textsf{\underbar{I}}\textsf{nsert\lyxarrow{}}\textsf{\underbar{L}}\textsf{abel}.
A dialog asks you for a label name, and gives you a suggestion. When
you click on \textsf{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 \texttt{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.


\subsection*{Your first cross-references}

Place the cursor somewhere in Section~2 of your document. Type 

\begin{lyxcode}
If~you~want~to~know~more~about~this~document,~then~see~~\\
Section~,~which~can~be~found~on~page~.
\end{lyxcode}
Now --- with the cursor after the word {}``section'' \texttt{}---
choose \textsf{\underbar{I}}\textsf{nsert\lyxarrow{}Cross~}\textsf{\underbar{R}}\textsf{eference}.
The \textsf{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),
and click \textsf{Apply}. Now put the cursor after the word {}``page'',
and change the reference type to use the page number then click \textsf{Apply}.
(To be really correct, you should put a \textsf{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 \textsf{Insert~Reference} dialog). Use \textsf{\underbar{V}}\textsf{iew\lyxarrow{}}\textsf{\underbar{U}}\textsf{pdate\lyxarrow{}}\textsf{\underbar{D}}\textsf{VI},
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).

Conveniently, a cross-reference acts a hyperlink when you're editing
a document in \LyX{}; clicking on it will pop up the \textsf{Reference}
dialog, clicking \textsf{Go~to~reference} will move the cursor to
the referenced label.


\subsection*{More fun with labels}

We told you that \LyX{} worries about numbering cross-references;
now you can test that. Add a new section before Section~2. Now rerun
\LaTeX{}, and --- voilà! --- the section cross reference changed to
{}``3''! Change {}``About this Document'' to a subsection, and
the cross-reference will reference Subsection~2.1 instead of Section~3.
The page reference won't change unless you add a whole page of text
before the label, of course. 

If you want some more practice with labels, then try putting a new
label 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 \textsf{Insert~Reference} window open.

If you want to make sure that the cross-referencing gets the pages
right even for larger documents, \textsf{\underbar{C}}\textsf{opy}
a couple pages of text from the \emph{User's Guide} to the clipboard,
and \textsf{\underbar{P}}\textsf{aste} the stolen text into your document%
\footnote{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~\ref{sec:textclasses}. %
}.

\textbf{Exercise}: Fix the references in \texttt{example\_raw.lyx}


\section{Footnotes and Margin Notes}

Footnotes can be added using the \textsf{Insert~Footnote} button
in the toolbar%
\footnote{The button shows an arrow pointing to red text, which is just below
some black text.%
} or \textsf{\underbar{I}}\textsf{nsert\lyxarrow{}}\textsf{\underbar{F}}\textsf{ootnote}\@.
Click at the end of the word {}``\LyX{}'' somewhere in your document
and hit the \textsf{Insert~Footnote} button. A footnote box appears
where you can enter the text of the footnote. \LyX{} should place
the cursor at the beginning of the footnote box. Type

\begin{lyxcode}
LyX~is~a~typesetting~word~processor.
\end{lyxcode}
Now click on the button labelled {}``foot.'' The footnote box disappears,
leaving the button 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 again on the {}``foot'' button.

You may wonder why the footnote button 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
\texttt{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 button%
\footnote{It may be easier to select it using the keyboard. You might accidentally
open the footnote if you're trying to select the marker itself with
the mouse.%
} and \textsf{\underbar{C}}\textsf{ut} and \textsf{\underbar{P}}\textsf{aste}
it. In addition, you can change regular text to a footnote, by selecting
it and hitting the \textsf{Insert~Footnote} button; change a footnote
to regular text by clicking the \textsf{Insert~Footnote} button when
the cursor is in a footnote.

Margin notes can be added using the toolbar button (the button shows
an arrow pointing to red text next to (i.e., in the margin of) black
text, and should be next to the \textsf{Insert~Footnote} button in
the toolbar.) or \textsf{\underbar{I}}\textsf{nsert\lyxarrow{}}\textsf{\underbar{M}}\textsf{arginal~Note}\@.
Margin notes are like footnotes, except that: 

\begin{itemize}
\item the on-screen boxes say {}``margin'' instead of {}``foot''
\item the notes will be placed in the margin, instead of below the text 
\item margin notes are not numbered
\end{itemize}
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.

\textbf{Exercise}: Fix the footnote in \texttt{example\_raw.lyx}


\section{Bibliographies}

\label{sec:bibliographies}Bibliographies (at least in the exact sciences)
are similar to cross references. 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 \textsf{Bibliography}
environment. Now, each paragraph you type will be a reference. Type
\texttt{The Lyx Tutorial, by the LyX Documentation Team} 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 \textsf{Bibliography~item}
dialog box appears. You use the first field, the \textsf{Key}, to
refer to this reference within the \LyX{} document. By default, it
is a number. Change the \textsf{Key} field to {}``lyxtutorial''
to make it easy to remember.

Now pick somewhere in your document that you would like to insert
a reference. Do so with \textsf{\underbar{I}}\textsf{nsert\lyxarrow{}}\textsf{\underbar{C}}\textsf{itation~Reference\@.}
A \textsf{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 cite. Select {}``lyxtutorial''
(right now, that's the only item in the bibliography), then use the
left arrow in the center to insert it. (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 \textsf{Text~aft}\textsf{\underbar{e}}\textsf{r}
field in the \textsf{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 \textsf{\underbar{L}}\textsf{abel} field
in the \textsf{Bibliography~item} dialog. As usual, you can see the
\emph{User's Guide} for details.

\textbf{Exercise:} Fix the bibliography and citation in \texttt{example\_raw.lyx}


\section{Table of Contents}

You may want to put a table of contents at the beginning of your document.
\LyX{} makes this very easy to do. Just hit \textsf{Return} after
your document title and before your first section title and choose
\textsf{\underbar{I}}\textsf{nsert\lyxarrow{}Lists~\&~}\textsf{\underbar{T}}\textsf{OC\lyxarrow{}Table~of~}\textsf{\underbar{C}}\textsf{ontents}.
The words {}``Table of Contents'' will appear in a button on the
first line of the document. 

This may not appear to be very useful. However, if you look at your
\texttt{dvi} file, you will see that a table of contents has been
generated, listing the various sections and subsections in your document.
As usual, if you reorder sections or create new ones, you will see
those changes in the \texttt{dvi} file when you update it. 

The table of contents is not printed in the on-screen version of the
document, because you can't edit it anyway. However, you can display
the table of contents in a separate window by clicking on the table
of contents button, or by using \textsf{\underbar{V}}\textsf{iew\lyxarrow{}}\textsf{\underbar{T}}\textsf{able~of~Contents}.
The menu command will work even if you don't have a table of contents
inset in your document. This is a very useful tool. You can use the
\textsf{Table~of~Contents} window to move around your document.
Clicking on a (sub)section title in the \textsf{Table~of~Contents}
window will highlight that line and move the cursor (in the \LyX{}
editing window) to that place in the document. You can also use the
arrow keys to move up and down in the table of contents. You may therefore
find it convenient to leave this window open throughout editing sessions.
You can get similar functionality from the \textsf{\underbar{N}}\textsf{avigate}
menu, though, where the table of contents appears automatically.

To get rid of the Table of Contents, you can delete the table of contents
button just like any other text.

\textbf{Exercise}: Fix the table of contents in \texttt{example\_raw.lyx}


\chapter{Using Math}

\LaTeX{} is used by many scientists because it outputs great looking
equations, avoiding the control characters used by word processors
and their equation editors. Many of these scientists are frustrated,
however, because writing equations in \LaTeX{} is more like programming
than writing. Happily, \LyX{} has WYSIWYM support for equations. If
you are used to \LaTeX{}, you'll find that all of the usual \LaTeX{}
math commands can be typed in normally, but they will show up in a
WYSIWYM fashion. If, on the other hand, you've never written in \LaTeX{},
then the \textsf{Math~Panel} will allow you to write professional-looking
math quickly and easily%
\footnote{\LyX{} can't check if the math you're writing is actually \emph{correct}.
Sorry.%
}.


\section{Math Mode}

Somewhere in your \LyX{} document, type: 

\begin{lyxcode}
I~like~what~Einstein~said,~E=mc\textasciicircum{}2,~because~it's~so~simple.~
\end{lyxcode}
Now, that equation doesn't look very good, even in the \texttt{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.

Instead, we create a formula that will get typeset properly. In order
to create a formula, just click the toolbar button with $\frac{a+b}{c}$
written on it in blue. \LyX{} will insert a little blue square, which
is an empty math formula. \LyX{} has placed the cursor in the blue
square, so just type \texttt{E=mc\textasciicircum{}2} again. The expression
is typed in blue, and the blue square disappears as soon as the formula
is not empty. Now type \textsf{Esc} to leave the equation The purple
markers disappear, 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 \texttt{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.

This math editor is another example of the WYSIWYM philosophy. In
\LaTeX{}, you write a mathematical expression using text and commands
like \texttt{\textbackslash{}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
\emph{content} of your mathematical expressions, not their format.


\section{Navigating an Equation}

Now let's change $E=mc^{2}$ to $E=1+mc^{2}$. Use the arrow keys
to move the cursor into the expression. Note that when you enter the
expression, the purple markers appear to let you know you're editing
math. Now you can use \textsf{Left} and \textsf{Right} to move the
cursor past the equals sign, and just type {}``1+''. Again, you
can use the arrow keys or \textsf{Esc} to leave the formula\@.

Other than the special keys described below, typing in math mode is
like editing regular text. Use \textsf{Delete} (or \textsf{Backspace})
to delete things. Select text either with the arrow keys or with the
mouse. \textsf{\underbar{E}}\textsf{dit\lyxarrow{}}\textsf{\underbar{U}}\textsf{ndo}
works in math mode, as does cutting and pasting. One thing to be careful
of: if you're right outside a Mathed expression and you type \textsf{Delete}
(or \textsf{Backspace}), it will delete the whole expression. Luckily,
you can just use \textsf{Undo} to get it back.

What if you want to change $E=mc^{2}$ to $E=mc^{2.5}+1$? Again,
you can use the mouse to click in the right place. However, you can
also use the arrow keys. If the cursor is just after the {}``c''
but before the {}``2'', then typing \textsf{Up} will move the cursor
to the level of the superscript, just before the {}``2''. Add the
{}``.5''. Now, hitting \textsf{Down} will move the cursor back to
the regular level. In fact, if you hit \textsf{Down} from anywhere
within the superscript, the cursor will be placed just \emph{after}
the superscript (so that you can then type the {}``+1'').


\section{Exponents and Indices}

An exponent can be entered from the \textsf{Math~Panel} (see below),
but it's actually simpler just to type the caret key, {}``\textasciicircum{}''.
\LyX{} will place another blue rectangle in the superscript, so that
whatever you write next will be superscripted, and in a smaller font
size. Everything you type until you hit a \textsf{Space} (or \textsf{Esc}
to exit Mathed entirely) will be in the superscript.

Writing a subscript (index) is just as easy --- start one by typing
the underscore key, {}``\_{}``. You can subscript and superscript
both subscripts and superscripts like this: $A_{a_{0}+b^{2}}+C^{a_{0}+b^{2}}$. 

\textbf{Exercise}: Put equation 1 of \texttt{example\_raw.lyx} into
math mode.


\section{The \textsf{Math Panel}}

The \textsf{Math~Panel} is a convenient way to enter symbols or to
perform many complicated Mathed functions. Many of these functions
can be accomplished from the keyboard or the \textsf{\underbar{E}}\textsf{dit\lyxarrow{}}\textsf{\underbar{M}}\textsf{ath}
or \textsf{\underbar{I}}\textsf{nsert}\textsf{\underbar{\lyxarrow{}}}\textsf{Mat}\textsf{\underbar{h}}
menus. However, we're going to concentrate on using the \textsf{Math~Panel},
just to let you know what's out there; you can learn keyboard shortcuts
later, from other manuals. So open it using \textsf{\underbar{I}}\textsf{nsert}\textsf{\underbar{\lyxarrow{}}}\textsf{Mat}\textsf{\underbar{h}}\textsf{\lyxarrow{}Math~Pane}\textsf{\underbar{l}}
now and leave it open while reading this section.

Right-clicking on a formula will open the \textsf{Math Panel} for
you.


\subsection{Greek and symbols}

The \textsf{Math~Panel} which allow you to choose from a large array
of symbols used in math: various arrows, relations, operators, and
sums and integrals. Note that subscripting and superscripting allow
you to put lower and upper limits on sums and integrals. 

{}``Nothing you can do that can't be done\ldots{} All you need is
$\heartsuit$.'' 


\subsection{Square roots, accents, and delimiters}

To type a square root, just click on the button with a square root
sign on it. The square root appears, and the cursor is in a new insertion
point inside the square root. You can type variables, numbers, other
square roots, fractions, whatever you want. \LyX{} will automatically
resize the square root to fit what's inside.

Accenting a character ($\overrightarrow{v}$) or group of characters
($\overrightarrow{a+b}$) is done the same way. The \textsf{Decoration}
types are available from the panel. Click on a decoration, and \LyX{}
will insert that decoration with an insertion point under (or over)
it. Just type what you want in the insertion point. There are two
sets of decorations: those that resize with the text you type, and
those that have fixed size, and are most appropriate for a single
letter. 

Delimiters such as parentheses, brackets, and braces work similarly,
but are a bit more complicated. Hit the \textsf{Delimiter} button,
which features a blue square surrounded by brackets, to pop up the
\textsf{Delimiter} dialog. Your current selection of delimiters is
displayed in a box. It's a pair of parentheses by default, but you
can choose a pair of braces, a brace and a parenthesis, or even choose
the empty square to have something like {}``$a=\left\langle 7\right.$''
(the empty delimiter is displayed as a broken line in \LyX{}, but
won't show up in the output).

If you're lazy, you can type actual parentheses in math mode, rather
than using the \textsf{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 \textsf{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 \textsf{Math~Panel}.
Try using this to change Newton's second law from scalar to vector
form ($f=ma$ to $\overrightarrow{f}=m\overrightarrow{a}$). Once
you've learned about matrices, this is how you'll put parentheses
or brackets around them.


\subsection{Fractions}

Fractions are very simple in Mathed. Just click on the \textsf{Fraction}
button in the \textsf{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 \textsf{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. 

\textbf{Exercise}: Put equation 2 of \texttt{example\_raw.lyx} into
math mode.


\subsection{\TeX{} mode: Limits, log, sin and others}

Because letters in math mode are considered to be variables, if you
type {}``sin'' in math mode, \LyX{} thinks you're typing the product
of the three variables $s$, $i$, and $n$. The three letters will
be typeset in italics, when what you really wanted was the word {}``sin''
typeset in Roman. In addition, \LyX{} won't put a space between the
word {}``sin'' and the {}``x'' (typing \textsf{Space} will just
exit math mode). So how do you get {}``$\sin x$'' instead of {}``$sinx$''?

Click on {}``sin'' in the \textsf{Functions} list in the \textsf{Math~Panel}.
The word {}``sin'' is written in black, in upright roman type. The
whole word is treated as one symbol, so if you type \textsf{Backspace},
it will delete the whole word. Now type {}``x'', which will be written
in blue italics, like you expect in Mathed. In the \texttt{dvi} file,
the expression will be correctly typeset. Try it.

Other commands you need to type in \TeX{} mode using the \textsf{Functions}
box include other trigonometric functions and their inverses, hyperbolic
functions, logarithms, limits, and quite a few others. These functions
can take subscripts and superscripts, important for typing {}``$\cos^{2}\theta$''
or {}``$\lim_{n\rightarrow\infty}$''.

\textbf{Exercise}: Put equation 3 of \texttt{example\_raw.lyx} into
math mode.


\subsection{Matrices}

\label{sec:matrices}Click on the \textsf{Matrix} button in the \textsf{Math~Panel}.
The dialog 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 \textsf{Apply} or \textsf{OK}. \LyX{} prints 6 insertion points
in a $2\times3$ 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.

\textsf{Tab} can be used to move horizontally between the columns
of a matrix. Alternatively, you can use the arrow keys to move around
- hitting \textsf{Right} at the end of one box will move to the next
box, \textsf{Down} will move to the next row, etc.

If you suddenly need more rows or columns, use \textsf{\underbar{E}}\textsf{dit\lyxarrow{}}\textsf{\underbar{M}}\textsf{ath\lyxarrow{}Add~Row}
and \textsf{Add~Column}. They add a row or column just after the
current position. Overdid it? Use \textsf{Delete~Row} and \textsf{Delete~Column}
from the same menu.

See the \emph{User's Guide} for information on how to change the horizontal
alignment 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.


\subsection{Display mode}

All of the expressions we have written so far have been on the same
line as the text that came before and after them, otherwise known
as inline expressions. This is fine for short, simple expressions,
but if you want to write larger ones, or if you want your expressions
to stand out from the text, you need to write them in display mode.
In addition, only displayed expressions can be labeled and numbered
(see the \emph{User's Guide}), and multi-line equations (see Sec.
\ref{sec:multiline}) must be in display mode.

Click on the \textsf{Display} button in the \textsf{Math~Panel},
which represents a couple lines of text before and after a centered
blue box. \LyX{} inserts a formula, but the insertion point is on
a new line, and it's centered within that line. Now type an expression
and run \LaTeX{} to see how it looks. The \textsf{Display} button
is actually a toggle; use it now to change a couple of your expressions
to display mode and back. 

Display mode has a couple differences from inline mode:

\begin{itemize}
\item The default font is larger for a few symbols, like $\sum$ and $\int$
\item Subscripts and superscripts for limits and sums (but not integrals)
are written under rather than next to the symbols
\item Text is centered
\end{itemize}
Other than these differences, though, displayed expressions and inline
expressions are very similar.

One final note about the way displayed formulae are typeset: be careful
about whether you're putting your equation into a new paragraph or
not. If your formula is in the middle of a sentence or paragraph,
then don't press \textsf{Return}. Doing so will cause the text \emph{after}
the formula to start a new paragraph. That text will therefore be
indented, which is probably not what you want.

\textbf{Exercise}: Put the various equations in \texttt{example\_raw.lyx}
into display mode, and see how they're typeset differently.

\textbf{Exercise}: Using various tools you've learned in this section,
you should be able to write an equation like%
\footnote{After you've done it the hard way, why don't you give \textsf{\underbar{I}}\textsf{nsert\lyxarrow{}Mat}\textsf{\underbar{h}}\textsf{\lyxarrow{}}\textsf{\underbar{C}}\textsf{ases~environment}
a try?%
}: \[
f(x)=\left\{ \begin{array}{cc}
\log_{8}x & x>0\\
0 & x=0\\
\sum_{i=1}^{5}\alpha_{i}+\sqrt{-\frac{1}{x}} & x<0\end{array}\right.\]



\section{More Math Stuff}

Mathed can do plenty more. By now, you're familiar with the basics,
so we'll just refer to the \emph{User's Guide} for tips on how to:

\begin{itemize}
\item Labeling and numbering expressions
\item Multi-line equations
\item Change typefaces, e.g., to write bold-face text in an expression.
\item Fine-tune font sizes and spacing within an expression. (Don't worry
about this until your final draft!)
\item Write macros. These are very powerful, because you just define them
once at the top of the document, and then you can use them throughout
the document. If you change the macro definition, the references to
the macro will be changed throughout the document. Macros can even
take arguments.
\item Do lots of other things we didn't have time to mention in this \emph{Tutorial}.
\end{itemize}

\chapter{Miscellaneous}


\section{Other Major \LyX{} Features}

We haven't gone through all the possible commands in \LyX{}, and we
aren't planning on it. As usual, see the \emph{User's Guide} for more
information. We'll just mention a couple more major things \LyX{}
can do\ldots{}

\begin{itemize}
\item \LyX{} has WYSIWYM support for tables. Use the \textsf{\underbar{I}}\textsf{nsert\lyxarrow{}Ta}\textsf{\underbar{b}}\textsf{ular~Material}
to get a table. Click on the table with the \emph{right button} to
get a \textsf{Tabular~Layout} dialog box which allows extensive table
editing.
\item \LyX{} also supports including pictures in a number of formats (including
JPEG and other bitmap formats, PostScript® and raw \LaTeX{}) within
documents. (You guessed it: \textsf{\underbar{I}}\textsf{nsert\lyxarrow{}}\textsf{\underbar{G}}\textsf{raphics}\@.
Then click on the figure to choose the file to include, rotate or
scale it, etc.) Tables and figures can have captions, and \LyX{} will
automatically generate lists of figures and/or tables.
\item Version control is supported, using RCS (\texttt{man rcsintro} for
more info).
\item \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 \textsf{\underbar{E}}\textsf{dit\lyxarrow{}}\textsf{\underbar{P}}\textsf{references}.
For more information on this, check out \textsf{\underbar{H}}\textsf{elp\lyxarrow{}}\textsf{\underbar{C}}\textsf{ustomization\@.}
\item \LyX{} is being developed by a team of programmers on five continents.
Therefore, \LyX{} has better support for non-English languages (such
as Dutch, German, French, Greek, Czech, Turkish, \ldots{}) than many
word processors. Even some right-to-left languages like Hebrew or
Arabic are supported. You can write documents in other languages,
but you can also configure \LyX{} to show its menus and error messages
in other languages. 
\item The \LyX{} menus feature keybindings. This means that you can do \textsf{\underbar{F}}\textsf{ile\lyxarrow{}}\textsf{\underbar{O}}\textsf{pen}
by typing \textsf{M-F} followed by \textsf{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 \textsf{\underbar{H}}\textsf{elp\lyxarrow{}}\textsf{\underbar{C}}\textsf{ustomization\@.}
\item \LyX{} can read in \LaTeX{} documents. See Section~\ref{sec:relyx}.
\item Spellchecking and thesaurus facilities are available.
\item The text box near the bottom of the \LyX{} window is called the minibuffer
(after a similar feature in \texttt{emacs}). 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.
\end{itemize}

\section{\LyX{} for \LaTeX{} Users}

\label{sec:latexusers}If you don't know anything about \LaTeX{},
you don't have to read this section. Actually, you might want to \emph{learn}
about \LaTeX{}, and then read this chapter. However, many people who
begin to use \LyX{} will be familiar with \LaTeX{}. If you are such
a person, you may be wondering if \LyX{} can really do everything
\LaTeX{} can do. The short answer is that \LyX{} can do pretty much
everything \LaTeX{} can do in one form or another, and it definitely
simplifies most parts of writing a \LaTeX{} document. Currently, there
may be some annoyance in converting old \LaTeX{} documents and in
a couple other areas, but later releases of \LyX{} will get rid of
these problems.

Because this is just a tutorial, we are only going to mention things
that new \LyX{} users will most likely be interested in. In the interests
of keeping the \emph{Tutorial} short, we will give only minimal information
here. The \emph{Extended Features} manual, specifically the \emph{Secrets
of the \LaTeX{} Masters} chapter, has a great deal of information
on differences between \LyX{} and \LaTeX{}, and how to do various
\LaTeX{} tricks in \LyX{}.


\subsection{\TeX{} Mode }

Anything that you enter in \TeX{} mode will be passed straight to
\LaTeX{}, and will be displayed in red on the screen. You can use
\TeX{} commands in \LyX{} by choosing \textsf{\underbar{I}}\textsf{nsert\lyxarrow{}}\textsf{\underbar{T}}\textsf{eX}.
This creates a text box, and everything within it is passed straight
to \LaTeX{}.

In a math formula, \TeX{} mode is handled a bit differently. Enter
\TeX{} mode by typing a backslash. The backslash is not written out,
but anything you type afterwards will be in red. You exit \TeX{} mode
by typing \textsf{Space} or some other non-alphabetic character, like
a number, underscore, caret, or parenthesis. Once you exit \TeX{}
mode, if \LyX{} knows the \TeX{} command you've typed in, it will
convert it to WYSIWYM\@. So if, in a formula, you type \texttt{\textbackslash{}gamma},
then when you type \textsf{Space}, \LyX{} will change the red {}``gamma''
to a blue {}``$\gamma$''. This will work for almost all, non-complicated
math macros. This may be faster than using the \textsf{Math~Panel},
and will be especially convenient for experienced \LaTeX{} users.

As a special case, if you type a brace in \TeX{} mode, then the beginning
\emph{and} ending braces will be inserted in red, then take you \emph{out}
of \TeX{} mode and place the cursor between the braces. This makes
it more convenient to type commands that \LyX{} 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 convenient features of \LyX{}, like
WYSIWYM math, tables, and editing. \LyX{} could never support every
\LaTeX{} package. However, by typing \texttt{\textbackslash{}usepackage\{foo\}}
in the preamble (see Section~\ref{sec:preamble}), you can use any
package you want --- although you won't have WYSIWYM support for that
package's features.


\subsection{Importing \LaTeX{} Documents--- \texttt{reLyX}}

\label{sec:relyx}You can import a \LaTeX{} file into \LyX{} by using
the \textsf{\underbar{F}}\textsf{ile\lyxarrow{}}\textsf{\underbar{I}}\textsf{mport\lyxarrow{}}\textsf{\underbar{L}}\textsf{a\TeX{}}
command in \LyX{}. This will call a Perl script called \texttt{reLyX}---which
will create a file \texttt{foo.lyx} from the file \texttt{foo.tex}---and
then open that file. If the translation doesn't work, you can try
calling \texttt{reLyX} from the command line%
\footnote{When \LyX{} is installed, a separate executable called \texttt{reLyX}
will be placed in the same folder as the \texttt{lyx} executable (e.g.,
\texttt{/usr/local/bin/reLyX}). \texttt{reLyX} requires Perl (version
5.002 as of this writing).%
}, possibly using fancier options.

\texttt{reLyX} will translate most legal \LaTeX{}, but not everything.
It will leave things it doesn't understand in \TeX{} mode, so after
translating a file with \texttt{reLyX}, you can look for red text
and hand-edit it to look right.

\texttt{reLyX} has its own manpage. Read it to find out about which
\LaTeX{} commands and environments aren't supported, bugs (and how
to get around them), and how to use the various options.


\subsection{Converting \LyX{} Documents to \LaTeX{}}

You might wish to convert a \LyX{} Document to a \LaTeX{} file. For
example, a co-worker or co-author who doesn't have \LyX{} might want
to read it. This is very easy to do with \LyX{}. Select \textsf{\underbar{F}}\textsf{ile\lyxarrow{}}\textsf{\underbar{E}}\textsf{xport\lyxarrow{}}\textsf{\underbar{L}}\textsf{a\TeX{}}.
This will create a file \texttt{whatever.tex} from the \texttt{whatever.lyx}
file you are editing. \LyX{} always creates temporary \LaTeX{} files
when viewing or printing files, so it is very good at generating \LaTeX{}.


\subsection{\LaTeX{} Preamble}


\subsubsection{Document Class}

The \textsf{\underbar{L}}\textsf{ayout\lyxarrow{}}\textsf{\underbar{D}}\textsf{ocument}
dialog takes care of many of the options that you would input in a
\texttt{\textbackslash{}documentclass} command. Change the class,
default font size and paper size here. Put any extra options to the
\texttt{\textbackslash{}documentclass} command in the \textsf{E}\textsf{\underbar{x}}\textsf{tra~Options}
area.


\subsubsection{Other Preamble Matter}

\label{sec:preamble}If you have special commands to put in the preamble
of a \LaTeX{} file, you can use them in a \LyX{} document as well.
Select \textsf{\underbar{L}}\textsf{ayout\lyxarrow{}}\textsf{\underbar{P}}\textsf{reamble\ldots{}}
and type in the dialog window. Anything you type will (like with \TeX{}
mode) be sent directly to \LaTeX{}.


\subsection{Bib\TeX{}}

\LyX{} has support for Bib\TeX{}, which allows you to build databases
of bibliographical references to be used in multiple documents. Select
\textsf{\underbar{I}}\textsf{nsert\lyxarrow{}Lists~\&~T}\textsf{\underbar{O}}\textsf{C\lyxarrow{}}\textsf{\underbar{B}}\textsf{ib\TeX{}~Reference}
to include a \texttt{bib} file. Click on the resulting {}``Bib\TeX{}~Generated~References''
button, and you will get a \textsf{Bib\TeX{}} dialog. In the \textsf{Database}
field, type what you would type inside the braces of a \texttt{\textbackslash{}bibliography\{\}}
command%
\footnote{Like in regular \LaTeX{}, multiple bibliographies should be separated
by commas, with no whitespace.%
}. Similarly, in the \textsf{Style} field, type what you would type
inside the braces of a \texttt{\textbackslash{}bibliographystyle\{\}}
command.

After you've done this, you can use citations from any bibliographies
you're including with \textsf{\underbar{I}}\textsf{nsert\lyxarrow{}}\textsf{\underbar{C}}\textsf{itation~Reference}
(see Section~\ref{sec:bibliographies}). \LyX{} will take care of
running Bib\TeX{}. The box in the \textsf{Citation} dialog will show
a list of all the references in your \texttt{bib} file.


\section{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.
\LyX{} will just include the error message that \LaTeX{} gave. Note
that the placement of these errors in often not accurate.
\end{document}
