SE381-03 (Week 2, lecture 1)
How to go about learning LaTeX?
Get a headstart (this lecture?)
Try things
Ask questions
Find sources of help
www.tug.org - TeX Users' Group
www.ctan.org - Archive of packages, implementations
An introduction to LaTeX
Whitespace
Like HTML, multiple spaces or single newlines treated the same
Empty lines (adjacent newlines) break paragraphs
Comments
Begin with "%" and extend to end of line
Causes rest of whitespace on line and beginning of next line to be ignored
Can be used to split long lines so no spurious whitespace is inserted
Special characters
$ & % # _ { } ~ ^ \
Must be escaped with "\"
What about quotes?
Double quotes (") should be entered as two open quotes or two close quotes
Example: Let's quote ``this text' ' in a sentence.
Single quotes (') are similar, but use only one open or close quote
Tilde (~) is a non-breaking space
LaTeX commands
Three kinds of commands
Single special characters (e.g., "$")
Escaped ("\") special characters
Usually, a command to print the special character literally
But, "\\" is a line-break command!
To get a literal "\", use "$\backslash$" (??)
The "$ ... $" sequence embeds a math formula, which knows what to do with the "\backslash"
Tip: you can use "$variable$" to make "variable" appear as it would in a math formula (as in a segment of Z text), inside a normal text segment
Named commands
Syntax
Start with "\"
Name (letters only)
Terminated by non-letter character
Often take arguments
Enclosed in [ ] or { }
Examples
\newline
\underline{some text}
Environments
Start with "\begin{something}"
End with "\end{something}"
Many named commands can be used as environments also
Input file structure
Preamble
Begin with "\documentclass[option, option, ...]{classname}"
Common options
Font size: "10pt", "11pt", "12pt"
Paper size: "letterpaper", "landscape"
Layout: "onecolumn", "twocolumn"
Common class names
"article", "book", "report", "slides"
Include "\usepackage[option, ...] {packagename}" declarations
Body text
Enclosed in "document" environment
\begin{document}
\end{document}
Often use a predefined template for the document
As in the IEEE Transactions example (IEEEtran)
Structuring body text
Often break up into hierarchical components
\section, \subsection, \subsubsection, \paragraph
Some document classes permit "\part", "\chapter", "\appendix"
Formatting the title
Define the components
\title{Title of the Paper}
\author{My Name}
\date{4 July 1776} (optional -- default = \today)
Make the title
\maketitle
Text formatting
Italic: \emph{the text} or \textit{the text}
Bold: \textbf{the text}
Underline: \underline{the text}
Typewriter font: \texttt{the text}
Sans-serif font (like Helvetica/Arial): \sffamily or \textsf{...}
Roman font (like Times Roman): \rmfamily or \textrm{...}
Superscript (math mode): ^ (e.g., "2^5" or "x^{y^3}")
Subscript (math mode): _ (e.g., "x_2" or "entry_{97}")
Paragraph/page formatting
\begin{center} ... \end{center}
\begin{flushleft} ... \end{flushleft} (equivalent: "\raggedright")
\begin{quote} ... \end{quote} ("quotation" is similar -- try them)
\newpage
\newline (like \\, but does not justify current line)
Margins
Set by default LaTeX style -- may seem big
Control with "geometry" package
"\usepackage[hmargin=0.5in,vmargin=1.0in,headheight=18pt]{geometry}"
Lists (bulleted or numbered)
\begin{itemize} or \begin{enumerate}
\item
\end{itemize} or \end{enumerate}
Tables
Can be a little complicated
See "tabular" environment
Special
"\LaTeX" produces the LaTeX logo