Introduction to La Te X David and Lucas

  • Slides: 21
Download presentation
Introduction to La. Te. X David and Lucas CS 173 Fall 2009 Written with

Introduction to La. Te. X David and Lucas CS 173 Fall 2009 Written with significant references to Oetiker et al. “The Not So Short Introduction to La. Te. X 2 e” CS 173 Fall 2009 1

(fairly) easy, (somewhat) automated typesetting does mathematical notation and does it well used in

(fairly) easy, (somewhat) automated typesetting does mathematical notation and does it well used in academic and technical fields CS 173 Fall 2009 2

History Late 1970 s -> 1989: Te. X by Don Knuth Decent typesetting by

History Late 1970 s -> 1989: Te. X by Don Knuth Decent typesetting by the authors! Same output now as in the future Low level, but powerful Frozen development Starting early 1980 s: La. Te. X by Leslie Lamport High level language (macros, really) for Te. X Easy to use! Current version is Latex 2 e CS 173 Fall 2009 3

La. Te. X as in “latex” or…? Some say LAY-teck Some say LAH-teck Some

La. Te. X as in “latex” or…? Some say LAY-teck Some say LAH-teck Some say LAY-tech (as in “Bach”) Some say LAY-tex … According to Wikipedia: Knuth says /tex/ (as in Bach) Lamport says “whatever…” CS 173 Fall 2009 4

Getting started… All you need is: La. Te. X installation with appropriate interpreters A.

Getting started… All you need is: La. Te. X installation with appropriate interpreters A. tex file (the document) Can also have: External style files Te. X editors (more on this later) CS 173 Fall 2009 5

Installation Linux Mac http: //www. tug. org/mactex/ Windows Typically comes with La. Te. X

Installation Linux Mac http: //www. tug. org/mactex/ Windows Typically comes with La. Te. X or has it easily available in the standard repositories “Te. X Live” http: //www. tug. org/protext/ This will install Mi. KTe. X, Ghostscript, and Te. Xnic. Center. Extra packages http: //en. wikibooks. org/wiki/La. Te. X/Packages/Installing_Extr a_Packages CS 173 Fall 2009 6

Editors Kile Ly. X (WYSIWYM) Te. Xnic. Center Others? (discuss on newsgroup…) CS 173

Editors Kile Ly. X (WYSIWYM) Te. Xnic. Center Others? (discuss on newsgroup…) CS 173 Fall 2009 7

Making your first La. Te. X documents 1. Start with a skeleton document 2.

Making your first La. Te. X documents 1. Start with a skeleton document 2. 3. 4. 5. Write your text Annotate the appropriate parts (math, etc) Interpret through appropriate program Fix errors or modify, and try again… Not unlike HTML or other markup languages Interpret via the provided programs: latex -> DVI pdflatex -> PDF Or built in features in your IDE. CS 173 Fall 2009 8

Structure A basic document: documentclass[11 pt, twocolumn]{article} usepackage{amsmath, graphicx} begin{document} %document contents go here

Structure A basic document: documentclass[11 pt, twocolumn]{article} usepackage{amsmath, graphicx} begin{document} %document contents go here end{document} Notice: begin and end (these define “environments”) { } and [ ] around parameters to commands Commands typically start with backslash CS 173 Fall 2009 9

Formatting Text Emphasis and size textbf{some bold text} emph{some italic text} underline{some underlined text}

Formatting Text Emphasis and size textbf{some bold text} emph{some italic text} underline{some underlined text} {large Some large text. } {Larger text. } {small Small. } Spacing Many spaces = one space Use \ for newline Hit return twice for a new paragraph newpage Quotes are done with `` and ‘ ‘ , not “ Add comments %comment text until end of line Like any language, some characters are special. For example, $ { } % cannot be written alone. Use \ or $ or … CS 173 Fall 2009 10

Organization Indenting text as a quotation (an environment!) begin{quote} A quote. end{quote} Section headings

Organization Indenting text as a quotation (an environment!) begin{quote} A quote. end{quote} Section headings section{an arbitrary name} subsubsection{an arbitrary name} CS 173 Fall 2009 11

Lists Done with an environment begin{enumerate} item some item in the list item another

Lists Done with an environment begin{enumerate} item some item in the list item another item in the list end{enumerate} Replace enumerate with itemize for nonnumbered CS 173 Fall 2009 12

Tables Another environment! Tables are tricky and have a lot of options. An example:

Tables Another environment! Tables are tricky and have a lot of options. An example: begin{tabular}{|r|l|} hline 7 C 0 & hexadecimal \ 3700 & octal \ cline{2 -2} 11111000000 & binary \ hline 1984 & decimal \ hline end{tabular} |r|l| tells how to setup and align the columns. & sets the columns See references for more details… CS 173 Fall 2009 13

Math Mode “Math mode” formats formal notation. 3+1 in normal mode will not look

Math Mode “Math mode” formats formal notation. 3+1 in normal mode will not look like 3+1 in math mode To enter inline math mode, use $ and $ When $x = 3$, $f(x, y)$ reduces to $y^2+16$. For standalone math lines, use [ and ] The equation can be expressed as follows: [ f(x) = x^2 + 4 x + 3 = (x+1)(x+3) ] CS 173 Fall 2009 14

Math Mode White space is typically ignored $f(x) = g(x)$ will be the same

Math Mode White space is typically ignored $f(x) = g(x)$ will be the same as $f( x )= g ( x )$ To put normal text in math mode, use text{} ${x in N | x text{ is an even number} }$ Some math is built in. To get all of the good stuff, add the amsmath package at the start of the document: usepackage{amsmath} CS 173 Fall 2009 15

Math Symbols, etc Subscript and superscripts: x^2 and x_2 Fractions: frac{a}{b} Radical: sqrt{x +

Math Symbols, etc Subscript and superscripts: x^2 and x_2 Fractions: frac{a}{b} Radical: sqrt{x + y} Floor and ceiling: lfloor x + y rfloor lceil x + y rceil Operators and relations: ge, le, in, subset, cap, cup, equiv, sim, rightarrow forall, exists Greek letters: lambda pi Pi Sets N, R, Z: mathbb{N} sum_{i=0}^{infty} i prod_{i = 0}^{n} i Binomial coefficient: {x choose y} And much more! See: http: //www. artofproblemsolving. com/La. Te. X/Ao. PS_L_Guide. Sym. php CS 173 Fall 2009 16

Lists of equations Aligning lists of equations is tricky (similar to tables) eqnarray uses

Lists of equations Aligning lists of equations is tricky (similar to tables) eqnarray uses & alignment hooks into the equations Don’t need to use $ $ or [ ]. Already in math mode. begin{eqnarray} f(x, y) &=& x + y \ &=& 4 x - 3 x + y \ &=& y (4 frac{x}{y} - 3 frac{x}{y} + 1) end{eqnarray} Use eqnarray* to suppress numbering CS 173 Fall 2009 17

Images usepackage{graphicx} includegraphics[height=50%, width=50%]{filename. png} CS 173 Fall 2009 18

Images usepackage{graphicx} includegraphics[height=50%, width=50%]{filename. png} CS 173 Fall 2009 18

Labels and references Use labels and references to automatically insert reference numbers: subsection{The first

Labels and references Use labels and references to automatically insert reference numbers: subsection{The first subsection} label{arbitrarylabel} Some text. subsection{Next subsection} The previous subsection was ref{arbitrarylabel}. And for equations: begin{equation} E = mc^2 label{einstein} end{equation} CS 173 Fall 2009 19

And more… Fonts, spacing, margins, bibliographies, footnotes, book formatting, chapters, … La. Te. X

And more… Fonts, spacing, margins, bibliographies, footnotes, book formatting, chapters, … La. Te. X is powerful! See final slide or google around for help… CS 173 Fall 2009 20

Resources For Te. X (not needed in this course): La. Tex project page http:

Resources For Te. X (not needed in this course): La. Tex project page http: //www. tug. org/ http: //www. latex-project. org/ Not so short introduction to La. Te. X: http: //ctan. tug. org/tex-archive/info/lshort/english/lshort. pdf La. Te. X information on our website: http: //www. cs. uiuc. edu/class/fa 09/cs 173/ Google is your friend… CS 173 Fall 2009 21