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

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

Guide to using 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.

Introduction to LATEX

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

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

Meeting One. Aaron Ecay. February 2, 2011

Introduction to L A T E X

Learning L A TEX. Patrick Lam

An introduction to L A TEX for students

Part - I : Short Course Typing Text

LATEX Primer. 1 Introduction (Read Me)

Intro to LaTeX Workshop

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

Introduction to L A TEX

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

Math 235: Introduction to LaTeX

Introduction to L A TEX for MCS-236

Latex Manually Set Font Size For Tables

Word - Basics. Course Description. Getting Started. Objectives. Editing a Document. Proofing a Document. Formatting Characters. Formatting Paragraphs

Learning LaTeX: The Basics

TeXnicCenter v1 Beta Frank Van Puyvlde ICT for Research K.U.Leuven

LATEX TYPESETTING SYSTEM. CAAM 519, CHAPTER 3

An Introduction to L A T E X

Absolute L A TEX Beginner

Course A, Part 1 Basic Formatting in 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.

My LaTeX Document. July 7, Introduction 2

Latex Tutorial. CIS400 Senior Design 9/5/2013

Getting started with Latex

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

Math 395 Homework #1 Due Wednesday, April 12

Getting Started with L A TEX

My Mathematical Thesis

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

Useful L A TEX Commands

1 Obtaining LyX and L A TEX

A Short L A TEX Introduction

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

An Introduction to L A T E X

An Introduction to L A TEX

Square cells: an array cooking lesson

A brief introduction to L A TEX

Outline. A Sneak Peek

An Introduction to LATEX

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

LaTeX installation guide

Introduction to Scientific Typesetting Lesson 1: Getting Started

PRISM Introduction to L A TEX

Creating a Template in WordPerfect

Formatting with LaTeX

Touring the Mac S e s s i o n 4 : S A V E, P R I N T, C L O S E & Q U I T

INSTALLING AND USING L A TEX

Introduction to MCS 220 and L A TEX

Creating Word Outlines from Compendium on a Mac

Using Word 2016: A Quick Guide

EXCEL BASICS: MICROSOFT OFFICE 2007

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.

Student Learning Service: Introduction to Latex

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

Getting Started With L A TEX

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

Written & Oral Presentation: Computer Tools

LAT E X week 2: Basics for Writing a Document

Homework # (Latex Handout) by Laura Parkinson

An Introduction to L A TEX

Math 291: Lecture 2. Presented by Prof. James for Prof. Fagerstrom

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

An Interactive Introduction to L A TEX

FileNET Guide for AHC PageMasters

Basic L A TEX. what is LaTeX?

Editing Documents on Your Mac (Part 1 of 3) Review

Lecture 1: Short summary of LaTeX basics

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

Imagery International website manual

Getting Funky: Headers, Tables, Abstracts etc.

FileNET Guide for AHC PageMasters

Site Owners: Cascade Basics. May 2017

You have to start somewhere, right?

How To Get Your Word Document. Ready For Your Editor

EXCEL BASICS: MICROSOFT OFFICE 2010

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

L A TEX for Psychological Researchers

Get comfortable using computers

WORD PROCESSING ASSIGNMENT # 1 ~ FILENAME: FONTS

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

Save Forum Messages will be sent and Pages will be completed by pressing this Save button.

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

Typesetting in wxmaxima

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

Word for Research Writing I: Text and Structure

Microsoft Word 2016 LEVEL 1

Lab 2. CSE 3, Summer 2010 In this lab you will learn about file structures and advanced features of Microsoft Word.

Style Guide. Lists, Numbered and Bulleted Lists are a great way to add visual interest and skimmers love them they make articles easier to read.

The Baptist College of Florida. MLA Formatting Guide

L A TEX: Online module 2

Mikkel Madsen

Introduction to LATEX

Intermediate Word by Alan Weaver

Introduction to L A TEX beamer

Transcription:

Outline UCLA Department of Statistics Statistical Consulting Center interface Working with text Tabbing and tables Figures Math and equations April 23, 2009 Installation Installing LaTeX Opening TeXShop Mac Installation. Download MacTeX, which can be found on http://www.tug.org/mactex/. LaTeX can then be accessed via the program TeXShop, which is included in this installation. Windows Installation. Download protext, which can be found on http://www.tug.org/protext/ 1. LaTeX can be accessed via TeXnicCenter, which is included in this installation. Both the MacTeX and protext downloads are very large: 1.2GB and 540MB, respectively. Finder (icon: ) Applications > TeX > TeXShop The interfaces for Macs and PCs are different, however, the LaTeX code works for both. 1 Another option: http://www.winshell.de/. (Winshell and MikTeX)

Creating a basic document Open a file. Use File > New or command-n (apple-n) to open a new document if one isn t already open. Creating a basic document Update the \title, \author, and then type a sentence above the last line, i.e. type right above \end{document}. Create a folder on the desktop and then save this file into that folder. Templates. Choose the LatexTemplate. Compiling Hit command-t or go to Typeset > Typeset. After compiling, double-click on the PDF page to magnify. Try triple-clicking... and quadruple-clicking. Files from the compile LaTeX takes the.tex document and it produces a bunch of other files. While each of these files has a purpose, only one file in addition to the original LaTeX file is of interest: the PDF. As more methods of LaTeX are used, this list of LaTeX output files might grow... but again, they (except the.tex and.pdf files) can just be ignored for the vast majority of LaTeX use.

Console When the code was compiled, two windows popped up. The console tells you what LaTeX is doing when it reads (compiles) the document. If you ve made an error (or just did something LaTeX doesn t like), the console will tell you. If the error is critical, LaTeX will stop compiling: Errors are inevitable Errors are inevitable with LaTeX, and they are common. To help identify errors, it is recommended that you compile frequently. At first, this probably means compiling every 1-2 minutes to verify your output matches what you anticipated. (You can continue working while a document compiles.) While it is always good to fix the problem immediately (hit ), you can continue compiling by hitting return on the keyboard. Common errors that will make more sense as we go along... Misspelling a command Not escaping special characters Not balancing {braces} Not balancing $ s Not balancing out beginning/ending environments (e.g. \begin{document} and \end{document}) Commenting Dual screens Return to the basic file you just created. What s with all the red (or gray in Windows)? These are comments, which is writing that will be ignored by LaTeX. Comments are made by using the percent symbol: %. In TeXShop, there is also the option to have dual screens by clicking on the icon to the right of Templates: Any text following a % on that line only will be ignored by LaTeX. This can be very useful when writing or editing a long document.

Example template Download the following zipped folder 2 to your desktop http://www.stat.ucla.edu/ david/latextemp.zip Unzip the file (on a Mac, double-click). latextemp s contents: latextemp.tex, other LaTeX files from compiling, a PDF of this presentation, a file named latextemppractice.pdf, and one image file, lower40.pdf. folders containing several figures and, for one figure, the R code used to produce the figure. latextemp.tex follows the rest of this presentation and is filled with examples and extra comments. Open this file now. Header section Document type Near the top of every LaTeX document is a line with the command \documentclass, which basically says what kind of document you are making. Right now we ll just use the class article. Other types of documents can also be written, such as letters (letter), presentations (beamer), or even books (book). Plenty of examples and help can be found online for these other classes. Alter [11pt] to change the default font size for the document, if desired. 2 If this URL no longer works, find the zip file on http://scc.stat.ucla.edu/ in the mini-course section. Header section Packages Packages are loaded at the start of the document. These packages contain new commands and environments or can be used to alter your document in particular ways. For example, the package amsmath is gives more equation options and fullpage formats the PDF output in different way. Outline Sections and subsections Documents are often broken up into sections and subsections, and this hierarchy will automatically be numbered by LaTeX. Many common packages are included in a LaTeX installations, however, many other packages are not (amsmath is usually included in a LaTeX installation... fullpage is not). Additional packages can be downloaded and installed, as needed (we won t cover this).

Paragraphs To end a paragraph and create a new one, do a double enter and this creates a line break. To put an extra line space between paragraphs, use the \\ command followed by a double line break in the.tex document. Indentation and space Indentation. To create an indent, use \indent, and to prevent an indent use \noindent. Indenting can be suppressed via \setlength{\parindent}{0in}. Space. To create horizontal space, use \hspace{1cm}. Similarly, follow the \\ command followed by the \vspace{0.5cm} command to create some extra vertical space. \hspace and \vspace are generally more useful in tables than in text. Playing with the font Lists Emphasize (italicize). Use the command \emph, e.g. \emph{emphasize}, to emphasize (italicize) a single word. Lists can be created via More manipulation. can also be bolded via \textbf or colored via \color. Font can be made to look typewriterish via \texttt. Font size. can also be made tiny, scriptsize, footnotesize, small, large, Large, LARGE, etc. via \tiny, \scriptsize, etc. which results in a bulleted list such as the following: Spacing Macros A couple additional examples are in latextemp.tex.

Macros Many more text alterations can be done using the Macros. Tabbing Tabbing Like in other text editors, LaTeX offers tabbing. While this environment tends to rarely be used (at least by me), it can be very useful under particular conditions. Macros offer many many options to alter text. See latextemp.tex for a brief introduction to tabbing and a few examples. Basic tables Basic tables Tables are created using the tabular environment. The {lcr} gives the alignment. The ampersands (&) are used to define when to go to the next column. Basic tables Centering and adding lines Building the table up: The \\ command tells LaTeX to start a new row. The result: Left Center Right 1 2 3 The result: Estimate Std. Error t value Pr(> t ) (Intercept) -0.2852 0.8434-0.34 0.7452 x 0.4192 0.1499 2.80 0.0266

Captions & referencing Floating table with a caption To add a caption or label, the table must be floated (i.e. add on the table environment). Then \caption can be used: Captions & referencing Referencing Tables can be dynamically referenced (many examples throughout latextemp.tex). The output: Usually a table has a number if it has a caption, e.g. Table 4. These numbers may change if more tables are added to the document, e.g. Table 4 may change to be Table 5 at a later time the user doesn t control this. Thankfully a table number can be dynamic referenced: Estimate Std. Error t value Pr(> t ) (Intercept) -0.2852 0.8434-0.34 0.7452 x 0.4192 0.1499 2.80 0.0266 Table: A regression summary. The table is numbered when a caption is added in the article document class. \label{regresstable} labels the table and then this table can be referenced using the LaTeX code Table \ref{regresstable}. xtable Using the R package xtable Inside R: > library(xtable) # may need install.packages( xtable ) > x <- 1:9 > z <- rnorm(9) > y <- x/7 + z 2 + rnorm(9) > xtable(summary(lm(y x+z))) [... output that can be copied/pasted into LaTeX...] R output directly copied/pasted into LaTeX: Estimate Std. Error t value Pr(> t ) (Intercept) -0.1563 0.6243-0.25 0.8107 x 0.1094 0.1145 0.96 0.3760 z 2.6170 0.4308 6.08 0.0009 Figures Basic figures A couple of the most basic examples of how figures can be added using the \includegraphics command. The first file is stored in the same folder as the LaTeX file while the second is a couple folders away. The files and folder names used should have no spaces. The [height=1.0in] is an optional argument to control the figure size.

Figures Figure centering Figures Adding a caption and referencing Just like tables, a figure can be centered: Just like in the floating table environment, a floating figure can have a caption and reference. How does the second method look similar to the floating tables? (This is a floating figure.) Just like with tables, the \label command must come after the \caption command for the reference to work properly. Keeping organized Keeping organized Math in text Inserting math into text Some tips to keeping organized when using LaTeX: Do not include several LaTeX documents in a single folder. When choosing a \label name for a figure, have it match the figure file name. Organize figure files into folders. If you use code to produce a figure, save it to the same folder as the figure and with the same name (but a different extension, of course). Remember, no spaces in file or folder names. LaTeX makes it easy to add Greek letters like α, ζ, µ, etc. into text. In the same way, equations can be added easily as well: y = x 3, z j, x 1 + + x n. It does take some practice to get used to writing math in LaTeX but, with practice, it becomes second nature. It is also sometimes easy to generalize. For instance, look at how to create α above: $\alpha$. How do you think β would be created?

Math in text Equation array Math in text Equation referencing While math inside text is nice, sometimes the equations are long and should be on their on lines. In such a case, use the eqnarray or eqnarray environment: The result in LaTeX for eqnarray : Just like tables and figures, equations can also be referenced. Use eqnarray (no asterisk) to make the equation be a numbered equation: 0.5 k = k=0 1 1 0.5 = 2 (1) \label{powerseries} can be put inside the equation array and then be referenced via \ref{powerseries}. 0.5 k = k=0 1 1 0.5 = 2 Math in text Matrices Matrices also can be made in LaTeX: ( 4 1 19 3 8 8 ) Math in text LaTeX and Matrix Panels Since it is a little difficult to learn all the math syntax, a good place to look for the proper syntax (using a click interface) is to the LaTeX and Matrix Panels: The code: The syntax for an array is the same as for tabular (a table). The Matrix Panel is especially useful since matrices can require a lot of writing.

Examples Diverse possibilities LaTeX has a lot of power to do diverse tasks: Chemistry figures Circuits Feynman diagrams Musical scores Crossword puzzles Sudoku puzzles These different applications require packages that are generally not included in a basic download of LaTeX but that can typically be downloaded at no cost. Resources Resources Online help: http://info.stat.ucla.edu/grad/ links to many useful sites http://forums.stat.ucla.edu/?5 online forum help A good resource in book format: Guide to LaTeX, by Helmut Kopka and Patrick W. Daly A document that can be used to find LOTS of symbols (4MB): www.ctan.org/tex-archive/info/symbols/comprehensive/symbols-a4.pdf The ability to make elegant documents and figures is one of LaTeX s major draws. It offers users nearly unlimited control of their documents (even though it might feel a bit out of control at first). Survey Survey Practice Try this #1 Please take the time to complete a survey about this mini-course: Produce the following result: http://scc.stat.ucla.edu/survey Your feedback is greatly appreciated. Some examples may be utilized in latextemp.tex.

Practice Try this #2 Using the image in latextemp/normalplots/lower82/, produce the following plot. Make it 0.8 inches tall, center it, add a caption, and add a reference. Be sure to write a sentence that references the Figure and compile your LaTeX document twice so the reference works. Practice Try this #3 Produce the following result using the eqnarray environment: 82% (0.82) 18% (0.18) Some examples may be utilized in latextemp.tex. 60.1 63.4 66.7 70 73.3 76.6 79.9 Feel free to utilize examples in latextemp.tex or to use the LaTeX Float Figure template.