L A TEX - First Class Siri Isaksson November 4, 2010 Abstract In this first class, we will go over some of the most useful features of Latex, most of the examples of how to use them stem from the Not so short intoduction to Latex 2e which is free for download and distribution on http://tobi.oetiker.ch/lshort/lshort.pdf. Here, we will go through the basic buidling of a L A TEX document and some of the most frequent environments packages and commands. To get a more indepth description of each of the topics covered, please refer the page number provided in the title of each section. 1
Contents 1 Why L A TEX 3 1.1 Motivation............................ 3 2 Sectioning and Structure of a L A TEX Article - page 35 3 2.1 Sectioning............................. 3 2.2 Subsection............................. 3 2.2.1 Subsubsection....................... 4 3 Fonts symbols and footnotes 4 3.1 Fonts - page 122......................... 4 4 Symbols - page 21 and footnotes - page 38 5 4.1 Problem 3............................. 5 5 Spacing - page 125 5 6 Environments - page 40 6 6.1 Itemize and Enumerate - page 40................ 6 6.2 Tabular environment - page 42................. 7 6.3 Bibliography environment - page 83.............. 7 7 Mathematical typesetting - page 49 8 7.1 Problem 3.1............................ 8 7.2 Tagging equations........................ 9 2
1 Why L A TEX 1.1 Motivation L A TEX is a typesetting program developed to minimize the time spent with formatting a document or article, thereby giving more time to write and research the topic of interest. L A TEX takes over the role of graphic designer and creates the layout for you, all you need to do is to write the commands and text, and then LaTeX produces a pdf-file with your work. With L A TEX, all you need to create a coherent, professional looking homework or thesis, is the knowledge of it s structure and a few commands. Furthermore, there exists a plethora of templates which effectively allow you to type in your text in an already predefined stucture, these you can find for instance at the insitutes website, under the section LaTeX Templates, there is also a number of built in templates available in the L A TEX program. Furthermore, L A TEX allows you to elegantely write mathematical formulas in your text, something that is crucial in Economics and Business but is hard to achieve with a regular word processor. Finally L A TEX allows you to very easily create complex structures such as footnotes, table of contents and bibliographies. 2 Sectioning and Structure of a L A TEX Article - page 35 2.1 Sectioning Writing \section{title}, you start a new section, the new section will automatically be enumerated and added to your table of contents (provided of course that you used the \tableofcontents command in your preamble). As you can tell from the syntax, whatever you write in the curly brackets will become you section title, and will appear as such in your section and in your table of contents. Subsections are parts of sections listed under the section in the table of contents. The subsections can be very useful when for instance writing a homework consisting of questions with subquestions such as a) b) c). Subsections are also enumerated and listed in the table of contents automatically: 2.2 Subsection Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet 3
sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Please note that you have to run LaTeX two times before the new table of contents is created when adding new sections. In case you do not want to have a section numbered and listed in the table of contents you can simply use a starred command, that is a command with a star after the command name. To see how this works take a look at the following section in the tex file. Starred section Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet sed diam voluptua. At vero eos et accusam et justo et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Finally, there is also a subsubsection which looks like this: 2.2.1 Subsubsection Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. 3 Fonts symbols and footnotes 3.1 Fonts - page 122 To use different fonts, such as bold and italics, you need to use the appropriate commands, such as makes the text bold and makes it italicized You can try some of the font commands on this text, Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam 4
voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. 4 Symbols - page 21 and footnotes - page 38 4.1 Problem 3 Since many symbols have meanings in LaTex, you can t just write them in your text, for instance if you just write a backslash in your text, LaTeX will think that you are starting a command. However, it is likely that you would want to use backslashes, brackets and soforth in your text, in order to to so you have to use commands. Some of the more useful ones (which also we will use later in the document) are... \, {and }. These are just random examples that we will use in this class, to find exatcly the signs and symbols you are looking for please refer The Comprehensive Latex Symbol List 1. Footnotes are written using the syntax \{footnotetext}. 5 Spacing - page 125 L A TEX does not read skips in the tex file, for instance pressing enter 10 times does not show more than just once, instead you have to use commands and tell L A TEX how much you want to skip and make spaces. The most simple space, the linebreak is easily done with the command \\, for larger vertical spaces, you have to use the command \vspace {}within the braces, you define how large you want your space to be (the space can be defined in pt, cm, mm and so forth) Analogue, L A TEX does not read it if you press the space button ten times, but just once, therefor you need an analogue command for horizontal spaces. This is achieved by using \hspace {}, within the curly brackets, you define the width of your horizontal space. To see how this work, let us make a horizontal space in the Lorem Ipsum text. Lorem ipsum dolor sit amet, consetetur sadipscing sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed elitr, 1 http://www.ctan.org/tex-archive/info/symbols/comprehensive/symbols-a4.pdf 5
diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit am. In case you don t want to have to determine the length of your vertical spaces, you can just use a predefined amount using \bigskip and \smallskip :.Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptu At vero eos et accusam et justo duo dolores et ea rebum. Stet sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit am. 6 Environments - page 40 Environments are written using the syntax \begin {aaa}text \end {aaa}, the text between begin and end will be treated as you define your environment. For instance, in the beginning of this document, the center environent centered the HU-logo, and as we will se below, the itemize environment makes a list. Environments can be mixed as long as you keep the internal order, i.e \begin {aaa}...\begin {bbb}...\end {bbb}...\end {aaa} 6.1 Itemize and Enumerate - page 40 Here, we see what happens if we use the itemize and enumerate environments. You can use itemize to make simple (unnumbered lists) and enumerate, for enumerated lists. First scentence Second scentence Third scentence 1. First number 2. Second number 3. Third number 6
6.2 Tabular environment - page 42 Now, let s see how we can build tables using the tabular environment in L A TEX. Tabular allows you to typeset tables using vertical ( \cline ) and horizontal (\hline ) lines. The syntax, when using the tabular envionment is, \begin {tabular}[pos]{table spec}. In table spec, you define the style of your table, r, l and c tells L A TEX where to align the text (right left cetner). The [pos ]argument allows you to position you table in the top, bottom or center and can be defined as t,b or c. Furthermore, & jumps to the next column, creates an horizontal line and \cline {i j }creates a partial line extending over the i j columns. 7CO hexadecimal 3700 octal 1110 binary hej hejda 1984 decimal Hello Paste Your Text Here Make A Table Using This Example Bye 6.3 Bibliography environment - page 83 You can build your list of reference in L A TEX simply by using: \begin{thebibliography}{} environment command. In the second pair of curly brackets you define the max number of resources you will use, so inserting 99 for instance means you will use maximum 99 sources. Each item, that is reference, is put in using the syntax \bibitem [label]{marker}. You choose a marker for each source, here we choose pa and cd and ja, so that you can cite your sources using the cite command - written \cite. It is optional to label your sources, if you do not choose a label, they will be automatically enumerated. Partl [1] has proposed that... but on the other hand, Dickens [2] has proposed that... however, Austen [3] claimed that.... Finally, [otto], claims in her novel that... References [1] H. Partl: German Tex, TUG Boat Volume -9, Issue 1 (1988) [2] C. Dickens: Oliver Twist [3] J. Austen: Pride and Prejudice 7
[otto] Otto Normalverbracuher: Das Verbrauch 7 Mathematical typesetting - page 49 7.1 Problem 3.1 Use the ams-math package (in the preamble) to write mathematical formulas. There are different ways of writing formulas either you can write a fomula with the equation environment, in which case the equation will stand on it s own and be automatically enumerated: a 2 + b 2 = c 2 (1) Or to write an equation in the middle of a text, use the dollar sign, for instance : a 2 + b 2 = c 2. A third option for writing equations, is to have them stand on their own but not have them be enumerated, this is made with \[... \]. For instance you can write the same equation as before using a 2 + b 2 = c 2 Let s take a look at some of the most common and useful math commands: In order to write greek letters, just use \and the name of the letter, for instance (using writing equations by dollar sign notation) γ, if you want capital gamma just go Γ. To create exponents and subscripts, use ˆ and respectively. Furthermore, you write the squareroot using the \sqrt command, summation operator using the \sum command, limes operator using the \lim \frac for writing fractions and so forth. Since most math commands only have an impact on the character standing next to the command, you have to bundle characters with{... }, if you want the command to work on all of them. For intstance writing x 2 22 is not the same as writing x 222. To see how all of this comes together we can look at a few examples: e = m c 2 (2) n I k = 0 (3) k=1 I D = I F I R (4) sin x lim x 0 x = 1 (5) As you can tell (looking at the tex file), using the summation operator, we put the lower limits in the first pair of curly brackets using underscore 8
and the upper limit in the second using ˆ and finally we write the function we want to sum. Similarily, for expressing a fraction, we put the numerator (in this case sin x) in the first pair of curly brackets and the denominator (x) in the second. Upper and lower limits are generally expressed using underscore and ˆ respectively, for another example, lets look at the integral operator, 8 5 There are differences when writing in text mode, and math mode, for instance all letters within mathmode, will be considered as variables by L A TEX, so if you want to enter usual text within your math formulae, you need to add a specific command for this, \text {... }. To see how this works, look at the example on page 52 which we will use here: x R : x 2 0 x 2 0 for all x R 7.2 Tagging equations You can also tag equations using \label {... }so that you can refer to them later in text using \eqref {label}. a 2 + b 2 = c 2 (6) Einstein says He didn t say This is a refernce to (7) E = mc 2 (7) 1 + 1 = 3 (8) 9