Presentation is loading. Please wait.

Presentation is loading. Please wait.

SIGNewGrad: Intro to LaTeX

Similar presentations


Presentation on theme: "SIGNewGrad: Intro to LaTeX"— Presentation transcript:

1 SIGNewGrad: Intro to LaTeX
Ben Breech

2 What is LaTeX Based on TeX Markup language for documents
hard to use (like prog. in assembly) Markup language for documents You write. LaTeX typesets LaTeX compiles your document Each letter/word/sentence/paragraph is a box. LaTeX arranges the boxes. Commands and environments instruct LaTeX to change layout LaTeX is case sensitive

3 Running LaTeX doc.tex latex doc.dvi pdflatex dvipdf dvips doc.pdf
doc.ps

4 Commands Change layout of text Format: Command names are only letters
\command[opt_arg1]{req_arg1} Command names are only letters Command ends with last {} or non-letter (exception: some commands have special -* form) May need empty {} for spacing if command has no args

5 Environments Affects all text within env
Conveniently hides tons of commands Format: \begin{name}[opts]{args} % text… \end{name}

6 Example Document [ex1.tex]
Sets doc. type \documentclass{article} % comments in LaTeX start with a %. anything after it is ignored. % this section is the preamble.. \begin{document} This is the first paragraph. For \LaTeX, a paragraph is a continuous sequence of lines, ending with a blank line. This means you can put one word per line if you wish and \LaTeX{} will treat the text as one paragraph. This is the second paragraph. Just put in here to show how paragraphs separate. \end{document} class type preamble body

7 Example Document [ex1.pdf]
Notice margins. Designed for typesetters Add \usepackage{fullpage} in preamble to get 1.0” margins Spacing between words/paragraphs 1 space = 10 spaces = 100 spaces, etc Paragraph is contiguous text separated by blank lines

8 Sectioning Commands Let you break document into sections
Each section has running counter (e.g., section 1, section 2, section 2.3.4) Commands: \section{title}, \subsection{title}, \subsubsection{title} Others available depending on style file

9 Sectioning Examples \section{Top Level Section}
\subsection{2nd Level Section} % second \subsection not shown \subsubsection{3rd Level Section} \paragraph{Paragraph.}

10 Labels and references \label{string} after sectioning command to save a label \ref{string} where you want number for section with label string May want ~\ref{string} ~ = non-breakable space \pageref{string} -- gives page number where section with label string appears

11 Example Document \section{Labels and References} \label{sec:lab-ref}
% other stuff cut out… For example, in section~\ref{sec:tls}, we discussed sectioning commands. Section~\ref{sec:3rd-ls} was a 3rd level section. In section~\ref{sec:lab-ref}, we discussed labels and references.

12 Lists Bulleted Lists: Enumerated Lists (automatically counted):
\begin{itemize} \item First item. \end{itemize} Enumerated Lists (automatically counted): \begin{enumerate} \item \label{it1} This is the first item. \end{enumerate}

13 Font Styles Change appearance of text Forms: \texttt{TeleType text}
\textbf{BoldFace text} \textsl{Slanted text} \textit{ITalicized text.} \textrm{RoMan} \textsc{Small Caps} \textsf{Sans Serif}

14 Font Sizes Affect everything after until end of current text block (e.g. } or \end{}) {\tiny really small } {\scriptsize next smallest} {\footnotesize size used in footnotes} {\small smaller than normal } {\normalsize regular sized text} {\large larger than normal } {\Large larger } {\LARGE larger still } {\huge very large } {\Huge extremely large}

15 Math Mode In normal text, $math formula$
In displayed math mode, \begin{displaymath} math formula \end{dispalymath} \begin{equation} math formula \end{equation} Equation adds an equation number in ()

16 Math Examples (text mode)
superscripts (^) -- x^2 + y^2 subscript (_) -- x_i + y_i \sqrt{x^2_i + y_i^2} \frac{x}{y} Greek letters -- \alpha, \beta, \pi, \Pi, \sum_{i=0}^n i (different in display mode)

17 Math Examples (equation)
Finally, here's a more complicated equation. The Ackermann function $A$ is defined as, \begin{equation} \label{eq:ack-def} A (m, n) = \left\{ \begin{array}{ll} n & \mathrm{if}\ m = 0 \\ A (m - 1, 1) & \mathrm{if }\ m > 0 \mathrm{\ and\ } n = 0 \\ A (m - 1, A (m, n - 1)) & \mathrm{if}\ m > 0 \mathrm{\ and\ } n > 0 \end{array} \right. \end{equation} Creates a { big enough to match what follows. \mathrm to make if appear as normal text Array env. (just like a table) Matching right . = don’t print anything \[space] to force a space here

18 Math Examples (equation)
(equation number was removed. See example.pdf) (If you’re bored, compute A (4, 3))

19 Floating Environments
Certain environments can “float” Do not appear exactly where you put them LaTeX moves them for better placement Can be frustrating if LaTeX picks bad spot Tables/Figures are most common

20 Tables \begin{table} \centering \begin{tabular}{|l|c|r|} \hline
Table template one letter/column l = left justify r = right justify c = center | = draw vert. Bar between two cols \begin{table} \centering \begin{tabular}{|l|c|r|} \hline left justified & center justified & right justified \\ \hline\hline row 2, col & row 2, col 2 & row 2 col 3 \\ row 3, col & & \\ \end{tabular} \caption{Example Table} \label{tab:ex} \end{table} Start table & separate columns Table body \\ ends each row Caption & label \hline draws horizontal line between rows

21 Tables

22 Paper Citations Place \cite{key} where you want citation to appear
key is unique citation key generates reference label at that spot Need to add special bibliography environment with papers DON’T BOTHER! USE BibTeX instead!

23 BibTeX BibTeX manages citations Add following to body of your doc
\bibliographstyle{type} type = style (plain, abbrv, alpha) Other styles available (see natbib) \bibliography{bib-files} bib-files are your BibTeX files with citations This command appears where you the bibliography (usually end of document)

24 Example Bib File @String{cl = "Computer Languages"}
Define string abbreviation @String{cl = "Computer Languages"} @Article{ChaitinEA-CL81, title={Register Allocation Via Coloring}, author={G.J. Chaitin and Auslander, M.A. and Chandra, A.K. and Cocke, J. and Hopkins, M.E. and Markstein, P.W.}, journal=cl, volume={6}, number={1}, pages={47--57}, year={1981} } Citation key for \cite BibTeX entry for article. Authors separated by and

25 BibTeX Examples Create document:
latex doc.tex bibtex doc Since I’m out of time, see examples in Example.tex Example.pdf Ex.bib

26 Other Resources Books Web “A Guide to LaTeX2e”, Kopka and Daly
“LaTeX: A Document Preparation System”, Lamport Web Google (tons of pages provide help on LaTeX)

27 Other Resources AucTeX - major mode for Emacs LyX - “GUI” for LaTeX Various packages Subfig, natbib, algorithms,epsfig


Download ppt "SIGNewGrad: Intro to LaTeX"

Similar presentations


Ads by Google