Introduction to L A TEX

Similar documents
Guide to using L A TEX

LaTeX A Tutorial. Mohsen Alimomeni, 2010

Introduction to LaTeX. Paul Fodor Stony Brook University

MATLAB for the Sciences

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

Math 235: Introduction to LaTeX

Getting started with Latex

1 Obtaining LyX and L A TEX

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

Become a L A TEX Guru

An introduction to L A TEX for students

Learning L A TEX. Patrick Lam

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

COMS 6100 Class note

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

An Introduction to LATEX

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

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

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

An Introduction to L A TEX

Dec. 27 th, 2010 University of Isfahan

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

An Interactive Introduction to L A TEX

L A TEX for Psychological Researchers

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

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

A Grasshopper s Approach to L A TEX

Learning LaTeX: The Basics

Assessments for CS students:

PRISM Introduction to L A TEX

Introduction to L A TEX

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

COMP496/901: Academic Presentation and Writing Skills Using LaTeX

L A TEXInstallation and Introduction

Outline. A Sneak Peek

Workshop: A Simple Introduction to L A TEX

Intro to LaTeX Workshop

Mikkel Madsen

Helen Cameron. A Brief Overview of LATEX

Typesetting in wxmaxima

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

Researcher Development Unit: Introduction to Latex

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

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

Learn how to [learn] LATEX

Latex Tutorial. CIS400 Senior Design 9/5/2013

Student Learning Service: Introduction to Latex

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

Helen Cameron. A Brief Overview of LATEX

A Brief Introduction to LaTeX

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

Math 395 Homework #1 Due Wednesday, April 12

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

LaTeX. Information Literacy II EN(IL2) Course

L A TEX for Psychological Researchers

Introduction to LATEX

Introduction to MCS 220 and 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

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

Workshop on LATEX 2ε. Asst. Prof. Dr. Kemal Bagzibagli Department of Economics. 20 May 2015

Introduction to Latex. A workshop by Dr. Ala Eshmawi


LAT E X week 2: Basics for Writing a Document

L A TEX From The Ground Up

Introduction to LATEX

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

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

Mikkel Madsen

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

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

Basics. Options. Commands

Introduction to LaTeX. Christoph Pickl

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.

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

Introduction to L A TEX

A Brief Introduction to L A TEX

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

Course A, Part 1 Basic Formatting in L A TEX

Introduction to L A TEX beamer

L A TEX for psychological researchers

Introduction to L A TEX

VERY VERY SHORT GUIDE TO LATEX

The MathType Window. The picture below shows MathType with all parts of its toolbar visible: Small bar. Tabs. Ruler. Selection.

A quick guide to L A TEX

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

LATEX TYPESETTING SYSTEM. CAAM 519, CHAPTER 3

1 Different Document Classes

Learn LaTeX in 30 Minutes. A. LOTFI School of Science and Technology Nottingham Trent University

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

How to get started in 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.

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

Using L A TEX Tom Edgar

Formatting with LaTeX

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

Introduction to LAT E X

Homework # (Latex Handout) by Laura Parkinson

Useful L A TEX Commands

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

Square cells: an array cooking lesson

Transcription:

NMT May 18, 2016 Written by Ian Jones Revised by Caleb Hightower Contents 1 What is L A TEX? 2 2 Your First L A TEX Document 2 2.1 Getting Started............................ 3 3 Document Structure 4 3.1 Titles, Dates, and Authors...................... 4 3.2 Sections and Subsections....................... 5 3.3 Reserved Characters......................... 5 4 Images 6 5 Equations 7 5.1 Math Environment.......................... 8 5.2 Other Symbols............................ 10 6 Tables of Contents 10 7 Other Common Commands 10 7.1 Text Appearance........................... 10 7.2 Lists.................................. 11 7.3 Quotations.............................. 12 7.4 Tables................................. 12 8 Bibliographies 13 9 L A TEX Code for This Document 14 10 Appendices 15 1

1 What is L A TEX? L A TEX (pronounced LAH-tek) is a typesetting language. This means that it takes text and commands in a scripted format, and then decides how best to present them on the page. Fortunately, it is very good at doing this, so even a rough L A TEX document ends up looking very professional, and a well-written L A TEX document can look better than almost anything Microsoft Word or similar programs can produce. This document was prepared in L A TEX, and shows what a typical document will look like. The best part about L A TEX is that every single thing on the page can be modified to your preference. Some things are more difficult to modify than others, but it can still be done if you are willing to work a little extra. While these things can all be changed, L A TEX is smart; if you don t specify how you want something to look, it will put it on the page the best way it sees fit. It also handles the page spacing automatically. If you have one extra line at the bottom of the page, rather than making a whole separate page for that one line, L A TEX will adjust spacing to fit it all onto a single page. Things like equations, bibliographies, and images can be incredibly difficult to manage in other document creators (looking at you, MS Word). But in L A TEX, they can take only a few seconds of typing commands to present them exactly how you want. L A TEX is the standard for typesetting scientific papers in many fields, and should be used for any kind of important presentation. Additionally, it looks nice and shows that thought and effort was put into the information being communicated. L A TEX is a freely available program, and is already installed on all TCC machines. Proficiency in L A TEX is an excellent skill to have. It looks good on a resumé, and instantly makes you more hireable. Using a program like L A TEX will make a very favorable impression on professors especially for large assignments, such as take-home tests and research papers. 2 Your First L A TEX Document This guide is written to be used on a New Mexico Tech TCC machine booted into Windows. If you prefer to use Linux, see Appendix 2 at the end of this document before moving on to learn how to write L A TEX documents that way. If you do not have access to a TCC computer and would like to install L A TEX on your own computer, see Appendix 1. To open L A TEX on a TCC machine in Windows, go to Start All Programs MiKTeX 2.9 TeXworks New Mexico Tech Spring 2016 2

Figure 1: The initial L A TEX window 2.1 Getting Started Once you ve done that, we can begin writing our document! The first thing that needs to be done is to tell L A TEX what kind of document we will be writing. The most common type of document that you will be using is article, however there are many other options. Since we just want a simple example, we can just use New Mexico Tech Spring 2016 3

an article format with L A TEX defaults. This is done using the following code: \documentclass{article} Common alternatives to article include minimal (primarily for debugging), report (for a very long academic paper), book, beamer (for a slide presentation), and letter. We could also specify things like what font to use in this line. For example if we wanted to write a book in 12 point font, we would write: \documentclass[12pt]{book} The next thing that needs to be done is telling L A TEX where your document starts and stops. This is done using the commands: \begin{document} \end{document} These should both go underneath your document class line. Now whatever you type in between the begin document and end document lines will be automatically typeset by L A TEX for you! A simple document that just prints out Hello World! is shown below. \documentclass{article} \begin{document} Hello World! \end{document} Typing this into L A TEX, and hitting compile (the green play button in the top left corner) will now create your first L A TEX document. 3 Document Structure Writing a bare text file is almost never enough. You will need to include titles, authors, and dates, as well as be able to structure the document in a logical manner. 3.1 Titles, Dates, and Authors Information on what a paper is about, who wrote it, and when should be included in every paper. L A TEX expects to receive this information immediately after the begin document line. This information is given by the commands \author, \date, and \title in any order, followed by a \maketitle command. For example, the code that was used to make the heading at the top of this document was: New Mexico Tech Spring 2016 4

\begin{document} \title{introduction to \LaTeX{}} \author{nmt } \date{\today} \maketitle The \today that you see in the date simply tells L A TEX to use the current date when it is typesetting. 3.2 Sections and Subsections Sections and subsections serve to organize your work in a logical manner, and allow a reader interested only in one part of what you ve done to quickly find it. These are created by using the commands \section, and \subsection. If you wanted to go into still finer divisions, \subsubsection, \paragraph, and \subparagraph can be used. If you are using anything below subsection you probably need to think about the structure of your document. For example some section and subsection in this document were created using the commands: \section{document Structure} \subsection{titles, Dates, and Authors} Notice that there are no numbers in the above commands. This is because L A TEX automatically numbers your sections and subsections in order that they appear in your code. Need to add in a section right in the middle of your document? No problem; all of the subsequent sections will automatically be re-numbered accordingly. 3.3 Reserved Characters Some characters are reserved by L A TEX for doing special commands. These characters cannot be typed into normal text. These characters are: #, $, %, ˆ, &,, {, },, and \. In each case, these characters can be produced in plain text by using the commands: \#, \$, \%, \^{}, \&, \_, \{, \}, \~{}, and \textbackslash Accidentally including a reserved character improperly is one of the reasons that a L A TEX code will fail to compile, or will compile in an unexpected way. Often, error messages in such a failure will let you know this is the case so you can find the mistake in your code and fix it. New Mexico Tech Spring 2016 5

4 Images Images can be added to L A TEX documents. However, unlike other document programs the image insertion is not a drag-and-drop process; we need to put a bit more work in. L A TEX alone cannot process these images, but packages have been developed as an extension to L A TEX. There are many packages that have been developed by the makers of L A TEX, all of which include different specialized sets of commands. To include a particular package in your document, use the following command. \usepackage{packagename} The packages that we will be using in this workshop for images are called graphicx and float. To use these packages, place their respective import commands after the \documentclass{article} command but before the \begin{document} as follows: \documentclass{article} \usepackage{graphicx} \usepackage{float} \begin{document} Once this is done, an image can be included by adding the following set of commands: \begin{figure} \centering \includegraphics[width=3in]{galaxy} \caption {A sample image.} \end{figure} This code produces the image seen on the next page. Let us dissect exactly what this code does. The commands \begin{figure} and \end{figure} tell L A TEX that you want to go into the figure environment. In L A TEX, an environment is a section of code where particular kinds of commands are valid. Therefore, some commands only work when you are in the associated environment. The figure environment is generally the best one to use for images, as it gives you access to many cool features, like figure numbering and captions. You can insert images outside of this environment, but this is not recommended. The \centering command tells L A TEX that the image is to be centered in the page. The line \includegraphics[width=3in]{galaxy} is what actually generates the image. It tells L A TEX to look in the same folder where the.tex file is saved, find the file galaxy, and print it on the page with a width of 3 inches. It gives L A TEX some flexibility to pick an appropriate place in the New Mexico Tech Spring 2016 6

Introduction to LATEX Figure 2: A sample image. document. Most common file extentions are recognized by LATEX, but usually.png or.jpg work best. The important part is the image must be saved in the same place as the.tex file. Here, LATEX has placed the image on the page in the best way it can. However, if you d like to override this and place the image at a precise spot in your document (in the same position as where the code is), replace the command \begin{figure} with the command \begin{figure}[h] This will tell LATEX, No, I want this right here. Anytime something appears in square brackets in a command, that indicates it is an optional parameter; LATEX doesn t need them in order to compile. This is what the additional [H] is in the above command. The letter H could be replaced by a t or b for placement at the top or bottom of the page respectively. 5 Equations The primary area where LATEX excels over other programs is typesetting equations. LaTeX has some basic equation functionality built-in, but using another package will be very helpful. In this tutorial, we will use the amsmath package, so you will need to add the corresponding command \usepackage{amsmath} at New Mexico Tech Spring 2016 7

the top of your code in the same section as the image packages. \documentclass{article} \usepackage{graphicx} \usepackage{float} \usepackage{amsmath} \begin{document} 5.1 Math Environment The math environment is what allows you to generate equations in a document. There are two types of math environments: inline math, and centered math. Inline math, as the name implies, creates math expressions within a line of text by surrounding the relevant equations by $ signs. For example, the command The equation of the line is $y = 3x-4$. produces the output: The equation of the line is y = 3x 4. Centered math takes equations and presents them in the middle of the page, with a bit of extra space above and below for emphasis. If you want your equations to be numbered, then the commands \begin{equation} and \end{equation} should be used. As with sections and figures, L A TEX handles the numbering of equations for you automatically. The commands \begin{equation} ax^2 + bx + c = 0 \end{equation} produce the output ax 2 + bx + c = 0 (1) However, if you want your equation to be centered but not have a number, the commands \[ and \] should be used to open and close the environment. produces: \[ ax^2 + bx + c = 0 \] ax 2 + bx + c = 0 It should be noted that many symbols, such as the summation symbol or fractions, look slightly different in centered math compared to inline math. Test out some of the commands below in both centered and inline to see the difference. New Mexico Tech Spring 2016 8

Exponents and Subscripts Exponents and subscripts can be created as follows: $e^{x}$ $x^{2}$ $F_{total}$ Which produces: e x, x 2, and F total. Fractions Fractions are produced using the \frac command. follows: This command works as $\frac{numerator}{denominator}$ \[ \frac{a}{b} \] This code produces: numerator denominator A B Greek Letters Greek letters are produced by simply putting a \before the name of the Greek letter you want. If you capitalize the first letter in the name of the Greek letter, you will get the capitalized version. For example: $\alpha \pi \Sigma \sigma \tau \theta$ produces: απσστ θ Special Functions Several common functions, such as trigonometric functions or logarithms, have special commands in L A TEX. Usually, it is just a \before the usual name of the function. For example, $\sin(\theta)$ $\log_{2}(y)$ $\arctan(x)$ produces: sin(θ), log 2 (y), and arctan(x). The command \[ \sin^{2} (x) + \cos^{2} (x) = 1 \] produces: sin 2 (x) + cos 2 (x) = 1 New Mexico Tech Spring 2016 9

Large Symbols Large math symbols involving bounds or limits usually involve the symbol name and upper/lower limits typed as super- or sub-scripts. \[ \sum_{i=1}^{\infty} n_i \] \[ \int_{a}^{b} f(x) dx \] \[ \lim_{x \to 0} h(x) \] This produces: i=1 n i b a f(x)dx lim h(x) x 0 5.2 Other Symbols L A TEX is capable of typesetting almost every math symbol that you will ever need if you give it the correct command. Visit http://web.ift.uib.no/teori/kurs/wrk/tex/symall.html for an extensive list of symbols. 6 Tables of Contents Many longer documents are required to have a table of contents. L A TEX will automatically generate this for you by placing the \tableofcontents command immediately after your \maketitle command. L A TEX will automatically generate your table of contents based on your section and subsection titles. NOTE: you have to compile the document twice to make the table of contents appear. 7 Other Common Commands 7.1 Text Appearance Italicized text can be created using the command \textit{this is the text to be italicized} This command produces the following: This is the text to be italicized Bold text can be created using the command \textbf{this is the text to be bolded} New Mexico Tech Spring 2016 10

This command produces the following: This is the text to be bolded Underlined text can be created using the command \underline{this is underlined text} This command produces the following: This is underlined text If you want a bit of extra space in your document, use the \hspace{value} or \vspace{value} commands for horizontal and vertical space respectively, and replace value with whatever amount you want. L A TEX recognizes most standard units, so you could use a command like \vspace{2in} to create a vertical empty space 2 inches tall. 7.2 Lists There are a few types of list environments in L A TEX. The two most popular are itemize, which creates a bulleted list; and enumerate, which creates a numbered list. To create lists, use the \begin{enumerate} and \end{enumerate} commands, or the \begin{itemize} and \end{itemize} commands. To place items in the list, use the command \item followed by that item s text between these commands. The code \begin{itemize} \item One thing \item Another thing \item Yet Another thing \end{itemize} \begin{enumerate} \item The first thing \item The second thing \item The third thing \end{enumerate} produces the following output: One thing Another thing Yet Another thing 1. The first thing 2. The second thing 3. The third thing New Mexico Tech Spring 2016 11

7.3 Quotations If you want to put something in quote marks, the usual double quote key on your keyboard doesn t quite work. Instead, you want to start a quote by putting two tick marks. (This is the symbol on the same key that has the mark. It s the key to the left of the 1 key on standard US keyboards.) You ll want to end a quote using two single quote marks (apostrophes). This is a quotation. produces: This is a quotation. 7.4 Tables Producing tables in L A TEX are a bit more tricky than some other things. This is because there are a couple of more details to manage to make sure it gets put on the page properly. The best way to insert a table is to use the figure environment just as with images. The table itself is created in the tabular environment within the figure environment. Here s an example of a table. \begin{figure}[h] \centering \begin{tabular}{ccc} Name & Age & Height \\ \hline Jeff & 21 & 6 1 \\ Amy & 19 & 5 8 \\ Sam & 24 & 5 10 \\ \hline \end{tabular} \caption{random humans ages and heights.} \end{figure} This produces the output: Name Age Height Jeff 21 6 1 Amy 19 5 8 Sam 24 5 10 Figure 3: Random humans ages and heights. On the line opening tabular, you must place in curly braces a set of letters indicating how many columns you will have, and how the text in each of those columns should be centered. The letter options are l, c, and r, for left, right, and centered, respectively. If you want to have vertical lines between the columns or on the edges, the symbol should be placed in these curly braces in the places New Mexico Tech Spring 2016 12

you want them. For horizontal lines, you ll place the command \hline between the rows where you want it to go. Rows should have a \\ placed at the end of the line where you want that row to end. Individual cells in a row are separated by the & symbol. Here is an example of another slightly different table. \begin{figure}[h] \centering \begin{tabular}{ l r r } \hline \textbf{element} & \textbf{atomic Weight} & \textbf{atomic Number} \\ Hydrogen & 1.008 & 1 \\ Helium & 4.003 & 2 \\ Lithium & 6.941 & 3 \\ \hline \end{tabular} \caption{first three elements.} \end{figure} produces: Element Atomic Weight Atomic Number Hydrogen 1.008 1 Helium 4.003 2 Lithium 6.941 3 Figure 4: First three elements. 8 Bibliographies L A TEX has many fancy bibliography packages. In this workshop, we are only going to explore a simple one. We will use the thebibliography environment. To do this, at the end of your document, just before the \end{document} command, put the following code: \begin{thebibliography}{99} \end{thebibliography} This places you in the bibliography environment. The 99 parameter that follows the \begin{thebibliography} command simply tells the program how wide to make the citations. If you have 1-9 sources, this can be any 1 digit number. If you have 10-99 sources, this can be any two digit number, and so on. You can now create a citation using the command \bibitem{tag} (Source citation in any format.) New Mexico Tech Spring 2016 13

This citation can now be referenced anywhere in your paper by using the \cite{tag} command. The tag is just any word or phrase that lets you know what the source is - it will never appear in your final document. Author s last name followed by year of publication is a good one to use. Now, using the following code, we will generate the References section. \begin{thebibliography}{9} \bibitem{copernicus} Nicholas Copernicus De revolutionibus orbium coelestium (On the Revolutions of the Heavenly Spheres) Nuremburg, Holy Roman Empire 1543 \end{thebibliography} This references section (seen below) will have a single entry, denoted by the above information, with the tag Copernicus as designated by the \bibitem command. We can now create an in-text citation by typing the line: The sun is the center of the solar system, and all planets revolve around it. \cite{copernicus} Using this, we obtain: The sun is the center of the solar system, and all planets revolve around it. [1] NOTE: Like the table of contents, producing the bibliography requires you to compile the document twice. References [1] Nicholas Copernicus De revolutionibus orbium coelestium (On the Revolutions of the Heavenly Spheres) Nuremburg, Holy Roman Empire 1543 9 L A TEX Code for This Document To serve as an additional example as well as for reference, attached is the L A TEX code that was used to generate the manual above. The code is in a.tex file and can be opened with any standard text editor, such as Notepad++, TextEdit, or gedit. New Mexico Tech Spring 2016 14

10 Appendices Appendix 1: Putting L A TEX on your personal computer If you would prefer to put L A TEX on your own computer instead of having to use a TCC machine, you will need to install what s known as a TeX distribution. It s a big package that includes the compilers (to actually create the documents) and a library of standard typesetting commands. Windows: Visit http://www.howtotex.com/howto/installing-latex-on-windows/ for a simple tutorial on how to install the TCC s L A TEX editor on your PC. Mac OS: Visit http://www.howtotex.com/howto/installing-latex-on-mac-os-x/ for a simple tutorial on how to install something similar to the TCC s L A TEX editor on your Mac. Linux: If you re brave enough to be a Linux user, you are hopefully familiar with your distro s program installation methods. A list of standard terminal commands can be found at http://latex-community.org/know-how/466-texlive-linux Appendix 2: Using L A TEX in Linux/UNIX with Terminal If you are accustomed to quicker work involving fewer mouse clicks in a Unix environment, you may want to avoid the clunkiness of a GUI for your document creation. The alternative method is to open a terminal and move into whatever directory you are going to have your.tex file in. Open up your favorite text editor (TCC machines come with the standard gedit program; the author recommends Sublime Text) and begin composing your document. When you are ready to compile, in the terminal enter the command pdflatex filename.tex replacing filename with the name of your file. If you are working through this tutorial and would like to use this method of document composition, just enter in the above command any place the instructions say compile. New Mexico Tech Spring 2016 15