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

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

Mikkel Madsen

Latex Tutorial. CIS400 Senior Design 9/5/2013

An Introduction to LATEX

LaTeX A Tutorial. Mohsen Alimomeni, 2010

Introduction to MCS 220 and L A TEX

Guide to using L A TEX

L A TEX for Psychological Researchers

An introduction to L A TEX for students

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.

Course A, Part 1 Basic Formatting in 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 Tutorial. 1 Introduction. 2 Running L A TEX. J. E. Rice. May 2010

Using L A TEX Tom Edgar

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

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

Become a L A TEX Guru

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

David Helmbold, October 2005, Revised October 2007

Introduction to L A TEX

Learn how to [learn] LATEX

Introduction to L A TEX for MCS-236

1 Obtaining LyX and L A TEX

Introduction to LaTeX. Paul Fodor Stony Brook University

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

Getting started with Latex

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

Introduction to L A TEX

Assessments for CS students:

An Introduction to L A TEX

Math 235: Introduction to LaTeX

Meeting One. Aaron Ecay. February 2, 2011

Getting Started with L A TEX

COMS 6100 Class note

Effective Programming Practices for Economists

L A TEX for Psychological Researchers

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

Learning LaTeX: The Basics

LaTeX. Information Literacy II EN(IL2) Course

Introduction to LATEX

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

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

Helen Cameron. A Brief Overview of LATEX

Introduction to L A T E X

Introduction to Scientific Typesetting Lesson 1: Getting Started

A brief introduction to L A TEX

Typing Mathematics. Darrin Doud

A Short L A TEX Introduction

Learning L A TEX. Patrick Lam

L A TEXInstallation and Introduction

A Grasshopper s Approach to L A TEX

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

MATLAB for the Sciences

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

Typesetting in wxmaxima

Helen Cameron. A Brief Overview of LATEX

Outline. A Sneak Peek

Introduction to L A TEX

Introduction to L A TEX

Student Learning Service: Introduction to Latex

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

simpletex Documentation

Mikkel Madsen

Basic L A TEX. what is LaTeX?

LATEX Primer. 1 Introduction (Read Me)

Intro to LaTeX Workshop

Written & Oral Presentation: Computer Tools

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

L A TEX - First Class

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

WYSIWYG Systems. CSCM10 Research Methodology Lecture 4 (11/2/16): A Taster of L A TEX WYSIWYM. Advantages/Disadvantages of WYSIWYG Systems

An Introduction to LATEX

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

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

Math 395 Homework #1 Due Wednesday, April 12

L A TEX E Here s the example of a X

A quick guide to L A TEX

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

Absolute L A TEX Beginner

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

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

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

A Brief Introduction to L A TEX

What is T E X? T E X and L A T E X Document preparation tools. Setting and casting type. What Knuth was setting. Setting and casting type

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

Typesetting with TEX

Introduzione a LaTex. Fabrizio Messina

Homework # (Latex Handout) by Laura Parkinson

CSCM10 Research Methodology A Taster of L A TEX

LaTeX is essentially a markup language

Introduction to Math in LaTeX

Formatting with LaTeX

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

COMP496/901: Academic Presentation and Writing Skills Using LaTeX


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

Teacher Activity: page 1/9 Mathematical Expressions in Microsoft Word

Dec. 27 th, 2010 University of Isfahan

Transcription:

How to L A TEX George Wong, David Mykytyn 6 October 2016 1 What is L A TEX? Used in textbooks, journal/conference articles, and lab reports! You provide the material and L A TEX renders according to typographical conventions &c. Not a WYSIWYG (what you see is what you get) editor! Initial release 1985 by Leslie Lamport Lamport TEX. TEX originally from Donald Knuth in 1978. 1 TEX should be pronounced as tech in technical. 2 L A TEX rendering tools In ye olde days, used the tex command from the command line produced postscript.ps file. Now straight to.pdf with many tools! OSX TeXworks MacTeX Windows Linux MiKTeX Google is your friend! Personally I use vim (but you can use any text editor) with pdflatex. 1 Knuth says to pronounce his name Ka-NOOTH. See http://www-cs-faculty.stanford.edu/~uno/faq.html 1

Alternatively, use an online service like https://www.overleaf.com/ https://www.sharelatex.com/ Some services might even allow you to collaborate (useful for partner lab reports!) 2 3 Document structure L A TEX expects a specific structure to your document. Generally, the document is in two parts, a preamble and a body. In the preamble, you tell the renderer what sort of document this is (books look different than journal articles), along with what extra packages to include, e.g., Greek or special math characters. The meat of your document everything that you want to actually show up goes in the body. Here s an example document: \documentclass[12pt]{article} \usepackage{amsmath} \usepackage{amssymb} \begin{document} \section{section the First} Lorem ipsum dolor sit amet, quo autem fugit vivendum eu, mel at lorem homero hendrerit \end{document} The first line tells the renderer to treat the document as an article and to normalize to 12 pt font. The next two lines are my personal always-use packages. They provide various math symbols and environments that I find interminably useful. The rest of the document lies with the document environment, enclosed by the \begin{ } and \end{ } tags. You can divide your document into sections, using \section { } and even \subsection and even even \subsubsection. L A TEXwill automatically number your sections and subsections for you. 2 But don t turn in the same lab report! - David 2

4 Styling In general, you try to avoid explicitly styling your document as much as possible. The renderer almost definitely knows better than you. Styling font, e.g., adding emphasis, is fine though. Product Your text here! Your text here! Your text here! Code \emph{your text here!} \textbf{your text here!} \underline{your text here!} When it s absolutely necessary, you can add spaces, carriage returns, and page breaks Effect Code Narrow space \, Em-width space \ followed by space Wide space \; Backwards space \! Single line break / carriage return \\ Four-line break \vspace{4em} Page break \vfill Fill extra horizontal space \hfill You ve noticed by now that commands seem to be preceded by the backslash \ character. The backslash is called an escape character. Using it lets the compiler know that it should treat the following characters a part of a command as opposed to normal text. 5 Labels Labels allow you to reference parts of the document (such as images / equations) by number without requiring you to keep a list yourself. Using this is very simple. Let s say I want to refer to the following equation. z 2 = 1 (1) Inside of my equation section I have written \label{eq:circle} 3. Now when I want to reference equation 1, I simply write \ref{eq:circle} and LaTeX will automatically put in the correct number. This works even as you change and add equations before and after the one you want to reference, meaning you don t have to update your numbers. Due to a quirk 3 Using prefixes is optional, but often useful 3

of how LaTeX is programmed 4, you must run LaTeX twice in order for the numbers to be filled in properly. (Some software will automatically do this for you.) 6 Math mode Equations are written in a special math mode In math mode, there are extra commands that work to produce mathematical symbols, for instance $\Gamma \pm \gamma$ will produce Γ ± γ, or whatever combinations your heart desires. Notice the $ are used to encase something to be used inline. If you want to have something on a separate line, and numbered, you should use the command \begin{equation} and end it similarily. \usepackage{amsmath} \usepackage{amssymb} To get a superscript, use a carot ^, and for subscript use an underscore. Note that if there is only one character or command in the super(sub)script, than there is no need to use brackets, but if you want multiple characters to be super(sub)scripted, you have to encase them in curly-brackets. e.g. 10 10100 which is produced by $10^{10^{100}}$ \sqrt 1 + x 2 e x 2 0 \int 2 dx Note also \iint and \iiint provide double and triple integrals respectively. special sequences sin You shouldn t write out sin or etc., instead you should use the provided functions \sin{...} and same for other common functions such as exp, log, or whatever. Styling fractions as x over y can be done with the \frac and \dfrac commands. The form of each command is \frac{x}{y} where x is what you want to appear in the numerator and y is what you want to appear in the denominator. The latter of the two, \dfrac puts the renderer into display mode, which generally expands the fraction, making the text larger. Compare 4 It is a one-pass compiler 4

x y vs x y The version on the left uses the \frac command; the version on the right uses \dfrac. \left and \right If you want to make sure that your parenthesis are scaled appropriately to whatever sized math is encased ) in them, use \left( and \right). For an example, see ( 100 n=0 2 1 n 2 ) versus ( 100 n=0 2 1 n 2 \mathrm This puts the text into roman font, i.e. not italics. You should definitely use this, for instance with units, which are not variables and therefore should not be in italics! (It s often useful to define a macro units that applies roman font) \mathbb This is used for fancy and useless mathematician symbols like N and Q or R 7 \mathcal Not sure how much this will come up, but in case it does, it looks like M or for instance the Laplace transform is often written as L(f(x)) putting spaces in math mode \mathfrak Perhaps even less useful but in case you want to talk about Lie algebras G or Lie groups g Aligning equations is often useful. This is done in the align environment. Put an & where you want the equations to be lined up at. An example: f(x) = x 3 + x 2 + x + 1 (2) f (x) = 3x 2 + 2x + 1 (3) f (x) = 6x + 2 (4) f (x) = 6 (5) Here are some useful symbols you may want: \times, ; \gg ; \neq ; \sim ; \approx ; \implies = \cdot \vec{x}, \hat{x} xˆx and so on and on. See next section if you can t find the symbol you need! 7 Detexify This tool deserves its own section Detexify http://detexify.kirelabs.org/ (It is very cool and self-explanatory) 5

8 Lists Lists are easy in LaTeX. For instance to get: Use: 1. Start 2. Middle 3. End (a) MiddleA (b) MiddleB \begin{enumerate} \item Start \item Middle \begin {enumerate} \item MiddleA \item MiddleB \end{enumerate} \item End \end{enumerate} You can also use \begin{itemize} if you want bullet points. 9 Floats Floats are a special type of environment that indicates to the renderer that the contained elements should all be displayed on one page. They should be used for things like tables and plots, which often include titles and captions that should not be spread over multiple pages. Because floats may not be able to be placed exactly where they appear in the source without breaking the flow of the document, they accept a positioning argument, which is one of h,t,b,p, indicating here, top of page, bottom of page, and special page for floats, respectively. If you include the float package, you can also use the capital H specifier which overrides all of the renderer s sensibilities and places the figure right Here. 5 5 If you find that LaTeX is ignoring where you want to place the image add an! and hopefully the typesetting gnomes will listen to you 6

A bit confusingly, floats are actually named figure in the source. Like any other section, they begin and end as \begin{figure}[h]... your source here \end{figure} 9.1 Tables Tables can be complicated to get right, but offer a ton of generality that makes them very useful once you learn. In general a table is defined first by a description of what columns there are. l is a left-justified column, and etc for c and r. Use for a vertical line. When creating the actual tables, the table is defined rows by rows, with elements seperated by an & and lines are separated by \\. If you want to add a horizontal line 6, use \hline Here is an example table code, and the result: \begin{center} \begin{tabular} { l c r } \hline 2 & 7 & 6 \\ \hline 9 & 5 & 1 \\ \hline 4 & 3 & 8 \\ \hline \end{tabular} \end{center} 2 7 6 9 5 1 4 3 8 9.2 Graphics L A TEX offers several options for adding graphics to your document. The first (and easiest) is to simply include an image file, like a bmp or png. This can be done using the \includegraphics command, formatted as \includegraphics[args]{filename} 6 George wants me to tell you that he thinks I overuse lines, and he is probably right 7

The args arguments can be used to set properties like the height=40mm or width=60mm of the image. As noted above, graphics you include should probably be within the float environment. You can mandate centering and add labels and captions to the object too, as per \begin{figure} \centering \includegraphics[height=35mm]{latex_is_cool.png} \caption{\latex is cool!} \label{fig:latexiscool} \end{figure} The second option for including an image is to draw it within a tikzpicture environment. For now, the exact mechanics of using tikzpicture is beyond the scope of this document, but see the following example for inspiration \begin{tikzpicture} \draw [black] (0,0) circle(2); \draw [black] (1.4,0) ellipse(0.2 and 1.4); \draw [loosely dashed] (0,0) -- (3.4,0); \filldraw[black] (0,0) circle (2pt); \draw [densely dotted] (0,0) -- (1.4, 1.42); \draw (0.5, 0.65) node[anchor=south] {$r$}; \draw [densely dotted, ->, xscale=0.18] (15,-0.35) arc (-20:240:1); \draw (2.5,1) node[anchor=south] {$\phi$}; \draw [densely dotted, ->] (1,0) arc (0:45:1); \draw (0.9, 0.27) node[anchor=east] {$\theta$}; \end{tikzpicture} r θ φ Figure 1: A tikz picture! 8

10 Miscellaneous 10.1 Comments Use % 10.2 How to deal with errors Fix them. 10.3 Quotations Note that quotations in LaTeX should be done with two uses of the key for left hand side and two uses of the key of the right hand side. This is because you might be used to working with smart quotes in which left and right quotations marks are done automatically for you, but in LaTeX you have to use separate marks for each quotation. (Note: In a good editor, for instance like EMACS, using the quotation key will automatically produce the correct kind if you are in LaTeX-Mode.) 10.4 Well wishes There s a lot to learn; don t be discouraged! You only need to remember a very small subset of everything in order to produce beautiful documents. Keep templates of useful document classes, look things up (@ Google How do I do X in LaTeX ), and ask questions when necessary. Learning to write with L A TEX is learning use a new skill. Keep at it and you ll be an expert in no time! 9