A T Introduction to L EX Benjamin Barenblat bbaren@mit.edu Student Information Processing Board Massachusetts Institute of Technology January 12, 2011 Benjamin Barenblat (SIPB/MIT) Introduction to L T EX January 12, 2011 1 / 50 A
Outline Introduction 1 Your First L A T EX Document 2 Basic Language Features 3 Mathematics 4 Specialized Applications 5 Where to Go from Here 6 Benjamin Barenblat (SIPB/MIT) Introduction to L T EX January 12, 2011 2 / 50 A
Introduction What is L A T EX? Figure: Donald Knuth in 2005. Source: Wikimedia Commons. Benjamin Barenblat (SIPB/MIT) Introduction to L T EX January 12, 2011 3 / 50 A
Introduction What is L A T EX? Figure: The Art of Computer Programming. Source: MSDN. Benjamin Barenblat (SIPB/MIT) Introduction to L T EX January 12, 2011 4 / 50 A
Introduction What is L A T EX? Figure: The T EX logo. Benjamin Barenblat (SIPB/MIT) Introduction to L T EX January 12, 2011 5 / 50 A
Introduction What is L A T EX? \ newif \ ifFPD@overflow \ newdimen \ FBD@denom \ def \ f p d i v i d e #1#2 { % \ FPD@overflowfalse \ i f d i m \ AbsValD#2 < 1 \ p@ \ begingroup \ FBD@denom \ i f d i m #2 < \ z@ −\ f i 5000#2 % \ l e t \ next \ @empty \ i f d i m \ AbsValD#1 > \ FBD@denom \ def \ next { % \ FPD@overflowtrue \ debug 2 { Overflow d i v i d i n g \ the #1 by \ the #2 − > i n f } % #1=5000 \ p@ } % \ f i \ i f d i m \ AbsValD#2 < .001 \ p@ \ i f d i m \ AbsValD#2 < .001 \ p@ \ def \ next { % \ FPD@overflowtrue \ debug 2 { Overflow d i v i d i n g \ the #1 by \ the #2 − > 0 } % #1=0 \ p@ } % \ f i \ f i \ expandafter \ endgroup \ next \ f i Figure: Some T EX code. Source: The Lone T EXnician. Benjamin Barenblat (SIPB/MIT) Introduction to L T EX January 12, 2011 6 / 50 A
Introduction What is L A T EX? Figure: Leslie Lamport in 2004. Source: Wikimedia Commons. Benjamin Barenblat (SIPB/MIT) Introduction to L T EX January 12, 2011 7 / 50 A
Introduction What is L A T EX? \ section { Problem 4 } \ begin { enumerate } \ setcounter { enumi }{ 24 } \ item \ begin { enumerate } \ item $ W $ i s the i n t e r i o r volume of a half − p a r a b o l o i d opening i n the $ +z $ d i r e c t i o n , truncated on the top by $ z = 4 − y ˆ2 $ , which l o o k s a b i t l i k e the r o o f of a greenhouse , and truncated on the bottom by the $ xy $ plane . The p a r a b o l o i d has equation $ z = xˆ2 + 3y ˆ2 $ , and i t s shadow i n the $ xy $ plane i s $ x ˆ2/4 + yˆ2 \ l e 1 $ . \ item The a p p r o p r i a t e i n t e g r a l i s \ begin { a l i g n } \ i n t 0ˆ1 \ i n t {− 2 \ sqrt { 1 − y ˆ2 }} ˆ { 2 \ sqrt { 1 − y ˆ2 }} \ i n t { xˆ2+3yˆ2 } ˆ { 4 − yˆ2 } \ l e f t ( xˆ3 + yˆ3 \ r i g h t ) dzdxdy . \ end { a l i g n } Figure: Some L A T EX code. Benjamin Barenblat (SIPB/MIT) Introduction to L T EX January 12, 2011 8 / 50 A
Introduction What is L A T EX? Figure: The L A T EX logo. Benjamin Barenblat (SIPB/MIT) Introduction to L T EX January 12, 2011 9 / 50 A
Introduction What is L A T EX? What is L A T EX? L A T EX is a sophisticated document preparation system and desktop publishing utility. L A T EX has . . . Footnotes and endnotes Bibliography support Reference tracking Stylistic uniformity Crazy algorithms However . . . L A T EX is not a word processor! Benjamin Barenblat (SIPB/MIT) Introduction to L T EX January 12, 2011 10 / 50 A
Introduction What is L A T EX? What is L A T EX not? L A T EXis a programming language, not a word processor. L A T EX will not . . . Spell-check your documents Give you complete control over the way your document looks Let you see your document while you are writing it Core L A T EX philosophy: You take care of writing; we’ll take care of presentation. Humans write text. Computers figure out how to display the text. Benjamin Barenblat (SIPB/MIT) Introduction to L T EX January 12, 2011 11 / 50 A
Introduction Why should I use L A T EX? Why should I use L A T EX? Sometimes, presentation gets in the way of content. Example: underlining vs. italics Word processor way: set italics and/or underlining each time L A T EX way: tell L A T EX to emphasize ; set what that means later Example: journal article / thesis Word processor way: risk accidentally modifying provided template L A T EX way: write your text, let L A T EX worry about layout Benjamin Barenblat (SIPB/MIT) Introduction to L T EX January 12, 2011 12 / 50 A
Introduction Why should I use L A T EX? Why should I not use L A T EX? Generally slower (exception: mathematics) Lack of complete control Benjamin Barenblat (SIPB/MIT) Introduction to L T EX January 12, 2011 13 / 50 A
Your First L A T EX Document Your first L A T EX document 4 basic steps 1 Write a .tex file using your favorite text editor 2 Typeset using L A T EX or PDFL A T EX 3 Preview the result using xdvi or xpdf (or Acrobat Reader or Evince) 4 (optional) Convert the result to PostScript and print Benjamin Barenblat (SIPB/MIT) Introduction to L T EX January 12, 2011 14 / 50 A
Your First L A T EX Document Writing a .tex File 1. Write a .tex file hello.tex \ documentclass { a r t i c l e } \ begin { document } Hello , world ! \ end { document } Benjamin Barenblat (SIPB/MIT) Introduction to L T EX January 12, 2011 15 / 50 A
Your First L A T EX Document Typesetting 2. Typeset using L A T EX In a terminal: $ cd path / to / f o l d e r / c o n t a i n i n g / your /. tex / f i l e $ l a t e x h e l l o . tex Benjamin Barenblat (SIPB/MIT) Introduction to L T EX January 12, 2011 16 / 50 A
Your First L A T EX Document Typesetting 2. Typeset using L A T EX Result: This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009) entering extended mode (./hello.tex LaTeX2e <2009/09/24> Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh yphenation, german-x-2009-06-19, ngerman-x-2009-06-19, ancientgreek, ibycus, ar abic, basque, bulgarian, catalan, pinyin, coptic, croatian, czech, danish, dutc h, esperanto, estonian, farsi, finnish, french, galician, german, ngerman, mono greek, greek, hungarian, icelandic, indonesian, interlingua, irish, italian, ku rmanji, latin, latvian, lithuanian, mongolian, mongolian2a, bokmal, nynorsk, po lish, portuguese, romanian, russian, sanskrit, serbian, slovak, slovenian, span ish, swedish, turkish, ukenglish, ukrainian, uppersorbian, welsh, loaded. (/usr/local/texlive/2009/texmf-dist/tex/latex/base/article.cls Document Class: article 2007/10/19 v1.4h Standard LaTeX document class (/usr/local/texlive/2009/texmf-dist/tex/latex/base/size10.clo)) No file hello.aux. (./hello.aux) ) Output written on hello.dvi (1 page, 232 bytes). Transcript written on hello.log. Benjamin Barenblat (SIPB/MIT) Introduction to L T EX January 12, 2011 17 / 50 A
Your First L A T EX Document Previewing 3. Preview using xdvi New files! hello.aux hello.dvi hello.log hello.dvi $ xdvi h e l l o . dvi Benjamin Barenblat (SIPB/MIT) Introduction to L T EX January 12, 2011 18 / 50 A
Your First L A T EX Document Previewing 3. Preview using xdvi Result: Benjamin Barenblat (SIPB/MIT) Introduction to L T EX January 12, 2011 19 / 50 A
Your First L A T EX Document Printing 4. Convert to PostScript and print Converting to PostScript $ dvips − t l e t t e r − o h e l l o . ps h e l l o . dvi Printing Don’t run this command right now! $ l p r − Pprintername h e l l o . ps Benjamin Barenblat (SIPB/MIT) Introduction to L T EX January 12, 2011 20 / 50 A
Your First L A T EX Document When L A T EX Complains When L A T EX complains Overfull/underfull hbox L A T EX couldn’t make your text fit nicely on one line. Overfull/underfull vbox L A T EX couldn’t make your text fit nicely on a page. Runaway argument You forgot to close a brace. Solution 1 Type x and hit enter 2 Fix the error 3 Re-run L A T EX Benjamin Barenblat (SIPB/MIT) Introduction to L T EX January 12, 2011 21 / 50 A
Basic Language Features Sample document 1 “Synthesizing Congestion Control Using Replicated Archetypes” Generated by SCIgen, the automatic computer science paper generator pdos.csail.mit.edu/scigen/ Benjamin Barenblat (SIPB/MIT) Introduction to L T EX January 12, 2011 22 / 50 A
Basic Language Features Commands Declarations and environments Declarations . . . Are stated once Take effect until further notice Can be constrained using curly braces Example: \ documentclass Environments . . . Have corresponding \ begin and \ end declarations Apply formatting to their contents Example: \ begin { document } / \ end { document } Benjamin Barenblat (SIPB/MIT) Introduction to L T EX January 12, 2011 23 / 50 A
Basic Language Features \ documentclass The \ documentclass declaration \ documentclass tells L A T EX what basic document template to use. Other templates (“classes”): book report letter revtex4-1 thesis beamer Benjamin Barenblat (SIPB/MIT) Introduction to L T EX January 12, 2011 24 / 50 A
Basic Language Features Structure Sectioning declarations \ part (book only) \ chapter (book and report only) \ section \ subsection \ subsubsection \ paragraph \ subparagraph \ subsubparagraph Example: \ chapter { A Mad Tea-Party } Benjamin Barenblat (SIPB/MIT) Introduction to L T EX January 12, 2011 25 / 50 A
Recommend
More recommend