LaTeX2e unofficial reference manual (October 2018)

Short Table of Contents

Table of Contents

LaTeX2e: An unofficial reference manual

This document is an unofficial reference manual (version of October 2018) for LaTeX2e, a document preparation system.

1 About this document

This is an unofficial reference manual for the LaTeX2e document preparation system, which is a macro package for the TeX typesetting program (see Overview).

This document’s home page is https://puszcza.gnu.org.ua/software/latexrefman. There you can get the sources, subscribe to the mailing list or read its archives, see other infrastructure, and get the current output in various formats. In particular, the output comes in two web formats. Probably the most convenient one, shown at http://latexref.xyz/, has pages for each topic and so is good for a quick lookup; see also the note there about easy-to-remember links. The other, shown at http://svn.gnu.org.ua/viewvc/latexrefman/trunk/latex2e.html?view=co, has all the information on single page.

In this document, we will mostly just use ‘LaTeX’ rather than ‘LaTeX2e’, since the previous version of LaTeX (2.09) was frozen decades ago.

LaTeX is currently maintained by a group of volunteers (http://latex-project.org). The official documentation written by the LaTeX project is available from their web site. This document is completely unofficial and has not been reviewed by the LaTeX maintainers. Do not send bug reports or anything else about this document to them. Instead, please send all comments to latexrefman@tug.org.

This document is a reference. There is a vast array of other sources of information about LaTeX, at all levels. Here are a few introductions.

http://ctan.org/pkg/latex-doc-ptr Two pages of recommended references to LaTeX documentation. http://ctan.org/pkg/first-latex-doc Writing your first document, with a bit of both text and math. http://ctan.org/pkg/usrguide The guide for document authors that is maintained as part of LaTeX. Many other guides by many other people are also available, independent of LaTeX itself; one such is the next item: http://ctan.org/pkg/lshort A short introduction to LaTeX, translated to many languages. http://tug.org/begin.html Introduction to the TeX system, including LaTeX, with further references.

2 Overview of LaTeX

LaTeX is a system for typesetting documents. It was originally created by Leslie Lamport and is now maintained by a group of volunteers (http://latex-project.org). It is widely used, particularly for complex and technical documents, such as those involving mathematics.

A LaTeX user writes an input file containing text along with interspersed commands, for instance commands describing how the text should be formatted. It is implemented as a set of related commands that interface with Donald E. Knuth’s TeX typesetting program (the technical term is that LaTeX is a macro package for the TeX engine). The user produces the output document by giving that input file to the TeX engine.

The term LaTeX is also sometimes used to mean the language in which the document is marked up, that is, to mean the set of commands available to a LaTeX user.

The name LaTeX is short for “Lamport TeX”. It is pronounced LAH-teck or LAY-teck, or sometimes LAY-tecks. Inside a document, produce the logo with \LaTeX . Where use of the logo is not sensible, such as in plain text, write it as ‘ LaTeX ’.

2.1 Starting and ending

LaTeX files have a simple global structure, with a standard beginning and ending. This is a small example.

\documentclass{article} \begin{document} Hello, \LaTeX\ world. \end{document}

Every LaTeX document has a \begin{document} line and an \end{document} line.

Here, the ‘ article ’ is the document class. It is implemented in a file article.cls . You can use any document class on your system. A few document classes are defined by LaTeX itself, and vast array of others are widely available. See Document classes.

You can include other LaTeX commands between the \documentclass and the \begin{document} commands. This area is called the preamble.

The \begin{document} , \end{document} pair defines an environment; the ‘ document ’ environment (and no others) is required in all LaTeX documents (see document). LaTeX make available to you many environments that are documented here (see Environments). Many more are available to you from external packages, most importantly those available at CTAN (see CTAN).

The following sections discuss how to produce PDF or other output from a LaTeX input file.

2.2 Output files

LaTeX produces a main output file and at least two auxiliary files. The main output file’s name ends in either .dvi or .pdf .

.dvi If LaTeX is invoked with the system command latex then it produces a DeVice Independent file, with extension .dvi . You can view this file with a command such as xdvi , or convert it to a PostScript .ps file with dvips or to a Portable Document Format .pdf file with dvipdfmx . The contents of the file can be dumped in human-readable form with dvitype . A vast array of other DVI utility programs are available (http://mirror.ctan.org/dviware). .pdf If LaTeX is invoked via the system command pdflatex , among other commands (see TeX engines), then the main output is a Portable Document Format (PDF) file. Typically this is a self-contained file, with all fonts and images included.

LaTeX also produces at least two additional files.

.log This transcript file contains summary information such as a list of loaded packages. It also includes diagnostic messages and perhaps additional information for any errors. .aux Auxiliary information is used by LaTeX for things such as cross references. For example, the first time that LaTeX finds a forward reference—a cross reference to something that has not yet appeared in the source—it will appear in the output as a doubled question mark ?? . When the referred-to spot does eventually appear in the source then LaTeX writes its location information to this .aux file. On the next invocation, LaTeX reads the location information from this file and uses it to resolve the reference, replacing the double question mark with the remembered location.

LaTeX may produce yet more files, characterized by the filename ending. These include a .lof file that is used to make a list of figures, a .lot file used to make a list of tables, and a .toc file used to make a table of contents (see Table of contents etc.). A particular class may create others; the list is open-ended.

2.3 TeX engines

LaTeX is defined to be a set of commands that are run by a TeX implementation (see Overview). This section gives a terse overview of the main programs (see also Command line).

latex pdflatex In TeX Live (http://tug.org/texlive), if LaTeX is invoked via either the system command latex or pdflatex , then the pdfTeX engine is run (http://ctan.org/pkg/pdftex). When invoked as latex , the main output is a .dvi file; as pdflatex , the main output is a .pdf file. pdfTeX incorporates the e-TeX extensions to Knuth’s original program (http://ctan.org/pkg/etex), including additional programming features and bi-directional typesetting, and has plenty of extensions of its own. e-TeX is available on its own as the system command etex , but this is plain TeX (and produces .dvi ). In other TeX distributions, latex may invoke e-TeX rather than pdfTeX. In any case, the e-TeX extensions can be assumed to be available in LaTeX. lualatex If LaTeX is invoked via the system command lualatex , the LuaTeX engine is run (http://ctan.org/pkg/luatex). This program allows code written in the scripting language Lua (http://luatex.org) to interact with TeX’s typesetting. LuaTeX handles UTF-8 Unicode input natively, can handle OpenType and TrueType fonts, and produces a .pdf file by default. There is also dvilualatex to produce a .dvi file, but this is rarely used. xelatex If LaTeX is invoked with the system command xelatex , the XeTeX engine is run (http://tug.org/xetex). Like LuaTeX, XeTeX natively supports UTF-8 Unicode and TrueType and OpenType fonts, though the implementation is completely different, mainly using external libraries instead of internal code. XeTeX produces a .pdf file as output; it does not support DVI output. Internally, XeTeX creates an .xdv file, a variant of DVI, and translates that to PDF using the ( x ) dvipdfmx program, but this process is automatic. The .xdv file is only useful for debugging.

Other variants of LaTeX and TeX exist, e.g., to provide additional support for Japanese and other languages ([u]pTeX, http://ctan.org/pkg/ptex, http://ctan.org/pkg/uptex).

2.4 LaTeX command syntax

In the LaTeX input file, a command name starts with a backslash character, \ . The name itself then consists of either (a) a string of letters or (b) a single non-letter.

LaTeX commands names are case sensitive so that \pagebreak differs from \Pagebreak (the latter is not a standard command). Most commands are lowercase, but in any event you must enter all commands in the same case as they are defined.

A command may be followed by zero, one, or more arguments. These arguments may be either required or optional. Required arguments are contained in curly braces, {...} . Optional arguments are contained in square brackets, [...] . Generally, but not universally, if the command accepts an optional argument, it comes first, before any required arguments.

Inside of an optional argument, to use the character close square bracket ( ] ) hide it inside curly braces, as in \item[closing bracket {]}] . Similarly, if an optional argument comes last, with no required argument after it, then to make the first character of the following text be an open square bracket, hide it inside curly braces.

Some of LaTeX’s commands are a declaration. Such a command changes the value the meaning of some other command or parameter. For instance, the \mainmatter declaration changes the typesetting of page numbers from roman numerals to arabic (see \frontmatter & \mainmatter & \backmatter).

LaTeX has the convention that some commands have a * form that is related to the form without a * , such as \chapter and \chapter* . The exact difference in behavior varies from command to command.

This manual describes all accepted options and * -forms for the commands it covers (barring unintentional omissions, a.k.a. bugs).

2.5 Environment

Synopsis:

\begin{ environment name } ... \end{ environment name }

An area of LaTeX source, inside of which there is a distinct behavior. For instance, for poetry in LaTeX put the lines between \begin{verse} and \end{verse} .

\begin{verse} There once was a man from Nantucket \\ ... \end{verse}

See Environments for a list of environments. Particularly notable is that every LaTeX document must have a document environment, a \begin{document} ... \end{document} pair.

The environment name at the beginning must exactly match that at the end. This includes the case where environment name ends in a star ( * ); both the \begin and \end texts must include the star.

Environments may have arguments, including optional arguments. This example produces a table. The first argument is optional (and causes the table to be aligned on its top row) while the second argument is required (it specifies the formatting of columns).

\begin{tabular}[t]{r|l} ... rows of table ... \end{tabular}

2.6 CTAN: the Comprehensive TeX Archive Network

The Comprehensive TeX Archive Network, CTAN, is the TeX and LaTeX community’s repository of free material. It is a set of Internet sites around the world that offer material related to LaTeX for download. Visit CTAN on the web at https://ctan.org.

This material is organized into packages, discrete bundles that typically offer some coherent functionality and are maintained by one person or a small number of people. For instance, many publishers have a package that allows authors to format papers to that publisher’s specifications.

In addition to the massive holdings, the web site offers features such as search by name or by functionality.

CTAN is not a single site, but instead is a set of sites. One of the sites is the core. This site actively manages the material, for instance, by accepting uploads of new or updated packages. It is hosted by the German TeX group DANTE e.V. Other sites around the world help out by mirroring, that is, automatically syncing their collections with the core site and then in turn making their copies publicly available. This gives users close to their location better access and relieves the load on the core site. The list of mirrors is at https://ctan.org/mirrors.

3 Document classes

The document’s overall class is defined with this command, which is normally the first command in a LaTeX source file.

\documentclass[ options ]{ class }

The following document class names are built into LaTeX. (Many other document classes are available as separate packages; see Overview.)

article For a journal article, a presentation, and miscellaneous general use. book Full-length books, including chapters and possibly including front matter, such as a preface, and back matter, such as an appendix (see Front/back matter). letter Mail, optionally including mailing labels (see Letters). report For documents of length between an article and a book , such as technical reports or theses, which may contain several chapters. slides For slide presentations—rarely used today. In its place the beamer package is perhaps the most prevalent (see beamer template).

Standard options are described in the next section.

3.1 Document class options

You can specify global options or class options to the \documentclass command by enclosing them in square brackets. To specify more than one option , separate them with a comma.

\documentclass[ option1 , option2 ,...]{ class }

Here is the list of the standard class options.

All of the standard classes except slides accept the following options for selecting the typeface size (default is 10pt ):

10pt 11pt 12pt

All of the standard classes accept these options for selecting the paper size (these show height by width):

a4paper 210 by 297mm (about 8.25 by 11.75 inches) a5paper 148 by 210mm (about 5.8 by 8.3 inches) b5paper 176 by 250mm (about 6.9 by 9.8 inches) executivepaper 7.25 by 10.5 inches legalpaper 8.5 by 14 inches letterpaper 8.5 by 11 inches (the default)

When using one of the engines pdfLaTeX, LuaLaTeX, or XeLaTeX (see TeX engines), options other than letterpaper set the print area but you must also set the physical paper size. One way to do that is to put \pdfpagewidth=\paperwidth and \pdfpageheight=\paperheight in your document’s preamble.

The geometry package provides flexible ways of setting the print area and physical page size.

Miscellaneous other options:

draft final Mark ( draft ) or do not mark ( final ) overfull boxes with a black box in the margin; default is final . fleqn Put displayed formulas flush left; default is centered. landscape Selects landscape format; default is portrait. leqno Put equation numbers on the left side of equations; default is the right side. openbib Use “open” bibliography format. titlepage notitlepage Specifies whether there is a separate page for the title information and for the abstract also, if there is one. The default for the report class is titlepage , for the other classes it is notitlepage .

The following options are not available with the slides class.

onecolumn twocolumn Typeset in one or two columns; default is onecolumn . oneside twoside Selects one- or two-sided layout; default is oneside , except that in the book class the default is twoside . For one-sided printing, the text is centered on the page. For two-sided printing, the \evensidemargin ( \oddsidemargin ) parameter determines the distance on even (odd) numbered pages between the left side of the page and the text’s left margin, with \oddsidemargin being 40% of the difference between \paperwidth and \textwidth , and \evensidemargin is the remainder. openright openany Determines if a chapter should start on a right-hand page; default is openright for book , and openany for report .

The slides class offers the option clock for printing the time at the bottom of each note.

3.2 Additional packages

Load a package pkg , with the package options given in the comma-separated list options , as here.

\usepackage[ options ]{ pkg }.

To specify more than one package you can separate them with a comma, as in \usepackage{ pkg1 , pkg2 ,...} , or use multiple \usepackage commands.

Any options given in the \documentclass command that are unknown to the selected document class are passed on to the packages loaded with \usepackage .

3.3 Class and package construction

You can create new document classes and new packages. For instance, if your memos must satisfy some local requirements, such as a standard header for each page, then you could create a new class smcmemo.cls and begin your documents with \documentclass{smcmemo} .

What separates a package from a document class is that the commands in a package are useful across classes while those in a document class are specific to that class. Thus, a command to set page headers is for a package while a command to make the page headers say Memo from the SMC Math Department is for a class.

Inside of a class or package file you can use the at-sign @ as a character in command names without having to surround the code containing that command with \makeatletter and \makeatother . See \makeatletter & \makeatother. This allow you to create commands that users will not accidentally redefine. Another technique is to preface class- or package-specific commands with some string to prevent your class or package from interfering with others. For instance, the class smcmemo might have commands \smc@tolist , \smc@fromlist , etc.

3.3.1 Class and package structure

A class file or package file typically has four parts.

In the identification part, the file says that it is a LaTeX package or class and describes itself, using the \NeedsTeXFormat and \ProvidesClass or \ProvidesPackage commands. The preliminary declarations part declares some commands and can also load other files. Usually these commands will be those needed for the code used in the next part. For example, an smcmemo class might be called with an option to read in a file with a list of people for the to-head, as \documentclass[mathto]{smcmemo} , and therefore needs to define a command

ewcommand{\setto}[1]{\def\@tolist{#1}} used in that file. In the handle options part the class or package declares and processes its options. Class options allow a user to start their document as \documentclass[ option list ]{ class name } , to modify the behavior of the class. An example is when you declare \documentclass[11pt]{article} to set the default document font size. Finally, in the more declarations part the class or package usually does most of its work: declaring new variables, commands and fonts, and loading other files.

Here is a starting class file, which should be saved as stub.cls where LaTeX can find it, for example in the same directory as the .tex file.

\NeedsTeXFormat{LaTeX2e} \ProvidesClass{stub}[2017/07/06 stub to start building classes from] \DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}} \ProcessOptions\relax \LoadClass{article}

It identifies itself, handles the class options via the default of passing them all to the article class, and then loads the article class to provide the basis for this class’s code.

For more, see the official guide for class and package writers, the Class Guide, at http://www.latex-project.org/help/documentation/clsguide.pdf (much of the descriptions here derive from this document), or the tutorial https://www.tug.org/TUGboat/tb26-3/tb84heff.pdf.

3.3.2 Class and package commands

These are the commands designed to help writers of classes or packages.

\AtBeginDvi{specials} Save in a box register things that are written to the .dvi file at the beginning of the shipout of the first page of the document. \AtEndOfClass{ code } \AtEndOfPackage{ code } Hook to insert code to be executed when LaTeX finishes processing the current class or package. You can use these hooks multiple times; the code will be executed in the order that you called it. See also \AtBeginDocument. \CheckCommand{ cmd }[ num ][ default ]{ definition } \CheckCommand*{ cmd }[ num ][ default ]{ definition } Like

ewcommand (see

ewcommand & \renewcommand) but does not define cmd ; instead it checks that the current definition of cmd is exactly as given by definition and is or is not long as expected. A long command is a command that accepts \par within an argument. The cmd command is expected to be long with the unstarred version of \CheckCommand . Raises an error when the check fails. This allows you to check before you start redefining cmd yourself that no other package has already redefined this command. \ClassError{ class name }{ error text }{ help text } \PackageError{ package name }{ error text }{ help text } \ClassWarning{ class name }{ warning text } \PackageWarning{ package name }{ warning text } \ClassWarningNoLine{ class name }{ warning text } \PackageWarningNoLine{ package name }{ warning text } \ClassInfo{ class name }{ info text } \PackageInfo{ package name }{ info text } \ClassInfoNoLine{ class name }{ info text } \PackageInfoNoLine{ package name }{ info text } Produce an error message, or warning or informational messages. For \ClassError and \PackageError the message is error text , followed by TeX’s ? error prompt. If the user then asks for help by typing h , they see the help text . The four warning commands are similar except that they write warning text on the screen with no error prompt. The four info commands write info text only in the transcript file. The NoLine versions do not show the number of the line generating the message, while the other versions do show that number. To format the messages, including the help text : use \protect to stop a command from expanding, get a line break with \MessageBreak , and get a space with \space when a space character does not allow it, like after a command. Note that LaTeX appends a period to the messages. \CurrentOption Expands to the name of the currently-being-processed option. Can only be used within the code argument of either \DeclareOption or \DeclareOption* . \DeclareOption{ option }{ code } \DeclareOption*{ code } Make an option available to a user to invoke in their \documentclass command. For example, the smcmemo class could have an option \documentclass[logo]{smcmemo} allowing users to put the institutional logo on the first page. The class file must contain \DeclareOption{logo}{ code } (and later, \ProcessOptions ). If you request an option that has not been declared, by default this will produce a warning like Unused global option(s): [badoption]. Change this behaviour with the starred version \DeclareOption*{ code } . For example, many classes extend an existing class, using a declaration such as \LoadClass{article} , and for passing extra options to the underlying class use code such as this. \DeclareOption*{% \PassOptionsToClass{\CurrentOption}{article}% } Another example is that the class smcmemo may allow users to keep lists of memo recipients in external files. Then the user could invoke \documentclass[math]{smcmemo} and it will read the file math.memo . This code handles the file if it exists and otherwise passes the option to the article class. \DeclareOption*{\InputIfFileExists{\CurrentOption.memo}{}{% \PassOptionsToClass{\CurrentOption}{article}}} \DeclareRobustCommand{ cmd }[ num ][ default ]{ definition } \DeclareRobustCommand*{ cmd }[ num ][ default ]{ definition } Like

ewcommand and

ewcommand* (see

ewcommand & \renewcommand) but these declare a robust command, even if some code within the definition is fragile. (For a discussion of robust and fragile commands see \protect.) Use this command to define new robust commands or to redefine existing commands and make them robust. Unlike

ewcommand these do not give an error if macro cmd already exists; instead, a log message is put into the transcript file if a command is redefined. Commands defined this way are a bit less efficient than those defined using

ewcommand so unless the command’s data is fragile and the command is used within a moving argument, use

ewcommand . The etoolbox package offers the commands

ewrobustcmd ,

ewrobustcmd* , as well as the commands \renewrobustcmd , \renewrobustcmd* , and the commands \providerobustcmd , and \providerobustcmd* . These are similar to

ewcommand ,

ewcommand* , \renewcommand , \renewcommand* , \providecommand , and \providecommand* , but define a robust cmd with two advantages as compared to \DeclareRobustCommand : They use the low-level e-TeX protection mechanism rather than the higher level LaTeX \protect mechanism, so they do not incur the slight loss of performance mentioned above, and They make the same distinction between

ew… , \renew… , and \provide… , as the standard commands, so they do not just make a log message when you redefine cmd that already exists, in that case you need to use either \renew… or \provide… or you get an error. \IfFileExists{ file name }{ true code }{ false code } \InputIfFileExists{ file name }{ true code }{ false code } Execute true code if LaTeX finds the file file name or false code otherwise. In the first case it executing true code and then inputs the file. Thus the command \IfFileExists{img.pdf}{% \includegraphics{img.pdf}}{\typeout{!! img.pdf not found} will include the graphic img.pdf if it is found and otherwise give a warning. This command looks for the file in all search paths that LaTeX uses, not only in the current directory. To look only in the current directory do something like \IfFileExists{./filename}{ true code }{ false code } . If you ask for a filename without a .tex extension then LaTeX will first look for the file by appending the .tex ; for more on how LaTeX handles file extensions see \input. \LoadClass[ options list ]{ class name }[ release date ] \LoadClassWithOptions{ class name }[ release date ] Load a class, as with \documentclass[ options list ]{ class name }[ release info ] . An example is \LoadClass[twoside]{article} . The options list , if present, is a comma-separated list. The release date is optional. If present it must have the form YYYY/MM/DD . If you request a release date and the date of the package installed on your system is earlier, then you get a warning on the screen and in the log like this. You have requested, on input line 4, version `2038/01/19' of document class article, but only version `2014/09/29 v1.4h Standard LaTeX document class' is available. The command version \LoadClassWithOptions uses the list of options for the current class. This means it ignores any options passed to it via \PassOptionsToClass . This is a convenience command that lets you build classes on existing ones, such as the standard article class, without having to track which options were passed. \ExecuteOptions{ options-list } For each option option in the options-list , in order, this command executes the command \ds@ option . If this command is not defined then that option is silently ignored. It can be used to provide a default option list before \ProcessOptions . For example, if in a class file you want the default to be 11pt fonts then you could specify \ExecuteOptions{11pt}\ProcessOptions\relax . \NeedsTeXFormat{ format }[ format date ] Specifies the format that this class must be run under. Often issued as the first line of a class file, and most often used as: \NeedsTeXFormat{LaTeX2e} . When a document using that class is processed, the format name given here must match the format that is actually being run (including that the format string is case sensitive). If it does not match then execution stops with an error like ‘ This file needs format `LaTeX2e' but this is `xxx'. ’ To specify a version of the format that you know to have certain features, include the optional format date on which those features were implemented. If present it must be in the form YYYY/MM/DD . If the format version installed on your system is earlier than format date then you get a warning like this. You have requested release `2038/01/20' of LaTeX, but only release `2016/02/01' is available. \OptionNotUsed Adds the current option to the list of unused options. Can only be used within the code argument of either \DeclareOption or \DeclareOption* . \PassOptionsToClass{ option list }{ class name } \PassOptionsToPackage{ option list }{ package name } Adds the options in the comma-separated list option list to the options used by any future \RequirePackage or \usepackage command for package package name or the class class name . The reason for these commands is: you may load a package any number of times with no options but if you want options then you may only supply them when you first load the package. Loading a package with options more than once will get you an error like Option clash for package foo. (LaTeX throws an error even if there is no conflict between the options.) If your own code is bringing in a package twice then you can collapse that to once, for example replacing the two \RequirePackage[landscape]{geometry} and \RequirePackage[margins=1in]{geometry} with the single command \RequirePackage[landscape,margins=1in]{geometry} . However, imagine that you are loading firstpkg and inside that package it loads secondpkg , and you need the second package to be loaded with option draft . Then before doing the first package you must queue up the options for the second package, like this. \PassOptionsToPackage{draft}{secondpkg} \RequirePackage{firstpkg} (If firstpkg.sty loads an option in conflict with what you want then you may have to alter its source.) These commands are useful for general users as well as class and package writers. For instance, suppose a user wants to load the graphicx package with the option draft and also wants to use a class foo that loads the graphicx package, but without that option. The user could start their LaTeX file with \PassOptionsToPackage{draft}{graphicx}\documentclass{foo} . \ProcessOptions \ProcessOptions* \@options Execute the code for each option that the user has invoked. Include it in the class file as \ProcessOptions\relax (because of the existence of the starred command). Options come in two types. Local options have been specified for this particular package in the options argument of \PassOptionsToPackage{ options } , \usepackage[ options ] , or \RequirePackage[ options ] . Global options are those given by the class user in \documentclass[ options ] (If an option is specified both locally and globally then it is local.) When \ProcessOptions is called for a package pkg.sty , the following happens: For each option option so far declared with \DeclareOption , it looks to see if that option is either a global or a local option for pkg . If so then it executes the declared code. This is done in the order in which these options were given in pkg.sty . For each remaining local option, it executes the command \ds@ option if it has been defined somewhere (other than by a \DeclareOption ); otherwise, it executes the default option code given in \DeclareOption* . If no default option code has been declared then it gives an error message. This is done in the order in which these options were specified. When \ProcessOptions is called for a class it works in the same way except that all options are local, and the default code for \DeclareOption* is \OptionNotUsed rather than an error. The starred version \ProcessOptions* executes the options in the order specified in the calling commands, rather than in the order of declaration in the class or package. For a package this means that the global options are processed first. \ProvidesClass{ class name }[ release date brief additional information ] \ProvidesClass{ class name }[ release date ] \ProvidesPackage{ package name }[ release date brief additional information ] \ProvidesPackage{ package name }[ release date ] Identifies the class or package, printing a message to the screen and the log file. When you load a class or package, for example with \documentclass{smcmemo} or \usepackage{test} , LaTeX inputs a file. If the name of the file does not match the class or package name declared in it then you get a warning. Thus, if you invoke \documentclass{smcmemo} , and the file smcmemo.cls has the statement \ProvidesClass{xxx} then you get a warning like You have requested document class `smcmemo', but the document class provides 'xxx'. This warning does not prevent LaTeX from processing the rest of the class file normally. If you include the optional argument then you must include a date, before any spaces, of the form YYYY/MM/DD . The rest of the optional argument is free-form, although it traditionally identifies the class, and is written to the screen during compilation and to the log file. Thus, if your file smcmemo.cls contains the line \ProvidesClass{smcmemo}[2008/06/01 v1.0 SMC memo class] and your document’s first line is \documentclass{smcmemo} then you will see Document Class: smcmemo 2008/06/01 v1.0 SMC memo class . The date in the optional argument allows class and package users to ask to be warned if the version of the class or package is earlier than release date . For instance, a user could enter \documentclass{smcmemo}[2018/10/12] or \usepackage{foo}[[2017/07/07]] to require a class or package with certain features by specifying that it must be released no earlier than the given date. (Although, in practice package users only rarely include a date, and class users almost never do.) \ProvidesFile{ file name }[ additional information ] Declare a file other than the main class and package files, such as configuration files or font definition files. Put this command in that file and you get in the log a string like File: test.config 2017/10/12 config file for test.cls for file name equal to ‘ test.config ’ and additional information equal to ‘ 2017/10/12 config file for test.cls ’. \RequirePackage[ option list ]{ package name }[ release date ] \RequirePackageWithOptions{ package name }[ release date ] Load a package, like the command \usepackage (see Additional packages). The LaTeX development team strongly recommends use of these commands over Plain TeX’s \input ; see the Class Guide. An example is \RequirePackage[landscape,margin=1in]{geometry} . The option list , if present, is a comma-separated list. The release date , if present, must have the form YYYY/MM/DD . If the release date of the package as installed on your system is earlier than release date then you get a warning like You have requested, on input line 9, version `2017/07/03' of package jhtest, but only version `2000/01/01' is available . The \RequirePackageWithOptions version uses the list of options for the current class. This means it ignores any options passed to it via \PassOptionsToClass . This is a convenience command to allow easily building classes on existing ones without having to track which options were passed. The difference between \usepackage and \RequirePackage is small. The \usepackage command is intended for the document file while \RequirePackage is intended for package and class files. Thus, using \usepackage before the \documentclass command causes LaTeX to give error like \usepackage before \documentclass , but you can use \RequirePackage there.

4 Fonts

Two important aspects of selecting a font are specifying a size and a style. The LaTeX commands for doing this are described here.

4.1 Font styles

The following type style commands are supported by LaTeX.

In the table below the listed commands, the \text... commands, is used with an argument, as in \textit{ text } . This is the preferred form. But shown after it, in parenthesis, is the corresponding declaration form, which is sometimes useful. This form takes no arguments, as in {\itshape text } . The scope of the declaration form lasts until the next type style command or the end of the current group. In addition, each has an environment form such as \begin{itshape}...\end{itshape} .

These commands, in both the argument form and the declaration form, are cumulative; for instance you can get bold sans serif by saying either of \sffamily\bfseries or \bfseries\sffamily .

One advantage of these commands is that they automatically insert italic corrections if needed (see \/). Specifically, they insert the italic correction unless the following character is in the list

ocorrlist , which by default consists of a period and a comma. To suppress the automatic insertion of italic correction, use

ocorr at the start or end of the command argument, such as \textit{

ocorr text} or \textsc{text

ocorr} .

\textrm (\rmfamily) Roman. \textit (\itshape) Italics. \textmd (\mdseries) Medium weight (default). \textbf (\bfseries) Boldface. \textup (\upshape) Upright (default). \textsl (\slshape) Slanted. \textsf (\sffamily) Sans serif. \textsc (\scshape) Small caps. \texttt (\ttfamily) Typewriter. \textnormal (

ormalfont) Main document font.

Although it also changes fonts, the \emph{ text } command is semantic, for text to be emphasized, and should not be used as a substitute for \textit . For example, \emph{ start text \emph{ middle text } end text } will result in the start text and end text in italics, but middle text will be in roman.

LaTeX also provides the following commands, which unconditionally switch to the given style, that is, are not cumulative. They are used as declarations: {\ cmd ...} instead of \ cmd {...} .

(The unconditional commands below are an older version of font switching. The earlier commands are an improvement in most circumstances. But sometimes an unconditional font switch is precisely what you want.)

\bf Switch to bold face. \cal Switch to calligraphic letters for math. \it Italics. \rm Roman. \sc Small caps. \sf Sans serif. \sl Slanted (oblique). \tt Typewriter (monospace, fixed-width).

The \em command is the unconditional version of \emph .

The following commands are for use in math mode. They are not cumulative, so \mathbf{\mathit{ symbol }} does not create a boldface and italic symbol ; instead, it will just be in italics. This is because typically math symbols need consistent typographic treatment, regardless of the surrounding environment.

\mathrm Roman, for use in math mode. \mathbf Boldface, for use in math mode. \mathsf Sans serif, for use in math mode. \mathtt Typewriter, for use in math mode. \mathit (\mit) Italics, for use in math mode. \mathnormal For use in math mode, e.g., inside another type style declaration. \mathcal Calligraphic letters, for use in math mode.

In addition, the command \mathversion{bold} can be used for switching to bold letters and symbols in formulas. \mathversion{normal} restores the default.

Finally, the command \oldstylenums{ numerals } will typeset so-called “old-style” numerals, which have differing heights and depths (and sometimes widths) from the standard “lining” numerals, which all have the same height as uppercase letters. LaTeX’s default fonts support this, and will respect \textbf (but not other styles; there are no italic old-style numerals in Computer Modern). Many other fonts have old-style numerals also; sometimes the textcomp package must be loaded, and sometimes package options are provided to make them the default. FAQ entry: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=osf.

4.2 Font sizes

The following standard type size commands are supported by LaTeX. The table shows the command name and the corresponding actual font size used (in points) with the ‘ 10pt ’, ‘ 11pt ’, and ‘ 12pt ’ document size options, respectively (see Document class options).

Command 10pt 11pt 12pt \tiny 5 6 6 \scriptsize 7 8 8 \footnotesize 8 9 10 \small 9 10 10.95

ormalsize (default) 10 10.95 12 \large 12 12 14.4 \Large 14.4 14.4 17.28 \LARGE 17.28 17.28 20.74 \huge 20.74 20.74 24.88 \Huge 24.88 24.88 24.88

The commands are listed here in declaration forms. You use them by declaring them, as with this example.

\begin{quotation} \small The Tao that can be named is not the eternal Tao. \end{quotation}

The scope of the \small lasts until the end of the quotation environment. It would also end at the next type style command or the end of the current group, so you could enclose it in extra curly braces {\small We are here, we are here, we are here!} . You can instead use the environment form of these commands; for instance, \begin{tiny}...\end{tiny} .

4.3 Low-level font commands

These commands are primarily intended for writers of macros and packages. The commands listed here are only a subset of the available ones.

\fontencoding{ encoding } Select the font encoding, the encoding of the output font. There are a large number of valid encodings. The most common are OT1 , Knuth’s original encoding for Computer Modern (the default), and T1 , also known as the Cork encoding, which has support for the accented characters used by the most widespread European languages (German, French, Italian, Polish and others), which allows TeX to hyphenate words containing accented letters. For more, see https://ctan.org/pkg/encguide. \fontfamily{ family } Select the font family. The web page http://www.tug.dk/FontCatalogue/ provides one way to browse through many of the fonts easily used with LaTeX. Here are examples of some common families. pag Avant Garde fvs Bitstream Vera Sans pbk Bookman bch Charter ccr Computer Concrete cmr Computer Modern cmss Computer Modern Sans Serif cmtt Computer Modern Typewriter pcr Courier phv Helvetica fi4 Inconsolata lmr Latin Modern lmss Latin Modern Sans lmtt Latin Modern Typewriter pnc New Century Schoolbook ppl Palatino ptm Times uncl Uncial put Utopia pzc Zapf Chancery \fontseries{ series } Select the font series. A series combines a weight and a width. Typically, a font supports only a few of the possible combinations. Some common combined series values include: m Medium (normal) b Bold c Condensed bc Bold condensed bx Bold extended The possible values for weight, individually, are: ul Ultra light el Extra light l Light sl Semi light m Medium (normal) sb Semi bold b Bold eb Extra bold ub Ultra bold The possible values for width, individually, are (the meaning and relationship of these terms varies with individual typefaces): uc Ultra condensed ec Extra condensed c Condensed sc Semi condensed m Medium sx Semi expanded x Expanded ex Extra expanded ux Ultra expanded When forming the series string from the weight and width, drop the m that stands for medium weight or medium width, unless both weight and width are m , in which case use just one (‘ m ’). \fontshape{ shape } Select font shape. Valid shapes are: n Upright (normal) it Italic sl Slanted (oblique) sc Small caps ui Upright italics ol Outline The two last shapes are not available for most font families, and small caps are often missing as well. \fontsize{ size }{ skip } Set the font size and the line spacing. The unit of both parameters defaults to points ( pt ). The line spacing is the nominal vertical space between lines, baseline to baseline. It is stored in the parameter \baselineskip . The default \baselineskip for the Computer Modern typeface is 1.2 times the \fontsize . Changing \baselineskip directly is inadvisable since its value is reset every time a size change happens; see \baselinestretch , next. \baselinestretch LaTeX multiplies the line spacing by the value of the \baselinestretch parameter; the default factor is 1. A change takes effect when \selectfont (see below) is called. You can make a line skip change happen for the entire document, for instance doubling it, by doing \renewcommand{\baselinestretch}{2.0} in the preamble. However, the best way to double-space a document is to use the setspace package. In addition to offering a number of spacing options, this package keeps the line spacing single-spaced in places where that is typically desirable, such as footnotes and figure captions. See the package documentation. \linespread{ factor } Equivalent to \renewcommand{\baselinestretch}{ factor } , and therefore must be followed by \selectfont to have any effect. Best specified in the preamble, or use the setspace package, as just described. \selectfont The effects of the font commands described above do not happen until \selectfont is called, as in \fontfamily{ familyname }\selectfont . It is often useful to put this in a macro:



ewcommand*{\myfont}{\fontfamily{ familyname }\selectfont}

(see

ewcommand & \renewcommand). \usefont{ enc }{ family }{ series }{ shape } The same as invoking \fontencoding , \fontfamily , \fontseries and \fontshape with the given parameters, followed by \selectfont . For example: \usefont{ot1}{cmr}{m}{n}

5 Layout

Commands for controlling the general page layout.

5.1 \onecolumn

Synopsis:

\onecolumn

Start a new page and produce single-column output. If the document is given the class option onecolumn then this is the default behavior (see Document class options). This command is fragile (see \protect).

5.2 \twocolumn

Synopses:

\twocolumn \twocolumn[ prelim one column text ]

Start a new page and produce two-column output. If the document is given the class option twocolumn then this is the default (see Document class options). This command is fragile (see \protect).

If the optional prelim one column text argument is present, it is typeset in one-column mode before the two-column typesetting starts.

These parameters control typesetting in two-column output:

\columnsep The distance between columns. The default is 35pt. Change it with a command such as \setlength{\columnsep}{40pt} You must change it before the two column environment starts; in the preamble is a good place. \columnseprule The width of the rule between columns. The rule appears halfway between the two columns. The default is 0pt, meaning that there is no rule. Change it with a command such as \setlength{\columnseprule}{0.4pt} , before the two-column environment starts. \columnwidth The width of a single column. In one-column mode this is equal to \textwidth . In two-column mode by default LaTeX sets the width of each of the two columns to be half of \textwidth minus \columnsep .

In a two-column document, the starred environments table* and figure* are two columns wide, whereas the unstarred environments table and figure take up only one column (see figure and see table). LaTeX places starred floats at the top of a page. The following parameters control float behavior of two-column output.

\dbltopfraction The maximum fraction at the top of a two-column page that may be occupied by two-column wide floats. The default is 0.7, meaning that the height of a table* or figure* environment must not exceed 0.7\textheight . If the height of your starred float environment exceeds this then you can take one of the following actions to prevent it from floating all the way to the back of the document: Use the [tp] location specifier to tell LaTeX to try to put the bulky float on a page by itself, as well as at the top of a page.

location specifier to tell LaTeX to try to put the bulky float on a page by itself, as well as at the top of a page. Use the [t!] location specifier to override the effect of \dbltopfraction for this particular float.

location specifier to override the effect of for this particular float. Increase the value of \dbltopfraction to a suitably large number, to avoid going to float pages so soon. You can redefine it, as with \renewcommand{\dbltopfraction}{0.9} . \dblfloatpagefraction For a float page of two-column wide floats, this is the minimum fraction that must be occupied by floats, limiting the amount of blank space. LaTeX’s default is 0.5 . Change it with \renewcommand . \dblfloatsep On a float page of two-column wide floats, this length is the distance between floats, at both the top and bottom of the page. The default is 12pt plus2pt minus2pt for a document set at 10pt or 11pt , and 14pt plus2pt minus4pt for a document set at 12pt . \dbltextfloatsep This length is the distance between a multi-column float at the top or bottom of a page and the main text. The default is 20pt plus2pt minus4pt . \dbltopnumber On a float page of two-column wide floats, this counter gives the maximum number of floats allowed at the top of the page. The LaTeX default is 2 .

This example uses \twocolumn ’s optional argument of to create a title that spans the two-column article:

\documentclass[twocolumn]{article}

ewcommand{\authormark}[1]{\textsuperscript{#1}} \begin{document} \twocolumn[{% inside this optional argument goes one-column text \centering \LARGE The Title \\[1.5em] \large Author One\authormark{1}, Author Two\authormark{2}, Author Three\authormark{1} \\[1em]

ormalsize \begin{tabular}{p{.2\textwidth}@{\hspace{2em}}p{.2\textwidth}} \authormark{1}Department one &\authormark{2}Department two \\ School one &School two \end{tabular}\\[3em] % space below title part }] Two column text here.

5.3 \flushbottom

Make all pages in the documents after this declaration have the same height, by stretching the vertical space where necessary to fill out the page. This is most often used when making two-sided documents since the differences in facing pages can be glaring.

If TeX cannot satisfactorily stretch the vertical space in a page then you get a message like ‘ Underfull \vbox (badness 10000) has occurred while \output is active ’. If you get that, one option is to change to \raggedbottom (see \raggedbottom). Alternatively, you can adjust the textheight to make compatible pages, or you can add some vertical stretch glue between lines or between paragraphs, as in \setlength{\parskip}{0ex plus0.1ex} . Your last option is to, in a final editing stage, adjust the height of individual pages (see \enlargethispage).

The \flushbottom state is the default only if you select the twoside document class option (see Document class options).

5.4 \raggedbottom

Make all later pages the natural height of the material on that page; no rubber vertical lengths will be stretched. Thus, in a two-sided document the facing pages may be different heights. This command can go at any point in the document body. See \flushbottom.

This is the default unless you select the twoside document class option (see Document class options).

5.5 Page layout parameters

\columnsep \columnseprule \columnwidth The distance between the two columns, the width of a rule between the columns, and the width of the columns, when the document class option twocolumn is in effect (see Document class options). See \twocolumn. \headheight Height of the box that contains the running head. The default in the article , report , and book classes is ‘ 12pt ’, at all type sizes. \headsep Vertical distance between the bottom of the header line and the top of the main text. The default in the article and report classes is ‘ 25pt ’. In the book class the default is: if the document is set at 10pt then it is ‘ 0.25in ’, and at 11pt and 12pt it is ‘ 0.275in ’. \footskip Distance from the baseline of the last line of text to the baseline of the page footer. The default in the article and report classes is ‘ 30pt ’. In the book class the default is: when the type size is 10pt the default is ‘ 0.35in ’, while at 11pt it is ‘ 0.38in ’, and at 12pt it is ‘ 30pt ’. \linewidth Width of the current line, decreased for each nested list (see list). That is, the nominal value for \linewidth is to equal \textwidth but for each nested list the \linewidth is decreased by the sum of that list’s \leftmargin and \rightmargin (see itemize). \marginparpush \marginsep \marginparwidth The minimum vertical space between two marginal notes, the horizontal space between the text body and the marginal notes, and the horizontal width of the notes. Normally marginal notes appear on the outside of the page, but the declaration \reversemarginpar changes that (and

ormalmarginpar changes it back). The defaults for \marginparpush in both book and article classes are: ‘ 7pt ’ if the document is set at 12pt, and ‘ 5pt ’ if the document is set at 11pt or 10pt. For \marginsep , in article class the default is ‘ 10pt ’ except if the document is set at 10pt and in two-column mode where the default is ‘ 11pt ’. For \marginsep in book class the default is ‘ 10pt ’ in two-column mode and ‘ 7pt ’ in one-column mode. For \marginparwidth in both book and article classes, in two-column mode the default is 60% of \paperwidth - \textwidth , while in one-column mode it is 50% of that distance. \oddsidemargin \evensidemargin The \oddsidemargin is the extra distance between the left side of the page and the text’s left margin, on odd-numbered pages when the document class option twoside is chosen and on all pages when oneside is in effect. When twoside is in effect, on even-numbered pages the extra distance on the left is evensidemargin . LaTeX’s default is that \oddsidemargin is 40% of the difference between \paperwidth and \textwidth , and \evensidemargin is the remainder. \paperheight The height of the paper, as distinct from the height of the print area. Normally set with a document class option, as in \documentclass[a4paper]{article} (see Document class options). \paperwidth The width of the paper, as distinct from the width of the print area. Normally set with a document class option, as in \documentclass[a4paper]{article} (see Document class options). \textheight The normal vertical height of the page body. If the document is set at a nominal type size of 10pt then for an article or report the default is ‘ 43\baselineskip ’, while for a book it is ‘ 41\baselineskip ’. At a type size of 11pt the default is ‘ 38\baselineskip ’ for all document classes. At 12pt it is ‘ 36\baselineskip ’ for all classes. \textwidth The full horizontal width of the entire page body. For an article or report document, the default is ‘ 345pt ’ when the chosen type size is 10pt, the default is ‘ 360pt ’ at 11pt, and it is ‘ 390pt ’ at 12pt. For a book document, the default is ‘ 4.5in ’ at a type size of 10pt, and ‘ 5in ’ at 11pt or 12pt. In multi-column output, \textwidth remains the width of the entire page body, while \columnwidth is the width of one column (see \twocolumn). In lists (see list), \textwidth remains the width of the entire page body (and \columnwidth the width of the entire column), while \linewidth may decrease for nested lists. Inside a minipage (see minipage) or \parbox (see \parbox), all the width-related parameters are set to the specified width, and revert to their normal values at the end of the minipage or \parbox . \hsize This entry is included for completeness: \hsize is the TeX primitive parameter used when text is broken into lines. It should not be used in normal LaTeX documents. \topmargin Space between the top of the TeX page (one inch from the top of the paper, by default) and the top of the header. The value is computed based on many other parameters: \paperheight - 2in - \headheight - \headsep - \textheight - \footskip , and then divided by two. \topskip Minimum distance between the top of the page body and the baseline of the first line of text. For the standard classes, the default is the same as the font size, e.g., ‘ 10pt ’ at a type size of 10pt.

5.6 Floats

Some typographic elements, such as figures and tables, cannot be broken across pages. They must be typeset outside of the normal flow of text, for instance floating to the top of a later page.

LaTeX can have a number of different classes of floating material. The default is the two classes, figure (see figure) and table (see table), but you can create a new class with the package float .

Within any one float class LaTeX always respects the order, so that the first figure in a document source must be typeset before the second figure. However, LaTeX may mix the classes, so it can happen that while the first table appears in the source before the first figure, it appears in the output after it.

The placement of floats is subject to parameters, given below, that limit the number of floats that can appear at the top of a page, and the bottom, etc. If so many floats are queued that the limits prevent them all from fitting on a page then LaTeX places what it can and defers the rest to the next page. In this way, floats may end up being typeset far from their place in the source. In particular, a float that is big may migrate to the end of the document. In which event, because all floats in a class must appear in sequential order, every following float in that class also appears at the end.

In addition to changing the parameters, for each float you can tweak where the float placement algorithm tries to place it by using its placement argument. The possible values are a sequence of the letters below. The default for both figure and table , in both article and book classes, is tbp .

t (Top)—at the top of a text page. b (Bottom)—at the bottom of a text page. (However, b is not allowed for full-width floats ( figure* ) with double-column output. To ameliorate this, use the stfloats or dblfloatfix package, but see the discussion at caveats in the FAQ: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=2colfloat. h (Here)—at the position in the text where the figure environment appears. However, h is not allowed by itself; t is automatically added. To absolutely force a float to appear “here”, you can \usepackage{float} and use the H specifier which it defines. For further discussion, see the FAQ entry at http://www.tex.ac.uk/cgi-bin/texfaq2html?label=figurehere. p (Page of floats)—on a separate float page, which is a page containing no text, only floats. ! Used in addition to one of the above; for this float only, LaTeX ignores the restrictions on both the number of floats that can appear and the relative amounts of float and non-float text on the page. The ! specifier does not mean “put the float here”; see above.

Note: the order in which letters appear in the placement argument does not change the order in which LaTeX tries to place the float; for instance, btp has the same effect as tbp . All that placement does is that if a letter is not present then the algorithm does not try that location. Thus, LaTeX’s default of tbp is to try every location except placing the float where it occurs in the source.

To prevent LaTeX from moving floats to the end of the document or a chapter you can use a \clearpage command to start a new page and insert all pending floats. If a pagebreak is undesirable then you can use the afterpage package and issue \afterpage{\clearpage} . This will wait until the current page is finished and then flush all outstanding floats.

LaTeX can typeset a float before where it appears in the source (although on the same output page) if there is a t specifier in the placement parameter. If this is not desired, and deleting the t is not acceptable as it keeps the float from being placed at the top of the next page, then you can prevent it by either using the flafter package or using the command \suppressfloats[t] , which causes floats for the top position on this page to moved to the next page.

Parameters relating to fractions of pages occupied by float and non-float text (change them with \renewcommand{ parameter }{ decimal between 0 and 1 } ):

\bottomfraction The maximum fraction of the page allowed to be occupied by floats at the bottom; default ‘ .3 ’. \floatpagefraction The minimum fraction of a float page that must be occupied by floats; default ‘ .5 ’. \textfraction Minimum fraction of a page that must be text; if floats take up too much space to preserve this much text, floats will be moved to a different page. The default is ‘ .2 ’. \topfraction Maximum fraction at the top of a page that may be occupied before floats; default ‘ .7 ’.

Parameters relating to vertical space around floats (change them with a command of the form \setlength{ parameter }{ length expression } ):

\floatsep Space between floats at the top or bottom of a page; default ‘ 12pt plus2pt minus2pt ’. \intextsep Space above and below a float in the middle of the main text; default ‘ 12pt plus2pt minus2pt ’ for 10 point and 11 point documents, and ‘ 14pt plus4pt minus4pt ’ for 12 point documents. \textfloatsep Space between the last (first) float at the top (bottom) of a page; default ‘ 20pt plus2pt minus4pt ’.

Counters relating to the number of floats on a page (change them with a command of the form \setcounter{ ctrname }{ natural number } ):

bottomnumber Maximum number of floats that can appear at the bottom of a text page; default 1. dbltopnumber Maximum number of full-sized floats that can appear at the top of a two-column page; default 2. topnumber Maximum number of floats that can appear at the top of a text page; default 2. totalnumber Maximum number of floats that can appear on a text page; default 3.

The principal TeX FAQ entry relating to floats http://www.tex.ac.uk/cgi-bin/texfaq2html?label=floats contains suggestions for relaxing LaTeX’s default parameters to reduce the problem of floats being pushed to the end. A full explanation of the float placement algorithm is in Frank Mittelbach’s article “How to influence the position of float environments like figure and table in LaTeX?” (http://latex-project.org/papers/tb111mitt-float.pdf).

6 Sectioning

Structure your text into divisions: parts, chapters, sections, etc. All sectioning commands have the same form, one of:

sectioning-command { title } sectioning-command *{ title } sectioning-command [ toc-title ]{ title }

For instance, declare the start of a subsection as with \subsection{Motivation} .

The table has each sectioning-command in LaTeX. All are available in all of LaTeX’s standard document classes book , report , and article , except that \chapter is not available in article .

Sectioning unit Command Level Part \part -1 ( book , report ), 0 ( article ) Chapter \chapter 0 Section \section 1 Subsection \subsection 2 Subsubsection \subsubsection 3 Paragraph \paragraph 4 Subparagraph \subparagraph 5

All these commands have a * -form that prints title as usual but is not numbered and does not make an entry in the table of contents. An example of using this is for an appendix in an article . The input \appendix\section{Appendix} gives the output ‘ A Appendix ’ (see \appendix). You can lose the numbering ‘ A ’ by instead entering \section*{Appendix} (articles often omit a table of contents and have simple page headers so the other differences from the \section command may not matter).

The section title title provides the heading in the main text, but it may also appear in the table of contents and in the running head or foot (see Page styles). You may not want the same text in these places as in the main text. All of these commands have an optional argument toc-title for these other places.

The level number in the table above determines which sectional units are numbered, and which appear in the table of contents. If the sectioning command’s level is less than or equal to the value of the counter secnumdepth then the titles for this sectioning command will be numbered (see Sectioning/secnumdepth). And, if level is less than or equal to the value of the counter tocdepth then the table of contents will have an entry for this sectioning unit (see Sectioning/tocdepth).

LaTeX expects that before you have a \subsection you will have a \section and, in a book, that before a \section you will have a \chapter . Otherwise you can get a something like a subsection numbered ‘ 3.0.1 ’.

Two counters relate to the appearance of sectioning commands.

secnumdepth Controls which sectioning commands are numbered. Suppress numbering of sectioning at any depth greater than level \setcounter{secnumdepth}{ level } (see \setcounter). See the above table for the level numbers. For instance, if the secnumdepth is 1 in an article then a \section{Introduction} command will produce output like ‘ 1 Introduction ’ while \subsection{Discussion} will produce output like ‘ Discussion ’, without the number. LaTeX’s default secnumdepth is 3 in article class and 2 in the book and report classes. tocdepth Controls which sectioning units are listed in the table of contents. The setting \setcounter{tocdepth}{ level } makes the sectioning units at level be the smallest ones listed (see \setcounter). See the above table for the level numbers. For instance, if tocdepth is 1 then the table of contents will list sections but not subsections. LaTeX’s default secnumdepth is 3 in article class and 2 in the book and report classes.

6.1 \part

Synopsis, one of:

\part{ title } \part*{ title } \part[ toc-title ]{ title }

Start a document part. The standard LaTeX classes book , report , and article , all have this command.

This produces a document part, in a book.

\part{VOLUME I \\ PERSONAL MEMOIRS OF U.\ S.\ GRANT} \chapter{ANCESTRY--BIRTH--BOYHOOD.} My family is American, and has been for generations, in all its branches, direct and collateral.

In each standard class the \part command outputs a part number such as ‘ Part I ’, alone on its line, in boldface, and in large type. Then LaTeX outputs title , also alone on its line, in bold and in even larger type. In class book , the LaTeX default puts each part alone on its own page. If the book is two-sided then LaTeX will skip a page if needed to have the new part on an odd-numbered page. In report it is again alone on a page, but LaTeX won’t force it onto an odd-numbered page. In an article LaTeX does not put it on a fresh page, but instead outputs the part number and part title onto the main document page.

The * form shows title but it does not show the part number, does not increment the part counter, and produces no table of contents entry.

The optional argument toc-title will appear as the part title in the table of contents (see Table of contents etc.) and in running headers (see Page styles). If it is not present then title will be there. This example puts a line break in title but leaves out the break in the table of contents.

\part[Up from the bottom; my life]{Up from the bottom\\ my life}

For determining which sectional units are numbered and which appear in the table of contents, the level number of a part is -1 (see Sectioning/secnumdepth and see Sectioning/tocdepth).

In the class article , if a paragraph immediately follows the part title then it is not indented. To get an indent you can use the package indentfirst .

One package to change the behavior of \part is titlesec . See its documentation on CTAN.

6.2 \chapter

Synopsis, one of:

\chapter{ title } \chapter*{ title } \chapter[ toc-title ]{ title }

Start a chapter. The standard LaTeX classes book and report have this command but article does not.

This produces a chapter.

\chapter{Loomings} Call me Ishmael. Some years ago---never mind how long precisely---having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world.

The LaTeX default starts each chapter on a fresh page, an odd-numbered page if the document is two-sided. It produces a chapter number such as ‘ Chapter 1 ’ in large boldface type (the size is \huge ). It then puts title on a fresh line, in boldface type that is still larger (size \Huge ). It also increments the chapter counter, adds an entry to the table of contents (see Table of contents etc.), and sets the running header information (see Page styles).

The * form shows title on a fresh line, in boldface. But it does not show the chapter number, does not increment the chapter counter, produces no table of contents entry, and does not affect the running header. (If you use the page style headings in a two-sided document then the header will be from the prior chapter.) This example illustrates.

\chapter*{Preamble}

The optional argument toc-title will appear as the chapter title in the table of contents (see Table of contents etc.) and in running headers (see Page styles). If it is not present then title will be there. This shows the full name in the chapter title,

\chapter[Weyl]{Hermann Klaus Hugo (Peter) Weyl (1885--1955)}

but only ‘ Weyl ’ on the contents page. This puts a line break in the title but that doesn’t work well with running headers so it omits the break in the contents

\chapter[Given it all\\ my story]{Given it all\\ my story}

For determining which sectional units are numbered and which appear in the table of contents, the level number of a chapter is 0 (see Sectioning/secnumdepth and see Sectioning/tocdepth).

The paragraph that follows the chapter title is not indented, as is a standard typographical practice. To get an indent use the package indentfirst .

You can change what is shown for the chapter number. To change it to something like ‘ Lecture 1 ’, put in the preamble either \renewcommand{\chaptername}{Lecture} or this (see \makeatletter & \makeatother).

\makeatletter \renewcommand{\@chapapp}{Lecture} \makeatother

To make this change because of the primary language for the document, see the package babel .

In a two-sided document LaTeX puts a chapter on odd-numbered page, if necessary leaving an even-numbered page that is blank except for any running headers. To make that page completely blank, see \clearpage & \cleardoublepage.

To change the behavior of the \chapter command, you can copy its definition from the LaTeX format file and make adjustments. But there are also many packages on CTAN that address this. One is titlesec . See its documentation, but the example below gives a sense of what it can do.

\usepackage{titlesec} % in preamble \titleformat{\chapter} {\Huge\bfseries} % format of title {} % label, such as 1.2 for a subsection {0pt} % length of separation between label and title {} % before-code hook

This omits the chapter number ‘ Chapter 1 ’ from the page but unlike \chapter* it keeps the chapter in the table of contents and the running headers.

6.3 \section

Synopsis, one of:

\section{ title } \section*{ title } \section[ toc-title ]{ title }

Start a section. The standard LaTeX classes article , book , and report all have this command.

This produces a section.

In this Part we tend to be more interested in the function, in the input-output behavior, than in the details of implementing that behavior. \section{Turing machines} Despite this desire to downplay implementation, we follow the approach of A~Turing that the first step toward defining the set of computable functions is to reflect on the details of what mechanisms can do.

For the standard LaTeX classes book and report the default output is like ‘ 1.2 title ’ (for chapter 1, section 2), alone on its line and flush left, in boldface and a larger type (the type size is \Large ). The same holds in article except that there are no chapters in that class so it looks like ‘ 2 title ’.

The * form shows title . But it does not show the section number, does not increment the section counter, produces no table of contents entry, and does not affect the running header. (If you use the page style headings in a two-sided document then the header will be from the prior section.)

The optional argument toc-title will appear as the section title in the table of contents (see Table of contents etc.) and in running headers (see Page styles). If it is not present then title will be there. This shows the full name in the title of the section,

\section[Elizabeth~II]{Elizabeth the Second, by the Grace of God of the United Kingdom, Canada and Her other Realms and Territories Queen, Head of the Commonwealth, Defender of the Faith.}

but only ‘ Elizabeth II ’ on the contents page and in the headers. This has a line break in title but that does not work with headers so it is omitted from the contents and headers.

\section[Truth is, I cheated; my life story]{Truth is, I cheated\\my life story}

For determining which sectional units are numbered and which appear in the table of contents, the level number of a section is 1 (see Sectioning/secnumdepth and see Sectioning/tocdepth).

The paragraph that follows the section title is not indented, as is a standard typographical practice. One way to get an indent is to use the package indentfirst .

In general, to change the behavior of the \section command, there are a number of options. One is the \@startsection command (see \@startsection). There are also many packages on CTAN that address this, including titlesec . See the documentation but the example below gives a sense of what they can do.

\usepackage{titlesec} % in preamble \titleformat{\section} {

ormalfont\Large\bfseries} % format of title {\makebox[1pc][r]{\thesection\hspace{1pc}}} % label {0pt} % length of separation between label and title {} % before-code hook \titlespacing*{\section} {-1pc}{18pt}{10pt}[10pc]

That puts the section number in the margin.

6.4 \subsection

Synopsis, one of:

\subsection{ title } \subsection*{ title } \subsection[ toc-title ]{ title }

Start a subsection. The standard LaTeX classes article , book , and report all have this command.

This produces a subsection.

We will show that there are more functions than Turing machines and that therefore some functions have no associated machine. \subsection{Cardinality} We will begin with two paradoxes that dramatize the challenge to our intuition posed by comparing the sizes of infinite sets.

For the standard LaTeX classes book and report the default output is like ‘ 1.2.3 title ’ (for chapter 1, section 2, subsection 3), alone on its line and flush left, in boldface and a larger type (the type size is \large ). The same holds in article except that there are no chapters in that class so it looks like ‘ 2.3 title ’.

The * form shows title . But it does not show the section number, does not increment the section counter, and produces no table of contents entry.

The optional argument toc-title will appear as the section title in the table of contents (see Table of contents etc.). If it is not present then title will be there. This shows the full name in the title of the section,

\subsection[$\alpha,\beta,\gamma$ paper]{\textit{The Origin of Chemical Elements} by R.A.~Alpher, H.~Bethe, and G.~Gamow}

but only ‘ α,β,γ paper ’ on the contents page.

For determining which sectional units are numbered and which appear in the table of contents, the level number of a subsection is 2 (see Sectioning/secnumdepth and see Sectioning/tocdepth).

The paragraph that follows the subsection title is not indented, as is a standard typographical practice. One way to get an indent is to use the package indentfirst .

There are a number of ways to change the behavior of the \subsection command. One is the \@startsection command (see \@startsection). There are also many packages on CTAN that address this, including titlesec . See the documentation but the example below gives a sense of what they can do.

\usepackage{titlesec} % in preamble \titleformat{\subsection}[runin] {

ormalfont

ormalsize\bfseries} % format of the title {\thesubsection} % label {0.6em} % space between label and title {} % before-code hook

That puts the subsection number and title in the first line of text.

6.5 \subsubsection , \paragraph , \subparagraph

Synopsis, one of:

\subsubsection{ title } \subsubsection*{ title } \subsubsection[ toc-title ]{ title }

or one of:

\paragraph{ title } \paragraph*{ title } \paragraph[ toc-title ]{ title }

or one of:

\subparagraph{ title } \subparagraph*{ title } \subparagraph[ toc-title ]{ title }

Start a subsubsection, paragraph, or subparagraph. The standard LaTeX classes article , book , and report all have these commands, although they are not commonly used.

This produces a subsubsection.

\subsubsection{Piston ring compressors: structural performance} Provide exterior/interior wall cladding assemblies capable of withstanding the effects of load and stresses from consumer-grade gasoline engine piston rings.

The default output of each of the three does not change over the standard LaTeX classes article , book , and report . For \subsubsection the title is alone on its line, in boldface and normal size type. For \paragraph the title is inline with the text, not indented, in boldface and normal size type. For \subparagraph the title is inline with the text, with a paragraph indent, in boldface and normal size type (Because an article has no chapters its subsubsections are numbered and so it looks like ‘ 1.2.3 title ’, for section 1, subsection 2, and subsubsection 3. The other two divisions are not numbered.)

The * form shows title . But it does not increment the associated counter and produces no table of contents entry (and does not show the number for \subsubsection ).

The optional argument toc-title will appear as the division title in the table of contents (see Table of contents etc.). If it is not present then title will be there.

For determining which sectional units are numbered and which appear in the table of contents, the level number of a subsubsection is 3, of a paragraph is 4, and of a subparagraph is 5 (see Sectioning/secnumdepth and see Sectioning/tocdepth).

The paragraph that follows the subsubsection title is not indented, as is a standard typographical practice. One way to get an indent is to use the package indentfirst .

There are a number of ways to change the behavior of the these commands. One is the \@startsection command (see \@startsection). There are also many packages on CTAN that address this, including titlesec . See the documentation on CTAN.

6.6 \appendix

Synopsis:

\appendix

This does not directly produce any output. But in a book or report it declares that subsequent \chapter commands start an appendix. In an article it does the same, for \section commands. It also resets the chapter and section counters to 0 in a book or report, and in an article resets the section and subsection counters.

In this book

\chapter{One} ... \chapter{Two} ... ... \appendix \chapter{Three} ... \chapter{Four} ...

the first two will generate output numbered ‘ Chapter 1 ’ and ‘ Chapter 2 ’. After the \appendix the numbering will be ‘ Appendix A ’ and ‘ Appendix B ’. See Larger book template for another example.

The appendix package adds the command \appendixpage to put a separate ‘ Appendices ’ in the document body before the first appendix, and the command \addappheadtotoc to do the same in the table of contents. You can reset the name ‘ Appendix ’ with a command like \renewcommand{\appendixname}{Specification} , as well as a number of other features. See the documentation on CTAN.

6.7 \frontmatter , \mainmatter , \backmatter

Synopsis, one of:

\frontmatter \mainmatter \backmatter

Format a book class document differently according to which part of the document is being produced. All three commands are optional.

Traditionally, a book’s front matter contains such things as the title page, an abstract, a table of contents, a preface, a list of notations, a list of figures, and a list of tables. (Some of these front matter pages, such as the title page, are traditionally not numbered.) The back matter may contain such things as a glossary, notes, a bibliography, and an index.

The \frontmatter declaration makes the pages numbered in lowercase roman, and makes chapters not numbered, although each chapter’s title appears in the table of contents; if you use other sectioning commands here, use the * -version (see Sectioning). The \mainmatter changes the behavior back to the expected version, and resets the page number. The \backmatter leaves the page numbering alone but switches the chapters back to being not numbered. See Larger book template for an example using the three.

6.8 \@startsection

Synopsis:

\@startsection{ name }{ level }{ indent }{ beforeskip }{ afterskip }{ style }

Used to help redefine the behavior of commands that start sectioning divisions such as \section or \subsection .

Note that the titlesec package makes manipulation of sectioning easier. Further, while most requirements for sectioning commands can be satisfied with \@startsection , some cannot. For instance, in the standard LaTeX book and report classes the commands \chapter and \report are not constructed in this way. To make such a command you may want to use the \secdef command.

Technically, \@startsection has the form

\@startsection{ name } { level } { indent } { beforeskip } { afterskip } { style }*[ toctitle ]{ title }

so that issuing

\renewcommand{\section}{\@startsection{ name } { level } { indent } { beforeskip } { afterskip } { style }}

redefines \section to have the form \section*[ toctitle ]{ title } (here too, the star * is optional). See Sectioning. This implies that when you write a command like \renewcommand{section}{...} , the \@startsection{...} must come last in the definition. See the examples below.

name Name of the counter used to number the sectioning header. This counter must be defined separately. Most commonly this is either section , subsection , or paragraph . Although in those cases the counter name is the same as the sectioning command itself, you don’t have to use the same name. Then \the name displays the title number and \ name mark is for the page headers. See the third example below. level An integer giving the depth of the sectioning command. See Sectioning for the list of standard level numbers. If level is less than or equal to the value of the counter secnumdepth then titles for this sectioning command will be numbered (see Sectioning/secnumdepth). For instance, if secnumdepth is 1 in an article then the command \section{Introduction} will produce output like “1 Introduction” while \subsection{Discussion} will produce output like “Discussion”, without the number prefix. If level is less than or equal to the value of the counter tocdepth then the table of contents will have an entry for this sectioning unit (see Sectioning/tocdepth). For instance, in an article , if tocdepth is 1 then the table of contents will list sections but not subsections. indent A length giving the indentation of all of the title lines with respect to the left margin. To have the title flush with the margin use 0pt . A negative indentation such as -\parindent will move the title into the left margin. beforeskip The absolute value of this length is the amount of vertical space that is inserted before this sectioning unit’s title. This space will be discarded if the sectioning unit happens to start at the top of a fresh page. If this number is negative then the first paragraph following the header is not indented, if it is non-negative then the first paragraph is indented. (Note that the negative of 1pt plus 2pt minus 3pt is -1pt plus -2pt minus -3pt .) For example, if beforeskip is -3.5ex plus -1ex minus -0.2ex then to start the new sectioning unit, LaTeX will add about 3.5 times the height of a letter x in vertical space, and the first paragraph in the section will not be indented. Using a rubber length, with plus and minus , is good practice here since it gives LaTeX more flexibility in making up the page (see Lengths). The full accounting of the vertical space between the baseline of the line prior to this sectioning unit’s header and the baseline of the header is that it is the sum of the \parskip of the text font, the \baselineskip of the title font, and the absolute value of the beforeskip . This space is typically rubber so it may stretch or shrink. (If the sectioning unit starts on a fresh page so that the vertical space is discarded then the baseline of the header text will be where LaTeX would put the baseline of the first text line on that page.) afterskip This is a length. If afterskip is non-negative then this is the vertical space inserted after the sectioning unit’s title header. If it is negative then the title header becomes a run-in header, so that it becomes part of the next paragraph. In this case the absolute value of the length gives the horizontal space between the end of the title and the beginning of the following paragraph. (Note that the negative of 1pt plus 2pt minus 3pt is -1pt plus -2pt minus -3pt .) As with beforeskip , using a rubber length, with plus and minus components, is good practice here since it gives LaTeX more flexibility in putting together the page. If afterskip is non-negative then the full accounting of the vertical space between the baseline of the sectioning unit’s header and the baseline of the first line of the following paragraph is that it is the sum of the \parskip of the title font, the \baselineskip of the text font, and the value of after . That space is typically rubber so it may stretch or shrink. (Note that because the sign of afterskip changes the sectioning unit header’s from standalone to run-in, you cannot use a negative afterskip to cancel part of the \parskip .) style Controls the styling of the title. See the examples below. Typical commands to use here are \centering , \raggedright ,

ormalfont , \hrule , or

ewpage . The last command in style may be one that takes one argument, such as \MakeUppercase or \fbox that takes one argument. The section title will be supplied as the argument to this command. For instance, setting style to \bfseries\MakeUppercase would produce titles that are bold and uppercase.

These are LaTeX’s defaults for the first three sectioning units that are defined with \@startsection , for the article , book , and report classes. For section, the level is 1, the indent is 0pt, the beforeskip is -3.5ex plus -1ex minus -0.2ex , the afterskip is 2.3ex plus 0.2ex , and the style is

ormalfont\Large\bfseries . For subsection, the level is 2, the indent is 0pt, the beforeskip is -3.25ex plus -1ex minus -0.2ex , the afterskip is 1.5ex plus 0.2ex , and the style is

ormalfont\large\bfseries . For subsubsection, the level is 3, the indent is 0pt, the beforeskip is -3.25ex plus -1ex minus -0.2ex , the afterskip is 1.5ex plus 0.2ex , and the style is

ormalfont

ormalsize\bfseries .

Here are examples. They go either in a package or class file or in the preamble of a LaTeX document. If you put them in the preamble they must go between a \makeatletter command and a \makeatother . (Probably the error message You can't use `\spacefactor' in vertical mode. means that you forgot this.) See \makeatletter & \makeatother.

This will put section titles in large boldface type, centered. It says \renewcommand because LaTeX’s standard classes have already defined a \section . For the same reason it does not define a section counter, or the commands \thesection and \l@section .

\renewcommand\section{% \@startsection{section}% name {1}% level {0pt}% indent {-3.5ex plus -1ex minus -.2ex}% beforeskip {2.3ex plus.2ex}% afterskip {\centering

ormalfont\Large\bfseries}% style }

This will put subsection titles in small caps type, inline with the paragraph.

\renewcommand\subsection{% \@startsection{subsection}% name {2}% level {0em}% indent {-1ex plus 0.1ex minus -0.05ex}% beforeskip {-1em plus 0.2em}% afterskip {\scshape}% style }

The prior examples redefined existing sectional unit title commands. This defines a new one, illustrating the needed counter and macros to display that counter.

\setcounter{secnumdepth}{6}% show counters this far down

ewcounter{subsubparagraph}[subparagraph]% counter for numbering \renewcommand{\thesubsubparagraph}% how to display {\thesubparagraph.\@arabic\c@subsubparagraph}% numbering

ewcommand{\subsubparagraph}{\@startsection {subsubparagraph}% {6}% {0em}% {\baselineskip}% {0.5\baselineskip}% {

ormalfont

ormalsize}}

ewcommand*\l@subsubparagraph{\@dottedtocline{6}{10em}{5em}}% for toc

ewcommand{\subsubparagraphmark}[1]{}% for page headers

7 Cross references

We often want something like ‘ See Theorem~31 ’. But by-hand typing the 31 is poor practice. Instead you should write a label such as \label{eq:GreensThm} and then reference it, as with See equation~\ref{eq:GreensThm} . LaTeX will automatically work out the number, put it into the output, and will change that number later if needed.

We will see this with Theorem~\ref{th:GreensThm}. % forward reference ... \begin{theorem} \label{th:GreensThm} ... \end{theorem} ... See Theorem~\ref{th:GreensThm} on page~\pageref{th:GreensThm}.

LaTeX tracks cross reference information in a file having the extension .aux and with the same base name as the file containing the \label . So if \label is in calculus.tex then the information is in calculus.aux . LaTeX puts the information in that file every time it runs across a \label .

The behavior described in the prior paragraph results in a quirk that happens when your document has a forward reference, a \ref that appears before the associated \label . If this is the first time that you are compiling the document then you will get ‘ LaTeX Warning: Label(s) may have changed. Rerun to get cross references right ’ and in the output the forward reference will appear as two question marks ‘ ?? ’, in boldface. A similar thing happens if you change some things so the references changes; you get the same warning and the output contains the old reference information. In both cases, resolve this by compiling the document a second time.

The cleveref package enhances LaTeX’s cross referencing features. You can arrange that if you enter \begin{thm}\label{th:Nerode}...\end{thm} then \cref{th:Nerode} will output ‘ Theorem 3.21 ’, without you having to enter the “Theorem.”

• \label: Assign a symbolic name to a piece of text. • \pageref: Refer to a page number. • \ref: Refer to a section, figure or similar.

7.1 \label

Synopsis:

\label{ key }

Assign a reference number to key . In ordinary text \label{ key } assigns to key the number of the current sectional unit. Inside an environment with numbering, such as a table or theorem environment, \label{ key } assigns to key the number of that environment. Retrieve the assigned number with the \ref{ key } command (see \ref).

A key name can consist of any sequence of letters, digits, or common punctuation characters. Upper and lowercase letters are distinguished, as usual.

A common convention is to use labels consisting of a prefix and a suffix separated by a colon or period. Thus, \label{fig:Post} is a label for a figure with a portrait of Emil Post. This helps to avoid accidentally creating two labels with the same name, and makes your source more readable. Some commonly-used prefixes:

ch for chapters sec subsec for lower-level sectioning commands fig for figures tab for tables eq for equations

In the auxiliary file the reference information is kept as the text of a command of the form

ewlabel{ label }{{ currentlabel }{ pagenumber }} . Here currentlabel is the current value of the macro \@currentlabel that is usually updated whenever you call \refstepcounter{ counter } .

Below, the key sec:test will get the number of the current section and the key fig:test will get the number of the figure. (Incidentally, put labels after captions in figures and tables.)

\section{section name} \label{sec:test} This is Section~\ref{sec:test}. \begin{figure} ... \caption{caption text} \label{fig:test} \end{figure} See Figure~\ref{fig:test}.

7.2 \pageref

Synopsis:

\pageref{ key }

Produce the page number of the place in the text where the corresponding \label { key } command appears.

If there is no \label{ key } then you get something like ‘ LaTeX Warning: Reference `th:GrensThm' on page 1 undefined on input line 11. ’

Below, the \label{eq:main} is used both for the formula number and for the page number. (Note that the two references are forward references so this document would need to be compiled twice to resolve those.)

The main result is formula~\ref{eq:main} on page~\pageref{eq:main}. ... \begin{equation} \label{eq:main} \mathbf{P}=\mathbf{NP} \end{equation}

7.3 \ref

Synopsis:

\ref{ key }

Produces the number of the sectional unit, equation, footnote, figure, …, of the corresponding \label command (see \label). It does not produce any text, such as the word ‘Section’ or ‘Figure’, just the bare number itself.

If there is no \label{ key } then you get something like ‘ LaTeX Warning: Reference `th:GrensThm' on page 1 undefined on input line 11. ’

In this example the \ref{popular} produces ‘ 2 ’. Note that it is a forward reference since it comes before \label{popular} so this document would have to be compiled twice.

The most widely-used format is item number~\ref{popular}. \begin{enumerate} \item Plain \TeX \item \label{popular} \LaTeX \item Con\TeX t \end{enumerate}

The cleveref package includes text such as ‘ Theorem ’ in the reference. See the documentation on CTAN.

8 Environments

LaTeX provides many environments for delimiting certain behavior. An environment begins with \begin and ends with \end , like this:

\begin{ environment-name } ... \end{ environment-name }

The environment-name at the beginning must exactly match that at the end. For instance, the input \begin{table*}...\end{table} will cause an error like: ‘ ! LaTeX Error: \begin{table*} on input line 5 ended by \end{table}. ’

Environments are executed within a group.

• abstract: Produce an abstract. • array: Math arrays. • center: Centered lines. • description: Labelled lists. • displaymath: Formulas that appear on their own line. • document: Enclose the whole document. • enumerate: Numbered lists. • eqnarray: Sequences of aligned equations. • equation: Displayed equation. • figure: Floating figures. • filecontents: Writing multiple files from the source. • flushleft: Flushed left lines. • flushright: Flushed right lines. • itemize: Bulleted lists. • letter: Letters. • list: Generic list environment. • math: In-line math. • minipage: Miniature page. • picture: Picture with text, arrows, lines and circles. • quotation & quote: Include a quotation. • tabbing: Align text arbitrarily. • table: Floating tables. • tabular: Align text in columns. • thebibliography: Bibliography or reference list. • theorem: Theorems, lemmas, etc. • titlepage: For hand crafted title pages. • verbatim: Simulating typed input. • verse: For poetry and other things.

8.1 abstract

Synopsis:

\begin{abstract} ... \end{abstract}

Produce an abstract, possibly of multiple paragraphs. This environment is only defined in the article and report document classes (see Document classes).

Using the example below in the article class produces a displayed paragraph. Document class option titlepage causes the abstract to be on a separate page (see Document class options); this is the default only in the report class.

\begin{abstract} We compare all known accounts of the proposal made by Porter Alexander to Robert E Lee at the Appomattox Court House that the army continue in a guerrilla war, which Lee refused. \end{abstract}

The next example produces a one column abstract in a two column document (for a more flexible solution, use the package abstract ).

\documentclass[twocolumn]{article} ... \begin{document} \title{Babe Ruth as Cultural Progenitor: a Atavistic Approach} \author{Smith \\ Jones \\ Robinson\thanks{Railroad tracking grant.}} \twocolumn[ \begin{@twocolumnfalse} \maketitle \begin{abstract} Ruth was not just the Sultan of Swat, he was the entire swat team. \end{abstract} \end{@twocolumnfalse} ] { % by-hand insert a footnote at page bottom \renewcommand{\thefootnote}{\fnsymbol{footnote}} \footnotetext[1]{Thanks for all the fish.} }

8.2 array

Synopsis:

\begin{array}{ cols } column 1 entry & column 2 entry ... & column n entry \\ ... \end{array}

or:

\begin{array}[ pos ]{ cols } column 1 entry & column 2 entry ... & column n entry \\ ... \end{array}

Produce a mathematical array. This environment can only be used in math mode, and normally appears within a displayed mathematics environment such as equation (see equation). Inside of each row the column entries are separated by an ampersand, ( & ). Rows are terminated with double-backslashes (see \\).

This example shows a three by three array.

\begin{equation*} \chi(x) = \left| % vertical bar fence \begin{array}{ccc} x-a &-b &-c \\ -d &x-e &-f \\ -g &-h &x-i \end{array} \right| \end{equation*}

The required argument cols describes the number of columns, their alignment, and the formatting of the intercolumn regions. For instance, \begin{array}{rcl}...\end{array} gives three columns: the first flush right, the second centered, and the third flush left. See tabular for the complete description of cols and of the other common features of the two environments, including the optional pos argument.

There are two ways that array diverges from tabular . The first is that array entries are typeset in math mode, in textstyle (see Modes) except if the cols definition specifies the column with p{...} , which causes the entry to be typeset in text mode. The second is that, instead of tabular ’s parameter \tabcolsep , LaTeX’s intercolumn space in an array is governed by \arraycolsep , which gives half the width between columns. The default for this is ‘ 5pt ’ so that between two columns comes 10pt of space.

To obtain arrays with braces the standard is to use the amsmath package. It comes with environments pmatrix for an array surrounded by parentheses (...) , bmatrix for an array surrounded by square brackets [...] , Bmatrix for an array surrounded by curly braces {...} , vmatrix for an array surrounded by vertical bars |...| , and Vmatrix for an array surrounded by double vertical bars ||...|| , along with a number of other array constructs.

The next example uses the amsmath package.

\usepackage{amsmath} % in preamble \begin{equation} \begin{vmatrix}{cc} % array with vert lines a &b \\ c &d \end{vmatrix}=ad-bc \end{equation}

There are many packages concerning arrays. The array package has many useful extensions, including more column types. The dcolumn package adds a column type to center on a decimal point. For both see the documentation on CTAN.

8.3 center

Synopsis:

\begin{center} line1 \\ line2 \\ ... \end{center}

Create a new paragraph consisting of a sequence of lines that are centered within the left and right margins. Use double-backslash, \\ , to get a line break (see \\). If some text is too long to fit on a line then LaTeX will insert line breaks that avoid hyphenation and avoid stretching or shrinking any interword space.

This environment inserts space above and below the text body. See \centering to avoid such space, for example inside a figure environment.

This example produces three centered lines. There is extra vertical space between the last two lines.

\begin{center} A Thesis Submitted in Partial Fufillment \\ of the Requirements of \\[0.5ex] the School of Environmental Engineering \end{center}

In this example, depending on the page’s line width, LaTeX may choose a line break for the part before the double backslash. If so, it will center each of the two lines and if not it will center the single line. Then LaTeX will break at the double backslash, and will center the ending.

\begin{center} My father considered that anyone who went to chapel and didn't drink alcohol was not to be tolerated.\\ I grew up in that belief. --Richard Burton \end{center}

A double backslash after the final line is optional. If present it doesn’t add any vertical space.

In a two-column document the text is centered in a column, not in the entire page.

• \centering: Declaration form of the center environment.

8.3.1 \centering

Synopsis:

{\centering ... }

or

\begin{group} \centering ... \end{group}

Center the material in its scope. It is most often used inside an environment such as figure , or in a parbox .

This example’s \centering declaration causes the graphic to be h