Docsity
Docsity

Prepare-se para as provas
Prepare-se para as provas

Estude fácil! Tem muito documento disponível na Docsity


Ganhe pontos para baixar
Ganhe pontos para baixar

Ganhe pontos ajudando outros esrudantes ou compre um plano Premium


Guias e Dicas
Guias e Dicas

The Not So Short Introduction to LATEX2e - v4.31, Notas de estudo de Física

Material de introdução ao LaTeX escrito por Tobias Oetiker e liberado sob licença GNU GPL. Em inglês. Versão 4.31 de 24 de junho de 2010.

Tipologia: Notas de estudo

2010

Compartilhado em 28/08/2010

glaucio-souza-8
glaucio-souza-8 🇧🇷

2 documentos

Pré-visualização parcial do texto

Baixe The Not So Short Introduction to LATEX2e - v4.31 e outras Notas de estudo em PDF para Física, somente na Docsity! The Not So Short Introduction to LATEX2ε Or LATEX 2ε in 154 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth Schlegl Version 4.31, June 24, 2010 ii Copyright ©1995-2010 Tobias Oetiker and Contributors. All rights reserved. This document is free; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This document is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fittness for a particular purpose. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this document; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Preface LATEX [1] is a typesetting system that is very suitable for producing scientific and mathematical documents of high typographical quality. It is also suitable for producing all sorts of other documents, from simple letters to complete books. LATEX uses TEX [2] as its formatting engine. This short introduction describes LATEX2ε and should be sufficient for most applications of LATEX. Refer to [1, 3] for a complete description of the LATEX system. This introduction is split into 6 chapters: Chapter 1 tells you about the basic structure of LATEX2ε documents. You will also learn a bit about the history of LATEX. After reading this chapter, you should have a rough understanding how LATEX works. Chapter 2 goes into the details of typesetting your documents. It explains most of the essential LATEX commands and environments. After reading this chapter, you will be able to write your first documents. Chapter 3 explains how to typeset formulae with LATEX. Many examples demonstrate how to use one of LATEX’s main strengths. At the end of the chapter are tables listing all mathematical symbols available in LATEX. Chapter 4 explains indexes, bibliography generation and inclusion of EPS graphics. It introduces creation of PDF documents with pdfLATEX and presents some handy extension packages. Chapter 5 shows how to use LATEX for creating graphics. Instead of drawing a picture with some graphics program, saving it to a file and then including it into LATEX you describe the picture and have LATEX draw it for you. Chapter 6 contains some potentially dangerous information about how to alter the standard document layout produced by LATEX. It will tell you how to change things such that the beautiful output of LATEX turns ugly or stunning, depending on your abilities. vi Preface It is important to read the chapters in order—the book is not that big, after all. Be sure to carefully read the examples, because a lot of the information is in the examples placed throughout the book. LATEX is available for most computers, from the PC and Mac to large UNIX and VMS systems. On many university computer clusters you will find that a LATEX installation is available, ready to use. Information on how to access the local LATEX installation should be provided in the Local Guide [5]. If you have problems getting started, ask the person who gave you this booklet. The scope of this document is not to tell you how to install and set up a LATEX system, but to teach you how to write your documents so that they can be processed by LATEX. If you need to get hold of any LATEX related material, have a look at one of the Comprehensive TEX Archive Network (CTAN) sites. The homepage is at http://www.ctan.org. You will find other references to CTAN throughout the book, especially pointers to software and documents you might want to download. Instead of writing down complete urls, I just wrote CTAN: followed by whatever location within the CTAN tree you should go to. If you want to run LATEX on your own computer, take a look at what is available from CTAN://systems. If you have ideas for something to be added, removed or altered in this document, please let me know. I am especially interested in feedback from LATEX novices about which bits of this intro are easy to understand and which could be explained better. Tobias Oetiker <tobi@oetiker.ch> OETIKER+PARTNER AG Aarweg 15 4600 Olten Switzerland The current version of this document is available on CTAN://info/lshort Contents Thank you! iii Preface v 1 Things You Need to Know 1 1.1 The Name of the Game . . . . . . . . . . . . . . . . . . . . . 1 1.1.1 TEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.1.2 LATEX . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.2 Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.2.1 Author, Book Designer, and Typesetter . . . . . . . . 2 1.2.2 Layout Design . . . . . . . . . . . . . . . . . . . . . . 2 1.2.3 Advantages and Disadvantages . . . . . . . . . . . . . 3 1.3 LATEX Input Files . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.3.1 Spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.3.2 Special Characters . . . . . . . . . . . . . . . . . . . . 5 1.3.3 LATEX Commands . . . . . . . . . . . . . . . . . . . . 5 1.3.4 Comments . . . . . . . . . . . . . . . . . . . . . . . . . 6 1.4 Input File Structure . . . . . . . . . . . . . . . . . . . . . . . 6 1.5 A Typical Command Line Session . . . . . . . . . . . . . . . 7 1.6 The Layout of the Document . . . . . . . . . . . . . . . . . . 9 1.6.1 Document Classes . . . . . . . . . . . . . . . . . . . . 9 1.6.2 Packages . . . . . . . . . . . . . . . . . . . . . . . . . 9 1.6.3 Page Styles . . . . . . . . . . . . . . . . . . . . . . . . 10 1.7 Files You Might Encounter . . . . . . . . . . . . . . . . . . . 13 1.8 Big Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 2 Typesetting Text 17 2.1 The Structure of Text and Language . . . . . . . . . . . . . . 17 2.2 Line Breaking and Page Breaking . . . . . . . . . . . . . . . . 19 2.2.1 Justified Paragraphs . . . . . . . . . . . . . . . . . . . 19 2.2.2 Hyphenation . . . . . . . . . . . . . . . . . . . . . . . 20 2.3 Ready-Made Strings . . . . . . . . . . . . . . . . . . . . . . . 21 2.4 Special Characters and Symbols . . . . . . . . . . . . . . . . . 21 x CONTENTS 6.1.4 Commandline LATEX . . . . . . . . . . . . . . . . . . . 120 6.1.5 Your Own Package . . . . . . . . . . . . . . . . . . . . 121 6.2 Fonts and Sizes . . . . . . . . . . . . . . . . . . . . . . . . . . 121 6.2.1 Font Changing Commands . . . . . . . . . . . . . . . 121 6.2.2 Danger, Will Robinson, Danger . . . . . . . . . . . . . 124 6.2.3 Advice . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 6.3 Spacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 6.3.1 Line Spacing . . . . . . . . . . . . . . . . . . . . . . . 125 6.3.2 Paragraph Formatting . . . . . . . . . . . . . . . . . . 125 6.3.3 Horizontal Space . . . . . . . . . . . . . . . . . . . . . 126 6.3.4 Vertical Space . . . . . . . . . . . . . . . . . . . . . . 127 6.4 Page Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 6.5 More Fun With Lengths . . . . . . . . . . . . . . . . . . . . . 130 6.6 Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 6.7 Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 A Installing LATEX 135 A.1 What to Install . . . . . . . . . . . . . . . . . . . . . . . . . . 135 A.2 TEX on Mac OS X . . . . . . . . . . . . . . . . . . . . . . . . 136 A.2.1 Get a TEX Distribution . . . . . . . . . . . . . . . . . 136 A.2.2 Picking an Editor . . . . . . . . . . . . . . . . . . . . . 136 A.2.3 Treat yourself to PDFView . . . . . . . . . . . . . . . 136 A.3 TEX on Windows . . . . . . . . . . . . . . . . . . . . . . . . . 136 A.3.1 Getting TEX . . . . . . . . . . . . . . . . . . . . . . . 136 A.3.2 A LATEX editor . . . . . . . . . . . . . . . . . . . . . . 137 A.3.3 Document Preview . . . . . . . . . . . . . . . . . . . . 137 A.3.4 Working with graphics . . . . . . . . . . . . . . . . . . 137 A.4 TEX on Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 Bibliography 139 Index 141 List of Figures 1.1 A Minimal LATEX File. . . . . . . . . . . . . . . . . . . . . . . 7 1.2 Example of a Realistic Journal Article. . . . . . . . . . . . . . 8 4.1 Example fancyhdr Setup. . . . . . . . . . . . . . . . . . . . . . 87 4.2 Sample code for the beamer class . . . . . . . . . . . . . . . . 99 6.1 Example Package. . . . . . . . . . . . . . . . . . . . . . . . . 121 6.2 Layout parameters for this book. . . . . . . . . . . . . . . . . 129 Chapter 1 Things You Need to Know The first part of this chapter presents a short overview of the philosophy and history of LATEX2ε. The second part focuses on the basic structures of a LATEX document. After reading this chapter, you should have a rough knowledge of how LATEX works, which you will need to understand the rest of this book. 1.1 The Name of the Game 1.1.1 TEX TEX is a computer program created by Donald E. Knuth [2]. It is aimed at typesetting text and mathematical formulae. Knuth started writing the TEX typesetting engine in 1977 to explore the potential of the digital printing equipment that was beginning to infiltrate the publishing industry at that time, especially in the hope that he could reverse the trend of deteriorating typographical quality that he saw affecting his own books and articles. TEX as we use it today was released in 1982, with some slight enhancements added in 1989 to better support 8-bit characters and multiple languages. TEX is renowned for being extremely stable, for running on many different kinds of computers, and for being virtually bug free. The version number of TEX is converging to π and is now at 3.141592. TEX is pronounced “Tech,” with a “ch” as in the German word “Ach”1 or in the Scottish “Loch.” The “ch” originates from the Greek alphabet where X is the letter “ch” or “chi”. TEX is also the first syllable of the Greek word texnologia (technology). In an ASCII environment, TEX becomes TeX. 1In german there are actually two pronounciations for “ch” and one might assume that the soft “ch” sound from “Pech” would be a more appropriate. Asked about this, Knuth wrote in the German Wikipedia: I do not get angry when people pronounce TEX in their favorite way . . . and in Germany many use a soft ch because the X follows the vowel e, not the harder ch that follows the vowel a. In Russia, ‘tex’ is a very common word, pronounced ‘tyekh’. But I believe the most proper pronunciation is heard in Greece, where you have the harsher ch of ach and Loch. 2 Things You Need to Know 1.1.2 LATEX LATEX enables authors to typeset and print their work at the highest typo- graphical quality, using a predefined, professional layout. LATEX was originally written by Leslie Lamport [1]. It uses the TEX formatter as its typesetting engine. These days LATEX is maintained by Frank Mittelbach. LATEX is pronounced “Lay-tech” or “Lah-tech.” If you refer to LATEX in an ASCII environment, you type LaTeX. LATEX2ε is pronounced “Lay-tech two e” and typed LaTeX2e. 1.2 Basics 1.2.1 Author, Book Designer, and Typesetter To publish something, authors give their typed manuscript to a publishing company. One of their book designers then decides the layout of the document (column width, fonts, space before and after headings, . . . ). The book designer writes his instructions into the manuscript and then gives it to a typesetter, who typesets the book according to these instructions. A human book designer tries to find out what the author had in mind while writing the manuscript. He decides on chapter headings, citations, examples, formulae, etc. based on his professional knowledge and from the contents of the manuscript. In a LATEX environment, LATEX takes the role of the book designer and uses TEX as its typesetter. But LATEX is “only” a program and therefore needs more guidance. The author has to provide additional information to describe the logical structure of his work. This information is written into the text as “LATEX commands.” This is quite different from the WYSIWYG2 approach that most modern word processors, such as MS Word or Corel WordPerfect, take. With these applications, authors specify the document layout interactively while typing text into the computer. They can see on the screen how the final work will look when it is printed. When using LATEX it is not normally possible to see the final output while typing the text, but the final output can be previewed on the screen after processing the file with LATEX. Then corrections can be made before actually sending the document to the printer. 1.2.2 Layout Design Typographical design is a craft. Unskilled authors often commit serious formatting errors by assuming that book design is mostly a question of aesthetics—“If a document looks good artistically, it is well designed.” But 2What you see is what you get. 1.2 Basics 3 as a document has to be read and not hung up in a picture gallery, the readability and understandability is much more important than the beautiful look of it. Examples: • The font size and the numbering of headings have to be chosen to make the structure of chapters and sections clear to the reader. • The line length has to be short enough not to strain the eyes of the reader, while long enough to fill the page beautifully. With WYSIWYG systems, authors often generate aesthetically pleasing documents with very little or inconsistent structure. LATEX prevents such formatting errors by forcing the author to declare the logical structure of his document. LATEX then chooses the most suitable layout. 1.2.3 Advantages and Disadvantages When people from the WYSIWYG world meet people who use LATEX, they often discuss “the advantages of LATEX over a normal word processor” or the opposite. The best thing to do when such a discussion starts is to keep a low profile, since such discussions often get out of hand. But sometimes there is no escaping . . . So here is some ammunition. The main advantages of LATEX over normal word processors are the following: • Professionally crafted layouts are available, which make a document really look as if “printed.” • The typesetting of mathematical formulae is supported in a convenient way. • Users only need to learn a few easy-to-understand commands that specify the logical structure of a document. They almost never need to tinker with the actual layout of the document. • Even complex structures such as footnotes, references, table of contents, and bibliographies can be generated easily. • Free add-on packages exist for many typographical tasks not directly supported by basic LATEX. For example, packages are available to include PostScript graphics or to typeset bibliographies conforming to exact standards. Many of these add-on packages are described in The LATEX Companion [3]. • LATEX encourages authors to write well-structured texts, because this is how LATEX works—by specifying structure. 6 Things You Need to Know You can \textsl{lean} on me! You can lean on me! Please, start a new line right here!\newline Thank you! Please, start a new line right here! Thank you! 1.3.4 Comments When LATEX encounters a % character while processing an input file, it ignores the rest of the present line, the line break, and all whitespace at the beginning of the next line. This can be used to write notes into the input file, which will not show up in the printed version. This is an % stupid % Better: instructive <---- example: Supercal% ifragilist% icexpialidocious This is an example: Supercalifragilisticex- pialidocious The % character can also be used to split long input lines where no whitespace or line breaks are allowed. For longer comments you could use the comment environment provided by the verbatim package. Add the line \usepackage{verbatim} to the preamble of your document as explained below to use this command. This is another \begin{comment} rather stupid, but helpful \end{comment} example for embedding comments in your document. This is another example for embedding comments in your document. Note that this won’t work inside complex environments, like math for example. 1.4 Input File Structure When LATEX2ε processes an input file, it expects it to follow a certain structure. Thus every input file must start with the command \documentclass{...} 1.5 A Typical Command Line Session 7 This specifies what sort of document you intend to write. After that, add commands to influence the style of the whole document, or load packages that add new features to the LATEX system. To load such a package you use the command \usepackage{...} When all the setup work is done,4 you start the body of the text with the command \begin{document} Now you enter the text mixed with some useful LATEX commands. At the end of the document you add the \end{document} command, which tells LATEX to call it a day. Anything that follows this command will be ignored by LATEX. Figure 1.1 shows the contents of a minimal LATEX2ε file. A slightly more complicated input file is given in Figure 1.2. 1.5 A Typical Command Line Session I bet you must be dying to try out the neat small LATEX input file shown on page 7. Here is some help: LATEX itself comes without a GUI or fancy buttons to press. It is just a program that crunches away at your input file. Some LATEX installations feature a graphical front-end where there is a LATEX button to start compiling your input file. On other systems there might be some typing involved, so here is how to coax LATEX into compiling your input file on a text based system. Please note: this description assumes that a working LATEX installation already sits on your computer.5 4The area between \documentclass and \begin{document} is called the preamble. 5This is the case with most well groomed Unix Systems, and . . . Real Men use Unix, so . . . ;-) \documentclass{article} \begin{document} Small is beautiful. \end{document} Figure 1.1: A Minimal LATEX File. 8 Things You Need to Know 1. Edit/Create your LATEX input file. This file must be plain ASCII text. On Unix all the editors will create just that. On Windows you might want to make sure that you save the file in ASCII or Plain Text format. When picking a name for your file, make sure it bears the extension .tex. 2. Open a shell or cmd window, cd to the directory where your input file is located and run LATEX on your input file. If successful you will end up with a .dvi file. It may be necessary to run LATEX several times to get the table of contents and all internal references right. When your input file has a bug LATEX will tell you about it and stop processing your input file. Type ctrl-D to get back to the command line. latex foo.tex 3. Now you may view the DVI file. There are several ways to do that. Look at the file on screen with xdvi foo.dvi & This only works on Unix with X11. If you are on Windows you might want to try yap (yet another previewer). \documentclass[a4paper,11pt]{article} % define the title \author{H.~Partl} \title{Minimalism} \begin{document} % generates the title \maketitle % insert the table of contents \tableofcontents \section{Some Interesting Words} Well, and here begins my lovely article. \section{Good Bye World} \ldots{} and here it ends. \end{document} Figure 1.2: Example of a Realistic Journal Article. Note that all the commands you see in this example will be explained later in the introduction. 1.6 The Layout of the Document 11 Table 1.2: Document Class Options. 10pt, 11pt, 12pt Sets the size of the main font in the document. If no option is specified, 10pt is assumed. a4paper, letterpaper, . . . Defines the paper size. The default size is letterpaper. Besides that, a5paper, b5paper, executivepaper, and legalpaper can be specified. fleqn Typesets displayed formulae left-aligned instead of centred. leqno Places the numbering of formulae on the left hand side instead of the right. titlepage, notitlepage Specifies whether a new page should be started after the document title or not. The article class does not start a new page by default, while report and book do. onecolumn, twocolumn Instructs LATEX to typeset the document in one column or two columns. twoside, oneside Specifies whether double or single sided output should be generated. The classes article and report are single sided and the book class is double sided by default. Note that this option concerns the style of the document only. The option twoside does not tell the printer you use that it should actually make a two-sided printout. landscape Changes the layout of the document to print in landscape mode. openright, openany Makes chapters begin either only on right hand pages or on the next page available. This does not work with the article class, as it does not know about chapters. The report class by default starts chapters on the next page available and the book class starts them on right hand pages. 12 Things You Need to Know Table 1.3: Some of the Packages Distributed with LATEX. doc Allows the documentation of LATEX programs. Described in doc.dtxa and in The LATEX Companion [3]. exscale Provides scaled versions of the math extension font. Described in ltexscale.dtx. fontenc Specifies which font encoding LATEX should use. Described in ltoutenc.dtx. ifthen Provides commands of the form ‘if. . . then do. . . otherwise do. . . .’ Described in ifthen.dtx and The LATEX Companion [3]. latexsym To access the LATEX symbol font, you should use the latexsym package. Described in latexsym.dtx and in The LATEX Companion [3]. makeidx Provides commands for producing indexes. Described in section 4.3 and in The LATEX Companion [3]. syntonly Processes a document without typesetting it. inputenc Allows the specification of an input encoding such as ASCII, ISO Latin-1, ISO Latin-2, 437/850 IBM code pages, Apple Macintosh, Next, ANSI-Windows or user-defined one. Described in inputenc.dtx. aThis file should be installed on your system, and you should be able to get a dvi file by typing latex doc.dtx in any directory where you have write permission. The same is true for all the other files mentioned in this table. Table 1.4: The Predefined Page Styles of LATEX. plain prints the page numbers on the bottom of the page, in the middle of the footer. This is the default page style. headings prints the current chapter heading and the page number in the header on each page, while the footer remains empty. (This is the style used in this document) empty sets both the header and the footer to be empty. 1.7 Files You Might Encounter 13 in The LATEX Companion [3] and in section 4.4 on page 86. 1.7 Files You Might Encounter When you work with LATEX you will soon find yourself in a maze of files with various extensions and probably no clue. The following list explains the various file types you might encounter when working with TEX. Please note that this table does not claim to be a complete list of extensions, but if you find one missing that you think is important, please drop me a line. .tex LATEX or TEX input file. Can be compiled with latex. .sty LATEX Macro package. Load this into your LATEX document using the \usepackage command. .dtx Documented TEX. This is the main distribution format for LATEX style files. If you process a .dtx file you get documented macro code of the LATEX package contained in the .dtx file. .ins The installer for the files contained in the matching .dtx file. If you download a LATEX package from the net, you will normally get a .dtx and a .ins file. Run LATEX on the .ins file to unpack the .dtx file. .cls Class files define what your document looks like. They are selected with the \documentclass command. .fd Font description file telling LATEX about new fonts. The following files are generated when you run LATEX on your input file: .dvi Device Independent File. This is the main result of a LATEX compile run. Look at its content with a DVI previewer program or send it to a printer with dvips or a similar application. .log Gives a detailed account of what happened during the last compiler run. .toc Stores all your section headers. It gets read in for the next compiler run and is used to produce the table of content. .lof This is like .toc but for the list of figures. .lot And again the same for the list of tables. .aux Another file that transports information from one compiler run to the next. Among other things, the .aux file is used to store information associated with cross-references. Chapter 2 Typesetting Text After reading the previous chapter, you should know about the basic stuff of which a LATEX2ε document is made. In this chapter I will fill in the remaining structure you will need to know in order to produce real world material. 2.1 The Structure of Text and Language By Hanspeter Schmid <hanspi@schmid-werren.ch> The main point of writing a text (some modern DAAC1 literature excluded), is to convey ideas, information, or knowledge to the reader. The reader will understand the text better if these ideas are well-structured, and will see and feel this structure much better if the typographical form reflects the logical and semantical structure of the content. LATEX is different from other typesetting systems in that you just have to tell it the logical and semantical structure of a text. It then derives the typographical form of the text according to the “rules” given in the document class file and in various style files. The most important text unit in LATEX (and in typography) is the paragraph. We call it “text unit” because a paragraph is the typographical form that should reflect one coherent thought, or one idea. You will learn in the following sections how to force line breaks with e.g. \\, and paragraph breaks with e.g. leaving an empty line in the source code. Therefore, if a new thought begins, a new paragraph should begin, and if not, only line breaks should be used. If in doubt about paragraph breaks, think about your text as a conveyor of ideas and thoughts. If you have a paragraph break, but the old thought continues, it should be removed. If some totally new line of thought occurs in the same paragraph, then it should be broken. Most people completely underestimate the importance of well-placed paragraph breaks. Many people do not even know what the meaning of 1Different At All Cost, a translation of the Swiss German UVA (Um’s Verrecken Anders). 18 Typesetting Text a paragraph break is, or, especially in LATEX, introduce paragraph breaks without knowing it. The latter mistake is especially easy to make if equations are used in the text. Look at the following examples, and figure out why sometimes empty lines (paragraph breaks) are used before and after the equation, and sometimes not. (If you don’t yet understand all commands well enough to understand these examples, please read this and the following chapter, and then read this section again.) % Example 1 \ldots when Einstein introduced his formula \begin{equation} e = m \cdot c^2 \; , \end{equation} which is at the same time the most widely known and the least well understood physical formula. % Example 2 \ldots from which follows Kirchhoff’s current law: \begin{equation} \sum_{k=1}^{n} I_k = 0 \; . \end{equation} Kirchhoff’s voltage law can be derived \ldots % Example 3 \ldots which has several advantages. \begin{equation} I_D = I_F - I_R \end{equation} is the core of a very different transistor model. \ldots The next smaller text unit is a sentence. In English texts, there is a larger space after a period that ends a sentence than after one that ends an abbreviation. LATEX tries to figure out which one you wanted to have. If LATEX gets it wrong, you must tell it what you want. This is explained later in this chapter. The structuring of text even extends to parts of sentences. Most languages have very complicated punctuation rules, but in many languages (including German and English), you will get almost every comma right if you remember what it represents: a short stop in the flow of language. If you are not sure about where to put a comma, read the sentence aloud and take a short 2.3 Ready-Made Strings 21 The command \- inserts a discretionary hyphen into a word. This also becomes the only point hyphenation is allowed in this word. This command is especially useful for words containing special characters (e.g. accented characters), because LATEX does not automatically hyphenate words containing special characters. I think this is: su\-per\-cal\-% i\-frag\-i\-lis\-tic\-ex\-pi\-% al\-i\-do\-cious I think this is: supercalifragilisticexpiali- docious Several words can be kept together on one line with the command \mbox{text} It causes its argument to be kept together under all circumstances. My phone number will change soon. It will be \mbox{0116 291 2319}. The parameter \mbox{\emph{filename}} should contain the name of the file. My phone number will change soon. It will be 0116 291 2319. The parameter filename should contain the name of the file. \fbox is similar to \mbox, but in addition there will be a visible box drawn around the content. 2.3 Ready-Made Strings In some of the examples on the previous pages, you have seen some very simple LATEX commands for typesetting special text strings: Command Example Description \today June 24, 2010 Current date \TeX TEX Your favorite typesetter \LaTeX LATEX The Name of the Game \LaTeXe LATEX2ε The current incarnation 2.4 Special Characters and Symbols 2.4.1 Quotation Marks You should not use the " for quotation marks as you would on a typewriter. In publishing there are special opening and closing quotation marks. In LATEX, use two ` (grave accent) for opening quotation marks and two ' (vertical quote) for closing quotation marks. For single quotes you use just one of each. 22 Typesetting Text ‘‘Please press the ‘x’ key.’’ “Please press the ‘x’ key.” Yes I know the rendering is not ideal, it’s really a back-tick or grave accent (`) for opening quotes and vertical quote (') for closing, despite what the font chosen might suggest. 2.4.2 Dashes and Hyphens LATEX knows four kinds of dashes. Access three of them with different number of consecutive dashes. The fourth sign is actually not a dash at all—it is the mathematical minus sign: daughter-in-law, X-rated\\ pages 13--67\\ yes---or no? \\ $0$, $1$ and $-1$ daughter-in-law, X-rated pages 13–67 yes—or no? 0, 1 and −1 The names for these dashes are: ‘-’ hyphen, ‘–’ en-dash, ‘—’ em-dash and ‘−’ minus sign. 2.4.3 Tilde (∼) A character often seen in web addresses is the tilde. To generate this in LATEX use \~ but the result: ˜ is not really what you want. Try this instead: http://www.rich.edu/\~{}bush \\ http://www.clever.edu/$\sim$demo http://www.rich.edu/˜bush http://www.clever.edu/∼demo 2.4.4 Degree Symbol (◦) Printing the degree symbol in pure LATEX. It’s $-30\,^{\circ}\mathrm{C}$. I will soon start to super-conduct. It’s −30 ◦C. I will soon start to super- conduct. The textcomp package makes the degree symbol also available as \textdegree or in combination with the C by using the \textcelsius. 30 \textcelsius{} is 86 \textdegree{}F. 30 ℃ is 86 °F. 2.4 Special Characters and Symbols 23 2.4.5 The Euro Currency Symbol (e) When writing about money these days, you need the Euro symbol. Many current fonts contain a Euro symbol. After loading the textcomp package in the preamble of your document \usepackage{textcomp} use the command \texteuro to access it. If your font does not provide its own Euro symbol or if you do not like the font’s Euro symbol, you have two more choices: First the eurosym package. It provides the official Euro symbol: \usepackage[official]{eurosym} If you prefer a Euro symbol that matches your font, use the option gen in place of the official option. Table 2.1: A bag full of Euro symbols LM+textcomp \texteuro € € € eurosym \euro e e e [gen]eurosym \euro AC AC AC 2.4.6 Ellipsis (. . . ) On a typewriter, a comma or a period takes the same amount of space as any other letter. In book printing, these characters occupy only a little space and are set very close to the preceding letter. Therefore, entering ‘ellipsis’ by just typing three dots would be wrong produce the wrong result. Instead, there is a special command for these dots. It is called \ldots Not like this ... but like this:\\ New York, Tokyo, Budapest, \ldots Not like this ... but like this: New York, Tokyo, Budapest, . . . 26 Typesetting Text encoding used for different groups of languages and/or on different computer platforms LATEX employs the inputenc package: \usepackage[encoding]{inputenc} When using this package, you should consider that other people might not be able to display your input files on their computer, because they use a different encoding. For example, the German umlaut ä on OS/2 is encoded as 132, on Unix systems using ISO-LATIN 1 it is encoded as 228, while in Cyrillic encoding cp1251 for Windows this letter does not exist at all; therefore you should use this feature with care. The following encodings may come in handy, depending on the type of system you are working on4 Operating encodings system western Latin Cyrillic Mac applemac macukr Unix latin1 koi8-ru Windows ansinew cp1251 DOS, OS/2 cp850 cp866nav If you have a multilingual document with conflicting input encodings, you might want to switch to unicode, using the ucs package. \usepackage{ucs} \usepackage[utf8x]{inputenc} will enable you to create LATEX input files in utf8x, a multi-byte encoding in which each character can be encoded in as little as one byte and as many as four bytes. Font encoding is a different matter. It defines at which position inside a TEX-font each letter is stored. Multiple input encodings could be mapped into one font encoding, which reduces number of required font sets. Font encodings are handled through fontenc package: \usepackage[encoding]{fontenc} where encoding is font encoding. It is possible to load several encodings simultaneously. The default LATEX font encoding is OT1, the encoding of the original Computer Modern TEX font. It contains only the 128 characters of the 7-bit ASCII character set. When accented characters are required, TEX creates 4To learn more about supported input encodings for Latin-based and Cyrillic-based languages, read the documentation for inputenc.dtx and cyinpenc.dtx respectively. Section 4.6 tells how to produce package documentation. 2.5 International Language Support 27 them by combining a normal character with an accent. While the resulting output looks perfect, this approach stops the automatic hyphenation from working inside words containing accented characters. Besides, some of Latin letters could not be created by combining a normal character with an accent, to say nothing about letters of non-Latin alphabets, such as Greek or Cyrillic. To overcome these shortcomings, several 8-bit CM-like font sets were created. Extended Cork (EC) fonts in T1 encoding contains letters and punctuation characters for most of the European languages based on Latin script. The LH font set contains letters necessary to typeset documents in languages using Cyrillic script. Because of the large number of Cyrillic glyphs, they are arranged into four font encodings—T2A, T2B, T2C, and X2.5 The CB bundle contains fonts in LGR encoding for the composition of Greek text. Improve/enable hyphenation in non-English documents by using these fonts. Another advantage of using new CM-like fonts is that they provide fonts of CM families in all weights, shapes, and optically scaled font sizes. 2.5.1 Support for Portuguese By Demerson Andre Polli <polli@linux.ime.usp.br> To enable hyphenation and change all automatic text to Portuguese, use the command: \usepackage[portuguese]{babel} Or if you are in Brazil, substitute the language for brazilian. As there are a lot of accents in Portuguese you might want to use \usepackage[latin1]{inputenc} to be able to input them correctly as well as \usepackage[T1]{fontenc} to get the hyphenation right. See table 2.3 for the preamble you need to write in the Portuguese language. Note that we are using the latin1 input encoding here, so this will not work on a Mac or on DOS. Just use the appropriate encoding for your system. 5The list of languages supported by each of these encodings could be found in [11]. 28 Typesetting Text Table 2.3: Preamble for Portuguese documents. \usepackage[portuguese]{babel} \usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} 2.5.2 Support for French By Daniel Flipo <daniel.flipo@univ-lille1.fr> Some hints for those creating French documents with LATEX: load French language support with the following command: \usepackage[francais]{babel} This enables French hyphenation, if you have configured your LATEX system accordingly. It also changes all automatic text into French: \chapter prints Chapitre, \today prints the current date in French and so on. A set of new commands also becomes available, which allows you to write French input files more easily. Check out table 2.4 for inspiration. Table 2.4: Special commands for French. \og guillemets \fg{} « guillemets » M\up{me}, D\up{r} Mme, Dr 1\ier{}, 1\iere{}, 1\ieres{} 1er, 1re, 1res 2\ieme{} 4\iemes{} 2e 4es \No 1, \no 2 No 1, no 2 20~\degres C, 45\degres 20 °C, 45° \bsc{M. Durand} M. Durand \nombre{1234,56789} 1 234,567 89 You will also notice that the layout of lists changes when switching to the French language. For more information on what the francais option of babel does and how to customize its behaviour, run LATEX on file frenchb.dtx and read the produced file frenchb.dvi. Recent versions of frenchb rely on numprint to implement the \nombre command. 2.5 International Language Support 31 Werner Lemberg.8 HLATEX and hLATEXp are specific to Korean and provide Korean localization on top of the font support. They both can process Korean input text files encoded in EUC-KR. HLATEX can even process input files encoded in CP949/Windows-949/UHC and UTF-8 when used along with Λ, Ω. The CJK package is not specific to Korean. It can process input files in UTF-8 as well as in various CJK encodings including EUC-KR and CP949/Windows-949/UHC, it can be used to typeset documents with multilingual content (especially Chinese, Japanese and Korean). The CJK package has no Korean localization such as the one offered by HLATEX and it does not come with as many special Korean fonts as HLATEX. 3. The ultimate purpose of using typesetting programs like TEX and LATEX is to get documents typeset in an ‘aesthetically’ satisfying way. Arguably the most important element in typesetting is a set of well- designed fonts. The HLATEX distribution includes UHC PostScript fonts of 10 different families and Munhwabu9 fonts (TrueType) of 5 different families. The CJK package works with a set of fonts used by earlier versions of HLATEX and it can use Bitstream’s cyberbit TrueType font. To use the HLATEX package for typesetting your Korean text, put the following declaration into the preamble of your document: \usepackage{hangul} This command turns the Korean localization on. The headings of chapters, sections, subsections, table of content and table of figures are all translated into Korean and the formatting of the document is changed to follow Korean conventions. The package also provides automatic “particle selection.” In Korean, there are pairs of post-fix particles grammatically equivalent but different in form. Which of any given pair is correct depends on whether the preceding syllable ends with a vowel or a consonant. (It is a bit more complex than this, but this should give you a good picture.) Native Korean speakers have no problem picking the right particle, but it cannot be determined which particle to use for references and other automatic text that will change while you edit the document. It takes a painstaking effort to place appropriate particles manually every time you add/remove references or simply shuffle parts of your document around. HLATEX relieves its users from this boring and error-prone process. 8They can be obtained at language/korean/HLaTeX/ language/korean/CJK/ and http://knot.kaist.ac.kr/htex/ 9Korean Ministry of Culture. 32 Typesetting Text Table 2.6: Preamble for Greek documents. \usepackage[english,greek]{babel} \usepackage[iso-8859-7]{inputenc} In case you don’t need Korean localization features but just want to typeset Korean text, put the following line in the preamble, instead. \usepackage{hfont} For more details on typesetting Korean with HLATEX, refer to the HLATEX Guide. Check out the web site of the Korean TEX User Group (KTUG) at http://www.ktug.or.kr/. There is also a Korean translation of this manual available. 2.5.5 Writing in Greek By Nikolaos Pothitos <pothitos@di.uoa.gr> See table 2.6 for the preamble you need to write in the Greek language. This preamble enables hyphenation and changes all automatic text to Greek.10 A set of new commands also becomes available, which allows you to write Greek input files more easily. In order to temporarily switch to English and vice versa, one can use the commands \textlatin{english text} and \textgreek{greek text} that both take one argument which is then typeset using the requested font encoding. Otherwise use the command \selectlanguage{...} described in a previous section. Check out table 2.7 for some Greek punctuation characters. Use \euro for the Euro symbol. Table 2.7: Greek Special Characters. ; · ? ; (( « )) » ‘‘ ‘ ’’ ’ 10If you select the utf8x option for the package inputenc, LATEX will understand Greek and polytonic Greek unicode characters. 2.5 International Language Support 33 2.5.6 Support for Cyrillic By Maksym Polyakov <polyama@myrealbox.com> Version 3.7h of babel includes support for the T2* encodings and for typeset- ting Bulgarian, Russian and Ukrainian texts using Cyrillic letters. Support for Cyrillic is based on standard LATEX mechanisms plus the fontenc and inputenc packages. But, if you are going to use Cyrillics in math mode, you need to load mathtext package before fontenc:11 \usepackage{mathtext} \usepackage[T1,T2A]{fontenc} \usepackage[koi8-ru]{inputenc} \usepackage[english,bulgarian,russian,ukranian]{babel} Generally, babel will authomatically choose the default font encoding, for the above three languages this is T2A. However, documents are not restricted to a single font encoding. For multi-lingual documents using Cyrillic and Latin-based languages it makes sense to include Latin font encoding explicitly. babel will take care of switching to the appropriate font encoding when a different language is selected within the document. In addition to enabling hyphenations, translating automatically gener- ated text strings, and activating some language specific typographic rules (like \frenchspacing), babel provides some commands allowing typesetting according to the standards of Bulgarian, Russian, or Ukrainian languages. For all three languages, language specific punctuation is provided: The Cyrillic dash for the text (it is little narrower than Latin dash and surrounded by tiny spaces), a dash for direct speech, quotes, and commands to facilitate hyphenation, see Table 2.8. The Russian and Ukrainian options of babel define the commands \Asbuk and \asbuk, which act like \Alph and \alph, but produce capital and small letters of Russian or Ukrainian alphabets (whichever is the active language of the document). The Bulgarian option of babel provides the commands \enumBul and \enumLat (\enumEng), which make \Alph and \alph produce letters of either Bulgarian or Latin (English) alphabets. The default behaviour of \Alph and \alph for the Bulgarian language option is to produce letters from the Bulgarian alphabet. 2.5.7 Support for Mongolian To use LATEX for typesetting Mongolian you have a choice between two packages: Multilingual Babel and MonTEX by Oliver Corff. 11If you use AMS-LATEX packages, load them before fontenc and babel as well. 36 Typesetting Text The following sectioning commands are available for the article class: \section{...} \subsection{...} \subsubsection{...} \paragraph{...} \subparagraph{...} If you want to split your document in parts without influencing the section or chapter numbering use \part{...} When you work with the report or book class, an additional top-level sectioning command becomes available \chapter{...} As the article class does not know about chapters, it is quite easy to add articles as chapters to a book. The spacing between sections, the numbering and the font size of the titles will be set automatically by LATEX. Two of the sectioning commands are a bit special: • The \part command does not influence the numbering sequence of chapters. • The \appendix command does not take an argument. It just changes the chapter numbering to letters.12 LATEX creates a table of contents by taking the section headings and page numbers from the last compile cycle of the document. The command \tableofcontents expands to a table of contents at the place it is issued. A new document has to be compiled (“LATEXed”) twice to get a correct table of contents. Sometimes it might be necessary to compile the document a third time. LATEX will tell you when this is necessary. All sectioning commands listed above also exist as “starred” versions. A “starred” version of a command is built by adding a star * after the command name. This generates section headings that do not show up in the table of contents and are not numbered. The command \section{Help}, for example, would become \section*{Help}. 12For the article style it changes the section numbering. 2.7 Titles, Chapters, and Sections 37 Normally the section headings show up in the table of contents exactly as they are entered in the text. Sometimes this is not possible, because the heading is too long to fit into the table of contents. The entry for the table of contents can then be specified as an optional argument in front of the actual heading. \chapter[Title for the table of contents]{A long and especially boring title, shown in the text} The title of the whole document is generated by issuing a \maketitle command. The contents of the title have to be defined by the commands \title{...}, \author{...} and optionally \date{...} before calling \maketitle. In the argument to \author, you can supply several names separated by \and commands. An example of some of the commands mentioned above can be found in Figure 1.2 on page 8. Apart from the sectioning commands explained above, LATEX2ε intro- duced three additional commands for use with the book class. They are useful for dividing your publication. The commands alter chapter headings and page numbering to work as you would expect it in a book: \frontmatter should be the very first command after the start of the document body (\begin{document}). It will switch page numbering to Roman numerals and sections be non-enumerated. As if you were using the starred sectioning commands (eg \chapter*{Preface}) but the sections will still show up in the table of contents. \mainmatter comes right before the first chapter of the book. It turns on Arabic page numbering and restarts the page counter. \appendix marks the start of additional material in your book. After this command chapters will be numbered with letters. \backmatter should be inserted before the very last items in your book, such as the bibliography and the index. In the standard document classes, this has no visual effect. 38 Typesetting Text 2.8 Cross References In books, reports and articles, there are often cross-references to figures, tables and special segments of text. LATEX provides the following commands for cross referencing \label{marker}, \ref{marker} and \pageref{marker} where marker is an identifier chosen by the user. LATEX replaces \ref by the number of the section, subsection, figure, table, or theorem after which the corresponding \label command was issued. \pageref prints the page number of the page where the \label command occurred.13 As with the section titles, the numbers from the previous run are used. A reference to this subsection \label{sec:this} looks like: ‘‘see section~\ref{sec:this} on page~\pageref{sec:this}.’’ A reference to this subsection looks like: “see section 2.8 on page 38.” 2.9 Footnotes With the command \footnote{footnote text} a footnote is printed at the foot of the current page. Footnotes should always be put14 after the word or sentence they refer to. Footnotes referring to a sentence or part of it should therefore be put after the comma or period.15 Footnotes\footnote{This is a footnote.} are often used by people using \LaTeX. Footnotesa are often used by people using LATEX. aThis is a footnote. 13Note that these commands are not aware of what they refer to. \label just saves the last automatically generated number. 14“put” is one of the most common English words. 15Note that footnotes distract the reader from the main body of your document. After all, everybody reads the footnotes—we are a curious species, so why not just integrate everything you want to say into the body of the document?16 16A guidepost doesn’t necessarily go where it’s pointing to :-). 2.11 Environments 41 \begin{center} At the centre\\of the earth \end{center} At the centre of the earth 2.11.3 Quote, Quotation, and Verse The quote environment is useful for quotes, important phrases and examples. A typographical rule of thumb for the line length is: \begin{quote} On average, no line should be longer than 66 characters. \end{quote} This is why \LaTeX{} pages have such large borders by default and also why multicolumn print is used in newspapers. A typographical rule of thumb for the line length is: On average, no line should be longer than 66 characters. This is why LATEX pages have such large borders by default and also why multicol- umn print is used in newspapers. There are two similar environments: the quotation and the verse envi- ronments. The quotation environment is useful for longer quotes going over several paragraphs, because it indents the first line of each paragraph. The verse environment is useful for poems where the line breaks are important. The lines are separated by issuing a \\ at the end of a line and an empty line after each verse. I know only one English poem by heart. It is about Humpty Dumpty. \begin{flushleft} \begin{verse} Humpty Dumpty sat on a wall:\\ Humpty Dumpty had a great fall.\\ All the King’s horses and all the King’s men\\ Couldn’t put Humpty together again. \end{verse} \end{flushleft} I know only one English poem by heart. It is about Humpty Dumpty. Humpty Dumpty sat on a wall: Humpty Dumpty had a great fall. All the King’s horses and all the King’s men Couldn’t put Humpty together again. 2.11.4 Abstract In scientific publications it is customary to start with an abstract which gives the reader a quick overview of what to expect. LATEX provides the abstract environment for this purpose. Normally abstract is used in documents typeset with the article document class. 42 Typesetting Text \begin{abstract} The abstract abstract. \end{abstract} The abstract abstract. 2.11.5 Printing Verbatim Text that is enclosed between \begin{verbatim} and \end{verbatim} will be directly printed, as if typed on a typewriter, with all line breaks and spaces, without any LATEX command being executed. Within a paragraph, similar behavior can be accessed with \verb+text+ The + is just an example of a delimiter character. Use any character except letters, * or space. Many LATEX examples in this booklet are typeset with this command. The \verb|\ldots| command \ldots \begin{verbatim} 10 PRINT "HELLO WORLD "; 20 GOTO 10 \end{verbatim} The \ldots command . . . 10 PRINT "HELLO WORLD "; 20 GOTO 10 \begin{verbatim*} the starred version of the verbatim environment emphasizes the spaces in the text \end{verbatim*} the␣starred␣version␣of the␣␣␣␣␣␣verbatim environment␣emphasizes the␣spaces␣␣␣in␣the␣text The \verb command can be used in a similar fashion with a star: \verb*|like this :-) | like␣␣␣this␣:-)␣ The verbatim environment and the \verb command may not be used within parameters of other commands. 2.11.6 Tabular The tabular environment can be used to typeset beautiful tables with optional horizontal and vertical lines. LATEX determines the width of the columns automatically. 2.11 Environments 43 The table spec argument of the \begin{tabular}[pos]{table spec} command defines the format of the table. Use an l for a column of left- aligned text, r for right-aligned text, and c for centred text; p{width } for a column containing justified text with line breaks, and | for a vertical line. If the text in a column is too wide for the page, LATEX won’t automatically wrap it. Using p{width } you can define a special type of column which will wrap-around the text as in a normal paragraph. The pos argument specifies the vertical position of the table relative to the baseline of the surrounding text. Use either of the letters t , b and c to specify table alignment at the top, bottom or center. Within a tabular environment, & jumps to the next column, \\ starts a new line and \hline inserts a horizontal line. Add partial lines by using the \cline{j-i}, where j and i are the column numbers the line should extend over. \begin{tabular}{|r|l|} \hline 7C0 & hexadecimal \\ 3700 & octal \\ \cline{2-2} 11111000000 & binary \\ \hline \hline 1984 & decimal \\ \hline \end{tabular} 7C0 hexadecimal 3700 octal 11111000000 binary 1984 decimal \begin{tabular}{|p{4.7cm}|} \hline Welcome to Boxy’s paragraph. We sincerely hope you’ll all enjoy the show.\\ \hline \end{tabular} Welcome to Boxy’s paragraph. We sincerely hope you’ll all en- joy the show. The column separator can be specified with the @{...} construct. This command kills the inter-column space and replaces it with whatever is between the curly braces. One common use for this command is explained below in the decimal alignment problem. Another possible application is to suppress leading space in a table with @{} . 46 Typesetting Text Any material enclosed in a figure or table environment will be treated as floating matter. Both float environments support an optional parameter \begin{figure}[placement specifier] or \begin{table}[. . . ] called the placement specifier. This parameter is used to tell LATEX about the locations to which the float is allowed to be moved. A placement specifier is constructed by building a string of float-placing permissions. See Table 2.9. A table could be started with the following line e.g. \begin{table}[!hbp] The placement specifier [!hbp] allows LATEX to place the table right here (h) or at the bottom (b) of some page or on a special floats page (p), and all this even if it does not look that good (!). If no placement specifier is given, the standard classes assume [tbp]. LATEX will place every float it encounters according to the placement specifier supplied by the author. If a float cannot be placed on the current page it is deferred either to the figures or the tables queue.19 When a new page is started, LATEX first checks if it is possible to fill a special ‘float’ page with floats from the queues. If this is not possible, the first float on each queue is treated as if it had just occurred in the text: LATEX tries again to place it according to its respective placement specifiers (except ‘h,’ which is no longer possible). Any new floats occurring in the text get placed into the appropriate queues. LATEX strictly maintains the original order of appearance 19These are FIFO—‘first in first out’—queues! Table 2.9: Float Placing Permissions. Spec Permission to place the float . . . h here at the very place in the text where it oc- curred. This is useful mainly for small floats. t at the top of a page b at the bottom of a page p on a special page containing only floats. ! without considering most of the internal param- etersa, which could stop this float from being placed. Note that pt and em are TEX units. Read more on this in table 6.5 on page 127. aSuch as the maximum number of floats allowed on one page. 2.12 Floating Bodies 47 for each type of float. That’s why a figure that cannot be placed pushes all further figures to the end of the document. Therefore: If LATEX is not placing the floats as you expected, it is often only one float jamming one of the two float queues. While it is possible to give LATEX single-location placement specifiers, this causes problems. If the float does not fit in the location specified it becomes stuck, blocking subsequent floats. In particular, you should never, ever use the [h] option—it is so bad that in more recent versions of LATEX, it is automatically replaced by [ht]. Having explained the difficult bit, there are some more things to mention about the table and figure environments. Use the \caption{caption text} command to define a caption for the float. A running number and the string “Figure” or “Table” will be added by LATEX. The two commands \listoffigures and \listoftables operate analogously to the \tableofcontents command, printing a list of figures or tables, respectively. These lists will display the whole caption, so if you tend to use long captions you must have a shorter version of the caption for the lists. This is accomplished by entering the short version in brackets after the \caption command. \caption[Short]{LLLLLoooooonnnnnggggg} Use \label and \ref,to create a reference to a float within your text. Note that the \label command must come after the \caption command since you want it to reference the number of the caption. The following example draws a square and inserts it into the document. You could use this if you wanted to reserve space for images you are going to paste into the finished document. Figure~\ref{white} is an example of Pop-Art. \begin{figure}[!hbtp] \makebox[\textwidth]{\framebox[5cm]{\rule{0pt}{5cm}}} \caption{Five by Five in Centimetres.\label{white}} \end{figure} 48 Typesetting Text In the example above, LATEX will try really hard (!) to place the figure right here (h).20 If this is not possible, it tries to place the figure at the bottom (b) of the page. Failing to place the figure on the current page, it determines whether it is possible to create a float page containing this figure and maybe some tables from the tables queue. If there is not enough material for a special float page, LATEX starts a new page, and once more treats the figure as if it had just occurred in the text. Under certain circumstances it might be necessary to use the \clearpage or even the \cleardoublepage command. It orders LATEX to immediately place all floats remaining in the queues and then start a new page. \cleardoublepage even goes to a new right-hand page. You will learn how to include PostScript drawings into your LATEX2ε documents later in this introduction. 2.13 Protecting Fragile Commands Text given as arguments of commands like \caption or \section may show up more than once in the document (e.g. in the table of contents as well as in the body of the document). Some commands will break when used in the argument of \section-like commands. Compilation of your document will fail. These commands are called fragile commands—for example, \footnote or \phantom. These fragile commands need protection (don’t we all?). Protect them by putting the \protect command in front of them. \protect only refers to the command that follows right behind, not even to its arguments. In most cases a superfluous \protect won’t hurt. \section{I am considerate \protect\footnote{and protect my footnotes}} 20assuming the figure queue is empty. 3.2 Single Equations 51 Add $a$ squared and $b$ squared to get $c$ squared. Or, using a more mathematical approach \begin{equation*} a^2 + b^2 = c^2 \end{equation*} or you can type less for the same effect: \[ a^2 + b^2 = c^2 \] Add a squared and b squared to get c squared. Or, using a more mathematical approach a2 + b2 = c2 or you can type less for the same effect: a2 + b2 = c2 While \[ is short and sweet, it does not allow to switch between numbered and not numbered style as easily as nicely equation and equation*. Note the difference in typesetting style between text style and display style equations: This is text style: $\lim_{n \to \infty} \sum_{k=1}^n \frac{1}{k^2} = \frac{\pi^2}{6}$. And this is display style: \begin{equation} \lim_{n \to \infty} \sum_{k=1}^n \frac{1}{k^2} = \frac{\pi^2}{6} \end{equation} This is text style: limn→∞ ∑n k=1 1 k2 = π2 6 . And this is display style: lim n→∞ n∑ k=1 1 k2 = π 2 6 (3.3) In text style, enclose tall or deep math expressions or sub expressions in \smash. This makes LATEX ignore the height of these expressions. This keeps the line spacing even. A $d_{e_{e_p}}$ mathematical expression followed by a $h^{i^{g^h}}$ expression. As opposed to a smashed \smash{$d_{e_{e_p}}$} expression followed by a \smash{$h^{i^{g^h}}$} expression. A deep mathematical expression followed by a hig h expression. As opposed to a smashed deep expression followed by a h ig h expression. 3.2.1 Math Mode There are also differences between math mode and text mode. For example, in math mode: 1. Most spaces and line breaks do not have any significance, as all spaces are either derived logically from the mathematical expressions, or have to be specified with special commands such as \,, \quad or \qquad (we’ll get back to that later, see section 3.7). 52 Typesetting Mathematical Formulae 2. Empty lines are not allowed. Only one paragraph per formula. 3. Each letter is considered to be the name of a variable and will be typeset as such. If you want to typeset normal text within a formula (normal upright font and normal spacing) then you have to enter the text using the \text{...} command (see also section 3.8 on page 66). $\forall x \in \mathbf{R}: \qquad x^{2} \geq 0$ ∀x ∈ R : x 2 ≥ 0 $x^{2} \geq 0\qquad \text{for all }x\in\mathbf{R}$ x 2 ≥ 0 for all x ∈ R Mathematicians can be very fussy about which symbols are used: it would be conventional here to use the ‘blackboard bold’ font, which is obtained using \mathbb from the package amssymb.4 The last example becomes $x^{2} \geq 0\qquad \text{for all } x \in \mathbb{R}$ x2 ≥ 0 for all x ∈ R See Table 3.14 on page 76 and Table 6.4 on page 123 for more math fonts. 3.3 Building Blocks of a Mathematical Formula In this section, we describe the most important commands used in mathe- matical typesetting. Most of the commands in this section will not require amsmath (if they do, it will be stated clearly), but load it anyway. Lowercase Greek letters are entered as \alpha, \beta, \gamma, . . . , uppercase letters are entered as \Gamma, \Delta, . . . 5 Take a look at Table 3.2 on page 72 for a list of Greek letters. $\lambda,\xi,\pi,\theta, \mu,\Phi,\Omega,\Delta$ λ, ξ, π, θ, µ,Φ,Ω,∆ Exponents and Subscripts can be specified using the ^ and the _ character. Most math mode commands act only on the next character, so if you want a command to affect several characters, you have to group them together using curly braces: {...}. 4amssymb is not a part of the AMS-LATEX bundle, but it is perhaps still a part of your LATEX distribution. Check your distribution or go to CTAN:/fonts/amsfonts/latex/ to obtain it. 5There is no uppercase Alpha, Beta etc. defined in LATEX2ε because it looks the same as a normal roman A, B. . . Once the new math coding is done, things will change. 3.3 Building Blocks of a Mathematical Formula 53 Table 3.3 on page 73 lists a lot of other binary relations like ⊆ and ⊥. $p^3_{ij} \qquad m_\text{Knuth} \\[5pt] a^x+y \neq a^{x+y}\qquad e^{x^2} \neq {e^x}^2$ p3ij mKnuth ax + y 6= ax+y ex2 6= ex2 The square root is entered as \sqrt; the nth root is generated with \sqrt[n]. The size of the root sign is determined automatically by LATEX. If just the sign is needed, use \surd. See other kinds of arrows like ↪→ and on Table 3.6 on page 74. $\sqrt{x} \Leftrightarrow x^{1/2} \quad \sqrt[3]{2} \quad \sqrt{x^{2} + \sqrt{y}} \quad \surd[x^2 + y^2]$ √ x⇔ x1/2 3 √ 2 √ x2 +√y √ [x2 +y2] Usually you don’t typeset an explicit dot sign to indicate the multiplica- tion operation when handling symbols; however sometimes it is written to help the reader’s eyes in grouping a formula. You should use \cdot which typesets a single dot centered. \cdots is three centered dots while \ldots sets the dots on the baseline. Besides that, there are \vdots for vertical and \ddots for diagonal dots. You can find another example in section 3.6. $\Psi = v_1 \cdot v_2 \cdot \ldots \qquad n! = 1 \cdot 2 \cdots (n-1) \cdot n$ Ψ = v1 · v2 · . . . n! = 1 · 2 · · · (n− 1) · n The commands \overline and \underline create horizontal lines directly over or under an expression: $0.\overline{3} = \underline{\underline{1/3}}$ 0.3 = 1/3 The commands \overbrace and \underbrace create long horizontal braces over or under an expression: $\underbrace{\overbrace{a+b+c}^6 \cdot \overbrace{d+e+f}^9} _\text{meaning of life} = 42$ 6︷ ︸︸ ︷ a+ b+ c · 9︷ ︸︸ ︷ d+ e+ f︸ ︷︷ ︸ meaning of life = 42 To add mathematical accents such as small arrows or tilde signs to variables, the commands given in Table 3.1 on page 72 might be useful. Wide hats and tildes covering several characters are generated with \widetilde 56 Typesetting Mathematical Formulae The integral operator is generated with \int, the sum operator with \sum, and the product operator with \prod. The upper and lower limits are specified with ^ and _ like subscripts and superscripts: \begin{equation*} \sum_{i=1}^n \qquad \int_0^{\frac{\pi}{2}} \qquad \prod_\epsilon \end{equation*} n∑ i=1 ∫ π 2 0 ∏  To get more control over the placement of indices in complex expressions, amsmath provides the \substack command: \begin{equation*} \sum^n_{\substack{0<i<n \\ j\subseteq i}} P(i,j) = Q(i,j) \end{equation*} n∑ 0<i<n j⊆i P (i, j) = Q(i, j) LATEX provides all sorts of symbols for braces and other delimiters (e.g. [ 〈 ‖ l). Round and square braces can be entered with the corresponding keys and curly braces with \{, but all other delimiters are generated with special commands (e.g. \updownarrow). \begin{equation*} {a,b,c} \neq \{a,b,c\} \end{equation*} a, b, c 6= {a, b, c} If you put \left in front of an opening delimiter and \right in front of a closing delimiter, LATEX will automatically determine the correct size of the delimiter. Note that you must close every \left with a corresponding \right. If you don’t want anything on the right, use the invisible “\right.”: \begin{equation*} 1 + \left(\frac{1}{1-x^{2}} \right)^3 \qquad \left. \ddagger \frac{~}{~}\right) \end{equation*} 1 + ( 1 1− x2 )3 ‡ ) In some cases it is necessary to specify the correct size of a mathematical delimiter by hand, which can be done using the commands \big, \Big, \bigg and \Bigg as prefixes to most delimiter commands: $\Big((x+1)(x-1)\Big)^{2}$\\ $\big( \Big( \bigg( \Bigg( \quad \big\} \Big\} \bigg\} \Bigg\} \quad \big\| \Big\| \bigg\| \Bigg\| \quad \big\Downarrow \Big\Downarrow \bigg\Downarrow \Bigg\Downarrow$ ( (x+ 1)(x− 1) )2 (((( }}}} ∥∥∥∥∥∥∥∥∥ ∥∥∥∥∥ www www wwww 3.4 Single Equations that are Too Long: multline 57 For a list of all delimiters available, see Table 3.8 on page 75. 3.4 Single Equations that are Too Long: multline If an equation is too long, we have to wrap it somehow. Unfortunately, wrapped equations are usually less easy to read than not wrapped ones. To improve the readability, there are certain rules on how to do the wrapping: 1. In general one should always wrap an equation before an equality sign or an operator. 2. A wrap before an equality sign is preferable to a wrap before any operator. 3. A wrap before a plus- or minus-operator is preferable to a wrap before a multiplication-operator. 4. Any other type of wrap should be avoided if ever possible. The easiest way to achieve such a wrapping is the use of the multline environment:6 \begin{multline} a + b + c + d + e + f + g + h + i \\ = j + k + l + m + n \end{multline} a+ b+ c+ d+ e+ f + g + h+ i = j + k + l +m+ n (3.4) The difference to the equation environment is that an arbitrary line-break (or also multiple line-breaks) can be introduced. This is done by putting a \\ on those places where the equation needs to be wrapped. Similarly to equation* there also exists a multline* version for preventing an equation number. However, in spite of its ease in use, often the IEEEeqnarray environment (see section 3.5) will yield better results. Particularly, consider the following common situation: \begin{equation} a = b + c + d + e + f + g + h + i + j + k + l + m + n + o + p \label{eq:equation_too_long} \end{equation} a = b+c+d+e+f+g+h+i+j+k+l+m+n+o+p (3.5) Here it is actually the RHS that is too long to fit on one line. The multline environment will now yield the following: 6The multline-environment is from amsmath. 58 Typesetting Mathematical Formulae \begin{multline} a = b + c + d + e + f + g + h + i + j \\ + k + l + m + n + o + p \end{multline} a = b+ c+ d+ e+ f + g + h+ i+ j + k + l +m+ n+ o+ p (3.6) This is of course much better than (3.5), but it has the disadvantage that the equality sign loses its natural stronger importance with respect to the plus operator in front of k. The better solution is provided by the IEEEeqnarray environment that will be discussed in detail in Section 3.5: \begin{IEEEeqnarray}{rCl} a & = & b + c + d + e + f + g + h + i + j \nonumber\\ && +\: k + l + m + n + o + p \label{eq:dont_use_multline} \end{IEEEeqnarray} a = b+ c+ d+ e+ f + g + h+ i+ j + k + l +m+ n+ o+ p (3.7) In this case the second line is vertically aligned to the first line: the + in front of k is exactly below b, i.e., the RHS is clearly visible as contrast to the LHS of the equation. 3.5 Multiple Equations In the most general situation we have a sequence of several equalities that do not fit onto one line. Here we need to work with vertical alignment in order to keep the array of equations in a nice and readable structure. Before we offer our suggestions on how to do this, we start with a few bad examples that show the biggest drawbacks of some common solutions. 3.5.1 Problems with Traditional Commands To group multiple equations the align environment7 could be used: \begin{align} a & = b + c \\ & = d + e \end{align} a = b+ c (3.8) = d+ e (3.9) However, this approach does not work once a single line is too long: 7The align-environment can also be used to group several blocks of equations beside each other. However, for this rather rare situation we also recommend to use the IEEEeqnarray environment with an argument like, {rCl+rCl}. 3.5 Multiple Equations 61 \begin{IEEEeqnarray}{rCl} a & = & b + c \\ & = & d + e + f + g + h + i + j + k \nonumber\\ && +\: l + m + n + o \\ & = & p + q + r + s \end{IEEEeqnarray} a = b+ c (3.22) = d+ e+ f + g + h+ i+ j + k + l +m+ n+ o (3.23) = p+ q + r + s (3.24) However, any number of columns can be specified: {c} will give only one column with all entries centered, or {rCll} would add a fourth, left-justified column to use for comments. Moreover, beside l, c, r, L, C, R for math mode entries there are also s, t, u for left, centered, and right text mode entries. Additional space can be added with . and / and ? in increasing order.10 In contrast to eqnarry the spaces around the equality signs are correct! 3.5.3 Common Usage In the following we will describe how we use IEEEeqnarray to solve the most common situations. • If a line overlaps with the equation number as in (3.18), the command \IEEEeqnarraynumspace can be used: it has to be added in the corresponding line and makes sure that the whole equation array is shifted by the size of the equation numbers (the shift depends on the size of the number!): instead of \begin{IEEEeqnarray}{rCl} a & = & b + c \\ & = & d + e + f + g + h + i + j + k \\ & = & l + m + n \end{IEEEeqnarray} a = b+ c (3.25) = d+ e+ f + g + h+ i+ j + k(3.26) = l +m+ n (3.27) we get \begin{IEEEeqnarray}{rCl} a & = & b + c \\ & = & d + e + f + g + h + i + j + k \IEEEeqnarraynumspace\\ & = & l + m + n. \end{IEEEeqnarray} a = b+ c (3.28) = d+ e+ f + g + h+ i+ j + k(3.29) = l +m+ n. (3.30) 10For more spacing types refer to Section 3.9.1. 62 Typesetting Mathematical Formulae • If the LHS is too long, as a replacement for the faulty \lefteqn com- mand, IEEEeqnarray offers the \IEEEeqnarraymulticol command which works in all situations: \begin{IEEEeqnarray}{rCl} \IEEEeqnarraymulticol{3}{l}{ a + b + c + d + e + f + g + h }\nonumber\\ \quad & = & i + j \\ & = & k + l + m \end{IEEEeqnarray} a+ b+ c+ d+ e+ f + g + h = i+ j (3.31) = k + l +m (3.32) The usage is identical to the \multicolumns command in the tabular- environment. The first argument {3} specifies that three columns shall be combined to one which will be left-justified {l}. Note that by adapting the \quad command one can easily adapt the depth of the equation signs,11 e.g., \begin{IEEEeqnarray}{rCl} \IEEEeqnarraymulticol{3}{l}{ a + b + c + d + e + f + g + h }\nonumber\\ \qquad\qquad & = & i + j \\ & = & k + l + m \end{IEEEeqnarray} a+ b+ c+ d+ e+ f + g + h = i+ j (3.33) = k + l +m (3.34) • If an equation is split into two or more lines, LATEX interprets the first + or − as sign instead of operator. Therefore, it is necessary to add an additional space \: between the operator and the term: instead of \begin{IEEEeqnarray}{rCl} a & = & b + c \\ & = & d + e + f + g + h + i + j + k \nonumber\\ && + l + m + n + o \\ & = & p + q + r + s \end{IEEEeqnarray} a = b+ c (3.35) = d+ e+ f + g + h+ i+ j + k +l +m+ n+ o (3.36) = p+ q + r + s (3.37) we should write 11I think that one quad is the distance that looks good for most cases. 3.5 Multiple Equations 63 \begin{IEEEeqnarray}{rCl} a & = & b + c \\ & = & d + e + f + g + h + i + j + k \nonumber\\ && +\: l + m + n + o \\ & = & p + q + r + s \end{IEEEeqnarray} a = b+ c (3.38) = d+ e+ f + g + h+ i+ j + k + l +m+ n+ o (3.39) = p+ q + r + s (3.40) (Compare the space between + and l!) Attention: LATEX is not completely silly: in certain situations like, e.g., in front of – an operator name like \log, \sin, \det, \max, etc., – an integral \int or sum \sum, – a bracket with adaptive size using \left and \right (this is in contrast to normal brackets or brackets with fixed size like \big( ), a + or − cannot be a sign, but must be an operator. In those situations LATEX will add the correct spacing and no additional space is needed.  Whenever you wrap a line, quickly check the result and verify that the spacing is correct! • If a particular line should not have an equation number, the number can be suppressed using \nonumber (or \IEEEnonumber). If on such a line a label \label{eq:...} is defined, then this label is passed on further to the next equation number that is not suppressed. However, it is recommended to put the labels right before the line-break \\ or the end of the equation it belongs to. Apart from improving the readability of the source code this prevents a compilation error in the situation of a \IEEEmulticol command after the label-definition. • There also exists a *-version where all equation numbers are suppressed. In this case an equation number can be made to appear using the command \IEEEyesnumber: \begin{IEEEeqnarray*}{rCl} a & = & b + c \\ & = & d + e \IEEEyesnumber\\ & = & f + g \end{IEEEeqnarray*} a = b+ c = d+ e (3.41) = f + g 66 Typesetting Mathematical Formulae \newcommand{\ud}{\,\mathrm{d}} \begin{equation*} \int_a^b f(x)\ud x \end{equation*} ∫ b a f(x) dx If you want to typeset multiple integrals, you’ll discover that the spacing between the integrals is too wide. You can correct it using \!, but amsmath provides an easier way for fine-tuning the spacing, namely the \iint, \iiint, \iiiint, and \idotsint commands. \newcommand{\ud}{\,\mathrm{d}} \begin{IEEEeqnarray*}{c} \int\int f(x)g(y) \ud x \ud y \\ \int\!\!\!\int f(x)g(y) \ud x \ud y \\ \iint f(x)g(y) \ud x \ud y \end{IEEEeqnarray*} ∫ ∫ f(x)g(y) dx dy∫∫ f(x)g(y) dx dy∫∫ f(x)g(y) dx dy See the electronic document testmath.tex (distributed withAMS-LATEX) or Chapter 8 of The LATEX Companion [3] for further details. 3.7.1 Phantoms When vertically aligning text using ^ and _ LATEX is sometimes just a little too helpful. Using the \phantom command you can reserve space for characters that do not show up in the final output. The easiest way to understand this is to look at an example: \begin{equation*} {}^{14}_{6}\text{C} \qquad \text{versus} \qquad {}^{14}_{\phantom{1}6}\text{C} \end{equation*} 14 6 C versus 146C If you want to typeset a lot of isotopes as in the example, the mhchem package is very useful for typesetting isotopes and chemical formulae too. 3.8 Fiddling with the Math Fonts Different math fonts are listed on Table 3.14 on page 76. $\Re \qquad \mathcal{R} \qquad \mathfrak{R} \qquad \mathbb{R} \qquad $ < R R R 3.8 Fiddling with the Math Fonts 67 The last two require amssymb or amsfonts. Sometimes you need to tell LATEX the correct font size. In math mode, this is set with the following four commands: \displaystyle (123), \textstyle (123), \scriptstyle (123) and \scriptscriptstyle (123). If ∑ is placed in a fraction, it’ll be typeset in text style unless you tell LATEX otherwise: \begin{equation*} P = \frac{\displaystyle{ \sum_{i=1}^n (x_i- x) (y_i- y)}} {\displaystyle{\left[ \sum_{i=1}^n(x_i-x)^2 \sum_{i=1}^n(y_i- y)^2 \right]^{1/2}}} \end{equation*} P = n∑ i=1 (xi − x)(yi − y)[ n∑ i=1 (xi − x)2 n∑ i=1 (yi − y)2 ]1/2 Changing styles generally affects the way big operators and limits are displayed. 3.8.1 Bold Symbols It is quite difficult to get bold symbols in LATEX; this is probably intentional as amateur typesetters tend to overuse them. The font change command \mathbf gives bold letters, but these are roman (upright) whereas math- ematical symbols are normally italic, and furthermore it doesn’t work on lower case Greek letters. There is a \boldmath command, but this can only be used outside math mode. It works for symbols too, though: $\mu, M \qquad \mathbf{\mu}, \mathbf{M}$ \qquad \boldmath{$\mu, M$} µ,M µ,M µ,M The package amsbsy (included by amsmath) as well as the bm from the tools bundle make this much easier as they include a \boldsymbol command: $\mu, M \qquad \boldsymbol{\mu}, \boldsymbol{M}$ µ,M µ,M 68 Typesetting Mathematical Formulae 3.9 Theorems, Lemmas, . . . When writing mathematical documents, you probably need a way to typeset “Lemmas”, “Definitions”, “Axioms” and similar structures. \newtheorem{name}[counter]{text}[section] The name argument is a short keyword used to identify the “theorem”. With the text argument you define the actual name of the “theorem”, which will be printed in the final document. The arguments in square brackets are optional. They are both used to specify the numbering used on the “theorem”. Use the counter argument to specify the name of a previously declared “theorem”. The new “theorem” will then be numbered in the same sequence. The section argument allows you to specify the sectional unit within which the “theorem” should get its numbers. After executing the \newtheorem command in the preamble of your document, you can use the following command within the document. \begin{name}[text] This is my interesting theorem \end{name} The amsthm package (part ofAMS-LATEX) provides the \theoremstyle{style} command which lets you define what the theorem is all about by picking from three predefined styles: definition (fat title, roman body), plain (fat title, italic body) or remark (italic title, roman body). This should be enough theory. The following examples should remove any remaining doubt, and make it clear that the \newtheorem environment is way too complex to understand. First define the theorems: \theoremstyle{definition} \newtheorem{law}{Law} \theoremstyle{plain} \newtheorem{jury}[law]{Jury} \theoremstyle{remark} \newtheorem*{marg}{Margaret} \begin{law} \label{law:box} Don’t hide in the witness box \end{law} \begin{jury}[The Twelve] It could be you! So beware and see law~\ref{law:box}.\end{jury} \begin{marg}No, No, No\end{marg} Law 1. Don’t hide in the witness box Jury 2 (The Twelve). It could be you! So beware and see law 1. Margaret. No, No, No 3.9 Theorems, Lemmas, . . . 71 Similarly, the correct way of putting the QED-symbol at the end of an equation array is as follows: \begin{proof} This is a proof that ends with an equation array: \begin{IEEEeqnarray}{+rCl+x*} a & = & b + c \\ & = & d + e. \\ &&& \qedhere\nonumber \end{IEEEeqnarray} \end{proof} Proof. This is a proof that ends with an equation array: a = b+ c (3.45) = d+ e. (3.46) which contrasts with \begin{proof} This is a proof that ends with an equation array: \begin{IEEEeqnarray}{rCl} a & = & b + c \\ & = & d + e. \end{IEEEeqnarray} \end{proof} Proof. This is a proof that ends with an equation array: a = b+ c (3.47) = d+ e. (3.48) 72 Typesetting Mathematical Formulae 3.10 List of Mathematical Symbols The following tables demonstrate all the symbols normally accessible from math mode. To use the symbols listed in Tables 3.12–3.10,12 the package amssymb must be loaded in the preamble of the document and the AMS math fonts must be installed on the system. If the AMS package and fonts are not installed on your system, have a look at CTAN:macros/latex/required/ amslatex. An even more comprehensive list of symbols can be found at CTAN:info/symbols/comprehensive. Table 3.1: Math Mode Accents. â \hat{a} ǎ \check{a} ã \tilde{a} à \grave{a} ȧ \dot{a} ä \ddot{a} ā \bar{a} ~a \vec{a} ÂAA \widehat{AAA} á \acute{a} ă \breve{a} ÃAA \widetilde{AAA} å \mathring{a} Table 3.2: Greek Letters. There is no uppercase of some of the letters like \Alpha, \Beta and so on, because they look the same as normal roman letters: A, B. . . α \alpha θ \theta o o υ \upsilon β \beta ϑ \vartheta π \pi φ \phi γ \gamma ι \iota $ \varpi ϕ \varphi δ \delta κ \kappa ρ \rho χ \chi  \epsilon λ \lambda % \varrho ψ \psi ε \varepsilon µ \mu σ \sigma ω \omega ζ \zeta ν \nu ς \varsigma η \eta ξ \xi τ \tau Γ \Gamma Λ \Lambda Σ \Sigma Ψ \Psi ∆ \Delta Ξ \Xi Υ \Upsilon Ω \Omega Θ \Theta Π \Pi Φ \Phi 12These tables were derived from symbols.tex by David Carlisle and subsequently changed extensively as suggested by Josef Tkadlec. 3.10 List of Mathematical Symbols 73 Table 3.3: Binary Relations. You can negate the following symbols by prefixing them with a \not com- mand. < < > > = = ≤ \leq or \le ≥ \geq or \ge ≡ \equiv  \ll  \gg .= \doteq ≺ \prec  \succ ∼ \sim  \preceq  \succeq ' \simeq ⊂ \subset ⊃ \supset ≈ \approx ⊆ \subseteq ⊇ \supseteq ∼= \cong @ \sqsubset a A \sqsupset a 1 \Join a v \sqsubseteq w \sqsupseteq ./ \bowtie ∈ \in 3 \ni , \owns ∝ \propto ` \vdash a \dashv |= \models | \mid ‖ \parallel ⊥ \perp ^ \smile _ \frown  \asymp : : /∈ \notin 6= \neq or \ne aUse the latexsym package to access this symbol Table 3.4: Binary Operators. + + − - ± \pm ∓ \mp / \triangleleft · \cdot ÷ \div . \triangleright × \times \ \setminus ? \star ∪ \cup ∩ \cap ∗ \ast t \sqcup u \sqcap ◦ \circ ∨ \vee , \lor ∧ \wedge , \land • \bullet ⊕ \oplus \ominus  \diamond \odot \oslash ] \uplus ⊗ \otimes © \bigcirc q \amalg 4 \bigtriangleup 5 \bigtriangledown † \dagger  \lhd a  \rhd a ‡ \ddagger  \unlhd a  \unrhd a o \wr 76 Typesetting Mathematical Formulae Table 3.12: AMS Delimiters. p \ulcorner q \urcorner x \llcorner y \lrcorner | \lvert | \rvert ‖ \lVert ‖ \rVert Table 3.13: AMS Greek and Hebrew. z \digamma κ \varkappa i \beth ג \gimel k \daleth Table 3.14: Math Alphabets. See Table 6.4 on 123 for other math fonts. Example Command Required package ABCDEabcde1234 \mathrm{ABCDE abcde 1234} ABCDEabcde1234 \mathit{ABCDE abcde 1234} ABCDEabcde1234 \mathnormal{ABCDE abcde 1234} ABCDE \mathcal{ABCDE abcde 1234} A BC DE \mathscr{ABCDE abcde 1234} mathrsfs ABCDEabcde1234 \mathfrak{ABCDE abcde 1234} amsfonts or amssymb ABCDEa1234 \mathbb{ABCDE abcde 1234} amsfonts or amssymb Table 3.15: AMS Binary Operators. u \dotplus  \centerdot n \ltimes o \rtimes > \divideontimes d \doublecup e \doublecap r \smallsetminus Y \veebar Z \barwedge [ \doublebarwedge  \boxplus \boxminus  \circleddash  \boxtimes \boxdot } \circledcirc ᵀ \intercal ~ \circledast i \rightthreetimes g \curlyvee f \curlywedge h \leftthreetimes 3.10 List of Mathematical Symbols 77 Table 3.16: AMS Binary Relations. l \lessdot m \gtrdot + \doteqdot 6 \leqslant > \geqslant : \risingdotseq 0 \eqslantless 1 \eqslantgtr ; \fallingdotseq 5 \leqq = \geqq P \eqcirc ≪ \lll or \llless ≫ \ggg $ \circeq . \lesssim & \gtrsim , \triangleq / \lessapprox ' \gtrapprox l \bumpeq ≶ \lessgtr ≷ \gtrless m \Bumpeq Q \lesseqgtr R \gtreqless ∼ \thicksim S \lesseqqgtr T \gtreqqless ≈ \thickapprox 4 \preccurlyeq < \succcurlyeq u \approxeq 2 \curlyeqprec 3 \curlyeqsucc v \backsim - \precsim % \succsim w \backsimeq w \precapprox v \succapprox  \vDash j \subseteqq k \supseteqq \Vdash q \shortparallel c \Supset  \Vvdash J \blacktriangleleft A \sqsupset  \backepsilon B \vartriangleright ∵ \because ∝ \varpropto I \blacktriangleright b \Subset G \between D \trianglerighteq a \smallfrown t \pitchfork C \vartriangleleft p \shortmid ` \smallsmile E \trianglelefteq ∴ \therefore @ \sqsubset 78 Typesetting Mathematical Formulae Table 3.17: AMS Arrows. L99 \dashleftarrow 99K \dashrightarrow ⇔ \leftleftarrows ⇒ \rightrightarrows  \leftrightarrows  \rightleftarrows W \Lleftarrow V \Rrightarrow  \twoheadleftarrow  \twoheadrightarrow  \leftarrowtail  \rightarrowtail \leftrightharpoons \rightleftharpoons  \Lsh  \Rsh " \looparrowleft # \looparrowright x \curvearrowleft y \curvearrowright \circlearrowleft  \circlearrowright ( \multimap  \upuparrows  \downdownarrows  \upharpoonleft  \upharpoonright  \downharpoonright \rightsquigarrow ! \leftrightsquigarrow Chapter 4 Specialities When putting together a large document, LATEX will help you with some special features like index generation, bibliography management, and other things. A much more complete description of specialities and enhancements possible with LATEX can be found in the LATEX Manual [1] and The LATEX Companion [3]. 4.1 Including Encapsulated PostScript LATEX provides the basic facilities to work with floating bodies, such as images or graphics, with the figure and table environments. There are several ways to generate the actual graphics with basic LATEX or a LATEX extension package, a few of them are described in chapter 5. Please refer to The LATEX Companion [3] and the LATEX Manual [1] for more information on that subject. A much easier way to get graphics into a document is to generate them with a specialised software package1 and then include the finished graphics into the document. Here again, LATEX packages offer many ways to do this, but this introduction will only discuss the use of Encapsulated PostScript (EPS) graphics, because it is quite easy to do and widely used. In order to use pictures in the EPS format, you must have a PostScript printer2 available for output. A good set of commands for inclusion of graphics is provided in the graphicx package by D. P. Carlisle. It is part of a whole family of packages called the “graphics” bundle.3 When working on a system with a PostScript printer available for output and with the graphicx package installed, use the following step by 1Such as XFig, Gnuplot, Gimp, Xara X . . . 2Another possibility to output PostScript is the GhostScript program available from CTAN://support/ghostscript. Windows and OS/2 users might want to look for GSview. 3CTAN://macros/latex/required/graphics 82 Specialities step guide to include a picture into your document: 1. Export the picture from your graphics program in EPS format.4 2. Load the graphicx package in the preamble of the input file with \usepackage[driver]{graphicx} where driver is the name of your “dvi to postscript” converter program. The most widely used program is called dvips. The name of the driver is required, because there is no standard on how graphics are included in TEX. Knowing the name of the driver, the graphicx package can choose the correct method to insert information about the graphics into the .dvi file, so that the printer understands it and can correctly include the .eps file. 3. Use the command \includegraphics[key=value, . . . ]{file} to include file into your document. The optional parameter accepts a comma separated list of keys and associated values. The keys can be used to alter the width, height and rotation of the included graphic. Table 4.1 lists the most important keys. Table 4.1: Key Names for graphicx Package. width scale graphic to the specified width height scale graphic to the specified height angle rotate graphic counterclockwise scale scale graphic 4If your software can not export into EPS format, you can try to install a PostScript printer driver (such as an Apple LaserWriter, for example) and then print to a file with this driver. With some luck this file will be in EPS format. Note that an EPS must not contain more than one page. Some printer drivers can be explicitly configured to produce EPS format. 4.2 Bibliography 83 The following example code may help to clarify things: \begin{figure} \centering \includegraphics[angle=90, width=0.5\textwidth]{test} \caption{This is a test.} \end{figure} It includes the graphic stored in the file test.eps. The graphic is first rotated by an angle of 90 degrees and then scaled to the final width of 0.5 times the width of a standard paragraph. The aspect ratio is 1.0, because no special height is specified. The width and height parameters can also be specified in absolute dimensions. Refer to Table 6.5 on page 127 for more information. If you want to know more about this topic, make sure to read [9] and [13]. 4.2 Bibliography Produce a bibliography with the thebibliography environment. Each entry starts with \bibitem[label]{marker} The marker is then used to cite the book, article or paper within the document. \cite{marker} If you do not use the label option, the entries will get enumerated auto- matically. The parameter after the \begin{thebibliography} command defines how much space to reserve for the number of labels. In the example below, {99} tells LATEX to expect that none of the bibliography item numbers will be wider than the number 99. Partl~\cite{pa} has proposed that \ldots \begin{thebibliography}{99} \bibitem{pa} H.~Partl: \emph{German \TeX}, TUGboat Volume~9, Issue~1 (1988) \end{thebibliography} Partl [1] has proposed that . . . Bibliography [1] H. Partl: German TEX, TUGboat Volume 9, Issue 1 (1988)
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved