LaTeX for B561
This document is intended for B461 and B561 students wishing to learn the
text formatting language LaTeX. LaTeX is the de facto standard for scientific
and mathematical documents. You will have many opportunities to use LaTeX
during your CS career. This document is intended to be a quick-start guide to
the basic elements you need to know for B461/B561. There are many much more
comprehensive references available, and it is recommended you also consult
one or more of these.
Overview: LaTeX at IUB
LaTeX is a Markup Language. This means the source code is plain
text with text markup commands. In LaTeX, markup commands usually start with
a "\" (backslash). There are 5 steps involved in going from plain text source
code to a finished PDF document.
- Create LaTeX source code using the text editor of your choice. Let's
say your source code is in a file "foo.tex".
- The text editor Emacs is recommended. Emacs recognizes LaTeX
and so does syntax highlighting for you in font-lock-mode.
- Unix/Linux: Emacs should come with the OS.
- Windows: A full-featured Emacs is available for Windows
at
http://www.gnu.org/software/emacs/windows/ntemacs.html.
- Compile your LaTeX source code to produce DVI (DeVice Independent)
WYSIWYG output.
- Unix/Linux: The command
"latex foo.tex"
produces "foo.dvi".
- Windows: The command "latex foo.tex" in a DOS window
produces "foo.dvi" as long as you've installed MikTeX on your PC. MikTeX is
a part of the ADS install. To get MikTeX on your home PC, follow the
instructions at http://www.miktex.org.
Note: You will need to install Ghostscript before installing
MikTeX. Ghostscript (and GSview, which is also recommended) is available
at: http://www.cs.wisc.edu/~ghost/.
- Note: You may have to run the LaTeX compiler up to 3 times to
reconcile all document references.
- View the DVI result.
- Unix/Linux: The viewing application is XDVI, the command
is "xdvi foo.dvi".
- Windows: The viewing application is Yap and comes with the
MikTeX installation.
- Edit the source code and recompile until you have achieved your
desired result.
- Both XDVI and Yap will automatically update when LaTeX is run
again. (If they don't, both have a refresh-type command.)
- Translate the finished version to PDF.
- Unix: Use the following two commands:
dvips -f foo.dvi >foo.ps
distill foo.ps
The first command produces PostScript, the second uses Adobe Distiller
(available on the IUB CS Unix machines) to translate PostScript to PDF.
- Linux: The only difference from Unix is that you will
probably have to use the Gnu PostScript translation utility:
dvips -f foo.dvi >foo.ps
ps2pdf foo.ps
- Windows: Instead of the command "latex" in step
2, use "pdflatex" to compile your finished source.
Document Skeleton
A sample document skeleton is available here.
This skeleton should give you the necessary formatting/packages for B561.
Your text goes between the \begin{document} and \end{document}
commands (after the \maketitle) command. You should change the
\author and \title input in the preamble accordingly.
Text Formatting
- Comments: Whenever the symbol % is encountered,
LaTeX ignores the rest of that line.
- List Environments:
The typical list environment is used as follows:
\begin{enumerate}
\item This is item 1.
\item This is item 2.
...
\end{enumerate}
The enumerate environment creates numbered lists. The
itemize environment creates bulletted lists. Lists can
be arbitrarily nested with one another.
- Sectioning:
The command \section{Your title here} creates a numbered section.
You also can use the subsection, subsubsection, and
paragraph commands to create sub-sections, etc. If you want
unnumbered sections, use the \section*{...} command.
- Font Formatting:
Some common font formatting commands:
\underline{this text will be underlined}
\textbf{this text will be bold}
\textit{this text will be italicized}
\texttt{this text will be typewriter text}
\textsc{this text will be small caps}
- Escaping: Many characters in LaTeX have special markup
meaning. If you want to include these in your document, you will need to
precede them with a "\". For example:
\#
\&
\$
\%
\@
\_
\{
\}
\^
LaTeX also includes two "verbatim" commands:
"\begin{verbatim} ... \end{verbatim}" (to set off text that displays exactly
as entered in the source code) and "\verb|...|" (to get inline verbatim
text).
- References:
Any part of your document can be given a label: "\label{myLabel}" and
then referred back (or forward) to using "\ref{myLabel}" or
"\pageref{myLabel}".
- Hard-Coded White Space:
The text "\ " (note the space after the \) can be used
to insert a space in the output. You can insert however much space you'd like
using the "\hspace*{...}" and "\vspace*{...}" commands.
Replace the "..." with a measurement, such as "2cm", "1in", or "3mm".
Formulas
- Equation Environments: equations can be set off from the text
using "\begin{equation}...\end{equation}", or can be inline set
off by "$...$". The following LaTeX markup will produce what you
want only inside an equation environment.
- Sub-Scripts: write x_y to get xy.
If you want more than a single character in the subscript, enclose it
with { and }: for example x_{135} produces
x135.
- Super-Scripts: write x^y to get xy.
If you want more than a single character in the superscript, enclose it
with { and }: for example x^{135} produces
x135.
Note: super- and sub-scripts can be arbitrarily nested as long
as you use { and } to disambiguate properly.
- Greek Letters: Just write the English word for the Greek
letter. For example: \alpha, \beta, \gamma, etc.
To get the capitalized Greek letters, capitalize the first letter of the
English: for example, \Gamma, \Delta, etc.
- Fractions: The command \frac{...}{...} produces
nicely formatted fractions. The numerator should replace the first "...", the
denominator should replace the second "...".
- Tuple Calculus Symbols: Here are the LaTeX markup codes for
the symbols of the Tuple Calculus:
| LaTeX | Produces |
| \rightarrow | logical "implies" symbol |
| \vee | logical "or" symbol |
| \wedge | logical "and" symbol |
| \exists | logical "there exists" symbol |
| \forall | logical "for all" symbol |
| \in | "is element of" symbol |
| \neg | logical "not" symbol |
| \bot | logical "false" symbol |
| \top | logical "true" symbol |
- Relational Algebra Symbols: Here are the LaTeX markup codes
for the symbols of the Relational Algebra:
| \times | "Cartesian product" symbol |
| \rho | renaming symbol |
| \cup | set union symbol |
| \cap | set intersection symbol |
| - | set difference symbol |
- Set Comparison
| LaTeX | Produces |
| \subset | "is subset of" |
| \subseteq | "is subset of or equal to" |
- Bold Symbols: Use \boldsymbol{...} enclosing a
symbol command to make that symbol appear bold.
Figures
- Figure Environment: Use the following LaTeX markup to produce
a captioned-figure environment setting off an external EPS figure:
\begin{figure}
\epsfig{file=myFig.eps, height=...}
\caption{Insert caption here}
\end{figure}
- Creating EPS Figures
- Unix/Linux: Use the program X-Fig to produce sophisticated
figures, which you can then export to EPS (encapsulated postscript).
- Windows:There is a Windows version of X-Fig called WinFig,
available at
http://www.user.cs.tu-berlin.de/~huluvu/WinFIG.htm.
LaTeX References
Books
|
L. Lamport. LaTeX: A Document Preparation System User's Guide and
Reference Manual. (Addison-Wesley, 1994.)
|
|
Goosens, Mittelback & Samarin. The LaTeX Companion (Addison-Wesley, 1994.)
|
Online References