A Grasshopper s Approach to L A TEX

Similar documents
A quick guide to L A TEX

Assessments for CS students:

An Introduction to L A TEX

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

Introduction to LaTeX. Paul Fodor Stony Brook University

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.

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

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

Math 235: Introduction to LaTeX

LaTeX A Tutorial. Mohsen Alimomeni, 2010

Getting Started with L A TEX

Introduction to L A TEX

David Helmbold, October 2005, Revised October 2007

Introduction to L A TEX

Introduction to L A TEX

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

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

COMP496/901: Academic Presentation and Writing Skills Using LaTeX

Introduction to L A TEX

Introduction to L A TEX

Document Preparation Word Processors

Introduction to MCS 220 and L A TEX

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

MATLAB for the Sciences

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

GROUP ASSIGNMENT. L A TEX Assignment 1/3

Guide to using L A TEX

L A T E X Tutorial. Wanmin Liu August. Department of Mathematics The Hong Kong University of Science and Technology

L A TEX From The Ground Up

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

Introduction to LAT E X

Absolute L A TEX Beginner

A Short Introduction to L A TEX

Introduction to LATEX

L A TEX for Psychological Researchers

L A TEXInstallation and Introduction

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

Helen Cameron. A Brief Overview of LATEX

Latex Tutorial. CIS400 Senior Design 9/5/2013

Learning L A TEX. Patrick Lam

An Introduction to LATEX

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

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

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

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

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

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


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

A Brief Introduction to L A TEX

Become a L A TEX Guru

A brief introduction to L A TEX

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

L A TEX - First Class

Introduction to L A T E X

Outline. A Sneak Peek

Dec. 27 th, 2010 University of Isfahan

Basic L A TEX. what is LaTeX?

How to get started in L A TEX

A L A T E X quick start

My LaTeX Document. July 7, Introduction 2

Introduction to LAT E X

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

GENERAL INFORMATION INSTRUCTIONS FOR MANUSCRIPT SUBMISSION

1 Obtaining LyX and L A TEX

Tools for Scientific Writing with LAT E X. Johan Carlson

Introduction to LaTeX. Christoph Pickl

Course A, Part 1 Basic Formatting in L A TEX

Typesetting in wxmaxima

Introduction to LATEX

Helen Cameron. A Brief Overview of LATEX

L A TEXday, morning session Discovering L A TEX

Lecture 1: Short summary of LaTeX basics

Getting started with Latex

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

Mikkel Madsen

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

Learning LaTeX: The Basics

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

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

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

Formatting with LaTeX

Useful L A TEX Commands

An Interactive Introduction to L A TEX

L A TEX Workshop. An Introduction to L A TEX. Rakesh Jana Research Scholar Department of Mathematics IIT Guwhati

An Introduction to LATEX

The AES Convention Paper LATEX class Adam H. Lewenberg (October 18, 2008) 1

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

Meeting One. Aaron Ecay. February 2, 2011

Mikkel Madsen

Introduction to Scientific Typesetting Lesson 1: Getting Started

Very Short Introduction to LaTeX

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

Writing a Thesis with L A TEX

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

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

A Short L A TEX Introduction

L A TEX for Psychological Researchers

LaTeX is essentially a markup language

Transcription:

A Grasshopper s Approach to L A TEX JHB Deane and S Reich Updated by PJ Aston February 1, 2011 Contents 1 Introduction 2 2 Winshell 2 2.1 Editor Commands..................................... 2 2.2 Processing a L A TEX File.................................. 2 2.3 Viewing the Output.................................... 2 3 First Steps 3 4 Basic L A TEX 3 4.1 The Absolute Minimum.................................. 3 4.2 Plain Text.......................................... 4 4.3 Type Styles......................................... 4 4.4 Environments........................................ 5 4.5 Vertical and Horizontal Spacing.............................. 6 5 More Basics 6 5.1 Titles for Documents.................................... 6 5.2 Sectioning Commands................................... 6 5.3 Bibliography........................................ 7 5.4 Troubleshooting....................................... 8 6 Typesetting Mathematics 8 6.1 Examples.......................................... 8 6.2 Equation Environments.................................. 9 6.3 Fonts and Indices...................................... 9 7 Introduction to Tables 10 8 Including Figures 11 9 Mathematical Functions and Symbols 11 10 Going Further 12 1

1 Introduction L A TEX is essentially a programming language. The text in your input file will look quite different from the final result in print. This requires knowledge of the commands that format your input into something that looks like typesetting by an expert. 2 Winshell Winshell is an editor that is designed to work with L A TEX. Processing a L A TEX file and viewing the output are easily done from within Winshell. Winshell is available in the AP and Library computer labs (All Programs Departmental Software FEPS Winshell). If you want to install L A TEX on your own (Windows) computer, then you should download MiKTeX 2.9 from http://www.miktex.org/ and WinShell from http://www.winshell.de/ 2.1 Editor Commands Many of the editing commands are common to other editors. The main ones are as follows: Copy: Ctrl + c Cut: Ctrl + x Paste: Ctrl + v Delete: Del or Backspace Select all: Ctrl + a Undo: Ctrl + z Redo: Ctrl + y Search: Ctrl + f Find next: F3 Replace: Ctrl + h Go to line: Ctrl + g Save: Ctrl + s 2.2 Processing a L A TEX File Once you have typed in a L A TEX document (and saved it!), it can be processed by clicking on the PDFLaTeX button (or pressing F10). If there are any errors, these will appear in the Output frame at the bottom of the window. You will need to go back and correct any errors, save the file and then process it again. 2.3 Viewing the Output Once you have got rid of all the errors, you can view the output by clicking on the PDFView button (or pressing F11). If you now change the L A TEX file and process it again, the output will be automatically updated, so you do not need to click on PDFview again. 2

3 First Steps Let s produce a file with name first.tex and content: \documentclass{article} \begin{document} Hello world. I claim that $\sqrt{\tan (\pi/5)} = \cos 2$. I will provide a proof in a short while once I ve learnt \LaTeX. \end{document} We know well enough that this is very likely to be rubbish. But L A TEX doesn t care. So we go ahead and turn this text into something printable. Step 1. After saving this file, process it by clicking the PDFLatex button (or pressing F10). Step 2. You can view the output by clicking on PDFView (or pressing F11). This allows you to view the translated content of our file first.tex. The output should look like this: Hello world. I claim that tan(π/5) = cos 2. I will provide a proof in a short while once I ve learnt L A TEX. 4 Basic L A TEX 4.1 The Absolute Minimum Each L A TEX file has to contain at least the following three lines. At the very beginning: \documentclass{******} \begin{document} and at the very end: \end{document} The six asterisks can be replaced by one of the following: article, report, book. It tells L A TEX what sort of author you are. If you wish to write an article to be submitted to a journal, you should use article. If you re writing a thesis or a final year project report, you should replace the six asterisks with report etc. L A TEX will try to interpret everything it finds between the \begin{document} command and the \end{document} command into something printable. We will now present various small chunks of L A TEX that live between these very basic commands. 3

4.2 Plain Text At first, we deal with plain text. Remember, even in this simplest of all situations, L A TEX will modify the appearance of the text as you typed it into your L A TEX document. A few rules: 1. The number of spaces between words is immaterial. A new line in the input file is thought of as a space. 2. A blank line in the input file signifies the start of a new paragraph. 3. The following characters have a special meaning in L A TEX: \ & $ % ~ _ { } # ^ When you want one of these characters to appear in the output, most of them can be generated by preceding the character with a backslash. Let us consider the following sample chunk of a L A TEX document: The special characters \&, \$, \%, \_, \{, \}, and \# may be printed by preceding each with a backslash ($\backslash$). It is likely that 50\% of the time you will be frustrated because you forgot to precede the % symbol by a backslash. The \% symbol is used to comment out the rest of the line. L A TEX will produce the following output: The special characters &, $, %,, {, }, and # may be printed by preceding each with a backslash (\). It is likely that 50% of the time you will be frustrated because you forgot to precede the The % symbol is used to comment out the rest of the line. 4.3 Type Styles The shape, series, and family of the type can be controlled. There are four shapes: upright, italic, slanted, and small caps, and two series: medium, boldface, and three families: roman, sans serif, and typewriter. This text was produced using the following lines: One can control the shape, series, and family of the type. There are four shapes: \textup{upright}, \textit{italic}, \textsl{slanted}, and \textsc{small caps}, and two series: \textmd{medium}, \textbf{boldface}, and three families: \textrm{roman}, \textsf{sans serif}, and \texttt{typewriter}. 4

Note that text whose type is to be changed is enclosed in curly brackets after the command. One can also combine features by staggered curly brackets. The declarations: \Huge \huge \LARGE \Large \large \normalize \small \footnotesize \scriptsize \tiny can be used to change the type size selectively. These declarations, and the words to which they apply, are enclosed in curly brackets to limit their scope. A space separates the command from the text. For example {\LARGE Large text} makes ideal {\Large text} for shortsighted people. produces 4.4 Environments Large text makes ideal text for shortsighted people. Environments are portions of the document that we want L A TEX to treat differently from the main body. They are generally created by enclosing the text between the commands \begin{environment name}. \end{environment name}. Some of the common non-mathematical environments are list-making environments such as itemize and enumerate, text centering via center, and the two table-making environments table and tabular. For example \begin{enumerate} \item Mr Green \item football \item England \end{enumerate} will turn into 1. Mr Green 2. football 3. England 5

4.5 Vertical and Horizontal Spacing The vertical spacing between lines can be altered using the \vspace command. For example, the command \vspace{3.5cm} will leave a vertical space of 3.5cm. Horizontal spacing works in a similar way using the \hspace command. For example Get out your rulers and measure these lengths. \vspace{1.0cm} Push right\hspace{1cm}one centimeter. This results in: Get out your rulers and measure these lengths. Push right one centimeter. 5 More Basics 5.1 Titles for Documents A title page can be generated automatically by specifying the title, authors, affiliations, and date. For example, the title page of this document was generated using the commands \title{\textbf{a Grasshopper s Approach to \LaTeX}} \author{jhb Deane and S Reich} \date{\today} \maketitle \tableofcontents A specific date such as \date{18/01/2011} could also be given. The command \today automatically puts in the date the document was produced. A table of contents can be automatically included by using the \tableofcontents command, as shown above. 5.2 Sectioning Commands We can regard L A TEX documents as organized hierarchically into units such as words, sentences, paragraphs and sections. The command \section{introduction} creates a section whose heading is Introduction. Each time it encounters the \section command, L A TEX starts a new section. The section number is generated automatically. We may also give the section a key, for example, intro, by using 6

\section{introduction}\label{intro} We can refer to that section later in the document using the \ref command It was shown in Section \ref{intro} that... The commands subsection and subsubsection subdivide the document even further and work in the same way as \section. Let us consider an example. \section{introduction}\label{intro} This is an empty intro. We go ahead and jump to the conclusions. \section{conclusions} As indicated in Section \ref{intro}, we didn t get any results. \subsection{acknowledgements} We thank the department for its hospitality during the preparation of this pointless paper. We obtain something like 1 Introduction This is an empty intro. We go ahead and jump to the conclusions. 2 Conclusions As indicated in Section 1, we didn t get any results. 2.1 Acknowledgements We thank the department for its hospitality during the preparation of this pointless paper. Using L A TEX s automatic numbering for sections (and equations see later) is a good idea, since if you add another section later on, the numbers will automatically change, and the references to the new sections will also be correct. Note that you have to process the file twice when labels change in order for the references to them to appear correctly. 5.3 Bibliography A bibliography can be created with the thebibliography environment. This is similar to the list-making environment discussed before. The command \bibitem, whose argument is enclosed in curly brackets, precedes each entry. The argument specifies the key by which the entry can be cited, anywhere in the document, using the \cite command. A bibliography is, for example, created by using \begin{thebibliography}{99} \bibitem{1a} Bill Bryson, \LaTeX\ is fun, Penguin, London, 2001. 7

\bibitem{1b} Claus Davidson, \LaTeX\ is no fun, Knopf, New York, 1564. \end{thebibliography} You should place the environment \thebibliography at the end of your document (but obviously before \end{document}).you can now cite both books in the text. For example the text The two most important sources on \LaTeX\ are \cite{1a,1b}. together with the bibliography section above produces: The two most important sources on L A TEX are [1,2]. References [1] Bill Bryson, L A TEX is fun, Penguin, London, 2001. [2] Claus Davidson, L A TEX is no fun, Knopf, New York, 1564. 5.4 Troubleshooting When you use L A TEX to process a file, you might get error messages and warnings. These are often not very helpful. However, you can try the following: If a pdf file has been produced, then preview the document. apparent. This may make the error Comment out suspicious looking lines by putting a % at the beginning of them. Insert the \end{document} command before (or about) where the error might have occurred. Run L A TEX on this abbreviated document and see if it works. Use this strategy to pinpoint the error. In cases of real desperation, have a look at a L A TEX manual. Ask a L A TEX expert. 6 Typesetting Mathematics 6.1 Examples Mathematical symbols that appear within the text are enclosed between dollar signs. For example, x = sin y is created by For example, $x = \sin y$ is created by L A TEX provides special expressions for many functions and expressions such as \sin. provided at the end of this document. A list is 8

6.2 Equation Environments Equations that are to be displayed on a separate line should be enclosed in \[...\]. To get a numbered expression, we must use the equation environment \begin{equation}...\end{equation}. If we include a labelling command, as in \label{fermat}, we can refer to the equation by its key \ref{fermat} rather than its number. If equations with more than one line have to be displayed, then use the environment \begin{eqnarray}...\end{eqnarray}. This environment has three fields (left, middle and right) which are separated by the symbol &. A new line can be started using \\. Given the inequality \[ 2 > 1 \] we can conclude that \begin{equation} \label{eqarr} 2^2 > 1^2. \end{equation} The statement (\ref{eqarr}) can be generalized to a sequence of inequalities such as \begin{eqnarray*} 2^1 &>& 1^1 \\ 2^2 &>& 1^2 \\ 2^3 &>& 1^3 \end{eqnarray*} etc. which yields: Given the inequality we can conclude that 2 > 1 2 2 > 1 2. (1) The statement (1) can be generalized to a sequence of inequalities such as etc. 2 1 > 1 1 2 2 > 1 2 2 3 > 1 3 If you don t want the equations to be numbered, use \begin{eqnarray*}...\end{eqnarray*}. 6.3 Fonts and Indices We continue with examples involving fractions, subscripts, and superscripts. The command \frac for formating fractions is always followed by two expressions that are enclosed in curly brackets (the numerator and denominator). The characters _ and ^ produce subscripts and superscripts, respectively. Here is an example 9

The equation \[ x^2 = \frac{\sqrt{2} + x^{3x}}{\sin x} \] is clearly a tough one. as you can see more clearly from The equation is clearly a tough one. x 2 = 2 + x 3x sin x You can also include Greek letters as well as calligraphic and many other fonts. Here is a short list of such: $\gamma,\gamma,\mathcal{h}, \mathbf{h},\mathit{h}$. or Here is a short list of such: γ, Γ, H, H, H. 7 Introduction to Tables This is best tackled through an example. The following \begin{tabular}{lcr} Name & Function & Range\\ \hline Sine & $\sin x$ & $[-1, 1]$\\ Gaussian & $\exp(-x^2)$ & $(0, 1]$\\ Unity & 1 & $[1]$\\ \hline \end{tabular} gives Name Function Range Sine sin x [ 1, 1] Gaussian exp( x 2 ) (0, 1] Unity 1 [1] Note that: 1. {lcr} says left-justify the first column, centre the second and right-justify the third. 2. & separates the columns, \\ ends the lines. 3. \hline puts a horizontal line right across the table. 4. to get vertical lines right down the table, change {lcr} into { l c r } try it and see. 5. to centre the table, enclose the tabular environment within \begin{center}... \end{center}. 10

8 Including Figures You may want to include include figures in your document. In order to do this, you will need \usepackage{graphicx} straight after the \documentclass line (i.e. the second line in your file). This loads a package capable of dealing with figures for you. Your figures should be either.jpg or.pdf files. Suppose a file called figure.pdf contains your figure. Then \begin{figure}[htbp] \begin{center} \includegraphics[width=8cm]{figure.pdf} \caption{a work of art: Untitled.} \label{fig1} \end{center} \end{figure} will include the figure, scale, caption and label it. The options [htbp] stand for here, top of current page, bottom of current page and on a separate page respectively. L A TEX will try to do the first one first; if it can t, it will try the second and so on. With the above code, this is what you get: A simple figure. Figure 1: A work of art: Untitled. 9 Mathematical Functions and Symbols The L A TEX code for some common functions is as follows: L A TEX code \sin x \cos x \tan x \sin^{-1} x \exp x \ln x \sqrt{x+2} \frac{dy}{dx} \int_{a}^{b} f(x) dx \lim_{x \to 0} f(x) \sum_{n=0}^{n} n^{2} Output sin x cos x tan x sin 1 x exp x ln x x + 2 b a dy dx f(x)dx lim f(x) x 0 N n 2 n=0 11

The L A TEX code for some common symbols is as follows: L A TEX code Output < < \leq > > \geq \neq \to \in \pm ± 10 Going Further Further L A TEX resources are available on the web: A list of symbols and how to generate them in L A TEX is available at http://omega.albany.edu:8008/symbols.html A guide called Getting Started with L A TEX is available at http://www.maths.tcd.ie/ dwilkins/latexprimer/index.html A longer guide called The Not So Short Introduction to L A TEX2ɛ is available at http://www.ctan.org/tex-archive/info/lshort/english/lshort.pdf There are many more L A TEX resources available on the web. 12