Abstract A quick intro by examples to the document preparation language L A TEX.

Similar documents
LATEX TYPESETTING SYSTEM. CAAM 519, CHAPTER 3

The basics of LaTeX. Cédric Buron. April 25, 2016

Introduction to L A TEX

Guide to using L A TEX

Outline. Installing LaTeX. Opening TeXShop. Intro to LaTeX. Intro to LaTeX interface Working with text Tabbing and tables Figures Math and equations

L A TEX for psychological researchers

L A TEX Primer. Randall R. Holmes. August 17, 2018

Introduction to Latex. A workshop by Dr. Ala Eshmawi

An Introduction to. Rado Ivanov CIS400 Senior Design Tutorial September 18, 2014

What is LaTeX. Is a document markup language and document preparation system for the TeX typesetting program

Math 235: Introduction to LaTeX

Become a L A TEX Guru

Latex Tutorial. CIS400 Senior Design 9/5/2013

Introduction to typesetting with L A TEX

Introduction to L A TEX

(Yet Another) Introduction to L A TEX 2ε (V3)

Meeting One. Aaron Ecay. February 2, 2011

Introduction to LATEX

Lecture 1: Short summary of LaTeX basics

Learn how to [learn] LATEX

1 Obtaining LyX and L A TEX

An introduction to L A TEX for students

L A TEX Overview. Jiayi Liu. January 31, Colorado School of Mines

Basic L A TEX. what is LaTeX?

Helen Cameron. A Brief Overview of LATEX

Formatting with LaTeX

1. Welcome. (1) Hello. My name is Dr. Christopher Raridan (Dr. R). (3) In this tutorial I will introduce you to the amsart documentclass.

Using L A TEX. A numbered list is just that a collection of items sorted and labeled by number.

L A TEX minicourse. dstowell, mag, sar, scannell,... September Typeset by FoilTEX

Introduzione a LaTex. Fabrizio Messina

An Introduction to L A TEX

L A TEX Tutorial. 1 Introduction. 2 Running L A TEX. J. E. Rice. May 2010

Introduction to L A TEX for MCS-236

Written & Oral Presentation: Computer Tools

L A TEX From The Ground Up

L A T E X FOSSEE. Department of Aerospace Engineering IIT Bombay. FOSSEE (IIT Bombay) LAT E X 1 / 58

Excellent support for mathematical formatting. Automatically downloads/installs missing components as needed Updates somewhat frequently

L A TEX and Linguistics

Learning LaTeX: The Basics

Intro to LATEX I. Aaron Erlich POLS/CSSS 510, Why LATEX? Programming Document Structure Floats Tables Lists Math

Very Short Introduction to LaTeX

An Introduction to L A T E X

Getting ready for L A TEX. Alexis Dimitriadis. Version: March 28, 2013

VERY VERY SHORT GUIDE TO LATEX

Absolute L A TEX Beginner

Research Method and Report Writing Lecture 4: An Introduction to L A TEX

Introduction to LaTeX. Paul Fodor Stony Brook University

COMP496/901: Academic Presentation and Writing Skills Using LaTeX

Mikkel Madsen

Introduction to L A TEX

Outline. A Sneak Peek

L A TEXInstallation and Introduction

An Introduction to L A T E X

Introduction to LAT E X

Latex Manually Set Font Size For Tables

THIS IS AN INTRODUCTION TO. LaTeX. Introduction to Latex. University of Minnesota, November 7, 2016

Introduction to L A T E X

Math 291: Lecture 2. Justin A James. Minnesota State University Moorhead web.mnstate.edu/jamesju/

How To Get Your Word Document. Ready For Your Editor

1 Installation (briefly)

Simple Math. Adam Dishaw 2011 September 21. Suppose you want to include some math in your documents. Just follow these basics steps:

Scientific Writing with LaTeX

Introduction to LaTex 2ε. Based on The Not So Short Introduction to LaTeX 2ε by Tobias Oetiker et al., April 2001

The ohio-etd template for Electronic Theses and Dissertations at Ohio University

Helen Cameron. A Brief Overview of LATEX

Preparing your scribe

Student Learning Service: Introduction to Latex

Tools for Scientific Writing with LAT E X. Johan Carlson

An Introduction to LATEX

LATEX Workshop. Yi Liu Chen SUNY Geneseo PRISM Math Club. February 6, Wordmark Reversed Geneseo Wordmark Style Guide 4

LaTeX A Tutorial. Mohsen Alimomeni, 2010

An Interactive Introduction to L A TEX. Part 2: Structured Documents & More. Dr John D. Lees-Miller. writel A TEX.

Learning L A TEX. Patrick Lam

Creating documents in L A TEX a basic tutorial

LATEX Primer. 1 Introduction (Read Me)

Homework # You ll want to use some LaTeX editor to edit and compile your.tex files

Style template and guidelines for SPIE Proceedings

Outline Getting started Editing. LA TE X introduction. Kyle Rawlins. February 26, 2009

Script for Interview about LATEX and Friends

Introduction to LATEX

L A TEX in the Classroom

Scientific Writing with LaTeX

An Introduction to. Andrew G. West, Jian Chang CIS400 Senior Design Tutorial September 15, 2009

Typesetting with TEX

Course A, Part 1 Basic Formatting in L A TEX

LaTeX is essentially a markup language

Assessments for CS students:

L A TEX. COMPSCI 111 / 111G Mastering Cyberspace: An introduction to practical computing. LaTeX. Development. Why?

simpletex Documentation

Introduction to Scientific Typesetting Lesson 1: Getting Started

A Beginner s guide to L A TEX for CSCA67/MATA67. Kohilan Mohanarajan

Electronic Production Guidelines

Math 395 Homework #1 Due Wednesday, April 12

LYX with Beamer and Sweave

Typing Mathematics. Darrin Doud

L A TEX for Philosophers

Using LaTex and BibTex to Write Academic Documents. Ligang He Department of Computer Science University of Warwick

The Joys of L A T E X

Introduction to MCS 220 and L A TEX

CS 189 L A TEX and Linux: Document Layout and Organization

Transcription:

Jumpstart LaTeX Bo Waggoner Updated: 2014-09-15 Abstract A quick intro by examples to the document preparation language L A TEX. 1 Overview LaTeX is essentially a programming language that, when executed, produces a document (usually a pdf). Think of it as similar to HTML in that the file you write is not the same as the end result file you see, but rather is a series of instructions for how to display that end result. 1. You write a plain text source code file myfile.tex. 2. You use LaTeX to compile this file into a document myfile.pdf. The source file uses some general style commands (e.g. sans-serif font, size 12, article format, reasonable margins) along with specific line-by-line commands (make this text italic and that text bold; put a section header here and a table there). 2 Installation 2.1 All-In-One Editors All-in-one editors help you combine the two steps I mentioned above into a single workflow. They show you the text source file and help you edit it, and also provide (for instance) a compile button that executes the command to create the pdf document. When this command finds an error or mistake, the editor might help you find the line in your file that contains the mistake and suggest fixes. etc. To get started ASAP from scratch: Mac: Install MacTeX, http://www.tug.org/mactex/. Then open up the TexWorks editor. Windows: Install protext, http://www.tug.org/protext/. Then open up the MiKTeX editor. Linux: Install TeX Live by running apt-get install texlive on the command line (substituting your package manager as necessary). Then install kile ( apt-get install kile ) and run it. If you are not in quite as much of a hurry, you might want to search around to see what your options are. The above options help you out by installing LaTeX and an editor all together. But you can always install LaTeX by itself, then look around for an editor you like. One solid choice is to install Texmaker, which is compatible with Windows, Mac, and Linux. http://www.xm1math.net/texmaker/. As a side note, let me mention Lyx, a what-you-see-is-what-you-get approach to LaTeX. Many people find it easier and/or faster and/or more convenient. However, in my opinion it is suboptimal for learning LaTeX because you don t see as clearly how the underlying plain text source code connects to the document you create, and in the long run you need to understand this to make sense of error messages or so on. But, you can find Lyx at http://www.lyx.org/. 1

2.2 Command-Line / Minimalist Approach All you need to write LaTeX is a text editor and the latex compiler tools like pdflatex. I ll give instructions here for Linux, but you should be able to adapt them to your operating system. This is how I write tex: I edit myfile.tex using vim, then on the Linux command line, execute $ pdflatex myfile.tex This produces myfile.pdf. You can install latex, including/especially the pdflatex tool, from the LaTeX project homepage: http: //www.latex-project.org/. Or on Linux, install using $ apt-get install texlive (substituting the appropriate package manager for apt-get). If you want to be sure you have almost every piece of latex you ll ever need, you can be sure to install the base, extras, and bibtex (but installation of the above should be sufficient for now): $ apt-get install texlive-full 2

3 Example 0 The file: \ documentclass [12 pt ]{ article } \ begin { document } Here s some text : Hello, World! % tell the world we love it Here s some math : $f( x) = y $. % ditto \ end { document } 3

The output: Here s some text: Hello, World! Here s some math: f(x) = y. 1 We already see some key features of LaTeX: The syntax of a command is \commandname[options]{stuff}. For instance, we could have just said \documentclass{article}, but we chose to add the option of 12pt font. Comments start with a % sign and go to the end of the line. Anything written in a comment is totally ignored by LaTeX. Math mode is surrounded by $ symbols. (When not in math mode, i.e. most of the document, it is called text mode.) 4

4 Example 1 The file: \ documentclass [12 pt ]{ article } \ usepackage { amsmath, amssymb, amsfonts, amsthm } % some nice default packages \ begin { document } \ title { Example 1} \ author { Archer Me Dees } \ date {\ today } % the command \ today inserts today s date \ maketitle % if you omit this line, the title won t appear! \ section { First Section } Let s talk about the quantity $c ^2$. I m pretty sure that \ begin { equation } c ^2 \ geq b ^2. % equation and align environments automatically enter math mode \ end { equation } In fact, my countryman showed that \ begin { align } c^2 &= a^2 + b^2 \\ &= 3^2 + 4^2 \\ &= 25 \ end { align } when $a = 3$ and $b = 4$. \ section { Second Section } In this paragraph, we notice how $n ^{ a + b}$ differs from $n^a + b $. And how $X _1$ is the same as $X _{1}$, but $X _{1 + 2}$ differs from $X_1 + 2$. Also that, in tex files, line breaks between sentences or even words or even weird whitespace don t matter. A \ emph { double } line break gives a \ textbf { paragraph } break. \ end { document } 5

The output: Example 1 Archer Me Dees February 24, 2014 1 First Section Let s talk about the quantity c 2. I m pretty sure that In fact, my countryman showed that when a = 3 and b = 4. c 2 b 2. (1) c 2 = a 2 + b 2 (2) = 3 2 + 4 2 (3) = 25 (4) 2 Second Section In this paragraph, we notice how n a+b differs from n a + b. And how X 1 is the same as X 1, but X 1+2 differs from X 1 + 2. Also that, in tex files, line breaks between sentences or even words or even weird whitespace don t matter. A double line break gives a paragraph break. 1 6

5 Example 2 The file: \ documentclass [12 pt ]{ article } \ usepackage { amsmath, amssymb, amsfonts, amsthm } \ def \ thebestsuperhero {\ textbf { Flash GORDON }} \ newcommand {\ bestin }[2]{#1 is the best superhero in #2!} \ newcommand {\ parenfrac }[2]{\ left (\ frac {#1}{#2}\ right )} \ begin { document } \ section { Using \ textbackslash def and \ textbackslash newcommand } \ label { section -of -def -and - newcommand } Facts : \ begin { enumerate } % use itemize instead of enumerate for bullet points \ item My favorite superhero is \ thebestsuperhero. \ item \ bestin { Spiderman }{ Gotham City } \ item We are currently in Section \ ref { section -of -def -and - newcommand }. \ item We will later see Equation \ ref { eqn : ab }. \ end { enumerate } \ vspace {36 pt} \ section { More Math } Here s an equation that is \ emph { labeled }: It is assigned a number, \ ref { eqn : ab}, that we can use to refer to it at any time. \ begin { equation } ( \ frac {a+b}{a} )^n \ leq e^{ nb/a}. \ label { eqn :ab} \ end { equation } Here s an unlabeled one : \[ \ left (1 -\ frac {x}{y}\ right )^n \ leq e^{n\ frac {x}{y}}. \] An array of equations that have optional labels, including Equation \ ref { eqn : rs }: \ begin { align } \ sum _{j =0}^{n -1} ar^j &= a\ left (1 + r + r^2 + \ dots \ right ) \ nonumber \\ &= a\ parenfrac {1 -r^n}{1 -r}. \ label { eqn :rs} \ end { align } An array of unlabeled equations as a Valentine s poem : \ begin { align *} x &= y &\ text {( given )} \\ y &= z &\ text {( inferred )} \\ z &= \ text { you } &\ text {( by Equation \ ref { eqn :ab })} \\ \ text { you } &\ heartsuit \ text {me }. &\ text {( Lemma in \ emph { The Heart Handbook })} \ end { align *} \ end { document } 7

The output: 1 Using \def and \newcommand Facts: 1. My favorite superhero is Flash GORDON. 2. Spiderman is the best superhero in Gotham City! 3. We are currently in Section 1. 4. We will later see Equation 1. 2 More Math Here s an equation that is labeled: It is assigned a number, 1, that we can use to refer to it at any time. Here s an unlabeled one: ( 1 x ) n e n x y. y ( a + b a )n e nb/a. (1) An array of equations that have optional labels, including Equation 2: n 1 ar j = a ( 1 + r + r 2 +... ) j=0 ( ) 1 r n = a 1 r. (2) An array of unlabeled equations as a Valentine s poem: x = y (given) y = z (inferred) z = you (by Equation 1) you me. (Lemma in The Heart Handbook) 1 One thing to note: Now that we re using references and labels (\label, \ref), we may have to compile the file twice (or possibly even more!). On the first pass, LaTeX will note all of the labels you create. On the second pass, it will fill in the references according to those labels. Another: Notice that using ( and ) in math mode results in standard-size parentheses, while \left( and \right) produce matching parentheses that expand in size as needed. 8

6 Bibliographies with Bibtex The Tex file bibexample.tex: \ documentclass [12 pt ]{ article } \ bibliographystyle { plain } \ begin { document } In spite of \ cite { gct 1994}, against the recommendation of \ cite { zd 1979}, and over the protestations of \ cite { qb 1972}, I decided to add a drum solo. \ bibliography { bibexample. bib } \ end { document } The bibliography file bibexample.bib: @article { gct 1994, author =" Johnny B. Goode and Sweet Caroline and Ruby Tuesday ", title =" How to Win and Friend Enemies Under the Influence ", journal =" Applied Microtunes ", volume ="1", issue ="1", pages ="1-1003", year ="1994" } @inproceedings {zd 1979, author =" Zeppelin, Led and Doors, The ", title =" Oops I Brought The Music But Forgot The Soul ( pt. 2)", booktitle =" Proceedings of the 200,000 th Joint Conference ", publisher =" The Human Spirit LLC ", pages ="21-24", year ="1979", } @book {qb 1972, author =" Queen and The Beach Boys ", title =" Har -Mo - Nius ", publisher =" Key of B", year ="1972" } To compile with a bibliography uses the program bibtex (which comes with LaTeX). If you re using an IDE, it should have instructions on how to do this (and it should be easy/obvious!). Like with labels, we have to run several times for LaTeX to get it all together, so on the Linux command line, I compile with: $ pdflatex bibexample.tex $ biblatex bibexample.aux # this file is created by pdflatex $ pdflatex bibexample.tex $ pdflatex bibexample.tex 9

The output: In spite of [1], against the recommendation of [3], and over the protestations of [2], I decided to add a drum solo. References [1] Johnny B. Goode, Sweet Caroline, and Ruby Tuesday. How to win and friend enemies under the influence. Applied Microtunes, 1:1 1003, 1994. [2] Queen and The Beach Boys. Har-Mo-Nius. Key of B, 1972. [3] Led Zeppelin and The Doors. Oops i brought the music but forgot the soul (pt. 2). In Proceedings of the 200,000th Joint Conference, pages 21 24. The Human Spirit LLC, 1979. 1 10

7 LaTeX Resources Here are some useful resources: Detexify: You draw a symbol, and it tells you what LaTeX command produces that symbol. http://detexify.kirelabs.org/classify.html. Tikz: package for professional diagrams/pictures. Install on Linux with apt-get install pgf or equivalent. http://www.texample.net/tikz/. 11