Guide to using L A TEX

Similar documents
Course A, Part 1 Basic Formatting in L A TEX

Learning LaTeX: The Basics

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

LaTeX A Tutorial. Mohsen Alimomeni, 2010

Math 235: Introduction to LaTeX

Introduction to MCS 220 and L A TEX

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

1 Obtaining LyX and L A TEX

L A TEX for Psychological Researchers

Homework # (Latex Handout) by Laura Parkinson

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

Introduction to L A TEX for MCS-236

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

A Brief Introduction to L A TEX

Meeting One. Aaron Ecay. February 2, 2011

An Interactive Introduction to L A TEX. Part 1: The Basics. John Lees-Miller. writel A TEX

An Interactive Introduction to L A TEX

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

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

An Introduction to LATEX

Getting started with Latex

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

Become a L A TEX Guru

Introduction to L A TEX


An introduction to L A TEX for students

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

Introduction to LATEX

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

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

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

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

NCSU Linguistics Eric Wilbanks & Jeff Mielke. November 21, An open-source typesetting language used for document mark-up

L A TEX examples. a b c a b c b b a c b c c b a. This table was typeset with the following commands.

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

Math 395 Homework #1 Due Wednesday, April 12

TUTORIAL 5: LIST ENVIRONMENTS. 1. Welcome. (1) Hello. My name is Dr. Christopher Raridan (Dr. R).

L A TEXInstallation and Introduction

A Short Introduction to L A TEX

Latex Tutorial 1 L A TEX. 1.1 Text

Latex Tutorial. CIS400 Senior Design 9/5/2013

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

Introduction to L A TEX

L A TEX for Psychological Researchers

Basic L A TEX. what is LaTeX?

Getting started General Tables Figures Math Wrap up. UCLA Department of Statistics Statistical Consulting Center. LaTeX Bootcamp

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

LAT E X week 2: Basics for Writing a Document

Typing Mathematics. Darrin Doud

Helen Cameron. A Brief Overview of LATEX

Absolute L A TEX Beginner

L A TEX. The Logo. Introduction to L A TEX. Overview. Primary Benefits. Kinds of Documents. Bill Slough and Andrew Mertz

Learn how to [learn] LATEX

A Very Brief Introduction to L A T E X MAT 3535

COMP496/901: Academic Presentation and Writing Skills Using LaTeX

Introduction to Latex. A workshop by Dr. Ala Eshmawi

Introduction to LaTeX. M&S Talk Series August 16 th, 2016 AH Sheikh

simpletex Documentation

How to L A TEX. George Wong, David Mykytyn. 6 October 2016

LATEX Primer. 1 Introduction (Read Me)

1 Different Document Classes

Learning L A TEX. Patrick Lam

Using L A TEX Tom Edgar

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

Introduction to Math in LaTeX

Introduction to L A TEX

L A TEX Workshop. Don Brower

Helen Cameron. A Brief Overview of LATEX

Introduction to L A TEX

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

Basics. Options. Commands

Part - I : Short Course Typing Text

My Mathematical Thesis

L A TEX and Basic Text Editing

A Brief Introduction to LaTeX

Intro to LaTeX Workshop

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

Introduction to L A TEX

INSTALLING AND USING L A TEX

TUTORIAL 10: ARRAYS AND MATRICES. 1. Welcome. Hello. My name is Dr. Christopher Raridan (Dr. R). I want to welcome you to the L A TEX Tutorial Series.

Introduction to LAT E X

A Beginner s Guide to LATEX. Last Revised: August 21, 2013

Assessments for CS students:

Introduction to L A TEX beamer

Getting Started with L A TEX

A Short L A TEX Introduction

Typesetting in wxmaxima

Effective Programming Practices for Economists

Formatting with LaTeX

Introduzione a LaTex. Fabrizio Messina

An Introduction to LATEX

The Name of the Game. An Introduction to LATEX. Why L A TEX? The Name of the Game

Lecture 1. MA2730: Analysis I. Lecture slides for MA2730 Analysis I. Study and Assessment Components. MA L A TEX: topics for Lecture 1

Student Learning Service: Introduction to Latex

EGR 53L - Spring 2011

Workshop: A Simple Introduction to L A TEX

Not-So-Frequently Asked Questions for L A TEX

Useful L A TEX Commands

To create, upload, share, or view shared files through Google Apps, go to Documents in the black bar above.

Introduction to L A T E X

Transcription:

Guide to using L A TEX Andrew Stevens, UC Berkeley 1 What is L A TEX, and why use it? L A TEX (pronounced LAH-tekh or LAY-tekh) is a language and document preparation system for typesetting. L A TEX is widely used in several academic disciplines where authors frequently typeset mathematical expressions such as in mathematics, economics, and physics. For instance, L A TEX makes it relatively easy to write even complicated equations like the one below (taken from one of my actual research papers in grad school): ln(k r ) = δ 0 + δ 1 + δ 3 g g={q,qf} + δ 5 ln(y r ) }{{} factor income effect (ˆθgr ˆθg ) ln(p gr ) }{{} quinoa regional tastes wealth effect [ ˆθg + z g ( p r, y r P r g, Z r )] } {{ } reallocation effect + δ 2 g\{q,qf} (ˆθgr ˆθg ) ln(p gr ) }{{} non-quinoa regional tastes wealth effect ( ln(p gr ) + δ 4 Jgr J ) r ln(pgr ) } {{ } standard wealth effect + δ 6 s gr J gr ln(s gr ) + ζ r Unlike programs such as Microsoft Word where what you see is what you get (WYSI- WYG), L A TEX is written like computer code and compiled into a final document where the program automatically typesets the contents. Because L A TEX automatically typesets your content into a final document, it is sometimes called a program where what you want is what you get (WYWIWYG). Who should use L A TEX? That depends on what you need to do. If you expect to pursue an academic career in a field that uses a lot of math, it is definitely worth learning. If you never want to take a derivative again after this course, you probably don t need it. However, once you learn how to use L A TEX, it is a very flexible language. You can use it to write problem set solutions, articles, essays, letters, and even books. This document itself is written in L A TEX. 2 Getting started: choose a L A TEX editor To use L A TEX, you will need to download and install an application that will allow you to compose and compile your documents. There are many different options, each with different strengths and weaknesses. For the purposes of someone just starting out using L A TEX, I suggest using either TeXShop (Mac) or texworks (Windows and Mac). I use and am most 1 g

familiar with TeXShop, but the fundamentals covered in this document should apply to both these applications. You can download TeXShop at http://pages.uoregon.edu/koch/texshop/index.html and can download texworks at https://code.google.com/p/texworks/. (If you are reading this document as a PDF on a computer, note that these urls are click-able. This is just one of the many cool things you can do with L A TEX.) Once you have a L A TEX editing application installed on your computer, you are ready to start composing documents. The basic file-type you will use is the.tex file-type. A.tex file is basically a blank slate where you will write your L A TEX code. Once you ve finished writing your.tex file, you will compile it to create a PDF file of your output. In the process of compiling, your editor application will create several necessary auxiliary files. So, for each unique document you create, there will be six different files (of different types) in the same folder. You should only ever need to open the.tex file or the.pdf file. 3 Setting up your.tex file The most difficult part of learning to use L A TEX is making sure your.tex file is set up the right way. In practice, once you have written one document in L A TEX, you will just copy-and-paste it to a new.tex file and replace the contents. That way, you will not need to re-write all the preamble material all over again. But for your first.tex file, there are several things you need to understand. 3.1 Document classes L A TEX can be used to create several different kinds of documents, referred to as document classes. The most common class (and the one you will use 90% of the time) is the article class. Others you may use include book, report, and letter. Finally, there is also the beamer class for creating PowerPoint-esqe presentations. This document does not cover beamer presentations, but the basics do not differ significantly from other L A TEX documents. At the top of your.tex file, the first line should read (including the backslash): \documentclass[12pt]{article} The documentclass command defines what kind of document you are writing, (in this case, article), and 12pt tells the editor how large your normal text size should be in the document. For the most part, your documents should be either 11 or 12 pt. Smaller sizes become very difficult to read. (This document is in 12pt font.) Under the documentclass line, you will include other options in your preamble. After those options, you will write a line to begin your document. At the very end of your document, you will write another line that ends the document. Only the content between those two lines will be typeset when you compile the documents. For instance: 2

\documentclass[12pt]{article} <Your preamble options go here> \begin{document} <Your content goes here> \end{document} 3.2 Packages For almost anything you want to do with L A TEX, you are going to need to use some packages that tell your compiler how to compile certain things like math variables or click-able links. To use a package, you simply include the following line in your L A TEXpreamble: \usepackage{packagename} Usually, you only really need a few packages in any given document. But since there is no cost to including many packages in your preamble, so you will probably develop a pretty long preamble over time as you keep copying and pasting your preamble from.tex file to.tex file. The packages below should be a bare minimum for any of your documents: amsfonts amsmath amssymb amstext graphicx hyperref 4 Creating content Most of your time using L A TEX will be spent creating content (such as the answers to your problem sets). The basics of creating content are straightforward, but there are several critical details that often trip up new users. This section tries to preemptively address these details. 3

4.1 Writing body text Writing text in the body of your L A TEX document is one of the easiest things to do. Just like any other word processor, you simply write sentences in your text editor. Unlike a program such as Microsoft Word, there is no need to indent paragraphs in your text editor. Simply hit the return key twice to separate paragraphs and L A TEX will automatically indent them when it compiles your document. However, putting larger vertical spaces in between paragraphs in your.tex file will not create vertical space in your final document. (Remember, L A TEX is not WYSIWYG.) If you really want to start messing around with blank spaces in your document, look up commands like \vspace{}. There are a few idiosyncrasies about writing in L A TEX that I try to address briefly here: Quotation marks: the regular quotation mark key on your keyboard will always show up as right-hand-side quotation marks in L A TEX. For instance, see how weird this looks? Instead, you can type two left-hand-side marks (in the upper-left-hand side of your keyboard) to get something that looks better, like this. Boldface, underlining, and italics: to create text that is bold, underlined, or italicized, use the commands \textbf{}, \underline{}, and \emph{} respectively. Then just write the text you want to be bolded/underlined/italicized inside the braces. Line breaks, page breaks, and white space: in addition to hitting the return button twice, you can also start a new line of text by typing two backslashes right next to each other: \\. To force a page break where L A TEX would not normally put it, you can type \pagebreak. Finally, the tilde key in the upper-left-hand side of your keyboard will give you a small amount of white space, similar to a tab in MS Word. Just type to mess around with adding this white space. Centering text: if you want to center your text, just write the following two lines in your document with the text you want centered in between them: \begin{center}, \end{center}. Important symbols: several common symbols you may want to use in your document are actually key components of L A TEX code. For instance, the dollar sign ($) toggles the math typesetting mode, and the percentage sign (%) toggles comments that will not be compiled into the final document. The ampersand (&) is another tricky symbol in L A TEX. If you want to use any of these symbols in your text like you normally would in MS Word, simply put a backslash in front of them: e.g. \$. 4.2 Typesetting math Math typesetting is one of the primary reasons (if not the primary reason) that L A TEX is so popular. In general, math type-setting is toggled by the dollar sign: $. To put an equation 4

in your body text, such as this: 2 + 2/4 = 2.5, just put one dollar sign on either end of the math expression. My code for the equation above looks like this: $2+2/4=2.5$. To set an equation centered outside your body text, use double dollar signs. For the equation below, my code looks like this: $$2+2/4=2.5$$. 2 + 2/4 = 2.5 When you don t know how to get a certain symbol in L A TEX, just Google it. Here are some common things you might use: Exponents/superscripts: use the ^ symbol on the 6 key: xˆa: x a Subscripts: use the underscore symbol: x a: x a Multi-character subscripts and superscripts: put the expression you want in brackets, such as xˆ{a+b}, x {a,b}: x a+b, x a,b Using both subscripts and superscripts, put subscripts first: x {a,b}ˆ{c+d}: x c+d a,b Square roots, use the command \sqrt{x}: x Summation signs and integration signs, use \sum and \int, respectively:, Fractions, either use \frac{a}{b} or {{a}\over{b}}: a b Primes, use an apostrophe, such as f (x) or f (x): f (x), f (x) The partial derivative symbol, use \partial: Less than or equal to (or greater than or equal to), use \leq, \geq:, Automatically sized parentheses, etc., use \left(, \right), and variations, $$\left[\left({{\left({{a}\over{b}}+c\right)-d}\over{e+f}}\right)-{{g}\over{h}}\right]$$: [(( a + c) ) ] d b e + f g h Greek letters, just add a backslash, e.g. \theta: θ Multi-line equations or systems of equations, use the \begin{align } command. Search online for more details if you are interested in using the align* environment. 4.3 Organizing your document into sections It is quite easy to organize your document into numbered sections using the \section{}, \subsection{}, and \subsubsection{} commands. The result is exactly what you see in this document. 5

4.4 Using lists or bullet points There are two primary environments you will likely use to create lists in L A TEX: itemize and enumerate. They both work the same way. For a list of bullet points, first, you write \begin{itemize}, then you create a new item with \item, and conclude the environment with \end{itemize}. The same works for a numbered list where you replace itemize with enumerate. You can also stack these environments within each other to create nestled lists. For instance: 1. Number 1 (a) Letter a (b) Letter b 2. Number 2 The code for the above list is: \begin{enumerate} \item Number 1 \begin{enumerate} \item Letter a \item Letter b \end{enumerate} \item Number 2 \end{enumerate} 5 Troubleshooting The most common problems when writing documents in L A TEX have to do with pairing dollar signs or brackets. If your document will not compile, double check to make sure you have the right number of dollar signs before and after all your mathematical expressions. Similarly, make sure you have the same number of left-hand brackets { as right-hand brackets }. Usually, your L A TEX compiler will tell you where your errors are by line number in your.tex file. Even if you cannot figure out what the error is from the error message, it should hopefully tell you where to look. Finally, it is a reality good idea to compile your document often as you are writing it. That way, if you do make an error, you have a pretty good idea of where the error is. 6 Additional resources When you have a question about L A TEX, Google is your friend. Just type the question you have and chances are someone else has already asked it (and answered it) before. For a great reference resource, try the L A TEX WikiBook at http://en.wikibooks.org/wiki/latex. It is the best place to start for most of your questions. 6