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

Similar documents
An Interactive Introduction to L A TEX

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

LaTeX A Tutorial. Mohsen Alimomeni, 2010

Getting started with Latex

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

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

MATLAB for the Sciences

L A TEX for Psychological Researchers

COMP496/901: Academic Presentation and Writing Skills Using LaTeX

Introduction to L A TEX beamer

Math 235: Introduction to LaTeX

Learning L A TEX. Patrick Lam

Guide to using L A TEX

An Introduction to 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

Introduction to LATEX

L A TEX for Psychological Researchers

Introduction to MCS 220 and L A TEX

Introduction to LAT E X

An introduction. C.D. Emmery & M.M. van Zaanen. October 22, Tilburg University

Helen Cameron. A Brief Overview of LATEX

Assessments for CS students:

Intro to LaTeX Workshop

Latex Tutorial 1 L A TEX. 1.1 Text

Introduction to LAT E X

Helen Cameron. A Brief Overview of LATEX

David Helmbold, October 2005, Revised October 2007

عمادة البحث العلمي جامعة الملك سعود

1 Obtaining LyX and L A TEX

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

L A TEX Workshop. Don Brower

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

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

Homework # (Latex Handout) by Laura Parkinson

Getting Started with L A T E X for a Technical Document or Thesis

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

Began as TeX, in 1982 (Knuth). Purely a typesetting tool. LaTeX added macros, maintaining TeX as it s typesetting engine (Lamport).

LearningLatex. % This file walks you through some basic things with LaTex % Thanks to Patrick Lam and Maya Sen for letting me borrow their materials

An Introduction to LATEX

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

Introduction to LaTeX. Paul Fodor Stony Brook University

Basics. Options. Commands

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

Part - I : Short Course Typing Text

Introduction to L A TEX

Dec. 27 th, 2010 University of Isfahan

L A T E X Workshop. Bijulal D & Anu Thomas Industrial Engineering and Operations Research Indian Institute of Technology

Workshop: A Simple Introduction to L A TEX

L A TEX 101. John Gardner and Alex Yuffa. May 2, How does L A TEX work? Exercise... 4

Using L A TEX Tom Edgar

A Short Introduction to L A TEX

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 TEXInstallation and Introduction

Course A, Part 1 Basic Formatting in L A TEX

An introduction to L A TEX for students

Student Learning Service: Introduction to Latex

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

LaTeX is essentially a markup language

A Brief Introduction to L A TEX

Introduction to LaTeX. Christoph Pickl

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

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

Lecture 3-Introduction to Latex (II)

Typesetting in wxmaxima

This is the LYX Beamer Template

Introduction to L A TEX

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

EBESS and MESS Presents: Learn to LaTeX. Presented by Joshua Tambunan 13 February 2018

Introduction to L A TEX

PRISM Introduction to L A TEX

Introduction to L A TEX

Introduction to Latex. A workshop by Dr. Ala Eshmawi

PHYS-4007/5007: Computational Physics

An Introduction to L A TEX

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

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

Basic L A TEX. what is LaTeX?

Pimp your thesis: a minimal introduction to L A T E X.

A quick guide to L A TEX

Researcher Development Unit: Introduction to Latex

Latex Tutorial. CIS400 Senior Design 9/5/2013

A Short L A TEX Introduction

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

Introduction to L A TEX

A Grasshopper s Approach to L A TEX

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

Typing Mathematics. Darrin Doud

A brief introduction to L A TEX

Learning LaTeX: The Basics

An Introduction to LATEX

Introduction to LATEX

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

Introduction to L A TEX for MCS-236

Getting Started with L A TEX

Become a L A TEX Guru

LaTeX: Scientific Document Writing

L A TEX From The Ground Up

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

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

LaTeX. Information Literacy II EN(IL2) Course

Transcription:

Intro to LATEX I 1 1 POLS/CSSS 510, 2012 Intro to LATEX I 1 / 32

Outline 1 Why L A TEX? 2 Programming 3 Document Structure 4 Floats 5 Tables 6 Lists 7 Math Intro to LATEX I 2 / 32

The Complaint This sucks and is hard. What makes L A TEX better than MS Word or Open Office? Why should I bother to learn this? Intro to LATEX I 3 / 32

The Pitch There are aesthetic and non-aesthetic motivations. L A TEX is: A typesetting program = pretty (look up Knuth) Allows you to easily write mathematical and statistical tables and make them easy to read Serves as a shibboleth. It signals to other academics that you are technically savvy and highly functional with a computer It is easy to get caught up in the minutiae of L A TEX. Try not to. Use it as a tool, and embrace rather than fight the constraints. Intro to LATEX I 4 / 32

LATEX as a Computer Program L A TEX is a programming language. Like R you need to tell it which packages you are using before it tries to run your code. You see this in your default template When you run your code you are doing what in computer science is known as compiling. There are different compilers! For now, try to stick to pdflatex. This means when you save your images make them PDFs! When you use bibtex you need to compile multiple times. More on this another time Intro to LATEX I 5 / 32

Error Messages There are terminal and non-terminal compiling errors. Typical terminal errors are because you have not ended something. Hunting this down can be annoying! L A TEX error messages help. But often finding your coding errors is best done using standard debugging techniques Non-terminal errors often you will have math code outside of math mode or other such errors. In this case, your document will still compile. Beware of symbols that have meaning to L A TEX as a programming language. These can ruin compiling. Most typical is the % sign. Make sure to write \%!. If you think a symbol may be causing problems, check online Intro to LATEX I 6 / 32

Doc Basics The backslash ( \ ) tells L A TEX to expect computer code rather than regular text Your script will be divided up into three basic sections 1 Preamble 2 Content 3 Postscript (we ignore this for now) Intro to LATEX I 7 / 32

Preamble Many things can go in the preamble. For now we can think of four things. 1 Telling L A TEX the type of document you want. Generally this will be an article \documentclass{article} but it could also be a beamer or a book 2 Some basic setup that happens before your document, which tells L A TEX what packages to use This generally involves calls to \usepackage{} 3 Some other setup items like the line spacing you might want (e.g., \linespread{1.5} gives you 1.5 spacing 4 Instructions to bibtex about formatting your references. Perhaps more on this another time. Intro to LATEX I 8 / 32

Contents Documents start with \begin{document} and end with \end{document} In between, put all the wonderful thoughts you have. In the beginning beyond basic text your documents will include three basic types of code: 1 Floats which are images (often graphs) placed within your text 2 Tables which are generally of regressions but could be simple crosstabs 3 Lists which is another way of saying bullet points or ordered lists (often numbered) We will treat these in order a little later... Intro to LATEX I 9 / 32

Content Commands L A TEX has its bold and italics equivalents those these can be manipulated in a much more sophisticated way. For now, we will learn three text manipulations 1 \textbf{} which stand for bold font 2 \emph{} which stands for emphasis and in default produces italics 3 \texttt{} which stands for typewriter text and produces...well, what you think it does Try to produce I love typesetting because it helps me with data Intro to LATEX I 10 / 32

Sections L A TEX has its equivalents of headers which are sections These can be numbered or unnumbered or numbered the default is numbered. When you don t want numbers include a *. So \section{my Section} vs. \section*{my Section} You can also have different levels by adding the word sub. So you get \subsection{my subsection} Try for yourself. Intro to LATEX I 11 / 32

Intro to Floats The concept of a float comes from typesetting You want images to be places seamlessly within the text. Figure: A gull nicely floated Intro to LATEX I 12 / 32

Code Float: Code Here is the code: \begin{figure} [!h] \begin{center} \includegraphics[scale=.3]{wrapfig.png} \end{center} \end{figure} How would I make the float bigger? Or justified it to the right? Could anyone figure out how to rotate it? Can anyone go online and figure out how to cross-reference using the \label Intro to LATEX I 13 / 32

Code Float Figure: A smaller crooked gull Intro to LATEX I 14 / 32

Code Float II Here is the code for the crooked gull \begin{figure} [!h] \begin{flushright} \caption{a smaller crooked gull} \label{gull} \includegraphics[ angle = 34, totalheight=0.5\textheight] {wrapfig.png} \end{flushright} \end{figure} Intro to LATEX I 15 / 32

A Note on Float Placement The good thing about floats is we have lots of control... The bad things is that L A TEX is not that smart and often puts things in the wrong place So what do we do? After begin{figure}, we have regular non-curly braces. This tells L A TEX about the placement of the float. You can learn more about this later, but for most of your homework assignments, you want your figure exactly where the text is. One way to ensure this is with the float package \usepackage{float} and use begin{figure} [H] There are other commands as well, however.. Intro to LATEX I 16 / 32

Referencing Floats One you have labeled your floats with \label you can reference it in the text. You you do this by using the \ref command I was referring to the gull in Figure ~\ref{gull} I was referring to the gull in Figure 1 Intro to LATEX I 17 / 32

Intro to Tables As we saw, the key to tables is exporting them from R. Use apsrtable and xtable It will be useful to understand some other basic things about tables let s look at one... Intro to LATEX I 18 / 32

Sample Table Table: This is a table reporting regression results. (Intercept) -6.79-6.85 2.63 (3.24) (3.22) (0.09) education 4.19 4.14 0.09 (0.39) (0.35) (0.01) income 0.00 0.00 0.00 (0.00) (0.00) (0.00) women -0.01 (0.03) N 102 102 102 R 2 0.80 0.80 0.70 adj. R 2 0.79 0.79 0.70 Resid. sd 7.85 7.81 0.22 Intro to LATEX I 19 / 32

Sample Table \begin{table}[!ht] \begin{center} \caption{this is a table reporting regression results.} \begin{tabular}{lccc} \hline (Intercept) & -6.79 ^* & -6.85 ^* & 2.63 ^* \\ & (3.24) & (3.22) & (0.09) \\ education & 4.19 ^* & 4.14 ^* & 0.09 ^* \\ & (0.39) & (0.35) & (0.01) \\ income & 0.00 ^* & 0.00 ^* & 0.00 ^* \\ & (0.00) & (0.00) & (0.00) \\ women & -0.01 & & \\ & (0.03) & & \\ $N$ & 102 & 102 & 102 \\ $R^2$ & 0.80 & 0.80 & 0.70 \\ adj. $R^2$ & 0.79 & 0.79 & 0.70 \\ Resid. sd & 7.85 & 7.81 & 0.22 \\ \hline \end{tabular} \end{center} \end{table} Intro to LATEX I 20 / 32

Sample Table What if we want this? Table: This is a table reporting regression results. (Intercept) -6.79-6.85 2.63 (3.24) (3.22) (0.09) education 4.19 4.14 0.09 (0.39) (0.35) (0.01) income 0.00 0.00 0.00 (0.00) (0.00) (0.00) women -0.01 (0.03) N 102 102 102 R 2 0.80 0.80 0.70 adj. R 2 0.79 0.79 0.70 Resid. sd 7.85 7.81 0.22 Intro to LATEX I 21 / 32

\frametitle{sample Table} \textbf{what if we want this?} \begin{table}[!ht] \begin{center} \caption{this is a table reporting regression results.} \begin{tabular} { r r r r } \hline (Intercept) & -6.79 ^* & -6.85 ^* & 2.63 ^* \\ & (3.24) & (3.22) & (0.09) \\ \hline education & 4.19 ^* & 4.14 ^* & 0.09 ^* \\ & (0.39) & (0.35) & (0.01) \\ \hline income & 0.00 ^* & 0.00 ^* & 0.00 ^* \\ & (0.00) & (0.00) & (0.00) \\ \hline women & -0.01 & & \\ & (0.03) & & \\ \hline $N$ & 102 & 102 & 102 \\ \hline $R^2$ & 0.80 & 0.80 & 0.70 \\ \hline adj. $R^2$ & 0.79 & 0.79 & 0.70 \\ \hline Resid. sd & 7.85 & 7.81 & 0.22 \\ \hline \end{tabular} \end{center} \end{table} Intro to LATEX I 22 / 32

Key tips In MS Word and other programs we waste a lot of time making the perfect list. Particularly in the beginning, try not to fight the defaults for list environments As you get better, online help is very good with making the perfect list Intro to LATEX I 23 / 32

Itemize \begin{itemize} is L A TEX s way of saying start making a list. Add an item to a list by simply typing \item Like with floats and tables we close with \end{itemize} Try making a list Intro to LATEX I 24 / 32

Enumerate \begin{enumerate} is L A TEX s way of saying start making an ordered (often numerical) list. It works exactly like itemize, so let s add complexity... how would we make a nested list? Intro to LATEX I 25 / 32

Math Pitch Often we want to write statistical equations. How can we do this? Use very clunky field codes in Word Pay money for Word add ons Write everything by hand Use L A TEX Note that L A TEX users can (and often do) use Latex notation to write math in emails. Very handy to know because can represent almost anything without special characters (h/t Chris Adolph). Intro to LATEX I 26 / 32

Basic Math Modes There are two basic math modes In-line text mode to write that f (x) = x 2 + e 2 within a sentence L A TEX knows your are in this mode when you type a single dollar sign on either side of the questions $y = x$ Separate line mode to present an equation on a separate line y = β 0 + β 1 + β 2... + β n + ε L A TEX knows your are in this mode when you type a double dollar sign on either side of the questions $$y = x$$ Try for yourselves without using any subscripts or superscripts! Intro to LATEX I 27 / 32

Subscripts and Superscripts These will be the tools you use most often in statistics The caret ( ^) tells L A TEX you want a superscript and the underscore ( _ ) tells L A TEX you want a subscript Typing $x^2$ into L A TEX yields x 2 and $x_2$ yields x 2 How would you get x 2x? $x^{2^x}$ Try the following X e5x2 $X^{e^{5{x^2}}}$ and $a_{ij}$ and the matrix format a ij Intro to LATEX I 28 / 32

Greek For many of the characters used in math L A TEX is intuitive You need to know the name of the character and enter math mode Lowercase letters are written in all lowercase letters (e.g., $\gamma$ yields γ for uppercase letters, you need to capitalize the first letter $\Gamma$ yields Γ Try µ,ν,τ,σ,ξ,υ,ℸ Intro to LATEX I 29 / 32

More Math What if you want to include a variable named after a word, like PartyID? If you put it in an equation, it comes out in ugly spaced italics. Instead, use \mathrm{} around PartyID, like so: \begin{equation} \mathrm{votechoice}_i = \beta_0 + \beta_1 \mathrm{partyid}_i + \varepsilon_i \end{equation} VoteChoice i = β 0 + β 1 PartyID i + ε i (1) Note the use of \begin{equation} Try writing your own equation Intro to LATEX I 30 / 32

More Math Modes There are lots of different ways to show your math equations. we just saw \begin{equation} we can also have \begin{eqnarray} To make an array of equations VoteChoice i = β 0 + β 1 PartyID i + ε i (2) VoteChoice i = β 0 + β 1 PartyID i + β 2 Ethnic i + ε i (3) Intro to LATEX I 31 / 32

Feedback?? Intro to LATEX I 32 / 32