Studycentre for the Visually Impaired
ICCHP Summer University 2016 on Maths, Science and Statistics for Blind and Partially Sighted Students
July 8-12, 2016Johannes Kepler Universität Linz, Austria
LaTeX for Beginners
A script for visually impaired users, based on the German script "Textsatz und Layout" by Ralf Banning and Heiko A. Groeneveld, University Tuebingen, Germany (1995).
Edited and translated by Dr. Thorsten Schwarz, Study Centre for the Visually Impaired (SZS), Karlsruhe Institute of Technology (KIT), Engesserstr. 4, 76131 Karlsruhe, Germany
(2012)
LaTeX for Beginners
Contacts
Dr. Thorsten Schwarz
Engesserstr. 4, Geb. 20.51D-76131 KarlsruheGermany
Email: [email protected]: www.szs.kit.edu
Version: 06/2014
2/70
LaTeX for Beginners
Contents
CONTENTS.....................................................................................................2
PROGRAM STRUCTURE OF LATEX.............................................................6WHAT IS LATEX?............................................................................................6
Layout........................................................................................................6How to work with LaTeX?..........................................................................7
STRUCTURE OF THE LATEX PROGRAM PACKAGE..............................................8The LaTeX input file...................................................................................8The LaTeX command.................................................................................8Selecting a default layout...........................................................................9Error handling..........................................................................................10TEX-and LaTeX error messages..............................................................11Warnings and error messages.................................................................12
THE DEFAULT DOCUMENTS (ARTICLE, REPORT, BOOK).....................................14Overview..................................................................................................14A first look at headers and footers...........................................................15A first look at headlines............................................................................15A first look at the table of contents...........................................................16Page break..............................................................................................17Line break................................................................................................17
LAYOUT UNDER LATEX..............................................................................19OVERALL LAYOUT AND PAGE LAYOUT..............................................................19
Layout under LaTeX.................................................................................19Measures.................................................................................................20Sizing and spacing in the page layout.....................................................21Changing of registers...............................................................................22More about registers................................................................................23Influencing of layout.................................................................................24The page style.........................................................................................25
FONT SELECTOR...........................................................................................26Fonts........................................................................................................26Font family...............................................................................................27Font style.................................................................................................27Display variants.......................................................................................28The font size............................................................................................28
HEADLINES AND FOOTNOTES.........................................................................30Outline commands...................................................................................30
3/70
LaTeX for Beginners
Footnotes.................................................................................................31PARAGRAPH FORMATTING.......................................................................33
BASICS.........................................................................................................33Environments...........................................................................................33Direct (raw) output...................................................................................34Justified and ragged text..........................................................................35Quoting of long sections..........................................................................36Multi-column texts....................................................................................36Lists.........................................................................................................37
TABLES........................................................................................................38Tabs.........................................................................................................38Tables: column Declaration and line layout..............................................39Tables: column declaration in detail.........................................................40
MATHEMATICAL FORMULA SET AND FONTS..........................................41CROSS REFERENCES AND MATHEMATICAL FORMULA SET.................................41
Cross references.....................................................................................41Principles for the formula set...................................................................42Mathematical environments.....................................................................43Mathematical environments: features......................................................43Basic commands in MM...........................................................................44More commands in MM...........................................................................45Sizeable operators and delimiters............................................................46Binary operators, relations, arrows..........................................................48Mathematical symbols: log-like, special...................................................51Mathematical symbols: alphabets, fonts..................................................53
FEATURES FOR THE FORMULA SET.................................................................55Adjusting space.......................................................................................55Theorem..................................................................................................56
BIBLIOGRAPHY, GRAPHICS AND VISUAL FORMATTING.......................57BIBLIOGRAPHY AND INDEX.............................................................................57
Bibliography.............................................................................................57Example of a bibliography........................................................................58BibTeX.....................................................................................................59BibTeX: An example of a database..........................................................59Index........................................................................................................60Index entries with MakeIndex..................................................................61
GRAPHIC......................................................................................................62General....................................................................................................62picture environment.................................................................................63
4/70
LaTeX for Beginners
More to the picture environment..............................................................64epic-and eepic-packages.........................................................................65Integration of bitmap graphics..................................................................66
EDITING LONG DOCUMENTS...........................................................................67Document detailed...................................................................................67Title page and summary..........................................................................67Structured files.........................................................................................68Selection of texts and hierarchies............................................................68Control for file hierarchies........................................................................69
5/70
LaTeX for Beginners
Program structure of LateXWhat is LaTeX?
TeX is a typesetting system developed by Donald E. Knuth at Stanford University. Originally it was developed to support in particular the set of mathematical formulas, but now TeX enters in all sections of text setting, for example for text setting with non-Latin alphabets. The typographical quality is comparable to high quality book printing set.
LaTeX is a macro package for TeX, which provides a number of understandable commands based on the logical structure of text documents, developed originally by Leslie Lamport. The user is limited to these commands, he is largely spared from the details of the print design.
Implementations of TeX and LaTeX are available for the various computer architectures - from the PC to the mainframe, for Windows, Mac and Linux. The handling of the programmes as well as their results are considered relatively platform independent.
Just... what does typesetting mean?
Setting refers to placing one in a general sense "graphical" element on a page. The record has to follow a layout, which makes provisions for the arrangement of the respective elements.
Typesetting deals therefore with the setting of text, so the "piecing together of letters." The graphical element of the type-setter it serves, is thus each a single letter, a sentence, or a special character.
Layout
The contents of a text is considered in the text set only in the set image (such as poems or set of formula). Text critical work is not a part of the text set.A document builds up from letters of different character sets, words, lines, paragraphs, figures, columns and pages.The graphical layout plan of the printed page, so the setting of the type area and the arrangement of columns the choice of fonts for body text, headings, etc., the execution order of body text, headings. ..
is the layout of the text. In the printing industry, the design of the layout is an
6/70
LaTeX for Beginners
own activity. In the LaTeX program system the functions are distributed as follows: LaTeX is the setting and layout language, which takes over the role of
the "layouter” for the record program TeX. LaTeX has a number of default layouts, but also allows the design of
your own layouts with so-called layout commands. Layout commands in LaTeX defining the functions of the elements in
the document. These commands inserted in the text convert to a set of commands for TeX. For example, here are some commands and what they mean:\section{layout}: "This is a headline with the content layout"\begin{figure}: "now a picture begins ..."\end{figure}: "... and here it ends again."
LaTeX is in the this sense a "markup language” such as HTML.
How to work with LaTeX?
The following example uses the input file "foo.tex". The file name can be chosen freely, the ending ". tex" is however provided. After choosing an appropriate editor (e.g., Notepad, vi, gedit, TexnicCentre,...) the processing is similar to programming in a programming language, in three steps (edit, compile, run).
Editing a LaTeX input file (create or edit):Minimal content example:\documentclass{article}\begin{document}Here is the text\end{document}
LaTeX-run (processing foo.tex with LaTeX, compile):latex foo.tex
Print or PDF creation (control on the basis of a Print preview, Run)PDF creation:"Dvipdf foo.dvi" or "pdflatex foo.tex"(be careful, pdflatex doesn't always work with all usepackages)
7/70
LaTeX for Beginners
Structure of the LaTeX program package
The LaTeX input file
The LaTeX input file is a normal ASCII file which can be created and edited with any ASCII editor.LaTeX analyzes the content of such an input file for text input and command input. Text input will appear directly set, and command input acts on the way and style how LaTeX sets the text, but it does not appear directly in the sentence. Besides letters and numbers, LaTeX accepts the following characters
as text input:◦ The punctuation characters: . , : ; ! ? ' ` -◦ Round and square brackets: () []◦ Some special characters: + = * / @◦ White space, such as tab or space
The three special characters < > and | used mainly in mathematical mode. They are used as text input, so they are rendered in the sentence as other characters.
The special characters # $ & ~ _ ^ \ {} are used exclusively in LaTeX commands and should not be used in text input.
The special character % is used to skip all following text on a line, including the newline character (comment out).
A part of the above special characters can be printed by simply prepending of the backslash:\$ \& \% \# \_ \{ \}
The German umlauts can be produced by prefixing of \" :write \"A \”U \”O \”a \”u \”o \ss for Ä Ü Ö ä ö ü ß.
The LaTeX command
Text formatting with LaTeX is controlled by commands in the input file.
Commands are initiated with \ (backslash). The command name follows immediately afterwards.A command is terminated by a space or special characters.
Example:Here is a \$ character
8/70
LaTeX for Beginners
Many commands have arguments; those in brackets are optional,Arguments in curly braces must be specified:\command[opt1,..., optn] {arg1} … {argn}
Example:\documentclass[a4paper,german]{article}
A command in an area (a so-called group) enclosed by curly braces {...} applies only within this group.
Example:A group {\bfseries limits} highlights.
Selecting a default layoutThe first line of a LaTeX input file sets the document class:\documentclass{class}
A document class defines the layout for all areas of the text. There are following standard classes available:
Table 1: document classesclass Descriptionarticle For short documents with simple structure.report For longer documents; more detailed levels.book For long documents that consist of multiple bands. Preparation for
double-sided printing.slides For slides.proc Similar to article, adapted however specifically for so-called
proceedings.
The layout of a document class can be influenced by so-called options; for example, the line\documentclass[a4paper]{article}prepares the input text for the paper size DIN A4.
There are options available for the setting of the paper size, the alignment of formulas,
9/70
LaTeX for Beginners
the selection of the normal font size, the preparation in accordance with double-sided set.
Error handling
TeX error messages.
Typos in LaTeX commands or incorrect commands result in the situation that LaTeX cannot fully compile the file. It comes to program interruptions that are displayed by so-called error messages. Because LaTeX is a macro package, which is composed of TeX commands, often more TeX error messages that result from the processing and expansion of faulty LaTeX constructs follow the actual LaTeX error messages. Error messages are clearly identifyed by a preceding exclamation mark.
The log file.Any error messages are written to the log file (foo.log), which has the following structure:
1. Header: This is TeX, version...Followed by information concerning the loaded document classes and packages.
2. LaTeX font information: the selected fonts are displayed.3. The actual log: every page that was typeset appears in square
brackets. The symbol 5 means that the typesetting of page 5 has begun. If there are no erros on page 5, the square bracket is closed: [5]. If an error message occurs before, the error is to be searched on page 5 or earlier.
4. A small statistic of storage requirements.If a source file foo.tex consists of multiple input files (e.g., foo1.tex and foo2.tex) the read-in (import) of the source foo1.tex is identified by the symbol (foo1.tex in the log file. When the processing of this partial file has ended, the parenthesis is closed. The causes of error messages that appear within this round bracket pair are then to be ed in the file foo1.tex.
TeX error messages.Typos are the most common error case in TeX/LaTeX. To write for example \TEX instead of \TeX to set the TeX icon, LaTeX reports during the processing of the source file (compile):
! Undefined control sequence
10/70
LaTeX for Beginners
1.5 Here stands the \TEX\Symbol.?
The first line identifies the error type, the second line indicates the context. 1.5 means that the error occurs in the 5th line of the current source file (see above). The last word in the context line before the new line (here: \TEX) refers to the place in the code where the error occurs. The question mark in the 4th line calls an action a button is pressed; possible actions include: ? : displays possible actions. r : Continue LaTeX run without further interruptions. q : like r with entirely suppressed error messages. s : calling the Editor (debugging). h : show additional help text. x : cancel LaTeX run. <return> : continue LaTeX run.
From all actions, especially pressing the return key is recommended. If the errors in this sense are ignored, they can be easier located, understood and eliminated by simultaneous examination of the log file and previewer.
TEX-and LaTeX error messages
LaTeX error messages.If an error occurs when processing LaTeX commands - commands described in this book - LaTeX comes up with own error logs. Formally, these differ only slightly from the TeX error messages, by a header:
! LaTeX Error: Environment berbatim undefined.See the LaTeX manual or LaTeX Companion for explanation.Type H <return> for immediate help....l.4 \begin{berbatim}?
Here \begin{berbatim} was mistakenly used instead of the verbatim environment. For these error messages, the same recommendations apply as before: try first to finish the LaTeX run by pressing <return>, then to locate and understand the error that occurred with the help of the log file.
11/70
LaTeX for Beginners
Error analysis.The localization of errors is sometimes difficult because errors can occur somewhere in the text before the position, where LaTeX foundan error. This is the case for example if the declaration of a document class with \documentclass is missing. A somewhat mysterious error message will then appear:
! LaTeX Error: The font size command \normalsize is not defined: there is probably something wrong with the class file.1.2 \begin{document}
The text in row 2 is of course a correct LaTeX construct. The error occurs as a result of incorrect or missing call on line 1 (\documentclass). So if rows of TeX/LaTeX, which are undoubtedly syntactically correct, are incorrectly taggedthen one speaks of an inherited error, which originates before the indicated place. The source file is in this case to be read "backwards" until you find the actual error. If this is not clearly localizable in case of complicated source files, then only step-by-step commenting out using % followed by a LaTeX run can help to locate the affected area. If the error no longer occurs after a few such steps, then the searching space has been at least reduced.A forgotten environment start is another way how you can generate followup (inherited) errors. If you forget the line \begin{itemize} for an enumeration, then the \item commands are not recognized, because these are only defined by the call to the environment. LaTeX reports in this case:
! LaTeX Error: Lonely \item--perhaps a missing list environment.
List of TeX error messages.A complete list of the possible errors is beyond the scope of this script.
Warnings and error messages
Also a syntactically correct LaTeX source can lead to (typographic) unsatisfactory results. This is largely recognized by TeX/LaTeX and communicated by warnings that are displayed during the program compilation.
12/70
LaTeX for Beginners
TeX warnings.These warnings apply exclusively to the goodness of the row and page break. A TEX warning is not an error! The alerts appear in the LaTeX run (compile) on the screen and are also recorded in the log file. The most common warning is
Overfull \hbox (6.98082pt too wide)in paragraph at lines 18--21[]\OT1/cmtt/m/n/14.4Here is the \LaTeX -icon
The keyword “Overfull” indicates that TeX in the paragraph of row 18 to 21 could not properly wrap a line and this line grows over the edge 6.98082pt (about 3 mm). The problem appears on the site "Here is the \LaTeX -icon".Additional hyphen (\-) can be a workaround. TeX is already complaining for overlengths of a fraction of a pt. An overlength of less than 1pt (approximately 0.3 mm) can still be regarded as acceptable. In such a case, the warning is easy to ignore.Sometimes, the warning of “Overfull \vbox” appears. Thus, LaTeX refers to a long page. In most cases, these warnings are due to too high not interruptible boxes in the text - as for example tables. In this case the box should be moved to a different location or changed to a floating environment.The warning for the case "too much empty space":
Underfull \hbox (badness 10000)in paragraph at lines 86--92[] \OT1\cmss\m\n\14.4 sev-er-al bl-ank li-nes
Here, TeX finds the spacing of words between line 86 and 92 as too big. The "badness" rates the deficiency of the existentbreak. 10.000 means "infinitely bad", a value up to 200 (no warning) is normal, and a value up to 2000 is mostly tolerable for the user. The warning is often caused by unnecessary or nonsensical newline commands \\. hyphens (\-) used can reduce the badness.The same applies for the error “Underfull \vbox”.
LaTeX warnings.LaTeX may also give warnings. All of these warnings start with LaTeX warning or LaTeX font warning:. The first kind of warnings refers generally to not (yet) resolved cross references. These warnings should be considered only if they do not disappear even after multiple runs of LaTeX. The second type of alerts
13/70
LaTeX for Beginners
generally informs users about the absence of a selected font and the replacement selected instead by LaTeX.
The default documents (article, report, book)
Overview
The default documents differ less in the formatting of the actual text, as in the accompanying text elements such as outline headings and directories.The following table shows the default settings for the main document classes
Table 2: outline level of the different document classesbook report article
Outline level: \part x - -Outline level: \chapter
x x -
Outline level: \section
x x x
Table of contents until subsection until subsection until subsubsection
double-sided Standard Only with document class option twoside
Only with document class option twoside
Numbering (table, figure)
Chapter number + continuously in the chapter; For example, 1.1, 1.2, 1.3,... 2.1, 2.2,...
Chapter number + continuously in the chapter; For example, 1.1, 1.2, 1.3,... 2.1, 2.2,...
Continuously; Example: 1, 2, 3,...
Abstract, title page
own page own page own page only with title-page option
Headings left chapter chapter sectionHeadings right section section subsection
The following discusses the layout elements of the document classes in detail.
14/70
LaTeX for Beginners
A first look at headers and footers
The text elements above and below of the actual text are known as header or footer, where, for example, headings and page numbers can be shown.
The shape of the headers and footers can be set with the command\pagestyle{style}
Example:\documentclass[german,a4paper]{report}\usepackage{babel}\pagestyle{headings}\begin{document}\tableofcontents\chapter{The page style}\section{Headings and Footers}Typography deals with the design of a text through fonts and other characters...\end{document}
There are several such page styles for headers and footers, which also set the type and position of the page numbering. For example, the line\pagestyle{empty}produces pages without headers and footers and page numbering.
A first look at headlines
Example:Chapter 1Word processing
1.1 LaTeX2e A new...1.1.1 The current state: LaTeX 2.09The LaTeX text formatter has in the past few years...
1.1.2 Why LaTeX2e?Today, several additions thave have led towards...
Headlines divide a text into chapters and sections.Often, such sections are numbered as seen in the example.
15/70
LaTeX for Beginners
Headings are generated with the commands \chapter for chapters, \section for the major sections, and so on.
\begin{document}\chapter{Text processing}\section{ltwoe: a new generation of LaTeX}\subsection{The current state: LaTeX ~ 2.09}The LaTeX text formatter has changed in the past years to ...\subsection{Why ltwoe?}Already nowadays several additions resulted in ...\end{document}
The font size and the nature of the numbering is automatically chosen by LaTeX if outline commands are used.
A first look at the table of contents
The headlines generated using the outline commands can be summarized in a table of contents automatically. This table of contents contains also the page number on which each section begins.
The table of contents is created by LaTeX, if the command\tableofcontentsis used in the source file. This looks for example like this:
\documentclass[german,a4paper]{report}\usepackage{babel}\parskip1ex plus0. 7ex minus0. 3ex\parindent 0em\begin{document}\tableofcontents\chapter{Programmstructure of LaTeX}\section{What is text?}Here is the main text\end{document}
The table of contents appears in the document class report before the start of the text, on a separate page. If the command \tableofcontents comes after the
16/70
LaTeX for Beginners
main text, LaTeX puts the table of contents at the end of the document.When you select the document class "article", the table of contents will only be displayed on its own page if the class option "titlepage" is set.
Note: The first LaTeX run (compile) creates the .aux file, which contains the table of contents. Therefore, the table of contents matches the true outline only after the second LaTeX run. Also at each modification and addition to the outline, two LaTeX runs are needed to get the correct outline.
Page break
When processing a LaTeX source file, the program automatically performs the distribution of lines in paragraphs and paragraphs on pages. This process is called row or page break. The page break can be enforced with:
\pagebreak[priority] Page break may be suppressed via:
\nopagebreak[priority]The priority is an integer between 0 and 4.
If the priority is less than 4, then this is only a non-binding recommendation for LaTeX (with growing urgency). At 4, the command applies absolutely.
The command \newpage cancels the current page in the middle of the current line and starts a new page.
Line break The line break with justification can be enforced anywhere with
\linebreakor\linebreak[priority]The priority can be between 0 and 4. When a priority is equal to 4, an unconditional line break is performed, which is the same with thecommand \linebreak.Example:The typography deals with the design of a text by fonts and other characters. Literally one two three \linebreak
Analogously, a line break at a certain position can be suppressed by\nolinebreakor\nolinebreak[priority]
17/70
LaTeX for Beginners
The command \newline or \\ immediately cancels the current row.
18/70
LaTeX for Beginners
Layout under LaTeXThe distribution of the text on the page, the choice of the character set, the arrangement of graphical elements, etc. – all that determines the first impression one gets from a printed text. Far more so than the first impression, the combination of such possibilities affects the good understandability of a text.The design of a document - the layout - is divided into multiple levels. Comprehensively, the page layout sets the spatial distribution and the font selection of columns, headers, footers, and the headings. The design of a longer document also includes for instance footnotes or marginal notes, with which a text can be clearly commented. The table of contents and table of figures help the reader to orient himself within the text.
Overall layout and page layout
Layout under LaTeX
There are various ways to affect the layout of a document in LaTeX. In this context, it is always desirable to make a layout adjustment so that it harmonises with the overall layout, and thus with the appearance of the entire document.Various extension mechanisms in and around LaTeX are available for such "harmonious" adjustments. LaTeX users feel often the desire for more targeted layout changes however - especially in the final layout of their documents. Such changes may affect: The way LaTeX counts document parts. The spacing of the layout elements from each other. The choice of the used character sets. The execution or inclusion of stylistic elements such as e.g. footnotes.
To tell LaTeX how you intend to change the layout, you must usually manipulate certain LaTeX registers. This is done with special commands which are explained later.
We differentiate between two types of LaTeX registers: Counting registers (counter; contain whole numbers) Length register (separations; include a measure/length)
To make use of the latter, the knowledge of measurement units supported by
19/70
LaTeX for Beginners
LaTeX is needed.
Measures
The following measures can be used in LaTeX:
Fixed measures:Table 3: fixed measuresunit descriptionmm millimetercm centimeter, 1 cm = 10 mmin Inch, 1 in ~ 25 mmpt Point, 1 pt ~ 1/3 mmpc Picas, 1 pc 12 pt = ~ 4 mm
Flexible measures:Horizontal:Table 4: horizontal flexible measuresunit/command descriptionem width of a large "M" (in the current font)\enspace so wide as a digit\quad so wide as an uppercase character\qquad twice as wide as \quad\hfill as large as the remaining space on the
line (theoretically from 0 mm to infinity)
Vertical axis:Table 5: vertical flexible measuresunit/command descriptionex height a small "x" (in the current font)/smallskip about 1/4 line/medskip about 1/2 row/bigskip about 1 line/vfill same as above, but on the side
20/70
LaTeX for Beginners
Sizing and spacing in the page layout
In LaTeX 13 spacings define the (single column) page layout.These spacings can be set in the preamble with the command\setlength{spacing}{measure}
Table 6: Spacingsspacing description\hoffset\voffset
To adjust the margins; on some printers or paper format changes.
\oddsidemargin\evensidemargin
Indentation on the odd-numbered or even-numbered pages.
\topmargin Distance from the top of the page to the header.\headheight Height of the header.\headsep Distance from the header to the flow text column.\textheight\textwidth
Define the height and width of flow text column.
\marginparsep Distance between edge of the notes column and text column.
\marginparwidth Width of marginal notes column.\footskip Distance from the lower edge of the text column to the
bottom of the footer box.\pagewidth\pageheight
Specify the width and height of the paper.
By using \enlargethispage{length} and \enlargethispage*{length} the height of the text column of a page can be increased to the length "length". The *-form of the command tries to compress the text maximally.Alternatively, the above distances can be also set by using a document class option to predefined values:
Table 7: DIN measuresOption (DIN) for paper sizea4paper 210 x 297 mma5paper 148 x 210 mmb5paper 176 x 250 mm
21/70
LaTeX for Beginners
Table 8: US measuresOption (US) for paper sizeletterpaper 8.5 x 11 inchlegalpaper 8.5 x 14 inchexecutivepaper 7.25 x 10.5 inch
Example:\documentclass[a5paper]{report}
Changing of registers
Counter: (in the following, “counter” stands for any counter's name.)Counters can be changed with the commands listed in the following table:
Table 9: counter definitionscommand description\value{counter} Provides the value of a counter.\setcounter{counter}{NUM} Sets the counter to the value num.\addtocounter{counter}{NUM} Adds the value of num to the numerator.\stepcounter{counter} Increments the counter value by 1.\refstepcounter{counter} Like \stepcounter, but can now also on the
counter with \ref be referenced.
A new counter cnt can be declared with the following command:\newcounter{cnt}[reset]The counter is reset to zero every time the command "reset" is called.
Spacings: (in the following “space” stands for any spacing's name.)Spacing can be changed using the following commands:
22/70
LaTeX for Beginners
Table 10: SpacingsCommand description\setlength{space}{len} Sets the spacing space to len.\addtolength{space}{len} Increases the spacing space to len.\settowidth{space}{text} Sets the spacing space to the width of the text
“text”.\settoheight{space}{text} Sets the spacing space to the height of the text
“text” above the baseline.\settodepth{space}{text} Sets the spacing space to the depth of the text
“text” below the baseline.
A new distance \lngth can be declared as follows:\newlength{\lngth}Distances are initialized with length zero upon declaration.
More about registers The value of each counter can be displayed with each command
associated to it\thecounter
There are a number of other output commands which can set a counter value in the following ways as text:◦ \arabic{counter}
Arabic numerals◦ \roman{counter}
Roman numerals in lowercase letters◦ \Roman{counter}
Roman numerals in uppercase◦ \alph{counter}
Lowercase, the value of counter must be less than 27◦ \Alph{counter}
Uppercase letters, the value of counter must be less than 27
Note: while number register are simple integer variables, the dimension-based distance registers have the character of a command (recognizable in the syntax by the backslash) and are sometimes used as commands.
Examples:
23/70
LaTeX for Beginners
To set the chapter count to zero, it is possible to use the command\setcounter{chapter}{0}
If you wish to set the section counter to the chapter counter value, you must use the command\setcounter{section}{\value{chapter}}
If you want to use your own counter, which is reset at the beginning of each section to zero, you can achieve this with the following definition:\newcounter{mycount}[\section]
Influencing of layout
Paragraphs:
Table 11: Paragraphscommands Description\sloppy Lets LaTeX be more "sloppy" when cutting, respectively
deleting and pasting.\fussy Switches the cutting back on "fussy".\frenchspacing Suppresses the extra space after punctuation marks.\parindent Horizontal distance that determines the indentation of the
first line of a paragraph.\parskip Additional vertical distance before starting a new
paragraph; should be a stretchable length.\baselineskip Line spacing within a paragraph.\baselinestretch Decimal factor with the \baselineskip is weighted in the
entire document. So, you can use e.g. text with "one and a half lines" line spacing.
24/70
LaTeX for Beginners
Options for document classes:
Table 12: options for document classesoption Descriptionlandscape Swaps page length and page width; Preparation for
typesetting in landscape format.10pt, 11pt, 12pt Adjusts the size of plain text.twoside Typesetting according to double-sided layout; Page
numbers are for example alternating left and right.draft Marks the lines on the edge, that exceed the column width.titlepage Sets an own front page in all cases.openany Starts a chapter on any page (default: chapter start only on
odd-numbered pages).twocolumn Two-column page layout.
The page style
The page style determines the composition or appearance of header and footer, as well as the appearance of the page numbers.The page style is used in the preamble:\pagestyle{style}Also, it can be individually set for each page:\thispagestyle{style}As mandatory arguments are possible:
Table 13: Page stylesstyle descriptionplain Only centered page number in the footer.empty Blank header and footer, no page numbers.headings Header with page number and current heading, depending on
the document class.myheadings The page header can be set by \markright or \markboth.
The page style “headings” determines the page header automatically.“Myheadings” is set by the page header\markright{right head}
25/70
LaTeX for Beginners
If double-sided layout is active (twoside option), then it is set by:\markboth{left head} {right head}The appearance of the page numbers can be changed with the command\pagenumbering{pstyle}possible number styles pstyle are:
Table 14: Number stylespstyle descriptionAlph big Latin letters: A, B, C,...alph small Latin letters: a, b, c,...Roman large Roman numerals: I, II, III, IV,...roman small Roman numerals: i, ii, iii, iv,...arabic arabic numerals: 1, 2, 3,...
Font selectorFontsThree characteristics of a typeface or font are different in typography: The font family the font weight and the decoration.
The three features in detail: A font family for example includes types which are based on a common
design idea:◦ Antiqua fonts (e.g. Times New Roman)◦ Sans serif fonts (such as Arial or Helvetica)◦ Typewriter font (such as Courier)
The weights provide various levels of fat letters of a font family. Three weights are shown in the following example.◦ Book font◦ Half fat font style◦ Bold font style
The decoration of writing results from a characteristic modification, e.g. by "tilting" the characters in oblique or italic font. Three examples:◦ Italics◦ Slanted◦ Small caps
26/70
LaTeX for Beginners
Font family
A family includes types with same "traits", otherwise put, with a common design idea.
LaTeX recognizes two classes of commands to change the font family: The first command class acts as a switch, that is, calling one of the
following commands "toggles on" the respective font family. To again use the original font family, you must know which one this was, and "switch back" with the right command.◦ \rmfamily to switch the font family roman. (This is in all document
classes by default.)◦ \sffamily to switch to sans serif.◦ \ttfamily to switch to typewriter.
To set short pieces of text in a particular font family, there is the second class of the commands to the choice of font family:◦ \textrm{...} sets the text in parantheses in font family roman,.◦ \textsf{...} in sans serif and◦ \texttt{...} in typewriter.
Example:The following command calls have the same result:There are \ttfamily various \sffamily fonts.There are \texttt{various} fonts.
Font style
LaTeX provides the fonts of the featured font families in various styles. There are currently only simple commands in LaTeX to choose the font styles medium weight (the opposite of boldface) and boldface . Analog to choose a family, there are also two command classes: The first command class acts as a switch.◦ \mdseries switches on the medium weight. (This is for all document
categories by default.)◦ \bfseries switches on boldface.
For short text partsthere is the second command class.◦ \textmd{...} selects for within the parenthesized text the medium
weight,◦ \textbf{...} selects boldface.
27/70
LaTeX for Beginners
Examples:The choice of font style is freely combined with the choice of the family:\rmfamily\bfseries typography\rmfamily\textbf typography\sffamily\bfseries typography\sffamily\bfseries typography \textmd{and} print
Display variants
LaTeX knows different fonts to emphasize a word or story. Such fonts are called accentuating fonts or display variants of a font family. Here, too, there are two command classes to enable the font: The first command class acts as a switch.◦ \itshape switches on the italic font.◦ \slshape switches on the slanted font.◦ \scshape switches on small caps.◦ \em switches on the respective standard marking variant.
There is the second command class for short pieces of text.◦ \textit{...} selects italics.◦ \textsl{...} selects slanted.◦ \textsc{...} selects small caps.◦ \textup{...} selects upright font.◦ \emph{...} selects the standard marking variant.
Examples:\textit{italics}, \textsl{slanted} and \textsc{small caps}
The underlined text is a well-known and unfortunately far common way. It should not or only in exceptional circumstances be used in texts.In LaTeX, the command to underline is\underline{text}This command has two strong restrictions, which show that its use in LaTeX is really only for justified exceptional cases intended:First, underlined text are not wrapped by LaTeX, and underlined words are therefore not automatically separated.Secondly, LaTeX sets the underline stroke different deep, depending on whether there are descenders, or not. The font size
28/70
LaTeX for Beginners
Each font is available in different sizes, which can be selected by the user using the following commands (based on 10pt):
Table 15: Font sizesFont size command Font size\tiny 5pt\scriptsize 7pt\footnotesize 8ptpublished 9pt\normalsize 10pt\large 12pt\Large 14.4pt\LARGE 17.28pt\huge 20.74pt\Huge 24.88pt
The "font size" feature sets along with the three characteristics, font family, font style, and mark-up variant a font to a character set.The fonts are not linearly scaled, rather small fonts of the same family are bolder.Each font size command is relative to the selected base size 10pt, 11pt or 12pt.Each font size command applies until he is replaced by a different font size command.To a font size command limited in its validity, it is in a group to cling.
Example:Change in {\huge a} line.
29/70
LaTeX for Beginners
Headlines and footnotes
Outline commands
For the structure of long documents LaTeX provides outline commands (ocommand) that are used among other things to create the headings in a document and, where appropriate, to enter in a table of contents.
Example:\section{Introduction}\subsection{First examples}\subsubsection{The logistic equation}
Output:1 Introduction1.1 First examples1.1.1 The logistic equation
These commands are as follows:ocommand[short form]{heading}orocommand*{heading}
In the first form, the heading in the table of contents is acquired and numbered.A short form of the heading can be specified in the optional argument that better fits in the table of contents.
The *-form of ocommand produces no numbering of the heading and no entry in the table of contents.
30/70
LaTeX for Beginners
The following outline commands can be used:
Table 16: outline commandsocommand description\subparagraph 5 up to 6-unit number.\paragraph 4 up to 5-unit number.\subsubsection subsubsection; 3 up to 4-unit number.\subsection subsection; 2-up 3-unit number.\section section; 1-up 2-unit number.\chapter chapter; only in document class book
or report; simple numbering with double spaced design.
\part Volume of a book; book only in document class.
Footnotes
On a footnote is usually referenced by a leading high symbol. The LaTeX command to produce a footnote is:\footnote{footnotetext}The footnote command can be used only in the body text.In the document class “article” the numbering is continuously for the entire document, in “report” and “book”, however, the count begins new with each chapter. The footnote counter “footnote” is used to count.Should the footnote counter in the document class article be reseted to zero after each newly started \section, the following command is needed before each \section-command:\setcounter{footnote}{0}In the mathematical mode, tables, headings, etc. the \footnote does not work. To create footnotes in such cases enter the footnote icon within the formula, table, heading, ... , and the associated text outside:\footnotemark[num]\footnotetext[num]{footnotetext}Each call to \footnotemark counts the footnote counter further. Are therefore several marks before the first \footnotetext command is used, the footnote counter must be set manually to the correct value.
31/70
LaTeX for Beginners
Example 1:For the sides of a right triangle is:($a^2=_b^2_+_C^2$) \footnote{Where $a$ is the hypotenuse}
Example 2: (does the same as example 1, but this time with the help of \footnotemark in mathematical mode and then with \footnotetext outside.)For the sides of a right triangle is:$(a^2=_b^2_+_C^2) \footnotemark$\footnotetext{Where $a$ is the hypotenuse}
Example 3: (reset of the footnote counter)So we have $[x, yz] + [y, zx] + [z, xy]\footnotemark$\\and $[x, yz] = [y x, z] + [x, y]z \footnotemark$.\addtocounter{footnote}{-1}\footnotetext{Jakobi-Identity}\stepcounter{footnote}\footnotetext{derivation characteristic}
32/70
LaTeX for Beginners
Paragraph formattingThe layout of the page establishes the general framework for a printed text, so this text actually “lives" through the paragraphs. The paragraphs distinguish a context and can highlight the essence of a section through their design:Quotes are used differently than normal text and poems have a different shape than the long tables of an inventory list. The following explains the technical tools provided byLaTeX to make such links suitable by the way of the paragraph formatting.
Basics
Environments
Environments allow the formatting of entire paragraphs of text. They provide special commands or set certain parameters. The effectiveness of all the commands in an environment is restricted to the text enclosed by it. Each environment consists of two commands, a start command
\begin{name}and a final command\end{name}The start and end commands work from a defined sequence of LaTeX commands respectively. The name of the environment name must match in both commands.
The initial command can have more necessary and optional arguments. The text to be formatted by the environment is between the start and
end command.
Example:\begin{center}Text\end{center}
Environments can be nested (such as brackets). Here, the bracket command structure may not be serrated.
So it is allowed:\begin{nameA}
33/70
LaTeX for Beginners
\begin{nameB}...\end{nameB}
\end{nameA}
It is, however, prohibited:\begin{nameA}
\begin{nameB}...\end{nameA}
\end{nameB}
You can define your own environments.
Direct (raw) output
Sometimes the code will be used as well, as it is entered, i.e. all spaces and line feeds with no interpretation of the LaTeX commands.This is possible by using the verbatim environment.
Example:\begin{verbatim}In the verbatim environment, no carriage returnis performed: the rows end up where theyend up in the editor.LaTeX commands are not expanded.\end{verbatim}
The \verb command has a similar effect, but doesn't create a new paragraph, and is used within text lines:\verb:\input:results \input.
Special feature: In this case the command argument bracket is optional and consists of the character that immediately follows the command name.
Example:Is allowed: \verb@blue@, \verb:blue: or \verb(blue(Not allowed: \verb(blue)
34/70
LaTeX for Beginners
Justified and ragged text
LaTeX uses the justify where the word space is so altered as standard rate creating a smoother left and right edge. Here TeX works paragraph harmonical, i.e. it shall ensure as far as possible uniform word spacing within a paragraph.
The column width for the normal text is given in single column set by the \textwidth parameter.
Three more record types are possible: centred, as well as left or right-aligned set. This uses the natural word spacing. When the end is reached, a new line is started without hyphenation.
The environment “flushright” right-sets the text enclosed by it. “Flushleft” environment sets the text left-aligned. The environment “center” is centred text.
Examples:\begin{flushleft}The raggedness is well known by the mechanical typewriter\end{flushleft}
\begin{flushright}right-alligned raggedness, however, does not.\end{flushright}
\begin{center}Often centred text setting is used for the title of a document.\end{center}
With the command \\ the beginning of a new line can be enforced in all record types.
35/70
LaTeX for Beginners
Quoting of long sections
The text size is set by the preamble for the entire document in LaTeX. Citations are, however, often identified on indent of the left and right edges. The environments allow this quote and quotation.
Example:The text in the environment \textsl{quote} and \textsl{quotation} right and left will be indented by the same amount: \begin{quote} Extra spaces are inserted between the indented text and the plain text. As usual, paragraphs are separated by blank lines. \end{quote} With \textit{quotation} the first line of a paragraph is indented, with \textit{quote} the paragraphs are separated by a space.
Multi-column texts
The package multicol (\usepackage{multicol}) allows the set of multi-column texts: With the multicols environment of the package it is possible to set up to ten columns. General syntax: \begin{multicols}{NUM}[title][rest]
By \begin{multicols}{NUM} a text setting with NUM columns is started, and with \end{multicols} again finished. Then, a new number of columns can be selected.
Example:\begin{multicols}{2} ... \end{multicols} \begin{multicols}{3} ... \end{multicols}
36/70
LaTeX for Beginners
With the optional parameter “title” a headline can be specified with “rest” the minimum size of the remaining side. If the free space is less than this, multicols starts a new page. A dividing line between the columns is set, if the parameter \columnseprule is set to a size greater than zero.
Example:\setlength{\columnseprule}{.4pt} \begin{multicols}{3} ... \end{multicols}
Lists
Lists consist of items, which are subdivided by symbols, numbers, or words. There are three default lists to choose from: the environments itemize, enumerate, and description. \item command creates an item within these environments. The list environments are distinguished by the used items: ◦ The environment enumerate numbered the paragraphs of the text.
The numbering is done automatically. ◦ itemize identifies the sections of text with symbols as * or -◦ description is divided into the sections of text with arbitrary terms or
symbols. Lists can be nested into four levels (1 to 4).
Example: \begin{enumerate} \item a enumeration \begin{enumerate} \item a sub-item. \item another. \end{enumerate} \item the numbering is done automatically. \end{enumerate}
Indentation and label the items with each level automatically switch. In the description area, the desired brand must be passed to the \item
command as an optional argument.
37/70
LaTeX for Beginners
Example: \item[this is my item]
Tables
Tabs
Tabs divide (invisible) a printed page into columns, in which the text can be assigned. LaTeX offers the possibility to put such tabs with the tabbing environment. In the tabbing environment you can placea tab with the command \=. Each line is explicitly closed by the command \\.
Example:The first tab is \= here.\\
With the command \> you can jump to the tab position.
Example:\begin{tabbing} The first tab is \= here.\\ There \> we jump. \end{tabbing}
Multiple tabs can be used and skipped in a row. With the command \kill, it is possible to put tabs in a pattern line first and then later to use them.
Example:\begin{tabbing} \hspace*{1em}\=birthday: \=\kill Record: \ \> Name: \> Gutenberg\\ \> First name: \> Johannes\\ \> Birthday: \> around 1400\\ \end{Tabbing}
38/70
LaTeX for Beginners
Tables: column Declaration and line layout
In a table, text material is arranged in rows and columns. Also horizontal and vertical lines are often used to separate optical as a row or split separator.
This text record tasks can be carried out with the environment “tabular”.
Example:\begin{tabular}{ccc}a & b & c\\AA & BB & CC\\123 & 456 & 789\\\end{tabular}
A table is divided by column declaration {ccc}, column control & and line end commands \\ .
Each letter in the column declaration sets the layout of a column. The table material is divided with the character & in columns. The
number of such shared columns must match the number of declared columns.
The command \\ starts a new row in the table.
39/70
LaTeX for Beginners
Tables: column declaration in detail
The column declaration of the tabular environment sets the formatting of each individual column of a table. There are the following ways:
Table 17: column declarationsdeclaration descriptionl Content of the column will appear left-justified.c Content of the column will appear centred.r Content of the column will appear right-aligned.p{dim} The text is set in a Parbox of the width dim (for example
p{5cm}). The first line of the Parbox is aligned to the current table row.
| A vertical line is used between the preceding and the following column.
|| As above, but a double line is used.*{num}{decl} The column declaration decl repeats num times. For example,
is *{3}{|r} equivalent to |r|r|r.@{text} The text element is used as with the hyphens before between
the preceding and following column (in each row!). This removes the usual column space.
Example:\begin{tabular}{l|c|r@{,}l@{\hspace{2mm}$\cal EUR$\hspace{2mm}}|{p{6cm}}Shirt & $ $1/2 arm & 60 & - & cotton; white\\Pants & & 159 & - & jeans; blue\\Socks & Pair & 7 & 98 & wool; white, black, brown and blue\end{tabular}
40/70
LaTeX for Beginners
Mathematical formula set and fonts
Conceived originally in particular as a system for sophisticated mathematical formula set TeX shows even today its full strength in this area. Although most word processing and WYSIWYG-based desktop publishing systems have now means for formula set (formula editors), but there is not a similar flexible system such as the team TeX/LaTeX on the market .In TeX it is even possible to extend TeX, if once a special character is missing, by high-quality fonts. This possibility was actively used by mathematicians around the world, and the collected fruits of this work leave hardly no wishes with regard to the now available symbols.
Cross references and mathematical formula set
Cross references
To create references to other places in the text, an invisible counter can be used, that you can reference later (or earlier). The command\label{ref}is such a mark, where the marking may consist of any characters (single-character commands \ # $, etc. are not allowed.). A reference to such a mark is done with one of the commands\pageref{ref}or\ref{ref}
The \pageref command sets the page number on which is the corresponding label, whereas the "reference number" of each referring body part is used with \ref {...}. Body parts that can provide a reference, are listed in the following table:
Table 18: text parts with references
41/70
LaTeX for Beginners
Object ReferenceOutline command (\section) Outline numberequation, eqnarray Equation numberfigure, table Image or table numberenumerate Value of itemstheorem environment Appropriate counter
Example:This slide contains a Label\label{slide}.The label \texttt{slide} is available on slide \ref{slide}.
Principles for the formula set
Formula set requires some flexibility, that is not necessary when "normal" text setting. So, some elements of a formula can be only determined when the formula is virtually already complete set (e.g. size and extension of a squareroot sign across a formula expression).
Example:\sqrt{\frac{1+1}{(-2+1)\cdot(-1)}} = 1.414213\ldots
Therefore, it is necessary to use graphic elements, which use far more strained the boxes logic of TeX as a normal text set in the formula set.LaTeX handles formula printouts, because of such graphical problems, in the so-called math mode (in the following short MM) and provides environments in which you can use it.Even if the formula generator of LaTeX is very powerful, so it may not take into account automatically all nuances, which request the readability setting of a formula (especially since some of these points strongly depend on the meaning of the formula).An important principle in the formula set is to do the precise settings only immediately before the final layout, because formulas are graphical elements and the work on graphical elements in such as a restructuring of the text takes the most time.
42/70
LaTeX for Beginners
Mathematical environments
The following three environments (or five, depending on the method of counting) are used for typesetting mathematical formulas: math places a formula in the body text : the math area can be
reached by \( ... \) or even shorter between two dollar signs $...$. equation creates a out-of-line and numbered formula:
To use displaymath (or shorter: \[ ... \]) instead of equation, the formula though deposed, but not numbered.
eqnarray creates a out-of-line and numbered equation field:a = b + c + d + e + f +
g + h + i + j + kb = 4c = 3A not numbered equation box can be created by eqnarray*.The eqnarray environment is like a column table without applying column declaration. The example above is implemented as:
\begin{eqnarray}a & = & b + c + d + e + f +.& & g + h + i + j + k\\b & = & 4\\c & = & 3\end{eqnarray}
Mathematical environments: features
The environments math, equation, displaymath and eqnarray(*) switch LaTeX in the MM (mathematical mode). In MM LaTeX interprets his input in a way adapted for formula set: LaTeX switches to a mathematical italic font. LaTeX changes the spacing on mathematical symbols instead of words
of a natural language (no ligatures, no kerning). In particular no blank lines should therefore appear in the MM! Space in MM creates no white space in the sentence, they are
necessary here only as a command separator (but still useful as optical isolators for clarity in the input file).
The array environment can be used to create a table with as many columns in
43/70
LaTeX for Beginners
MM (the eqnarray environment is fixed at three columns). The array environment required a column declaration, as in the tabular environment and can be used for example to represent matrices.
Example:$\left(\begin{array}{cccc}1 & 2 & 3 & 4\\2 & 2 & 2 & 4\\3 & 2 & 1 & 4\\4 & 2 & 0 & 5\\\end{array}\right)$
Basic commands in MM
Subscript: _{}: terms like H2O can be set by prefixing the underscore.$H_2O$
Superscript: ^{}: all according to an expression like x² is innovate by prepending a roof (arrow-to-above characters).$x^2$
Fractions: \frac{}{}: A fraction such as 1/2 is easy to use, but you need a
command for .$1/2$$\frac{1}{2}$
Roots: \sqrt[]{}: whether a square root or an n-th root is used now, it takes in both cases the "squareroot"-command.$\sqrt{2}$ $n$-th root $\sqrt[n]{x}$
Accents: The following commands produce accents in MM:
44/70
LaTeX for Beginners
Table 19: AccentsWritten symbol
Latex command description
\hat{a} Hat over a.\check{a} Reverse hat over a.\breve{a} Semicircle with opening to the top of a.\acute{a} Dash from left below to right above over a.\grave{a} Das from left above to right below over a.\tilde{a} Tilde over a.\bar{a} Bar over a.\vec{a} Vector arrow over a.\dot{a} Dot over a.\ddot{a} Two dots over a.
More commands in MM
Two extra commands are available for "extended" accents:\widehat{abc} \widetilde{abc}Note: \widevec is not available unfortunately.
Horizontal lines (over / underlining): \overline{}: there is not a \widebar-command, instead use the overline-command:You can $\overline{\mbox{overline}}$as well as $\underline{\mbox{underline}}$.
Horizontal brackets (over / underbracing): \overbrace{}: analog horizontal braces can be set (even with caption, if desired):\[\overbrace{h+h+\cdots+h}^{\mbox{i times}} \qquad\underbrace{k+k+ cdots + k} _ {\mbox {j times}}\]
Heaping stacks (stacking): \stackrel{}{}: is used to place two
45/70
LaTeX for Beginners
expressions in the MM one above the other.\pi\stackrel {?}{{=} \frac{22]{7}
Sizeable operators and delimiters
Sizeable operators (sizable symbols): there are operators, the effects of which leads, on all printouts to that size adapts to these prints (e.g., integral and sum operator). These are:
Table 20: Sizeable operatorsWritten symbol
Latex command
description
\sum Summation sign
\int Integral sign
\oint contour integral
\prod Product sign
\coprod Reversed product sign
\bigodot Dot within an O
\bigotimes Cross within an O
\bigoplus Plus within an O
\bigcap Intersection, large
\bigcup Union, large
\bigvee Logical or sign, large
\bigwedge Logical and sign, large
Example:\[\int\limits_{-\infty}^\infty e^{x^2}\, dx = \sqrt{\pi}\]Delimiters: Delimiters provide logical function of a parenthesis, which is why they must occur in pairs. Similarly to the above operators the following control
46/70
LaTeX for Beginners
icons adjust their size to the parenthesized expression, if you forward a \left and \right :
Table 21: DelimitersWritten symbol
Latex command
description
( Round bracket (parenthesis) left) Round bracket (parenthesis) right[ Left square bracket] Right square bracket\{ Left curly brace\} Right curly brace\lfloor Floor brace left\rfloor Floor brace right\lceil Rounding bracket left (ceiling
function)\rceil Rounding bracket right (ceiling
function)\langle Left angle bracket\rangle Right angle bracket/ slash\backslash Backslash| Vertical line - pipe \| Double vertical line\uparrow Up arrow\downarrow Down arrow\updownarrow
Up/Down arrow
\Uparrow Thicker/double up arrow\Downarrow Thicker/double down arrow
47/70
LaTeX for Beginners
\Updownarrow
Thicker/double up/down arrow
For example, (A point serves as the invisible delimiter.)\[y = \left\{\begin{array}{rcl}-1 &: & x < 0\\0 &: & x = 0\\ 1 &: & x > 0 \end{array} \right.\]
Binary operators, relations, arrows
Binary operators:
Table 22: Binary operatorsWritten symbol
Latex command
description
\pm Plus-Minus\ \setminus Discrepancy of
quantity – see backslash
\times Vector product – Cartesian product
\star Star\circ Circle – connected with\div Division sign\wedge Wedge – logical and
sign\ominus Minus within an o\cap Intersection\bigcirc Big circle\oslash Slash within an o\odot Dot within an o\mp Minus-Plus\cdot Multiplication dot\ast Star
48/70
LaTeX for Beginners
\diamond Diamond\bullet Thick dot\vee Logical or sign\oplus Plus within an o\otimes Cross within an o\cup Union\triangleleft Triangle with top left\triangleright Triangle with top right\bigtriangleup Triangle with top up\bigtriangledown
Triangle with top down
Relations:Table 23: RelationsWritten symbol
Latex command
description
\leq Less than or equal to
\geq Greater than or equal to
\ll Much less than\gg Much greater than\subset subset\supset superset\subseteq Subset of or equal to
\supseteq Superset of or equal to
\in Element of
\ni Not an element of\parallel Parallel
\cong congruent\equiv equivalent
49/70
LaTeX for Beginners
\sim Similar to\propto Proportional to\simeq Similar or equal to\approx approximately\perp Perpendicular,
orthogonal toArrows:
Table 24: ArrowsWritten symbol
Latex command description
\leftarrow Left arrow\Leftarrow Thicker/double arrow to the left\rightarrow Right arrow\Rightarrow Thicker/double arrow to the right
\leftrightarrow Left-right arrow\Leftrightarrow Thicker/double left-right arrow
\mapsto Maps to\hookleftarrow Arrow left with hacking upwards at the
end\hookrightarrow Arrow right hook to the top at the end
of\leftharpponup Left arrow only with upper arrow head\leftharpoondown
Left arrow only with lower arrow head
\rightharpoonup Right arrow only with upper arrow head
\rightharpoondown
Right arrow only with lower arrow head
\rightleftharpoons
Right upper arrow tipped arrow combined with arrow to the left with lower arrow head
50/70
LaTeX for Beginners
\longleftarrow Long left arrow
\Longleftarrow Thicker/double long left arrow\longrightarrow Long right arrow\Longrightarrow Thicker/double long right arrow\longleftrightarrow
Long left right arrow
\Longleftrightarrow
Thicker/double long left right arrow
\longmapsto Long maps to\uparrow Up arrow
\Uparrow Thicker/double up arrow
\downarrow Down arrow
\Downarrow Thicker/double down arrow
\updownarrow Up-down arrow
\Updownarrow Thicker/double up-down arrow
\nearrow North East arrow\searrow South East arrow
\swarrow South West arrow
\nwarrow North West arrow
The vast majority of the here pictured relation commands can by prefixing the \not command be negated. It is for example ≠ \not= (crossed-out =).
Mathematical symbols: log-like, special
Log-type featured symbols (log-like functions): in order that LaTeX knows
51/70
LaTeX for Beginners
that you set a function as log, and not the product of the three variable l, o and g, there are these functions/symbols as own commands in MM:
Table 25: math functions\arccos \arcsin \arctan \arg \cos \cosh \cot \coth\csc \deg \det \dim \exp \gcd \hom \inf\ker \lg \lim \liminf \limsup \ln \log \max\min \Pr \sec \sin \sinh \sup \tan \tanh
52/70
LaTeX for Beginners
Various special symbols:
Table 26: special symbolsWritten symbol
Latex command
description
\aleph Aleph (from Set Theory)\imath Gothic I without i-dot\ell Gothic l\Re Real part\partial Round d (for partial derivatives)\prime Prime – apostrophe (like in
derivatives)\nabla Nabla\angle Angle symbol\exists There is\triangle triangle\hbar H-bar, crossed h from physics\jmath Gothic J without j-dot
\Im Imaginary part\infty Infinity\emptyset Empty set (phi)\forall For all
53/70
LaTeX for Beginners
Mathematical symbols: alphabets, fonts
Greek uppercase letters:
Table 27: Greek uppercase lettersGreek letter
Latex command
\Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon \Phi \Psi \Omega
Greek lowercase: (with the in the formula usual versions)
Table 28: Greek lowercase lettersGreek letter
Latex command
\alpha \beta \gamma \delta \epsilon \varepsilon \zeta \eta \theta
54/70
LaTeX for Beginners
\vartheta \iota \kappa \lambda \mu \nu \xi o \pi \varpi \rho \varrho \sigma \tau \upsilon \phi \varphi \chi \psi \omega
Calligraphic capital letters:$\mathcal{COMPUTERCALLI}$
Calligraphic lowercase: not available.
Mathematical fonts:
Table 29: mathematical fontsMath font examplemath italic $\mathit{math\ italic\ a_1$
55/70
LaTeX for Beginners
math roman $\mathrm{math\ roman\ b_2$math bold $\mathbf{math\ bold\ c_3$math sans serif $\mathsf{math\ sans serif\ d_4$math typewriter $\mathtt{math\ typewriter\ e_5$
Features for the formula set
Adjusting space
Predefined distances in LaTeX:
Table 30: predefined distancesLatex command
description
\quad as wide as a letter is high\qquad two quad\! -3/18 of a quad\, 3/18 of a quad\: 4/18 of a quad\; 5/18 of a quad
56/70
LaTeX for Beginners
Theorem
In the mathematical typesetting you need usually structural elements such as theorems, axioms, assumptions, lemma, etc.. The \newtheorem covers all this with a single command in LaTeX i, by providing the opportunity to define own "theorem" environments:
Definition:\newtheorem{environment_identifier}{environment_name}[counter]
Table 31: Theorem environmentsParameter Descriptionenvironment_identifier Logical identifier of the new environment, so the
name under which the new environment is now addressed within the input file.
environment_name "Real" environment name, as it is to be used later by LaTeX.
counter Counter for the new environment; is further increased when the environment is used. The counter should depend on a second count (for example, to new number sentences within each chapter), lets the latter under the optional argument specify counter to.
Call:\begin{EnvironmentIdentifier}[Addition]Text\end{EnvironmentIdentifier}
Table 32: Theorem environments – part 2Parameter DescriptionEnvironment identifier
see above
Addition An add-on such as for example the name of the person to which the "theorem" is attributed.
57/70
LaTeX for Beginners
Bibliography, graphics and Visual formatting
Long and demanding texts get first accessible by accompanying guidance like bibliography and index. Also pictures involve often in the text, which should help to illustrate the written. LaTeX has a variety of ways to get a text to complement material like.As for the author, not only a readable result of his work is important, but that this work - on LaTeX source files - while his writing remains manageable, too, are finally techniques presented with even very large documents remain editable.
Bibliography and index
Bibliography
A bibliography is created with the thebibliography environment.\begin{thebibliography}{sample_mark}\bibitem[mark_1]{ref_1}entry 1...\end{thebibliography}
The \bibtitem command provides the items in the bibliography with marks of the form [1], [2],... The optional argument is used to determined each entry freely.
sample_mark is a placeholder for the width of the bibliography mark used by \bibitem.Examples:1-9 Items: sample_mark = 9 (for marks of the form [5])10-99 Items: sample_mark = 65Author abbreviation: sample_mark = XYZ (for marks of the form [Kop])
ref_1 refers to a reference mark in the current text with\cite[addition]{ref}More text can optionally be added at the point [addition].Example:For a detailed description see \cite[lam941] and \
cite[S.~60 ff] {kop941}.
58/70
LaTeX for Beginners
"For a detailed description see [12] and [10, p. 60 ff]."
Example of a bibliography
A bibliography lists the literature quoted in the document. The bibliography can be formatted with the thebibliography environment and is issued in its place.
Example:\begin{thebibliography}{XXX}\bibitem[Lam]{Lam94} L.~Lamport: {\itshape \LaTeX,A Document Preparation System, User's Guide and ReferenceManual }, 2nd ed, Addison-Wesley Publishing Company (1994)\bibitem[Kop]{Kop94} H.~Kopka {\itshape \LaTeX, Bd.\ 1.\Einf"uhrung , Addison-Wesley Publishing Company (1994)\end{thebibliography}
is printed out at this point as follows:
Bibliography[Lam] L. Lamport: LaTeX, A Document Preparation System, User's
Guide and Reference Manual, 2nd ed, Addison-Wesley Publishing Company (1994)
[Kop] H. Kopka LaTeX, Bd. 1. Einführung, Addison-Wesley Publishing Company (1994)
Procedure of LaTeX: LaTeX writes the reference marks invoked with \cite in the .aux file.
Theirs is written in our example:\citation{Lam94}\citation{Kop94}
At the next round of LaTeX, these reference marks are replaced by the bibliography marks.
At least two LaTeX runs are necessary for creating a bibliography by the correct marks.
59/70
LaTeX for Beginners
BibTeX
A thebibliography environment with the quoted entering can be created automatically with the BibTeX program. BibTeX uses a database in which the bibliography entries in defined
fields must be entered. This database must be placed in a file with the extension .bib, such as math.bib or bio.bib.
In Foo.tex the .bib file has to be announced with the command \bibliography{...}:\documentclass{article}\begin{document}...\bibliography{math,bio}\end{document}The bibliography will appear in the place of this command.
BibTeX reads out the names of the selected databases from the file foo.aux, such as math.bib and bio.bib.
BibTeX examines the database for entries that have been selected with \cite. BibTeX takes such entries, it writes them to a file called foo.bbl.
These entries are formatted in the form of a \bibitems. BibTeX uses a stylefile with the extension .bst.
Error messages are recorded in the file foo.blg. A LaTeX, a BibTeX and again two LaTeX runs are needed to obtain a
correctly used bibliography. Not with \cite called messages can be added by \nocite{*}.
BibTeX: An example of a database
A BibTeX database is a file with fixed field entries:@string{lhbook = "Chaotic behavior of deterministic systems (LES HOUCHES 1981)"}@inproceedings{lh:mis,AUTHOR = "Misiurewicz, M.",TITLE = "Maps of an Interval",BOOKTITLE = lhbook,PAGES = "565 -- 590",PUBLISHER = "North-Holland",ADDRESS = "Amsterdam -- New York",YEAR = "1983"}
60/70
LaTeX for Beginners
@book{abr&rob,AUTHOR = "Abraham, R. and Robbin, J.",TITLE = "Transversal Mappings and Flows",PUBLISHER = "Benjamin Inc.",ADDRESS = "New York",YEAR = "1967"}@article{cel,AUTHOR = "Collet, P. and Eckmann, {J.-P}. and Lanford, O. E.",TITLE = "Universal Properties of Maps...",JOURNAL = "Comm. Math. Phys.",PAGES = "211 -- 254",YEAR = "1980"}
After the character @ follows the input type: book, article,.... Required and optional fields belong to each type (AUTHOR, TITLE...). By \bibliographystyle{style} different styles of bibliography can be
selected in foo.tex:
Table 33: bibliography stylesstyle Bibliography is used as follows:plain Alphabetically sorted by authors; Form: [1], [2].unsrt In the order of the \cite commands.alpha Alphabetically sorted by authors; Form: [Kop], [Lam].abbrv Like alpha, but with automatic generation of marks.
In addition, there are many more bibliography styles.
Index
An index breaks down important terms of a text to page numbers. The author must decide what is a "major".
To create an index, LaTeX provides the theindex environment:\begin{theindex}...Index entries…\end{theindex}
61/70
LaTeX for Beginners
Index entries can be integrated with the \item, \subitem, and \subsubitem commands and a gap between the index entries can be associated with \indexspace.
Example:\begin{theindex}\item quotient ring \dotfill 5\subitem of Martindale \dotfill 6\subitem symmetric \dotfill 8\subsubitem restricted \dotfill 9\indexspace\item The central carrier \dotfill 11\end{theindex}
Index entries with MakeIndex
The page number of a term to be included in the index, can be determined by LaTeX.To do this, there are two ways: Index formatting by hand: in the source code put behind the to be
added text (without spaces!)\index{Index_entry}to carry out, where Index_entry is the text, which is to be registered in the table of contents.Example:rare blue wildebeest \item{wildebeest}◦ If you put \makeindex in the preamble of source code (foo.tex),
LaTeX creates a file foo.idx in which the index entries and the corresponding page numbers are available.
◦ The file foo.idx is edited by hand with environment theindex. You can format the index entries by the MakeIndex program:◦ Such as LaTeX, MakeIndex uses the same \index-commands.
However, they have an extended syntax; for example, you can mark \subitem's in the \index-command:
rare blue wildebeest \index{wildebeest!blue}which is equivalent to \item wildebeest \subitem blue within the theindex environment.
◦ In the preamble of the source foo.tex the \makeindex-command hast to be entered as well the \makeidx-package has to be loaded with
62/70
LaTeX for Beginners
the \usepackage-command.◦ An index is created with makeindex foo, which is used by the \
printindex-command in foo.tex in its place.
Graphic
General
The inclusion of images is only indirectly to abandon of the page formatting (the text set).Usually there is the task to make the paragraphs in that way, so that images can be added in the free areas.To this end, there are various LaTeX environments that automatically perform appropriate positioning:◦ Figure-and table environment.
Furthermore there are LaTeX environments available, that can be used to create graphics directly in LaTeX:◦ picture environment.◦ epic-and eepic packages.
Complex, high-quality images should be created better with appropriate, external graphic programs. Those created graphics must then be integrated into the LaTeX document. Unfortunately there were no standards nor recommendations in the childhood of TeX/LaTeX how to do that. As a result, a bunch of different methods was available to include graphics in LaTeX. In the meantime is LaTeX has a "standard package” for the purpose of integration of graphics to the page, but has this so far not the potential to displace the other established methods. We will discuss briefly:◦ bm2font◦ EPSF package◦ graphics package
63/70
LaTeX for Beginners
picture environmentThe picture environment provides a tool with the \put-command, that allows to position graphic or text freely; that is elements can be placed outside of the image dimensions. In positioning the picture environment uses an internal unit, which can be used by the command \setlength{\unitlength}{unit}.
The general syntax is:\setlength{\unitlength}{unit}\begin{picture}(width,height)(x-origin,y-origin)\put(x,y){picture command}...\end{picture}
Table 34: picture environmentParameter Descriptionunit An image is specified by this measure.width Width of the image in screen units.height Hight of the image in screen units.x-origin X-coordinate of the image origin in image units.y-origin Y-coordinate of the image origin in image units.x X-coordinate of the element to be placed.y X-coordinate of the element to be placed.
picture commands can be:Table 35: picture commandsCommand Description\line(a,b){length} Line of the slope of a/b and the length “length”.\vector(a,b){length} Vector of the slope of a/b and the length “length”.\circle{diam} Empty circle of diameter diam.\circle*{diam} Filled circle of diameter diam.\oval(width,height) A rectangle of width “width” and height “height”
described a oval.\makebox A short text / single line\framebox A framed text\shortstack Multiple, aligned rows\parbox full paragraphs
64/70
LaTeX for Beginners
More to the picture environment
Notes:There are two different line thicknesses to the graphical elements available in the picture environment. Between these can be toggled with the commands \thicklines and \thinlines. Default is \thinlines.There are also the positioning command \multiput besides the positioning command \put. This one has two increment arguments for the X- and Y-coordinate and a repeat factor in addition; see example.
Except for the command \framebox, there are also the \dashbox, \fbox and \frame commands.Also bezier curves and grids can be in the drawn in the picture environment.
Example:\setlength{\unitlength}{1mm}\thicklines\begin{picture}(130,70)\put(0,0){\dashbox(130,10){{\large\bf the love triangle}}}\multiput(0,15)(5,0){27}{\circle*{1}}\multiput(0,70)(5,0){27}{\circle*{1}}\multiput(0,15)(0,5){11}{\circle*{1}}\multiput(130,15)(0,5){11}{\circle*{1}}\put(65,20){\makebox(0,10){{\normalsize bf seven dwarfs}}}\put(35,35){\line(1,0){60}}\put(35,35){\line(1,1){30}}\put(95,35){\line(-1,1){30}}\put(65,47){\circle{15}}\put(65,42){\vector(0,1){10}}\put(5,55){\framebox(40,10){{\normalsize bf snow white}}}\put(85,55){\framebox(40,10){{\normalsize bf stepmother}}\end{picture}
65/70
LaTeX for Beginners
epic-and eepic-packagesThe picture environment has many weaks, of which many are eliminated by using the epic package (enhanced picture-environment): The picture environment allows only certain line slopes, since epic lines
can supply lines, any upgrades are possible, even if the lines are not always nice looking.
epic knows polylines, dashed and dotted lines. The \multiput-command has been extended in the epic package. EPIC has an own command to draw grids.
The problem of the radii of which LaTeX knows only 22 was not resolved in the epic package. New commands/environments of the epic package are:
Table 36: epic commandsCommand Description\drawline Improved \line\multiputlist Advanced \multiput\matrixput More \multiput-versions\grid New command to draw
grids\dottedline Dotted lines\dashline Dashed lines\jput For polylines
Table 37: epic commands – part 2Environment Description\join For solid strokes.\dashjoin For dashed strokes.\dottedjoin For dotted line trains.
The eepic package expanded the picture environment. With eepic finally any radii can be drawn, however eepic works with special commands, that will not work together with all dvi drivers. For this reason, eepic is only partially recommended. Parts of the eepic commands can be emulated dvi driver independent by the eepicemu package, however, this has the disadvantage that TeX claims significant CPU time.
66/70
LaTeX for Beginners
Integration of bitmap graphics
While the LaTeX picture environment or as the epic package quasi enable displaying vector graphics, here it is discussed how bitmap graphics, such as scanned photographs, can be included in LaTeX. Three methods have established themselves: bm2font (bitmap to font) by Friedhelm Sowa makes a usable TeX font
from a BitMap-graphic and generates the necessary TeX and LaTeX commands automatically to reassemble the fragmented picture in TeX/LaTeX, i.e. to include. The method is though comparatively complicated, but very well thought out and has the distinct advantage to be completely independent of the used dvi driver.
The epsf package by Tomas Rokicki needs a dvi driver that understands the \special-commands of the package, i.e. the coming also from Rokicki and very popular driver dvips output of graphics.The easiest way to use this package, is to insert a call to the following type in a LaTeX document:\begin{center}\epsffile{filename.eps}\end{center}
The package handles actually only "Encapsulated PostScript-files", which may contain bitmaps, can cope under circumstances as well as with a normal PostScript file unless it is able to calculate the dimensions of the image.
The graphics package associated with LaTeX2e enables the integration of a raster image of the epsf package similar to by it generates \special-commands for file types that are supported by the driver. E.g. dvips used the graphics package can integrate also PostScript files:\begin{center}\includegraphics{filename}\end{center}An optional argument gives you the choice of an image section in the \includegraphics-command.
67/70
LaTeX for Beginners
Editing long documents
Document detailed
A longer document is generally divided into many different elements, from the title to index and glossary. LaTeX makes environments and tools available to format these body parts and makes these parts suitable to reference (LaTeX constructs), as well to manage the parts and references (Tools).
Title page and summary
A title page can be formatted with the \maketitle command automatically. The title report appears in the document classes and book on a separate page without a page number.\title and \author must be used. The title is to complete by \maketitle.A date is automatically generated if \date is not set.The \thanks{...} command corresponds to the footnote command.
A summary can be created in the abstract environment with edge feeder and small print (\begin{abstract} ... \end{abstract})
Example:\documentclass[11pt,twoside]{article}\begin{document}\title{{\bfseries Text Setting and Layout with LaTeX}}\author{\textsc{Ralf Banning} and \textsc{Heiko A. ~Groeneveld}}\date{1995}\maketitle
\begin{abstract}LaTeX is a developed by Leslie Lamport...\end{abstract}
As a universal system developed, he "opening..."\end{document}
68/70
LaTeX for Beginners
Structured files
Long LaTeX sources are much easier to handle if they are split into multiple files. This is supported by the following commands: \input{name} reads the contents of the file name and puts it at the point
in the code where the \input-command is. \include{name} works like \input, kept but the reference of selected files;
\include starts getting a new page!
Selection of texts and hierarchies
Especially for long texts, it is not effective to "compile" every time the whole source file with LaTeX, if only a single chapter currently being edited. Structured files allow a partial processing.These two approaches are different: Are parts read by \input, comment out all \input-lines that contains the
files that should not be handled. Are parts read by \include, you can select with the line \
includeonly{nam1,nam2,...} the \include-files you like to edit. This command must be in the preamble.
Example:In a process of\documentclass{report}\includeonly{preamble,chap1}\begin{document}\input{title}%\tableofcontents\include{preabmle}\include{chap1}\include{chap2}\include{chap3}%\Input{lit}\end{document}
only the files title.tex, preamble.tex and chap1.tex will be accounted.The \include-command sets on its own an .aux file for each file read by him. Choose therefore the text to be processed with \includeonly, previously created cross references are preserved (in contrast to the \input-selection!).Changes in the body can however lead to wrong page references in the
69/70
LaTeX for Beginners
following text, which can be only removed by a complete compilation of all source files.
Control for file hierarchies
The subfiles of a disassembled source code are still too long or too confusing, the subfiles can be decomposed in turn: A file that is loaded with \input, can in turn load files via \input. A file that is loaded with \include cannot load in turn files with \include,
but with \input.
Example:The file chap1.tex is decomposed into individual sections sec1_1.tex, sec1_2.tex,... and could look like this:File chap1.tex:\chapter{Basics}\input{sec1_1}\input{sec1_2}\input{sec1_2}
To keep track of the parts of a source text, the \listfiles command can be used in the preamble. As a result, a list of currently used files is displayed on the screen and in the .log file.
Example:With \includeonly{preamble,chap1}, the following list is as follows:
report.cls 1994/12/09 v1. 2 x Standard LaTeX document classsize10.clo 1994/12/09 v1. 2 x Standard LaTeX file (size option)preamble.texchap1.texsec1_1.texsec1_2.texsec1_2.tex***********
70/70