\input texinfo @c $Id: latex2e.texi 1079 2022-01-26 18:15:20Z karl $ @comment %**start of header (This is for running Texinfo on a region.) @setfilename latex2e.info @set UPDATED January 2022 @include common.texi @settitle @LaTeX{}2e unofficial reference manual (@value{UPDATED}) @comment %**end of header (This is for running Texinfo on a region.) @c latex 2.09 commands should all be present now, @c xx but latex2e stuff is missing. @c xx random list of a few of the missing items is at the end of this file @c xx read through latex2e news for things to update. @c @c xx ctan, distributions, components of TeX @c xx classes and packages: required, additional, useful; oberdiek; fonts @c xx merge permuted-index @c xx merge latex-manual from savannah @c xx merge display style math @c xx check recent ltnews for (lots of) changes @c xx \write of non-ASCII chars (vincent mail of 14 Mar 2020 21:39:41) @c xx \nonstopmode etc., if they are officially supported by LaTeX? @c xx JH explain nfss somewhere @c xx JH expand BiBTeX @c xx JH expand theorem, AMS math @c xx JH something on code listings @c xx JH ligatures @c @c xx \NewCommandCopy et al. (Brian Dunn, 21 Dec 2021 06:50:17). @c @c xx The typeset source2e has an index with all kernel @c xx commands, though some are internal and shouldn't be included. @c xx classes.dtx et al. define additional commands. @c xx See also http://ctan.org/pkg/macros2e. @c @c xx All the special characters should be definitively described. @copying This document is an unofficial reference manual for @LaTeX{}, a document preparation system, version of @value{UPDATED}. This manual was originally translated from @file{LATEX.HLP} v1.0a in the VMS Help Library. The pre-translation version was written by George@tie{}D. Greenwade of Sam Houston State University. The @LaTeX{}@tie{}2.09 version was written by Stephen Gilmore. The @LaTeX{}2e version was adapted from this by Torsten Martinsen. Karl Berry made further updates and additions, and gratefully acknowledges using @cite{Hypertext Help with @LaTeX{}}, by Sheldon Green, and @cite{@LaTeX{} Command Summary} (for @LaTeX{}@tie{}2.09) by L.@tie{}Botway and C.@tie{}Biemesderfer (published by the @TeX{} Users Group as @cite{@TeX{}niques} number 10), as reference material. We also gratefully acknowledge additional material appearing in latex2e-reference by Martin Herbert Dietze. (From these references no text was directly copied.) Copyright 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 Karl Berry.@* Copyright 1988, 1994, 2007 Stephen Gilmore.@* Copyright 1994, 1995, 1996 Torsten Martinsen. @comment start of License Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. @ignore Permission is granted to process this file through TeX and print the results, provided the printed document carries copying permission notice identical to this one except for the removal of this paragraph (this paragraph not being relevant to the printed manual). @end ignore Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions. @comment end of License @end copying @c Merge into one index (arbitrarily chosen to be the concept index). @syncodeindex fn cp @dircategory TeX @direntry * LaTeX2e: (latex2e). Unofficial LaTeX reference manual. @end direntry @tex \global\hbadness=4444 % don't complain much @end tex @html
This is an unofficial reference manual for
LaTeX. See below for the Table of Contents.
If you want a tutorial then please instead visit learnlatex.org
or this list.
This manual has two versions. One has separate web pages for each section or subsection. It's also available as a single web page and as a pdf. Note that there is also a separately-maintained French edition.
This document is not official. It has not been reviewed by the LaTeX maintainers. Our goal is to cover all (non-private) LaTeX commands. Your comments and contributions, including bug reports, are very welcome. See our project page for more, including license information and information on how you can contribute to this manual as well as mirror it.
@end html @titlepage @title @LaTeX{}2e: An unofficial reference manual @subtitle @value{UPDATED} @author @url{@value{LTXREFMAN_HOME_PAGE}} @page @vskip 0pt plus 1filll @insertcopying @end titlepage @shortcontents @contents @c Best Effort Symbol @iftex @macro visiblespace @tex% {@tt@char`@ }% @end tex@c @end macro @macro BES {utf8,math} @math{\math\} @end macro @macro BESU {utf8,math} @code{@backslashchar{}\math\} @end macro @end iftex @ifnottex @macro visiblespace @w{ } @end macro @macro BES {utf8,math} @U{\utf8\} @end macro @macro BESU {utf8,math} @U{\utf8\} @end macro @end ifnottex @macro EnvIndex {env} @findex @r{environment}, @code{\env\} @findex @code{\env\} @r{environment} @end macro @macro PkgIndex {pkg} @cindex @r{package}, @code{\pkg\} @cindex @code{\pkg\} @r{package} @end macro @set NotInPlainTeX Not available in plain @TeX{}. @set NeedsAMSSymb @value{NotInPlainTeX} In @LaTeX{} you need to load the @package{amssymb} package. @set NeedsSTIX @value{NotInPlainTeX} In @LaTeX{} you need to load the @file{stix} package. @ifnottex @node Top @top @LaTeX{}2e: An unofficial reference manual This document is an unofficial reference manual (version of @value{UPDATED}) for @LaTeX{}2e, a document preparation system. @end ifnottex @menu * About this document:: Bug reporting, etc. * Overview:: What is @LaTeX{}? * Document classes:: Some of the various classes available. * Fonts:: Italic, bold, typewriter, etc. * Layout:: Controlling the page layout. * Sectioning:: Parts, Chapters, Sections, etc. * Cross references:: Automatic referencing. * Environments:: Such as enumerate & itemize. * Line breaking:: Influencing line breaks. * Page breaking:: Influencing page breaks. * Footnotes:: How to produce footnotes. * Definitions:: Define your own commands, etc. * Counters:: Internal counters used by @LaTeX{}. * Lengths:: The length commands. * Making paragraphs:: Paragraph commands. * Math formulas:: How to create mathematical formulas. * Modes:: Paragraph, Math or LR modes. * Page styles:: Various styles of page layout. * Spaces:: Horizontal and vertical space. * Boxes:: Making boxes. * Color:: Defining and using colors. * Graphics:: Importing graphics from outside @LaTeX{}. * Special insertions:: Inserting reserved and special characters. * Splitting the input:: Dealing with big files by splitting. * Front/back matter:: Tables of contents, glossaries, indexes. * Letters:: The @code{letter} class. * Input/output:: User interaction. * Command line interface:: Common command-line options. * Document templates:: Starter templates for various document classes. * Index:: General index. @end menu @node About this document @chapter About this document @cindex home page for manual This is an unofficial reference manual for the @LaTeX{}2e document preparation system, which is a macro package for the @TeX{} typesetting program (@pxref{Overview}). This document's home page is @url{@value{LTXREFMAN_HOME_PAGE}}; it has separate web pages for each topic. Alternatively. @url{https://latexref.xyz/dev/latex2e.html} has the entire document on a single page. For other output formats, the sources, and plenty more information, see @url{https://latexref.xyz/dev/}. @cindex @LaTeX{} vs.@: @LaTeX{}2e In this document, we will mostly just use `@LaTeX{}' rather than `@LaTeX{}2e', since the previous version of @LaTeX{}@tie{}(2.09) was frozen decades ago. @cindex unofficial nature of this manual @cindex @LaTeX{} Project team @findex @email{@value{LTXREFMAN_BUGS}} @r{email address} @LaTeX{} is maintained by a group of volunteers (@url{https://latex-project.org}). The official documentation written by the @LaTeX{} project is available from their web site. The present document is completely unofficial and has not been written or reviewed by the @LaTeX{} maintainers. @cindex bug reporting @cindex reporting bugs Do not send bug reports or anything else about this document to them. Instead, please send all comments to @email{@value{LTXREFMAN_BUGS}}. This document is a reference, not a tutorial. There is a vast array of other information available about @LaTeX{}, at all levels. Here are a few introductions. @table @url @item https://ctan.org/pkg/latex-doc-ptr @findex latex-doc-ptr @r{document} Two pages of recommended references to @LaTeX{} documentation. @item https://ctan.org/pkg/first-latex-doc @findex first-latex-doc @r{document} Writing your first document, with a bit of both text and math. @item https://ctan.org/pkg/lshort @findex lshort @r{document} A longer introduction to @LaTeX{}, translated to many languages. @item https://tug.org/begin.html Introduction to the @TeX{} system, including @LaTeX{}, with further references. @end table @node Overview @chapter Overview of @LaTeX{} @cindex overview of @LaTeX{} @cindex basics of @LaTeX{} @cindex Knuth, Donald E. @cindex Lamport, Leslie @cindex @LaTeX{} overview @LaTeX{} is a system for typesetting documents. It was originally created by Leslie Lamport in 1984, but has been maintained by a group of volunteers for many years now (@url{https://latex-project.org}). It is widely used, particularly but not exclusively for mathematical and technical documents. @cindex UTF-8, default @LaTeX{} input encoding A @LaTeX{} user writes an input file containing text to be typeset along with interspersed commands. The default encoding for the text is UTF-8 (as of 2018). The commands specify, for example, how the text should be formatted. @LaTeX{} is implemented as a set of related so-called ``macros'' which use Donald@tie{}E. Knuth's @TeX{} typesetting program or one of its derivatives, collectively known as ``engines''. Thus, the user produces output, typically PDF, by giving the input file to a @TeX{} engine. (The following sections describe all this in more detail.) The term @LaTeX{} is also sometimes used to mean the language in which the input document is marked up, that is, to mean the set of commands available to a @LaTeX{} user. @cindex Lamport @TeX{} @cindex pronunciation 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 @code{\LaTeX}. Where use of the logo is not sensible, such as in plain text, write it as @samp{LaTeX}. @menu * Starting and ending:: The standard beginning and end of a document. * Output files:: Files produced. * @TeX{} engines:: Programs that can compile @TeX{} and @LaTeX{}. * @LaTeX{} command syntax:: General syntax of @LaTeX{} commands. * Environment:: An area of the source with distinct behavior. * CTAN:: Our repository. @end menu @node Starting and ending @section Starting and ending @anchor{Starting & ending}@c old name @cindex starting and ending @cindex ending and starting @cindex hello, world @LaTeX{} files have a simple global structure, with a standard beginning and ending. This is a small example. @example \documentclass@{article@} \begin@{document@} Hello, \LaTeX\ world. \end@{document@} @end example @noindent Every @LaTeX{} document has a @code{\begin@{document@}} line and an @code{\end@{document@}} line. @cindex document class, defined @noindent Here, the @samp{article} is the @dfn{document class}. It is implemented in a file @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. @xref{Document classes}. @cindex preamble, defined You can include other @LaTeX{} commands between the @code{\documentclass} and the @code{\begin@{document@}} commands. This area is called the @dfn{preamble}. The @code{\begin@{document@}}, @code{\end@{document@}} pair defines an @cindex environment @dfn{environment}; the @samp{document} environment (and no others) is required in all @LaTeX{} documents (@pxref{document}). @LaTeX{} make available to you many environments that are documented here (@pxref{Environments}). Many more are available to you from external packages, most importantly those available at CTAN (@pxref{CTAN}). The following sections discuss how to produce PDF or other output from a @LaTeX{} input file. @node Output files @section Output files @LaTeX{} produces a main output file and at least two auxiliary files. The main output file's name ends in either @file{.dvi} or @file{.pdf}. @table @code @item .dvi @findex .dvi @r{file} @findex latex @r{command} @findex xdvi @r{command} @findex dvips @r{command} @findex dvipdfmx @r{command} @findex dvitype @r{command} @anchor{output files dvi} If @LaTeX{} is invoked with the system command @command{latex} then it produces a DeVice Independent file, with extension @file{.dvi}. You can view this file with a command such as @command{xdvi}, or convert it to a PostScript @code{.ps} file with @command{dvips} or to a Portable Document Format @code{.pdf} file with @command{dvipdfmx}. The contents of the file can be dumped in human-readable form with @command{dvitype}. A vast array of other DVI utility programs are available (@url{https://mirror.ctan.org/dviware}). @item .pdf @findex .pdf @r{file} @cindex pdf@TeX{} @findex pdflatex @r{command} @anchor{output files pdf} If @LaTeX{} is invoked via the system command @command{pdflatex}, among other commands (@pxref{@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. @end table @LaTeX{} always produces at least two additional files. @table @code @item .log @cindex transcript file @cindex log file @findex .log @r{file} @anchor{output 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. @item .aux @cindex auxiliary file @findex .aux @r{file} @cindex cross references, resolving @cindex forward references, resolving @cindex references, resolving forward @anchor{output files 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 @code{??}. When the referred-to spot does eventually appear in the source then @LaTeX{} writes its location information to this @code{.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. @end table @findex .lof @r{file} @cindex list of figures file @findex .lot @r{file} @cindex list of tables file @findex .toc @r{file} @cindex table of contents file @cindex contents file @LaTeX{} may produce yet more files, characterized by the filename ending. These include a @code{.lof} file that is used to make a list of figures, a @code{.lot} file used to make a list of tables, and a @code{.toc} file used to make a table of contents (@pxref{Table of contents etc.}). A particular class may create others; the list is open-ended. @node @TeX{} engines @section @TeX{} engines @cindex engines, @TeX{} @cindex implementations of @TeX{} @cindex UTF-8, engine support for @cindex Unicode input, native @cindex TrueType fonts @cindex OpenType fonts @cindex @TeX{} format (@code{.fmt}) files @cindex @LaTeX{} format (@code{.fmt}) files @cindex format files, @TeX{} @findex .fmt @r{file} @LaTeX{} is a large set of commands that is executed by a @TeX{} program (@pxref{Overview}). Such a set of commands is called a @dfn{format}, and is embodied in a binary @code{.fmt} file, which can be read much more quickly than the corresponding @TeX{} source. This section gives a terse overview of the @TeX{} programs that are commonly available (see also @ref{Command line interface}). @ftable @code @item latex @itemx pdflatex @findex etex @r{command} @cindex pdf@TeX{} engine @cindex e-@TeX{} @anchor{tex engines latex} In @TeX{} Live (@url{https://tug.org/texlive}), if @LaTeX{} is invoked via either the system command @command{latex} or @command{pdflatex}, then the pdf@TeX{} engine is run (@url{https://ctan.org/pkg/pdftex}). When invoked as @command{latex}, the main output is a @file{.dvi} file; as @command{pdflatex}, the main output is a @file{.pdf} file. pdf@TeX{} incorporates the e-@TeX{} extensions to Knuth's original program (@url{https://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 @command{etex}, but this is plain @TeX{} (and produces @file{.dvi}). In other @TeX{} distributions, @command{latex} may invoke e-@TeX{} rather than pdf@TeX{}. In any case, the e-@TeX{} extensions can be assumed to be available in @LaTeX{}. @item lualatex @cindex Lua@TeX{} @anchor{tex engines lualatex} If @LaTeX{} is invoked via the system command @command{lualatex}, the Lua@TeX{} engine is run (@url{https://ctan.org/pkg/luatex}). This program allows code written in the scripting language Lua (@url{http://luatex.org}) to interact with @TeX{}'s typesetting. Lua@TeX{} handles UTF-8 Unicode input natively, can handle OpenType and TrueType fonts, and produces a @file{.pdf} file by default. There is also @command{dvilualatex} to produce a @file{.dvi} file. @item xelatex @cindex Xe@TeX{} @findex .xdv @r{file} @findex xdvipdfmx @anchor{tex engines xelatex} If @LaTeX{} is invoked with the system command @command{xelatex}, the Xe@TeX{} engine is run (@url{https://tug.org/xetex}). Like Lua@TeX{}, Xe@TeX{} natively supports UTF-8 Unicode and TrueType and OpenType fonts, though the implementation is completely different, mainly using external libraries instead of internal code. Xe@TeX{} produces a @file{.pdf} file as output; it does not support DVI output. Internally, Xe@TeX{} creates an @code{.xdv} file, a variant of DVI, and translates that to PDF using the (@code{x})@code{dvipdfmx} program, but this process is automatic. The @code{.xdv} file is only useful for debugging. @item platex @itemx uplatex These commands provide significant additional support for Japanese and other languages; the @code{u} variant supports Unicode. See @url{https://ctan.org/pkg/ptex} and @url{https://ctan.org/pkg/uptex}. @end ftable As of 2019, there is a companion @code{-dev} command and format for all of the above: @ftable @code @item dvilualatex-dev @itemx latex-dev @itemx lualatex-dev @itemx pdflatex-dev @itemx platex-dev @itemx uplatex-dev @itemx xelatex-dev @cindex release candidates @cindex prerelease testing These are candidates for an upcoming @LaTeX{} release. The main purpose is to find and address compatibility problems before an official release. These @code{-dev} formats make it easy for anyone to help test documents and code: you can run, say, @code{pdflatex-dev} instead of @code{pdflatex}, without changing anything else in your environment. Indeed, it is easiest and most helpful to always run the @code{-dev} versions instead of bothering to switch back and forth. During quiet times after a release, the commands will be equivalent. These are not daily snapshots or untested development code. They undergo the same extensive regression testing by the @LaTeX{} team before being released. For more information, see ``The @LaTeX{} release workflow and the @LaTeX{} @code{dev} formats'' by Frank Mittelbach, @cite{TUGboat} 40:2, @url{https://tug.org/TUGboat/tb40-2/tb125mitt-dev.pdf}. @end ftable @node @LaTeX{} command syntax @section @LaTeX{} command syntax @cindex command syntax @findex \ @r{character starting commands} @findex [...] @r{for optional arguments} @findex @{...@} @r{for required arguments} In the @LaTeX{} input file, a command name starts with a backslash character, @code{\}. The name itself then consists of either (a)@tie{}a string of letters or (b)@tie{}a single non-letter. @LaTeX{} commands names are case sensitive so that @code{\pagebreak} differs from @code{\Pagebreak} (the latter is not a standard command). Most command names 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, @code{@{...@}}. Optional arguments are contained in square brackets, @code{[...]}. 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@tie{}(@code{]}) hide it inside curly braces, as in@tie{}@code{\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. @LaTeX{} has the convention that some commands have a @code{*} form that is related to the form without a @code{*}, such as @code{\chapter} and @code{\chapter*}. The exact difference in behavior varies from command to command. This manual describes all accepted options and @code{*}-forms for the commands it covers (barring unintentional omissions, a.k.a.@: bugs). @PkgIndex{expl3} @PkgIndex{xparse} @cindex @LaTeX{}3 syntax As of the 2020-10-01 release of @LaTeX{}, the @package{expl3} and @package{xparse} packages are part of the @LaTeX{}2e format. They provide a completely different underlying programming language syntax. We won't try to cover them in this document; see the related package documentation and other @LaTeX{} manuals. @node Environment @section Environment Synopsis: @example \begin@{@var{environment-name}@} ... \end@{@var{environment-name}@} @end example An @dfn{environment} is an area of @LaTeX{} source, inside of which there is a distinct behavior. For instance, for poetry in @LaTeX{} put the lines between @code{\begin@{verse@}} and @code{\end@{verse@}}. @example \begin@{verse@} There once was a man from Nantucket \\ ... \end@{verse@} @end example @xref{Environments}, for a list of environments. Particularly notable is that every @LaTeX{} document must have a @code{document} environment, a @code{\begin@{document@} ... \end@{document@}} pair. The @var{environment-name} at the beginning must exactly match that at the end. This includes the case where @var{environment-name} ends in a star@tie{}(@code{*}); both the @code{\begin} and @code{\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). @example \begin@{tabular@}[t]@{r|l@} ... rows of table ... \end@{tabular@} @end example @node CTAN @section CTAN: The Comprehensive @TeX{} Archive Network @cindex CTAN 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 @url{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 @code{ctan.org} web site offers features such as search by name or by functionality. @cindex DANTE e.V. CTAN is not a single host, but instead is a set of hosts, one of which is the so-called ``master''. The master host actively manages the material, for instance, by accepting uploads of new or updated packages. For many years, it has been hosted by the German @TeX{} group, DANTE e.V. @cindex mirrors of CTAN Other sites around the world help out by mirroring, that is, automatically syncing their collections with the master 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 master site. The list of mirrors is at @url{https://ctan.org/mirrors}. @node Document classes @chapter Document classes @cindex document classes @cindex classes of documents @findex \documentclass The document's overall class is defined with this command, which is normally the first command in a @LaTeX{} source file. @example \documentclass[@var{options}]@{@var{class}@} @end example @findex article @r{class} @findex report @r{class} @findex book @r{class} @findex letter @r{class} @findex slides @r{class} The following document @var{class} names are built into @LaTeX{}. (Many other document classes are available as separate packages; @pxref{Overview}.) @table @code @item article @anchor{document classes article} For a journal article, a presentation, and miscellaneous general use. @item book @anchor{document classes book} Full-length books, including chapters and possibly including front matter, such as a preface, and back matter, such as an appendix (@pxref{Front/back matter}). @item letter @anchor{document classes letter} Mail, optionally including mailing labels (@pxref{Letters}). @item report @anchor{document classes report} For documents of length between an @code{article} and a @code{book}, such as technical reports or theses, which may contain several chapters. @item slides @anchor{document classes slides} For slide presentations---rarely used nowadays. The @package{beamer} package is perhaps the most prevalent (@url{https://ctan.org/pkg/beamer}). @xref{beamer template}, for a small template for a beamer document. @end table Standard @var{options} are described in the next section. @menu * Document class options:: Global options. * Additional packages:: Bring in packages. * Class and package construction:: Create new classes and packages. @end menu @node Document class options @section Document class options @cindex document class options @cindex options, document class @cindex class options @cindex global options You can specify @dfn{global options} or @dfn{class options} to the @code{\documentclass} command by enclosing them in square brackets. To specify more than one @var{option}, separate them with a comma. @example \documentclass[@var{option1},@var{option2},...]@{@var{class}@} @end example Here is the list of the standard class options. @findex 10pt @r{option} @findex 11pt @r{option} @findex 12pt @r{option} All of the standard classes except @code{slides} accept the following options for selecting the typeface size (default is @code{10pt}): @example 10pt 11pt 12pt @end example @findex a4paper @r{option} @findex a5paper @r{option} @findex b5paper @r{option} @findex executivepaper @r{option} @findex legalpaper @r{option} @findex letterpaper @r{option} All of the standard classes accept these options for selecting the paper size (these show height by width): @table @code @item a4paper 210 by 297@dmn{mm} (about 8.25 by 11.75@tie{}inches) @item a5paper 148 by 210@dmn{mm} (about 5.8 by 8.3@tie{}inches) @item b5paper 176 by 250@dmn{mm} (about 6.9 by 9.8@tie{}inches) @item executivepaper 7.25 by 10.5@tie{}inches @item legalpaper 8.5 by 14@tie{}inches @item letterpaper 8.5 by 11@tie{}inches (the default) @end table @findex \pdfpagewidth @findex \pdfpageheight @PkgIndex{geometry} When using one of the engines pdf@LaTeX{}, Lua@LaTeX{}, or Xe@LaTeX{} (@pxref{@TeX{} engines}), options other than @code{letterpaper} set the print area but you must also set the physical paper size. One way to do that is to put @code{\pdfpagewidth=\paperwidth} and @code{\pdfpageheight=\paperheight} in your document's preamble. @PkgIndex{geometry} The @package{geometry} package provides flexible ways of setting the print area and physical page size. @findex draft @r{option} @findex final @r{option} @findex fleqn @r{option} @findex landscape @r{option} @findex leqno @r{option} @findex openbib @r{option} @findex titlepage @r{option} @findex notitlepage @r{option} Miscellaneous other options: @table @code @item draft @itemx final @cindex black boxes, omitting Mark (@code{draft}) or do not mark (@code{final}) overfull boxes with a black box in the margin; default is @code{final}. @item fleqn @cindex flush left equations @cindex centered equations @cindex equations, flush left vs.@: centered Put displayed formulas flush left; default is centered. @item landscape @cindex landscape orientation @cindex portrait orientation Selects landscape format; default is portrait. @item leqno @cindex left-hand equation numbers @cindex right-hand equation numbers @cindex equation numbers, left vs.@: right Put equation numbers on the left side of equations; default is the right side. @item openbib @cindex bibliography format, open Use ``open'' bibliography format. @item titlepage @itemx notitlepage @cindex title page, separate or run-in Specifies whether there is a separate page for the title information and for the abstract also, if there is one. The default for the @code{report} class is @code{titlepage}, for the other classes it is @code{notitlepage}. @end table The following options are not available with the @code{slides} class. @findex onecolumn @r{option} @findex twocolumn @r{option} @findex oneside @r{option} @findex twoside @r{option} @findex openright @r{option} @findex openany @r{option} @table @code @item onecolumn @itemx twocolumn Typeset in one or two columns; default is @code{onecolumn}. @item oneside @itemx twoside @findex \evensidemargin @findex \oddsidemargin @c xx TODO re-align on the French version which is more accurate. Selects one- or two-sided layout; default is @code{oneside}, except that in the @code{book} class the default is @code{twoside}. For one-sided printing, the text is centered on the page. For two-sided printing, the @code{\evensidemargin} (@code{\oddsidemargin}) parameter determines the distance on even (odd) numbered pages between the left side of the page and the text's left margin, with @code{\oddsidemargin} being 40% of the difference between @code{\paperwidth} and @code{\textwidth}, and @code{\evensidemargin} is the remainder. @item openright @itemx openany Determines if a chapter should start on a right-hand page; default is @code{openright} for @code{book}, and @code{openany} for @code{report}. @end table @findex clock @r{option to @code{slides} class} The @code{slides} class offers the option @code{clock} for printing the time at the bottom of each note. @node Additional packages @section Additional packages @cindex loading additional packages @cindex packages, loading additional @cindex additional packages, loading @findex \usepackage Load a package @var{pkg}, with the package options given in the comma-separated list @var{options}, as here. @example \usepackage[@var{options}]@{@var{pkg}@}. @end example To specify more than one package you can separate them with a comma, as in @code{\usepackage@{@var{pkg1},@var{pkg2},...@}}, or use multiple @code{\usepackage} commands. @cindex global options @cindex options, global Any options given in the @code{\documentclass} command that are unknown to the selected document class are passed on to the packages loaded with @code{\usepackage}. @node Class and package construction @section Class and package construction @cindex document class commands @cindex commands, document class @cindex new class commands 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 @code{smcmemo.cls} and begin your documents with @code{\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 @code{Memo from the SMC Math Department} is for a class. @cindex class and package difference @cindex difference between class and package Inside of a class or package file you can use the at-sign @code{@@} as a character in command names without having to surround the code containing that command with @code{\makeatletter} and @code{\makeatother}. @xref{\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 @code{smcmemo} might have commands @code{\smc@@tolist}, @code{\smc@@fromlist}, etc. @menu * Class and package structure:: Layout of the file. * Class and package commands:: List of commands. @end menu @node Class and package structure @subsection Class and package structure @cindex class and package structure @cindex class file layout @cindex package file layout @cindex options, document class @cindex options, package @cindex class options @cindex package options A class file or package file typically has four parts. @enumerate @item In the @dfn{identification part}, the file says that it is a @LaTeX{} package or class and describes itself, using the @code{\NeedsTeXFormat} and @code{\ProvidesClass} or @code{\ProvidesPackage} commands. @item The @dfn{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 @code{smcmemo} class might be called with an option to read in a file with a list of people for the to-head, as @code{\documentclass[mathto]@{smcmemo@}}, and therefore needs to define a command @code{\newcommand@{\setto@}[1]@{\def\@@tolist@{#1@}@}} used in that file. @item In the @dfn{handle options part} the class or package declares and processes its options. Class options allow a user to start their document as @code{\documentclass[@var{option list}]@{@var{class name}@}}, to modify the behavior of the class. An example is when you declare @code{\documentclass[11pt]@{article@}} to set the default document font size. @item Finally, in the @dfn{more declarations part} the class or package usually does most of its work: declaring new variables, commands and fonts, and loading other files. @end enumerate Here is a starting class file, which should be saved as @file{stub.cls} where @LaTeX{} can find it, for example in the same directory as the @file{.tex} file. @example \NeedsTeXFormat@{LaTeX2e@} \ProvidesClass@{stub@}[2017/07/06 stub to start building classes from] \DeclareOption*@{\PassOptionsToClass@{\CurrentOption@}@{article@}@} \ProcessOptions\relax \LoadClass@{article@} @end example @cindex class file example @noindent It identifies itself, handles the class options via the default of passing them all to the @code{article} class, and then loads the @code{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 @url{https://www.latex-project.org/help/documentation/clsguide.pdf} (much of the descriptions here derive from this document), or the tutorial @url{https://www.tug.org/TUGboat/tb26-3/tb84heff.pdf}. @node Class and package commands @subsection Class and package commands @cindex class and package commands @cindex commands, class and package These are the commands designed to help writers of classes or packages. @table @code @item \AtBeginDvi@{specials@} @findex \AtBeginDvi Save in a box register things that are written to the @file{.dvi} file at the beginning of the shipout of the first page of the document. @item \AtEndOfClass@{@var{code}@} @item \AtEndOfPackage@{@var{code}@} @findex \AtEndOfClass @findex \AtEndOfPackage Hook to insert @var{code} to be executed when @LaTeX{} finishes processing the current class or package. You can use these hooks multiple times; the @code{code} will be executed in the order that you called it. See also @ref{\AtBeginDocument}. @item \CheckCommand@{@var{cmd}@}[@var{num}][@var{default}]@{@var{definition}@} @item \CheckCommand*@{@var{cmd}@}[@var{num}][@var{default}]@{@var{definition}@} @findex \CheckCommand @findex \CheckCommand* @cindex new command, check Like @code{\newcommand} (@pxref{\newcommand & \renewcommand}) but does not define @var{cmd}; instead it checks that the current definition of @var{cmd} is exactly as given by @var{definition} and is or is not @cindex long command @dfn{long} as expected. A long command is a command that accepts @code{\par} within an argument. The @var{cmd} command is expected to be long with the unstarred version of @code{\CheckCommand}. Raises an error when the check fails. This allows you to check before you start redefining @code{cmd} yourself that no other package has already redefined this command. @item \ClassError@{@var{class name}@}@{@var{error text}@}@{@var{help text}@} @item \PackageError@{@var{package name}@}@{@var{error text}@}@{@var{help text}@} @item \ClassWarning@{@var{class name}@}@{@var{warning text}@} @item \PackageWarning@{@var{package name}@}@{@var{warning text}@} @item \ClassWarningNoLine@{@var{class name}@}@{@var{warning text}@} @item \PackageWarningNoLine@{@var{package name}@}@{@var{warning text}@} @item \ClassInfo@{@var{class name}@}@{@var{info text}@} @item \PackageInfo@{@var{package name}@}@{@var{info text}@} @item \ClassInfoNoLine@{@var{class name}@}@{@var{info text}@} @item \PackageInfoNoLine@{@var{package name}@}@{@var{info text}@} @findex \ClassError @findex \PackageError @findex \ClassWarning @findex \PackageWarning @findex \ClassWarningNoLine @findex \PackageWarningNoLine @findex \ClassInfo @findex \PackageInfo @findex \ClassInfoNoLine @findex \PackageInfoNoLine Produce an error message, or warning or informational messages. For @code{\ClassError} and @code{\PackageError} the message is @var{error text}, followed by @TeX{}'s @code{?} error prompt. If the user then asks for help by typing @code{h}, they see the @var{help text}. The four warning commands are similar except that they write @var{warning text} on the screen with no error prompt. The four info commands write @var{info text} only in the transcript file. The @code{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 @var{help text}: use @code{\protect} to stop a command from expanding, get a line break with @code{\MessageBreak}, and get a space with @code{\space} when a space character does not allow it, like after a command. Note that @LaTeX{} appends a period to the messages. @item \CurrentOption @findex \CurrentOption Expands to the name of the currently-being-processed option. Can only be used within the @var{code} argument of either @code{\DeclareOption} or @code{\DeclareOption*}. @item \DeclareOption@{@var{option}@}@{@var{code}@} @item \DeclareOption*@{@var{code}@} @findex \DeclareOption @findex \DeclareOption* @cindex class options @cindex package options @cindex options, class @cindex options, package Make an option available to a user to invoke in their @code{\documentclass} command. For example, the @code{smcmemo} class could have an option @code{\documentclass[logo]@{smcmemo@}} allowing users to put the institutional logo on the first page. The class file must contain @code{\DeclareOption@{logo@}@{@var{code}@}} (and later, @code{\ProcessOptions}). If you request an option that has not been declared, by default this will produce a warning like @code{Unused global option(s): [badoption].} Change this behavior with the starred version @code{\DeclareOption*@{@var{code}@}}. For example, many classes extend an existing class, using a command such as @code{\LoadClass@{article@}}, and for passing extra options to the underlying class use code such as this. @example \DeclareOption*@{% \PassOptionsToClass@{\CurrentOption@}@{article@}% @} @end example Another example is that the class @code{smcmemo} may allow users to keep lists of memo recipients in external files. Then the user could invoke @code{\documentclass[math]@{smcmemo@}} and it will read the file @code{math.memo}. This code handles the file if it exists and otherwise passes the option to the @code{article} class. @example \DeclareOption*@{\InputIfFileExists@{\CurrentOption.memo@}@{@}@{% \PassOptionsToClass@{\CurrentOption@}@{article@}@}@} @end example @item \DeclareRobustCommand@{@var{cmd}@}[@var{num}][@var{default}]@{@var{definition}@} @item \DeclareRobustCommand*@{@var{cmd}@}[@var{num}][@var{default}]@{@var{definition}@} @findex \DeclareRobustCommand @findex \DeclareRobustCommand* @cindex new command, definition Like @code{\newcommand} and @code{\newcommand*} (@pxref{\newcommand & \renewcommand}) but these declare a robust command, even if some code within the @var{definition} is fragile. (For a discussion of robust and fragile commands @pxref{\protect}.) Use this command to define new robust commands or to redefine existing commands and make them robust. Unlike @code{\newcommand} these do not give an error if macro @var{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 @code{\newcommand} so unless the command's data is fragile and the command is used within a moving argument, use @code{\newcommand}. @PkgIndex{etoolbox} The @package{etoolbox} package offers the commands @code{\newrobustcmd}, @code{\newrobustcmd*}, as well as the commands @code{\renewrobustcmd}, @code{\renewrobustcmd*}, and the commands @code{\providerobustcmd}, and @code{\providerobustcmd*}. These are similar to @code{\newcommand}, @code{\newcommand*}, @code{\renewcommand}, @code{\renewcommand*}, @code{\providecommand}, and @code{\providecommand*}, but define a robust @var{cmd} with two advantages as compared to @code{\DeclareRobustCommand}: @enumerate @item They use the low-level e-@TeX{} protection mechanism rather than the higher level @LaTeX{} @code{\protect} mechanism, so they do not incur the slight loss of performance mentioned above, and @item They make the same distinction between @code{\new@dots{}}, @code{\renew@dots{}}, and @code{\provide@dots{}}, as the standard commands, so they do not just make a log message when you redefine @var{cmd} that already exists, in that case you need to use either @code{\renew@dots{}} or @code{\provide@dots{}} or you get an error. @end enumerate @item \IfFileExists@{@var{filename}@}@{@var{true code}@}@{@var{false code}@} @item \InputIfFileExists@{@var{filename}@}@{@var{true code}@}@{@var{false code}@} @findex \IfFileExists @findex \InputIfFileExists Execute @var{true code} if @LaTeX{} finds the file @file{@var{file name}} or @var{false code} otherwise. In the first case it executing @var{true code} and then inputs the file. Thus the command @example \IfFileExists@{img.pdf@}@{% \includegraphics@{img.pdf@}@}@{\typeout@{!! img.pdf not found@} @end example @noindent will include the graphic @file{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 @code{\IfFileExists@{./filename@}@{@var{true code}@}@{@var{false code}@}}. If you ask for a filename without a @code{.tex} extension then @LaTeX{} will first look for the file by appending the @code{.tex}; for more on how @LaTeX{} handles file extensions see @ref{\input}. @item \LoadClass[@var{options list}]@{@var{class name}@}[@var{release date}] @item \LoadClassWithOptions@{@var{class name}@}[@var{release date}] @findex \LoadClass @findex \LoadClassWithOptions Load a class, as with @code{\documentclass[@var{options list}]@{@var{class name}@}[@var{release info}]}. An example is @code{\LoadClass[twoside]@{article@}}. The @var{options list}, if present, is a comma-separated list. The @var{release date} is optional. If present it must have the form @var{YYYY/MM/DD}. @c BTW, there are at-macros documented in macros2e.pdf to check the version @c and do some actions conditionnally on version later or not to some @c date. If you request a @var{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. @example 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. @end example The command version @code{\LoadClassWithOptions} uses the list of options for the current class. This means it ignores any options passed to it via @code{\PassOptionsToClass}. This is a convenience command that lets you build classes on existing ones, such as the standard @code{article} class, without having to track which options were passed. @item \ExecuteOptions@{@var{options-list}@} @findex \ExecuteOptions For each option @var{option} in the @var{options-list}, in order, this command executes the command @code{\ds@@@var{option}}. If this command is not defined then that option is silently ignored. It can be used to provide a default option list before @code{\ProcessOptions}. For example, if in a class file you want the default to be 11pt fonts then you could specify @code{\ExecuteOptions@{11pt@}\ProcessOptions\relax}. @item \NeedsTeXFormat@{@var{format}@}[@var{format date}] @findex \NeedsTeXFormat 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: @code{\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 @var{format} string is case sensitive). If it does not match then execution stops with an error like @samp{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 @var{format date} on which those features were implemented. If present it must be in the form @code{YYYY/MM/DD}. If the format version installed on your system is earlier than @var{format date} then you get a warning like this. @example You have requested release `2038/01/20' of LaTeX, but only release `2016/02/01' is available. @end example @item \OptionNotUsed @findex \OptionNotUsed Adds the current option to the list of unused options. Can only be used within the @var{code} argument of either @code{\DeclareOption} or @code{\DeclareOption*}. @c I cannot reproduce this behavior as it is documented in clsguide. @c In the absence of a @code{\DeclareOption*} declaration, @LaTeX{} issues @c on the console a warning like @code{LaTeX Warning: Unused global @c option(s): [unusedoption].} with the list of not-used options when it @c reaches @code{\begin@{document@}}. @item \PassOptionsToClass@{@var{option list}@}@{@var{class name}@} @item \PassOptionsToPackage@{@var{option list}@}@{@var{package name}@} @findex \PassOptionsToClass @findex \PassOptionsToPackage Adds the options in the comma-separated list @var{option list} to the options used by any future @code{\RequirePackage} or @code{\usepackage} command for package @var{package name} or the class @var{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 @code{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 @code{\RequirePackage[landscape]@{geometry@}} and @code{\RequirePackage[margins=1in]@{geometry@}} with the single command @code{\RequirePackage[landscape,margins=1in]@{geometry@}}. However, imagine that you are loading @file{firstpkg} and inside that package it loads @file{secondpkg}, and you need the second package to be loaded with option @code{draft}. Then before doing the first package you must queue up the options for the second package, like this. @example \PassOptionsToPackage@{draft@}@{secondpkg@} \RequirePackage@{firstpkg@} @end example @noindent (If @code{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 @code{graphicx} package with the option @code{draft} and also wants to use a class @code{foo} that loads the @code{graphicx} package, but without that option. The user could start their @LaTeX{} file with @code{\PassOptionsToPackage@{draft@}@{graphicx@}\documentclass@{foo@}}. @item \ProcessOptions @item \ProcessOptions*@var{\@@options} @findex \ProcessOptions @findex \ProcessOptions* Execute the code for each option that the user has invoked. Include it in the class file as @code{\ProcessOptions\relax} (because of the existence of the starred command). Options come in two types. @dfn{Local options} have been specified for this particular package in the @var{options} argument of @code{\PassOptionsToPackage@{@var{options}@}}, @code{\usepackage[@var{options}]}, or @code{\RequirePackage[@var{options}]}. @dfn{Global options} are those given by the class user in @code{\documentclass[@var{options}]} (If an option is specified both locally and globally then it is local.) When @code{\ProcessOptions} is called for a package @file{pkg.sty}, the following happens: @enumerate @item For each option @var{option} so far declared with @code{\DeclareOption}, it looks to see if that option is either a global or a local option for @code{pkg}. If so then it executes the declared code. This is done in the order in which these options were given in @file{pkg.sty}. @item For each remaining local option, it executes the command @code{\ds@@}@var{option} if it has been defined somewhere (other than by a @code{\DeclareOption}); otherwise, it executes the default option code given in @code{\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. @end enumerate When @code{\ProcessOptions} is called for a class it works in the same way except that all options are local, and the default @var{code} for @code{\DeclareOption*} is @code{\OptionNotUsed} rather than an error. The starred version @code{\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. @item \ProvidesClass@{@var{class name}@}[@var{release date} @var{brief additional information}] @item \ProvidesClass@{@var{class name}@}[@var{release date}] @item \ProvidesPackage@{@var{package name}@}[@var{release date} @var{brief additional information}] @item \ProvidesPackage@{@var{package name}@}[@var{release date}] @findex \ProvidesClass @findex \ProvidesPackage 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 @code{\documentclass@{smcmemo@}} or @code{\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 @code{\documentclass@{smcmemo@}}, and the file @file{smcmemo.cls} has the statement @code{\ProvidesClass@{xxx@}} then you get a warning like @code{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 @code{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 @file{smcmemo.cls} contains the line @code{\ProvidesClass@{smcmemo@}[2008/06/01 v1.0 SMC memo class]} and your document's first line is @code{\documentclass@{smcmemo@}} then you will see @code{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 @var{release date}. For instance, a user could enter @code{\documentclass@{smcmemo@}[2018/10/12]} or @code{\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.) @item \ProvidesFile@{@var{filename}@}[@var{additional information}] @findex \ProvidesFile 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 @code{File: test.config 2017/10/12 config file for test.cls} for @var{filename} equal to @samp{test.config} and @var{additional information} equal to @samp{2017/10/12 config file for test.cls}. @item \RequirePackage[@var{option list}]@{@var{package name}@}[@var{release date}] @item \RequirePackageWithOptions@{@var{package name}@}[@var{release date}] @findex \RequirePackage @findex \RequirePackageWithOptions Load a package, like the command @code{\usepackage} (@pxref{Additional packages}). The @LaTeX{} development team strongly recommends use of these commands over Plain@tie{}@TeX{}'s @code{\input}; see the Class Guide. An example is @code{\RequirePackage[landscape,margin=1in]@{geometry@}}. The @var{option list}, if present, is a comma-separated list. The @var{release date}, if present, must have the form @var{YYYY/MM/DD}. If the release date of the package as installed on your system is earlier than @var{release date} then you get a warning like @code{You have requested, on input line 9, version `2017/07/03' of package jhtest, but only version `2000/01/01' is available}. The @code{\RequirePackageWithOptions} version uses the list of options for the current class. This means it ignores any options passed to it via @code{\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 @code{\usepackage} and @code{\RequirePackage} is small. The @code{\usepackage} command is intended for the document file while @code{\RequirePackage} is intended for package and class files. Thus, using @code{\usepackage} before the @code{\documentclass} command causes @LaTeX{} to give error like @code{\usepackage before \documentclass}, but you can use @code{\RequirePackage} there. @end table @node Fonts @chapter Fonts @anchor{Typefaces}@c old name @cindex typefaces @cindex fonts @LaTeX{} comes with powerful font capacities. For one thing, its New Font Selection Scheme allows you to work easily with the font families in your document (for instance, see@tie{}@ref{Font styles}). And, @LaTeX{} documents can use most fonts that are available today, including versions of Times Roman, Helvetica, Courier, etc. (Note, though, that many fonts do not have support for mathematics.) The first typeface in the @TeX{} world was the Computer Modern family, developed by Donald Knuth. It is the default for @LaTeX{} documents and is still the most widely used. But changing to another font often only involves a few commands. For instance, putting the following in your preamble gives you a Palatino-like font, which is handsome and more readable online than many other fonts, while still allowing you to typeset mathematics. (This example is from Michael Sharpe, @url{https://math.ucsd.edu/~msharpe/RcntFnts.pdf}.) @example \usepackage[osf]@{newpxtext@} % osf for text, not math \usepackage@{cabin@} % sans serif \usepackage[varqu,varl]@{inconsolata@} % sans serif typewriter \usepackage[bigdelims,vvarbb]@{newpxmath@} % bb from STIX \usepackage[cal=boondoxo]@{mathalfa@} % mathcal @end example @noindent In addition, the @command{xelatex} or @command{lualatex} engines allow you to use any fonts on your system that are in OpenType or TrueType format (@pxref{@TeX{} engines}). The @LaTeX{} Font Catalogue (@url{https://tug.org/FontCatalogue}) shows font sample graphics and copy-and-pasteable source to use many fonts, including many with support for mathematics. It aims to cover all Latin alphabet free fonts available for easy use with @LaTeX{}. More information is also available from the @TeX{} Users Group, at @url{https://www.tug.org/fonts/}. @menu * fontenc package:: Encoding of the font. * Font styles:: Select roman, italics, etc. * Font sizes:: Select point size. * Low-level font commands:: Select encoding, family, series, shape. @end menu @node fontenc package @section @code{fontenc} package @cindex font encoding @cindex UTF-8, font support for @cindex T1 @cindex OT1 @findex fontenc Synopsis: @example \usepackage[@var{font_encoding}]@{fontenc@} @end example or @example \usepackage[@var{font_encoding1}, @var{font_encoding2}, ...]@{fontenc@} @end example Specify the font encodings. A font encoding is a mapping of the character codes to the font glyphs that are used to typeset your output. @PkgIndex{fontspec} This package only applies if you use the @code{pdflatex} engine (@pxref{@TeX{} engines}). If you use the @command{xelatex} or @command{lualatex} engine then instead use the @package{fontspec} package. @TeX{}'s original font family, Computer Modern, has a limited character set. For instance, to make common accented characters you must use @code{\accent} (@pxref{\accent}) but this disables hyphenation. @TeX{} users have agreed on a number of standards to access the larger sets of characters provided by modern fonts. If you are using @command{pdflatex} then put this in the preamble @example \usepackage[T1]@{fontenc@} @end example @noindent gives you support for the most widespread European languages, including French, German, Italian, Polish, and others. In particular, if you have words with accented letters then @LaTeX{} will hyphenate them and your output can be copied and pasted. (The optional second line allows you to directly enter accented characters into your source file.) @PkgIndex{lmodern} @PkgIndex{cm-super} If you are using an encoding such as @code{T1} and the characters appear blurry or do not magnify well then your fonts may be bitmapped, sometimes called raster or Type@tie{}3. You want vector fonts. Use a package such as @package{lmodern} or @package{cm-super} to get a font that extends @LaTeX{}'s default using vector fonts. For each @var{font_encoding} given as an option but not already declared, this package loads the encoding definition files, named @file{@var{font_encoding}enc.def}. It also sets @code{\encodingdefault} to be the last encoding in the option list. These are the common values for @var{font_encoding}. @table @code @item OT1 The original encoding for @TeX{}. Limited to mostly English characters. @item OMS, OML Math symbols and math letters encoding. @item T1 @TeX{} text extended. Sometimes called the Cork encoding for the Users Group meeting where it was developed. Gives access to most European accented characters. The most common option for this package. @item TS1 Text Companion encoding. @end table @noindent @LaTeX{}'s default is to load @code{OML}, @code{T1}, @code{OT1}, and then @code{OMS}, and set the default to @code{OT1}. Even if you do not use accented letters, you may need to specify a font encoding if your font requires it. If you use @code{T1}@tie{}encoded fonts other than the default Computer Modern family then you may need to load the package that selects your fonts before loading @file{fontenc}, to prevent the system from loading any @code{T1}@tie{}encoded fonts from the default. The @LaTeX{} team reserve encoding names starting with: @samp{T} for the standard text encodings with 256 characters, @samp{TS} for symbols that extend the corresponding T encodings, @samp{X} for test encodings, @samp{M} for standard math encodings with 256 characters, @samp{A} for special applications, @samp{OT} for standard text encodings with 128 characters, and @samp{OM} for standard math encodings with 128 characters (@samp{O} stands for @samp{obsolete}). This package provides a number of commands, detailed below. Many of them are encoding-specific, so if you have defined a command that works for one encoding but the current encoding is different then the command is not in effect. @menu * \DeclareFontEncoding:: Define an encoding. * \DeclareTextAccent:: Define an accent in the encoding. * \DeclareTextAccentDefault:: Fallback for using an accent in the encoding. * \DeclareTextCommand & \ProvideTextCommand:: New encoding-specific command. * \DeclareTextCommandDefault & \ProvideTextCommandDefault:: Fallback for encoding-specific commands. * \DeclareTextComposite:: Directly access an accented glyph, in the encoding. * \DeclareTextCompositeCommand:: Run code in slot, in the encoding. * \DeclareTextSymbol:: Define a symbol in the encoding. * \DeclareTextSymbolDefault:: Fallback for a symbol in the encoding. * \LastDeclaredEncoding:: Save most recently declared encoding. * \UseTextSymbol & \UseTextAccent:: Temporarily switch to another encoding. @end menu @node \DeclareFontEncoding @subsection @code{\DeclareFontEncoding} @cindex font encoding, declaring @cindex encoding, font @cindex accents, defining @findex \DeclareFontEncoding Synopsis: @example \DeclareFontEncoding@{@var{encoding}@}@{@var{text-settings}@}@{@var{math-settings}@} @end example Declare the font encoding @var{encoding}. It also saves the value of @var{encoding} in @code{\LastDeclaredEncoding} (@pxref{\LastDeclaredEncoding}). The file @file{t1enc.def} contains this line (followed by many others). @example \DeclareFontEncoding@{T1@}@{@}@{@} @end example The @var{text-settings} are the commands that @LaTeX{} will run every time it switches from one encoding to another with the @code{\selectfont} and @code{\fontencoding} commands. The @var{math-settings} are the commands that @LaTeX{} will use whenever the font is accessed as a math alphabet. @LaTeX{} ignores any space characters inside @var{text-settings} and @var{math-settings}, to prevent unintended spaces in the output. If you invent an encoding you should pick a two or three letter name starting with @samp{L} for @samp{local}, or @samp{E} for @samp{experimental}. Note that output encoding files may be read several times by @LaTeX{} so using, e.g., @code{\newcommand} may cause an error. In addition, such files should contain @code{\ProvidesFile} line (@pxref{Class and package commands}). Note also that you should use the @code{\...Default} commands only in a package, not in the encoding definition files, since those files should only contain declarations specific to that encoding. @node \DeclareTextAccent @subsection @code{\DeclareTextAccent} @cindex font encoding @cindex accents, defining @findex \DeclareTextAccent Synopsis: @example \DeclareTextAccent@{@var{cmd}@}@{@var{encoding}@}@{@var{slot}@} @end example Define an accent, to be put on top of other glyphs, in the encoding @var{encoding} at the location @var{slot}. @cindex slot, font A @dfn{slot} is the number identifying a glyph within a font. This line from @file{t1enc.def} declares that to make a circumflex accent as in @code{\^A}, the system will put the accent in slot@tie{}2 over the @samp{A} character, which is represented in ASCII as@tie{}65. (This holds unless there is a relevant @code{DeclareTextComposite} or @code{\DeclareTextCompositeCommand} declaration; @pxref{\DeclareTextComposite}.) @example \DeclareTextAccent@{\^@}@{T1@}@{2@} @end example If @var{cmd} has already been defined then @code{\DeclareTextAccent} does not give an error but it does log the redefinition in the transcript file. @node \DeclareTextAccentDefault @subsection @code{\DeclareTextAccentDefault} @cindex accents, defining @findex \DeclareTextAccent @findex \DeclareTextAccentDefault Synopsis: @example \DeclareTextAccentDefault@{\@var{cmd}@}@{@var{encoding}@} @end example If there is an encoding-specific accent command \@var{cmd} but there is no associated @code{\DeclareTextAccent} for that encoding then this command will pick up the slack, by saying to use it as described for @var{encoding}. For example, to make the encoding @code{OT1} be the default encoding for the accent @code{\"}, declare this. @example \DeclareTextAccentDefault@{\"@}@{OT1@} @end example @noindent If you issue a @code{\"} when the current encoding does not have a definition for that accent then @LaTeX{} will use the definition from @code{OT1} That is, this command is equivalent to this call (@pxref{\UseTextSymbol & \UseTextAccent}). @example \DeclareTextCommandDefault[1]@{\@var{cmd}@} @{\UseTextAccent@{@var{encoding}@}@{\@var{cmd}@}@{#1@}@} @end example Note that @code{\DeclareTextAccentDefault} works for any one-argument @file{fontenc} command, not just the accent command. @node \DeclareTextCommand & \ProvideTextCommand @subsection @code{\DeclareTextCommand} & @code{\ProvideTextCommand} @findex \DeclareTextCommand @findex \ProvideTextCommand Synopsis, one of: @example \DeclareTextCommand@{\@var{cmd}@}@{@var{encoding}@}@{@var{defn}@} \DeclareTextCommand@{\@var{cmd}@}@{@var{encoding}@}[@var{nargs}]@{@var{defn@}} \DeclareTextCommand@{\@var{cmd}@}@{@var{encoding}@}[@var{nargs}][@var{optargdefault}]@{@var{defn}@} @end example or one of: @example \ProvideTextCommand@{\@var{cmd}@}@{@var{encoding}@}@{@var{defn}@} \ProvideTextCommand@{\@var{cmd}@}@{@var{encoding}@}[@var{nargs}]@{@var{defn}@} \ProvideTextCommand@{\@var{cmd}@}@{@var{encoding}@}[@var{nargs}][@var{optargdefault}]@{@var{defn}@} @end example Define the command @code{\@var{cmd}}, which will be specific to one encoding. The command name @var{cmd} must be preceded by a backslash, @code{\}. These commands can only appear in the preamble. Redefining \@var{cmd} does not cause an error. The defined command will be robust even if the code in @var{defn} is fragile (@pxref{\protect}). For example, the file @file{t1enc.def} contains this line. @example \DeclareTextCommand@{\textperthousand@}@{T1@}@{\%\char 24 @} @end example With that, you can express parts per thousand. @example \usepackage[T1]@{fontenc@} % in preamble ... Legal limit is \( 0.8 \)\textperthousand. @end example @noindent If you change the font encoding to @code{OT1} then you get an error like @samp{LaTeX Error: Command \textperthousand unavailable in encoding OT1}. @findex \DeclareTextSymbol The @code{\ProvideTextCommand} variant does the same, except that it does nothing if @code{\@var{cmd}} is already defined. The @code{\DeclareTextSymbol} command is faster than this one for simple slot-to-glyph association (@pxref{\DeclareTextSymbol}) The optional @var{nargs} and @var{optargdefault} arguments play the same role here as in @code{\newcommand} (@pxref{\newcommand & \renewcommand}). Briefly, @var{nargs} is an integer from 0 to 9 specifying the number of arguments that the defined command @code{\@var{cmd}} takes. This number includes any optional argument. Omitting this argument is the same as specifying 0, meaning that @code{\@var{cmd}} will have no arguments. And, if @var{optargdefault} is present then the first argument of @code{\@var{cmd}} is optional, with default value @var{optargdefault} (which may be the empty string). If @var{optargdefault} is not present then @code{\@var{cmd}} does not take an optional argument. @node \DeclareTextCommandDefault & \ProvideTextCommandDefault @subsection @code{\DeclareTextCommandDefault} & @code{\ProvideTextCommandDefault } @findex \DeclareTextCommand @findex \DeclareTextCommandDefault @findex \ProvideTextCommand @findex \ProvideTextCommandDefault Synopsis: @example \DeclareTextCommandDefault@{\@var{cmd}@}@{@var{defn}@} @end example or: @example \ProvideTextCommandDefault@{\@var{cmd}@}@{@var{defn}@} @end example Give a default definition for @code{\@var{cmd}}, for when that command is not defined in the encoding currently in force. This default should only use encodings known to be available. This makes @code{\copyright} available. @example \DeclareTextCommandDefault@{\copyright@}@{\textcircled@{c@}@} @end example @noindent It uses only an encoding (OMS) that is always available. The @code{\DeclareTextCommandDefault} should not occur in the encoding definition files since those files should declare only commands for use when you select that encoding. It should instead be in a package. As with the related non-default commands, the @code{\ProvideTextCommandDefault} has exactly the same behavior as @code{\DeclareTextCommandDefault} except that it does nothing if @code{\@var{cmd}} is already defined (@pxref{\DeclareTextCommand & \ProvideTextCommand}). So, packages can use it to provide fallbacks that other packages can improve upon. @node \DeclareTextComposite @subsection @code{\DeclareTextComposite} @cindex accents, defining @findex \DeclareTextComposite Synopsis: @example \DeclareTextComposite@{\@var{cmd}@}@{@var{encoding}@}@{@var{simple_object}@}@{@var{slot}@} @end example Access an accented glyph directly, that is, without having to put an accent over a separate character. This line from @file{t1enc.def} means that @code{\^o} will cause @LaTeX{} to typeset lowercase@tie{}@samp{o} by taking the character directly from slot 224 in the font. @example \DeclareTextComposite@{\^@}@{T1@}@{o@}@{244@} @end example @xref{fontenc package}, for a list of common encodings. The @var{simple_object} should be a single character or a single command. The @var{slot} argument is usually a positive integer represented in decimal (although octal or hexadecimal are possible). Normally \@var{cmd} has already been declared for this encoding, either with @code{\DeclareTextAccent} or with a one-argument @code{\DeclareTextCommand}. In @file{t1enc.def}, the above line follows the @code{\DeclareTextAccent@{\^@}@{T1@}@{2@}} command. @node \DeclareTextCompositeCommand @subsection @code{\DeclareTextCompositeCommand} @cindex accents, defining @findex \DeclareTextCompositeCommand Synopsis: @example \DeclareTextCompositeCommand@{\@var{cmd}@}@{@var{encoding}@}@{@var{arg}@}@{@var{code}@} @end example A more general version of @code{\DeclareTextComposite} that runs arbitrary code with @code{\@var{cmd}}. This allows accents on @samp{i} to act like accents on dotless@tie{}i, @code{\i}. @example \DeclareTextCompositeCommand@{\'@}@{OT1@}@{i@}@{\'\i@} @end example @xref{fontenc package}, for a list of common encodings. Normally @code{\@var{cmd}} will have already been declared with @code{\DeclareTextAccent} or as a one argument @code{\DeclareTextCommand}. @node \DeclareTextSymbol @subsection @code{\DeclareTextSymbol} @cindex symbol, defining @findex \DeclareTextSymbol Synopsis: @example \DeclareTextSymbol@{\@var{cmd}@}@{@var{encoding}@}@{@var{slot}@} @end example Define a symbol in the encoding @var{encoding} at the location @var{slot}. Symbols defined in this way are for use in text, not mathematics. For example, this line from @file{t1enc.def} declares the number of the glyph to use for @BES{00AB,\hbox{\guillemotleft}}, the left guillemet. @example \DeclareTextSymbol@{\guillemotleft@}@{T1@}@{19@} @end example @noindent The command @code{\DeclareTextCommand@{\guillemotleft@}@{T1@}@{\char 19@}} has the same effect but is slower (@pxref{\DeclareTextCommand & \ProvideTextCommand}). @xref{fontenc package}, for a list of common encodings. The @var{slot} can be specified in decimal, or octal (as in @code{'023}), or hexadecimal (as in @code{"13}), although decimal has the advantage that single quote or double quote could be redefined by another package. If @code{\@var{cmd}} has already been defined then @code{\DeclareTextSymbol} does not give an error but it does log the redefinition in the transcript file. @node \DeclareTextSymbolDefault @subsection @code{\DeclareTextSymbolDefault} @cindex accents, defining @findex \DeclareTextSymbol @findex \DeclareTextSymbolDefault Synopsis: @example \DeclareTextSymbolDefault@{\@var{cmd}@}@{@var{encoding}@} @end example If there is an encoding-specific symbol command @code{\@var{cmd}} but there is no associated @code{\DeclareTextSymbol} for that encoding, then this command will pick up the slack, by saying to get the symbol as described for @var{encoding}. For example, to declare that if the current encoding has no meaning for @code{\textdollar} then use the one from @code{OT1}, declare this. @example \DeclareTextSymbolDefault@{\textdollar@}@{OT1@} @end example That is, this command is equivalent to this call (@pxref{\UseTextSymbol & \UseTextAccent}). @example \DeclareTextCommandDefault@{\@var{cmd}@} @{\UseTextSymbol@{@var{encoding}@}@{\@var{cmd}@}@} @end example Note that @code{\DeclareTextSymbolDefault} can be used to define a default for any zero-argument @file{fontenc} command. @node \LastDeclaredEncoding @subsection @code{\LastDeclaredEncoding} @findex \LastDeclaredEncoding Synopsis: @example \LastDeclaredEncoding @end example Get the name of the most recently declared encoding. The @code{\DeclareFontEncoding} command stores the name so that it can be retrieved with this command (@pxref{\DeclareFontEncoding}). This relies on @code{\LastDeclaredEncoding} rather than give the name of the encoding explicitly. @example \DeclareFontEncoding@{JH1@}@{@}@{@} \DeclareTextAccent@{\'@}@{\LastDeclaredEncoding@}@{0@} @end example @node \UseTextSymbol & \UseTextAccent @subsection @code{\UseTextSymbol} & @code{\UseTextAccent} @findex \UseTextSymbol @findex \UseTextAccent Synopsis: @example \UseTextSymbol@{@var{encoding}@}@{\@var{cmd}@} @end example or: @example \UseTextAccent@{@var{encoding}@}@{\@var{cmd}@}@{@var{text}@} @end example Use a symbol or accent not from the current encoding. In general, to use a @file{fontenc} command in an encoding where it is not defined, and if the command has no arguments, then you can use it like this: @example \UseTextSymbol@{OT1@}@{\ss@} @end example @noindent which is equivalent to this (note the outer braces form a group, so @LaTeX{} reverts back to the prior encoding after the @code{\ss}): @example @{\fontencoding@{OT1@}\selectfont\ss@} @end example Similarly, to use a @file{fontenc} command in an encoding where it is not defined, and if the command has one argument, you can use it like this: @example \UseTextAccent@{OT1@}@{\'@}@{a@} @end example @noindent which is equivalent to this (again note the outer braces forming a group): @example @{fontencoding@{OT1@}\selectfont\'@{\fontencoding@{@var{enc_in_use}@}\selectfont a@}@} @end example @noindent Here, @var{enc_in_use} is the encoding in force before this sequence of commands, so that @samp{a} is typeset using the current encoding and only the accent is taken from @code{OT1}. @node Font styles @section Font styles @cindex font styles @cindex type styles @cindex styles of text The following type style commands are supported by @LaTeX{}. @cindex declaration form of font style commands In the table below the listed commands, the @code{\text...} commands, are used with an argument as in @code{\textit@{@var{text}@}}. This is the preferred form. But shown after it in parenthesis is the corresponding @dfn{declaration form}, which is often useful. This form takes no arguments, as in @code{@{\itshape @var{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 @code{\begin@{itshape@}...\end@{itshape@}}, which we'll describe further at the end of the section. These commands, in any of the three forms, are cumulative; for instance you can get bold sans serif by saying either of @code{\sffamily\bfseries} or @code{\bfseries\sffamily}. @findex \nocorrlist @findex \nocorr One advantage of these commands is that they automatically insert italic corrections if needed (@pxref{\/}). Specifically, they insert the italic correction unless the following character is in the list @code{\nocorrlist}, which by default consists of period and comma. To suppress the automatic insertion of italic correction, use @code{\nocorr} at the start or end of the command argument, such as @code{\textit@{\nocorr text@}} or @code{\textsc@{text \nocorr@}}. @table @code @item \textrm (\rmfamily) @findex \textrm @findex \rmfamily Roman. @item \textit (\itshape) @findex \textit @findex \itshape Italics. @item \textmd (\mdseries) @findex \textmd @findex \mdseries Medium weight (default). @item \textbf (\bfseries) @findex \textbf @findex \bfseries Boldface. @item \textup (\upshape) @findex \textup @findex \upshape Upright (default). @item \textsl (\slshape) @findex \textsl @findex \slshape Slanted. @item \textsf (\sffamily) @findex \textsf @findex \sffamily Sans serif. @item \textsc (\scshape) @findex \textsc @findex \scshape Small caps. @item \texttt (\ttfamily) @findex \texttt @findex \ttfamily Typewriter. @item \textnormal (\normalfont) @findex \textnormal @findex \normalfont Main document font. @end table @cindex emphasis @findex \emph Although it also changes fonts, the @code{\emph@{@var{text}@}} command is semantic, for text to be emphasized, and should not be used as a substitute for @code{\textit}. For example, @code{\emph@{@var{start text} \emph@{@var{middle text}@} @var{end text}@}} will result in the @var{start text} and @var{end text} in italics, but @var{middle text} will be in roman. @LaTeX{} also provides the following commands, which unconditionally switch to the given style, that is, are @emph{not} cumulative. They are used as declarations: @code{@{\@var{cmd}...@}} instead of @code{\@var{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 what is needed.) @ftable @code @item \bf @cindex bold font Switch to bold face. @item \cal @cindex script letters for math @cindex calligraphic letters for math Switch to calligraphic letters for math. @item \it @cindex italic font Italics. @item \rm @cindex roman font Roman. @item \sc @cindex small caps font Small caps. @item \sf @cindex sans serif font Sans serif. @item \sl @cindex slanted font @cindex oblique font Slanted (oblique). @item \tt @cindex typewriter font @cindex monospace font @cindex fixed-width font Typewriter (monospace, fixed-width). @end ftable The @code{\em} command is the unconditional version of @code{\emph}. The following commands are for use in math mode. They are not cumulative, so @code{\mathbf@{\mathit@{@var{symbol}@}@}} does not create a boldface and italic @var{symbol}; instead, it will just be in italics. This is because typically math symbols need consistent typographic treatment, regardless of the surrounding environment. @table @code @item \mathrm @findex \mathrm Roman, for use in math mode. @item \mathbf @findex \mathbf Boldface, for use in math mode. @item \mathsf @findex \mathsf Sans serif, for use in math mode. @item \mathtt @findex \mathtt Typewriter, for use in math mode. @item \mathit @itemx (\mit) Italics, for use in math mode. @item \mathnormal @findex \mathnormal For use in math mode, e.g., inside another type style declaration. @item \mathcal @findex \mathcal Calligraphic letters, for use in math mode. @end table @findex \mathversion @cindex math, bold @cindex bold math In addition, the command @code{\mathversion@{bold@}} can be used for switching to bold letters and symbols in formulas. @code{\mathversion@{normal@}} restores the default. @findex \oldstylenums @cindex numerals, old-style @cindex old-style numerals @cindex lining numerals Finally, the command @code{\oldstylenums@{@var{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 @code{\textbf} (but not other styles; there are no italic old-style numerals in Computer Modern). Many other fonts have old-style numerals also; sometimes package options are provided to make them the default. FAQ entry: @url{https://www.texfaq.org/FAQ-osf}. @node Font sizes @section Font sizes @cindex font sizes @cindex typeface sizes @cindex sizes of text 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 @samp{10pt}, @samp{11pt}, and @samp{12pt} document size options, respectively (@pxref{Document class options}). @findex \tiny @findex \scriptsize @findex \footnotesize @findex \small @findex \normalsize @findex \large @findex \Large @findex \LARGE @findex \huge @findex \Huge @multitable {@code{\normalsize} (default)@ @ } {24.88@ @ } {24.88@ @ } {24.88} @headitem Command @tab @code{10pt} @tab @code{11pt} @tab @code{12pt} @item @code{\tiny} @tab 5 @tab 6 @tab 6 @item @code{\scriptsize} @tab 7 @tab 8 @tab 8 @item @code{\footnotesize} @tab 8 @tab 9 @tab 10 @item @code{\small} @tab 9 @tab 10 @tab 10.95 @item @code{\normalsize} (default) @tab 10 @tab 10.95 @tab 12 @item @code{\large} @tab 12 @tab 12 @tab 14.4 @item @code{\Large} @tab 14.4 @tab 14.4 @tab 17.28 @item @code{\LARGE} @tab 17.28 @tab 17.28 @tab 20.74 @item @code{\huge} @tab 20.74 @tab 20.74 @tab 24.88 @item @code{\Huge} @tab 24.88 @tab 24.88 @tab 24.88 @end multitable @cindex declaration form of font size commands The commands are listed here in declaration (not environment) form, since that is how they are typically used. For example. @example \begin@{quotation@} \small The Tao that can be named is not the eternal Tao. \end@{quotation@} @end example @noindent Here, the scope of the @code{\small} lasts until the end of the @code{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 curly braces @code{@{\small This text is typeset in the small font.@}}. Trying to use these commands in math, as with @code{$\small mv^2/2$}, results in @samp{LaTeX Font Warning: Command \small invalid in math mode}, and the font size doesn't change. To work with a too-large formula, often the best option is to use the @code{displaymath} environment (@pxref{Math formulas}), or one of the environments from the @package{amsmath} package. For inline mathematics, such as in a table of formulas, an alternative is something like @code{@{\small $mv^2/2$@}}. (Sometimes @code{\scriptsize} and @code{\scriptstyle} are confused. Both change the font size, but the latter also changes a number of other aspects of how mathematics is typeset. @xref{Math styles}.) @cindex environment form of font size commands An @dfn{environment form} of each of these commands is also defined; for instance, @code{\begin@{tiny@}...\end@{tiny@}}. However, in practice this form can easily lead to unwanted spaces at the beginning and/or end of the environment without careful consideration, so it's generally less error-prone to stick to the declaration form. (Aside: Technically, due to the way @LaTeX{} defines @code{\begin} and @code{\end}, nearly every command that does not take an argument technically has an environment form. But in almost all cases, it would only cause confusion to use it. The reason for mentioning the environment form of the font size declarations specifically is that this particular use is not rare.) @node Low-level font commands @section Low-level font commands @cindex low-level font commands @cindex font commands, low-level These commands are primarily intended for writers of macros and packages. The commands listed here are only a subset of the available ones. @c xx but it should be complete @c xx something about ultimately reading ENCFAM.fd? @table @code @anchor{low level font commands fontencoding} @item \fontencoding@{@var{encoding}@} @findex \fontencoding Select the font encoding, the encoding of the output font. There are a large number of valid encodings. The most common are @code{OT1}, Knuth's original encoding for Computer Modern (the default), and @code{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 @url{https://ctan.org/pkg/encguide}. @anchor{low level font commands fontfamily} @item \fontfamily@{@var{family}@} @findex \fontfamily @cindex families, of fonts @cindex font catalogue Select the font family. The web page @url{https://tug.org/FontCatalogue/} provides one way to browse through many of the fonts easily used with @LaTeX{}. Here are examples of some common families. @multitable {font} {Computer Modern Typewriter more space} @item @code{pag} @tab Avant Garde @item @code{fvs} @tab Bitstream Vera Sans @item @code{pbk} @tab Bookman @item @code{bch} @tab Charter @item @code{ccr} @tab Computer Concrete @item @code{cmr} @tab Computer Modern @item @code{cmss} @tab Computer Modern Sans Serif @item @code{cmtt} @tab Computer Modern Typewriter @item @code{pcr} @tab Courier @item @code{phv} @tab Helvetica @item @code{fi4} @tab Inconsolata @item @code{lmr} @tab Latin Modern @item @code{lmss} @tab Latin Modern Sans @item @code{lmtt} @tab Latin Modern Typewriter @item @code{pnc} @tab New Century Schoolbook @item @code{ppl} @tab Palatino @item @code{ptm} @tab Times @item @code{uncl} @tab Uncial @item @code{put} @tab Utopia @item @code{pzc} @tab Zapf Chancery @end multitable @anchor{low level font commands fontseries} @item \fontseries@{@var{series}@} @findex \fontseries @cindex series, of fonts Select the font series. A @dfn{series} combines a @dfn{weight} and a @dfn{width}. Typically, a font supports only a few of the possible combinations. Some common combined series values include: @multitable {xx} {Medium (normal)xx} @item @code{m} @tab Medium (normal) @item @code{b} @tab Bold @item @code{c} @tab Condensed @item @code{bc} @tab Bold condensed @item @code{bx} @tab Bold extended @end multitable @cindex weights, of fonts The possible values for weight, individually, are: @multitable {xx} {Medium (normal) xx} @item @code{ul} @tab Ultra light @item @code{el} @tab Extra light @item @code{l} @tab Light @item @code{sl} @tab Semi light @item @code{m} @tab Medium (normal) @item @code{sb} @tab Semi bold @item @code{b} @tab Bold @item @code{eb} @tab Extra bold @item @code{ub} @tab Ultra bold @end multitable @cindex widths, of fonts The possible values for width, individually, are (the meaning and relationship of these terms varies with individual typefaces): @multitable {xx} {Ultra condensed} @item @code{uc} @tab Ultra condensed @item @code{ec} @tab Extra condensed @item @code{c} @tab Condensed @item @code{sc} @tab Semi condensed @item @code{m} @tab Medium @item @code{sx} @tab Semi expanded @item @code{x} @tab Expanded @item @code{ex} @tab Extra expanded @item @code{ux} @tab Ultra expanded @end multitable When forming the @var{series} string from the weight and width, drop the @code{m} that stands for medium weight or medium width, unless both weight and width are @code{m}, in which case use just one (@samp{@code{m}}). @anchor{low level font commands fontshape} @item \fontshape@{@var{shape}@} @findex \fontshape @cindex shapes, of fonts Select font shape. Valid shapes are: @multitable {xx} {Slanted (oblique)xx} @item @code{n} @tab Upright (normal) @item @code{it} @tab Italic @item @code{sl} @tab Slanted (oblique) @item @code{sc} @tab Small caps @item @code{ui} @tab Upright italics @item @code{ol} @tab Outline @end multitable The two last shapes are not available for most font families, and small caps are often missing as well. @anchor{low level font commands fontsize} @item \fontsize@{@var{size}@}@{@var{skip}@} @findex \fontsize @cindex font size @findex \baselineskip Set the font size and the line spacing. The unit of both parameters defaults to points (@code{pt}). The line spacing is the nominal vertical space between lines, baseline to baseline. It is stored in the parameter @code{\baselineskip}. The default @code{\baselineskip} for the Computer Modern typeface is 1.2 times the @code{\fontsize}. Changing @code{\baselineskip} directly is inadvisable since its value is reset every time a size change happens; instead use @code{\baselinestretch}. (@pxref{\baselineskip & \baselinestretch}). @anchor{low level font commands linespread} @item \linespread@{@var{factor}@} @findex \linespread Equivalent to @code{\renewcommand@{\baselinestretch@}@{@var{factor}@}}, and therefore must be followed by @code{\selectfont} to have any effect. Best specified in the preamble. @xref{\baselineskip & \baselinestretch}, for using @package{setspace} package instead. @anchor{low level font commands selectfont} @item \selectfont @findex \selectfont The effects of the font commands described above do not happen until @code{\selectfont} is called, as in @code{\fontfamily@{@var{familyname}@}\selectfont}. It is often useful to put this in a macro:@* @code{\newcommand*@{\myfont@}@{\fontfamily@{@var{familyname}@}\selectfont@}}@* (@pxref{\newcommand & \renewcommand}). @anchor{low level font commands usefont} @item \usefont@{@var{enc}@}@{@var{family}@}@{@var{series}@}@{@var{shape}@} @findex \usefont The same as invoking @code{\fontencoding}, @code{\fontfamily}, @code{\fontseries} and @code{\fontshape} with the given parameters, followed by @code{\selectfont}. For example: @example \usefont@{ot1@}@{cmr@}@{m@}@{n@} @end example @end table @node Layout @chapter Layout @cindex layout commands Commands for controlling the general page layout. @menu * \onecolumn:: Use one-column layout. * \twocolumn:: Use two-column layout. * \flushbottom:: Make all text pages the same height. * \raggedbottom:: Allow text pages of differing height. * Page layout parameters:: @code{\headheight} @code{\footskip}. * \baselineskip & \baselinestretch:: Space between lines. * Floats:: Figures, tables, etc. @end menu @node \onecolumn @section @code{\onecolumn} @findex \onecolumn @cindex one-column output Synopsis: @example \onecolumn @end example Start a new page and produce single-column output. If the document is given the class option @code{onecolumn} then this is the default behavior (@pxref{Document class options}). This command is fragile (@pxref{\protect}). @node \twocolumn @section @code{\twocolumn} @findex \twocolumn @cindex multicolumn text @cindex two-column output Synopses: @example \twocolumn \twocolumn[@var{prelim one column text}] @end example Start a new page and produce two-column output. If the document is given the class option @code{twocolumn} then this is the default (@pxref{Document class options}). This command is fragile (@pxref{\protect}). If the optional @var{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: @ftable @code @item \columnsep @anchor{twocolumn columnsep} The distance between columns. The default is 35pt. Change it with a command such as @code{\setlength@{\columnsep@}@{40pt@}}. You must change it before the two column mode starts; in the preamble is a good place. @item \columnseprule @anchor{twocolumn columnseprule} The width of the rule between columns. The default is 0pt, meaning that there is no rule. Otherwise, the rule appears halfway between the two columns. Change it with a command such as @code{\setlength@{\columnseprule@}@{0.4pt@}}, before the two-column mode starts. @item \columnwidth @anchor{twocolumn columnwidth} The width of a single column. In one-column mode this is equal to @code{\textwidth}. In two-column mode by default @LaTeX{} sets the width of each of the two columns, @code{\columnwidth}, to be half of @code{\textwidth} minus @code{\columnsep}. @end ftable In a two-column document, the starred environments @code{table*} and @code{figure*} are two columns wide, whereas the unstarred environments @code{table} and @code{figure} take up only one column (@pxref{figure} and @pxref{table}). @LaTeX{} places starred floats at the top of a page. The following parameters control float behavior of two-column output. @ftable @code @anchor{twocolumn dbltopfraction} @item \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 @code{table*} or @code{figure*} environment must not exceed @code{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: @itemize @bullet @item Use the @code{[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. @item Use the @code{[t!]} location specifier to override the effect of @code{\dbltopfraction} for this particular float. @item Increase the value of @code{\dbltopfraction} to a suitably large number, to avoid going to float pages so soon. @end itemize You can redefine it, as with @code{\renewcommand@{\dbltopfraction@}@{0.9@}}. @item \dblfloatpagefraction @anchor{twocolumn 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 @code{0.5}. Change it with @code{\renewcommand}. @item \dblfloatsep @anchor{twocolumn 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 @code{12pt plus2pt minus2pt} for a document set at @code{10pt} or @code{11pt}, and @code{14pt plus2pt minus4pt} for a document set at @code{12pt}. @item \dbltextfloatsep @anchor{twocolumn 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 @code{20pt plus2pt minus4pt}. @item \dbltopnumber @anchor{twocolumn 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 @code{2}. @end ftable @c From egreg at http://tex.stackexchange.com/a/142232/339 This example uses @code{\twocolumn}'s optional argument of to create a title that spans the two-column article: @example \documentclass[twocolumn]@{article@} \newcommand@{\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] \normalsize \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. @end example @node \flushbottom @section @code{\flushbottom} @findex \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 @samp{Underfull \vbox (badness 10000) has occurred while \output is active}. If you get that, one option is to change to @code{\raggedbottom} (@pxref{\raggedbottom}). Alternatively, you can adjust the @code{textheight} to make compatible pages, or you can add some vertical stretch glue between lines or between paragraphs, as in @code{\setlength@{\parskip@}@{0ex plus0.1ex@}}. Your last option is to, in a final editing stage, adjust the height of individual pages (@pxref{\enlargethispage}). The @code{\flushbottom} state is the default only if you select the @code{twoside} document class option (@pxref{Document class options}). @node \raggedbottom @section @code{\raggedbottom} @findex \raggedbottom @cindex stretch, omitting vertical 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 @ref{\flushbottom}. This is the default unless you select the @code{twoside} document class option (@pxref{Document class options}). @node Page layout parameters @section Page layout parameters @cindex page layout parameters @cindex parameters, page layout @cindex layout, page parameters for @cindex header, parameters for @cindex footer, parameters for @cindex running header and footer @ftable @code @item \columnsep @itemx \columnseprule @itemx \columnwidth @findex \columnsep @findex \columnseprule @findex \columnwidth @anchor{page layout parameters columnsep} @anchor{page layout parameters columnseprule} @anchor{page layout parameters 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 @code{twocolumn} is in effect (@pxref{Document class options}). @xref{\twocolumn}. @item \headheight @findex \headheight @anchor{page layout parameters headheight} Height of the box that contains the running head. The default in the @code{article}, @code{report}, and @code{book} classes is @samp{12pt}, at all type sizes. @item \headsep @findex \headsep @anchor{page layout parameters headsep} Vertical distance between the bottom of the header line and the top of the main text. The default in the @code{article} and @code{report} classes is @samp{25pt}. In the @code{book} class the default is: if the document is set at 10pt then it is @samp{0.25in}, and at 11pt or 12pt it is @samp{0.275in}. @item \footskip @findex \footskip @anchor{page layout parameters footskip} Distance from the baseline of the last line of text to the baseline of the page footer. The default in the @code{article} and @code{report} classes is @samp{30pt}. In the @code{book} class the default is: when the type size is 10pt the default is @samp{0.35in}, while at 11pt it is @samp{0.38in}, and at 12pt it is @samp{30pt}. @item \linewidth @findex \linewidth @anchor{page layout parameters linewidth} Width of the current line, decreased for each nested @code{list} (@pxref{list}). That is, the nominal value for @code{\linewidth} is to equal @code{\textwidth} but for each nested list the @code{\linewidth} is decreased by the sum of that list's @code{\leftmargin} and @code{\rightmargin} (@pxref{itemize}). @c The default varies with the font size, paper width, two-column mode, @c etc. For an @code{article} document set in 10pt, the default is @c @samp{345pt}, while in two-column mode that becomes @samp{229.5pt}. @item \marginparpush @itemx \marginsep @itemx \marginparwidth @findex \marginparpush @findex \marginsep @findex \marginparwidth @anchor{page layout parameters marginparpush} @anchor{page layout parameters marginsep} @anchor{page layout parameters 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 @code{\reversemarginpar} changes that (and @code{\normalmarginpar} changes it back). The defaults for @code{\marginparpush} in both @code{book} and @code{article} classes are: @samp{7pt} if the document is set at 12pt, and @samp{5pt} if the document is set at 11pt or 10pt. For @code{\marginsep}, in @code{article} class the default is @samp{10pt} except if the document is set at 10pt and in two-column mode where the default is @samp{11pt}. For @code{\marginsep} in @code{book} class the default is @samp{10pt} in two-column mode and @samp{7pt} in one-column mode. For @code{\marginparwidth} in both @code{book} and @code{article} classes, in two-column mode the default is 60% of @code{\paperwidth @minus{} \textwidth}, while in one-column mode it is 50% of that distance. @item \oddsidemargin @itemx \evensidemargin @findex \oddsidemargin @findex \evensidemargin @anchor{page layout parameters oddsidemargin} @anchor{page layout parameters evensidemargin} @c xx TODO re-align on French version that is more complete/accurate. The @code{\oddsidemargin} length 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 @code{twoside} is chosen and on all pages when @code{oneside} is in effect. When @code{twoside} is in effect, on even-numbered pages the extra distance on the left is @code{\evensidemargin}. @LaTeX{}'s default is that @code{\oddsidemargin} is 40% of the difference between @code{\paperwidth} and @code{\textwidth}, and @code{\evensidemargin} is the remainder. @item \paperheight @findex \paperheight @anchor{page layout parameters paperheight} The height of the paper, as distinct from the height of the print area. Normally set with a document class option, as in @code{\documentclass[a4paper]@{article@}} (@pxref{Document class options}). @item \paperwidth @findex \paperwidth @anchor{page layout parameters paperwidth} The width of the paper, as distinct from the width of the print area. Normally set with a document class option, as in @code{\documentclass[a4paper]@{article@}} (@pxref{Document class options}). @item \textheight @findex \textheight @anchor{page layout parameters textheight} The normal vertical height of the page body. If the document is set at a nominal type size of 10pt then for an @code{article} or @code{report} the default is @samp{43\baselineskip}, while for a @code{book} it is @samp{41\baselineskip}. At a type size of 11pt the default is @samp{38\baselineskip} for all document classes. At 12pt it is @samp{36\baselineskip} for all classes. @item \textwidth @findex \textwidth @anchor{page layout parameters textwidth} The full horizontal width of the entire page body. For an @code{article} or @code{report} document, the default is @samp{345pt} when the chosen type size is 10pt, the default is @samp{360pt} at 11pt, and it is @samp{390pt} at 12pt. For a @code{book} document, the default is @samp{4.5in} at a type size of 10pt, and @samp{5in} at 11pt or 12pt. In multi-column output, @code{\textwidth} remains the width of the entire page body, while @code{\columnwidth} is the width of one column (@pxref{\twocolumn}). In lists (@pxref{list}), @code{\textwidth} remains the width of the entire page body (and @code{\columnwidth} the width of the entire column), while @code{\linewidth} may decrease for nested lists. Inside a minipage (@pxref{minipage}) or @code{\parbox} (@pxref{\parbox}), all the width-related parameters are set to the specified width, and revert to their normal values at the end of the @code{minipage} or @code{\parbox}. @item \hsize @findex \hsize @anchor{page layout parameters hsize} This entry is included for completeness: @code{\hsize} is the @TeX{} primitive parameter used when text is broken into lines. It should not be used in normal @LaTeX{} documents. @item \topmargin @findex topmargin @anchor{page layout parameters topmargin} @c xxx TODO re-align on French version that is more accurate. 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: @code{\paperheight @minus{} 2in @minus{} \headheight @minus{} \headsep @minus{} \textheight @minus{} \footskip}, and then divided by two. @item \topskip @findex \topskip @anchor{page layout parameters 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., @samp{10pt} at a type size of 10pt. @end ftable @node \baselineskip & \baselinestretch @section @code{\baselineskip} & @code{\baselinestretch} @findex \baselineskip @findex \baselinestretch @findex \linespread @cindex space between lines @cindex interline space @cindex leading @cindex double spacing The @code{\baselineskip} is a rubber length (@pxref{Lengths}). It gives the @dfn{leading}, the normal distance between lines in a paragraph, from baseline to baseline. Ordinarily document authors do not directly change @code{\baselineskip} while writing. Instead, it is set by the low level font selection command @code{\fontsize} (@pxref{low level font commands fontsize}). The @code{\baselineskip}'s value is reset every time a font change happens and so any direct change to @code{\baselineskip} would vanish the next time there was a font switch. For how to influence line spacing, see the discussion of @code{\baselinestretch} below. Usually, a font's size and baseline skip is assigned by the font designer. These numbers are nominal in the sense that if, for instance, a font's style file has the command @code{\fontsize@{10pt@}@{12pt@}} then that does not mean that the characters in the font are 10@dmn{pt} tall; for instance, parentheses and accented capitals may be taller. Nor does it mean that if the lines are spaced less than 12@dmn{pt} apart then they risk touching. Rather these numbers are typographic judgements. (Often, the @code{\baselineskip} is about twenty percent larger than the font size.) @c adapted from FAQ The @code{\baselineskip} is not a property of each line but of the entire paragraph. As a result, large text in the middle of a paragraph, such as a single @code{@{\Huge Q@}}, will be squashed into its line. @TeX{} will make sure it doesn't scrape up against the line above but won't change the @code{\baselineskip} for that one line to make extra room above. For the fix, use a @code{\strut} (@pxref{\strut}). The value of @code{\baselineskip} that @TeX{} uses for the paragraph is the value in effect at the blank line or command that ends the paragraph unit. So if a document contains this paragraph then its lines will be scrunched together, compared to lines in surrounding paragraphs. @c Adapted from B Beeton's "Lapses in TeX" TB 42:1 p 13. @example Many people see a page break between text and a displayed equation as bad style, so in effect the display is part of the paragraph. Because this display is in footnotesize, the entire paragraph has the baseline spacing matching that size. @{\footnotesize $$a+b = c$$@} @end example @findex \lineskip @findex \lineskiplimit @findex \prevdepth The process for making paragraphs is that when a new line is added, if the depth of the previous line plus the height of the new line is less than @code{\baselineskip} then @TeX{} inserts vertical glue to make up the difference. There are two fine points. The first is that if the lines would be too close together, closer than @code{\lineskiplimit}, then @TeX{} instead uses @code{\lineskip} as the interline glue. The second is that @TeX{} doesn't actually use the depth of the previous line. Instead it uses @code{\prevdepth}, which usually contains that depth. But at the beginning of the paragraph (or any vertical list) or just after a rule, @code{\prevdepth} has the value -1000@dmn{pt} and this special value tells @TeX{} not to insert any interline glue at the paragraph start. In the standard classes @code{\lineskiplimit} is 0@dmn{pt} and @code{\lineskip} is 1@dmn{pt}. By the prior paragraph then, the distance between lines can approach zero but if it becomes zero (or less than zero) then the lines jump to 1@dmn{pt} apart. Sometimes authors must, for editing purposes, put the document in double space or one-and-a-half space. The right way to influence the interline distance is via @code{\baselinestretch}. It scales @code{\baselineskip}, and has a default value of 1.0. It is a command, not a length, so change the scale factor as in @code{\renewcommand@{\baselinestretch@}@{1.5@}\selectfont}. The most straightforward way to change the line spacing for an entire document is to put @code{\linespread@{@var{factor}@}} in the preamble. For double spacing, take @var{factor} to be 1.6 and for one-and-a-half spacing use 1.3. These number are rough: for instance, since the @code{\baselineskip} is about 1.2 times the font size, multiplying by 1.6 gives a baseline skip to font size ratio of about 2. (The @code{\linespread} command is defined as @code{\renewcommand@{\baselinestretch@}@{@var{factor}@}} so it won't take effect until a font setting happens. But that always takes place at the start of a document, so there you don't need to follow it with @code{\selectfont}.) @PkgIndex{setspace} A simpler approach is the @package{setspace} package. The basic example: @example \usepackage@{setspace@} \doublespacing % or \onehalfspacing for 1.5 @end example @noindent In the preamble these will start the document off with that sizing. But you can also use these declarations in the document body to change the spacing from that point forward, and consequently there is @code{\singlespacing} to return the spacing to normal. In the document body, a better practice than using the declarations is to use environments, such as @code{\begin@{doublespace@} ... \end@{doublespace@}}. The package also has commands to do arbitrary spacing: @code{\setstretch@{@var{factor}@}} and @code{\begin@{spacing@}@{@var{factor}@} ... \end@{spacing@}}. This package also keeps the line spacing single-spaced in places where that is typically desirable, such as footnotes and figure captions. See the package documentation. @node Floats @section 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, @code{figure} (@pxref{figure}) and @code{table} (@pxref{table}), but you can create a new class with the package @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. @cindex placement of floats @cindex specifier, float placement In addition to changing the parameters, for each float you can tweak where the float placement algorithm tries to place it by using its @var{placement} argument. The possible values are a sequence of the letters below. The default for both @code{figure} and @code{table}, in both @code{article} and @code{book} classes, is @code{tbp}. @table @code @item t (Top)---at the top of a text page. @item b (Bottom)---at the bottom of a text page. (However, @code{b} is not allowed for full-width floats (@code{figure*}) with double-column output. To ameliorate this, use the @file{stfloats} or @file{dblfloatfix} package, but see the discussion at caveats in the FAQ: @url{https://www.texfaq.org/FAQ-2colfloat}. @item h (Here)---at the position in the text where the @code{figure} environment appears. However, @code{h} is not allowed by itself; @code{t} is automatically added. @cindex here, putting floats @PkgIndex{float} To absolutely force a float to appear ``here'', you can @code{\usepackage@{float@}} and use the @code{H} specifier which it defines. For further discussion, see the FAQ entry at @url{https://www.texfaq.org/FAQ-figurehere}. @item p @cindex float page (Page of floats)---on a separate @dfn{float page}, which is a page containing no text, only floats. @item ! 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 @code{!} specifier does @emph{not} mean ``put the float here''; see above. @end table Note: the order in which letters appear in the @var{placement} argument does not change the order in which @LaTeX{} tries to place the float; for instance, @code{btp} has the same effect as @code{tbp}. All that @var{placement} does is that if a letter is not present then the algorithm does not try that location. Thus, @LaTeX{}'s default of @code{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 @code{\clearpage} command to start a new page and insert all pending floats. If a pagebreak is undesirable then you can use the @file{afterpage} package and issue @code{\afterpage@{\clearpage@}}. This will wait until the current page is finished and then flush all outstanding floats. @PkgIndex{flafter} @LaTeX{} can typeset a float before where it appears in the source (although on the same output page) if there is a @code{t} specifier in the @var{placement} parameter. If this is not desired, and deleting the @code{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 @package{flafter} package or using the command @findex \suppressfloats @code{\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 @code{\renewcommand@{@var{parameter}@}@{@var{decimal between 0 and 1}@}}): @ftable @code @item \bottomfraction @findex \bottomfraction @anchor{floats bottomfraction} The maximum fraction of the page allowed to be occupied by floats at the bottom; default @samp{.3}. @item \floatpagefraction @findex \floatpagefraction @anchor{floats floatpagefraction} The minimum fraction of a float page that must be occupied by floats; default @samp{.5}. @item \textfraction @findex \textfraction @anchor{floats 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 @samp{.2}. @item \topfraction @findex \topfraction @anchor{floats topfraction} Maximum fraction at the top of a page that may be occupied before floats; default @samp{.7}. @end ftable Parameters relating to vertical space around floats (change them with a command of the form @code{\setlength@{@var{parameter}@}@{@var{length expression}@}}): @ftable @code @item \floatsep @findex \floatsep @anchor{floats floatsep} Space between floats at the top or bottom of a page; default @samp{12pt plus2pt minus2pt}. @item \intextsep @findex \intextsep @anchor{floats intextsep} Space above and below a float in the middle of the main text; default @samp{12pt plus2pt minus2pt} for 10 point and 11 point documents, and @samp{14pt plus4pt minus4pt} for 12 point documents. @item \textfloatsep @findex \textfloatsep @anchor{floats textfloatsep} Space between the last (first) float at the top (bottom) of a page; default @samp{20pt plus2pt minus4pt}. @end ftable Counters relating to the number of floats on a page (change them with a command of the form @code{\setcounter@{@var{ctrname}@}@{@var{natural number}@}}): @ftable @code @item bottomnumber @findex bottomnumber @anchor{floats bottomnumber} Maximum number of floats that can appear at the bottom of a text page; default 1. @item dbltopnumber @findex dbltopnumber @anchor{floats dbltopnumber} Maximum number of full-sized floats that can appear at the top of a two-column page; default 2. @item topnumber @findex topnumber @anchor{floats topnumber} Maximum number of floats that can appear at the top of a text page; default 2. @item totalnumber @findex totalnumber @anchor{floats totalnumber} Maximum number of floats that can appear on a text page; default 3. @end ftable The principal @TeX{}@tie{}FAQ entry relating to floats @url{https://www.texfaq.org/FAQ-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{}?'' (@url{https://www.latex-project.org/publications/2014-FMi-TUB-tb111mitt-float-placement.pdf}). @menu * \caption:: Make a caption for a floating environment. @end menu @node \caption @subsection @code{\caption} @findex \caption @cindex captions Synopsis: @example \caption@{@var{caption-text}@} @end example @noindent or @example \caption[@var{short-caption-text}]@{@var{caption-text}@} @end example Make a caption for a floating environment, such as a @code{figure} or @code{table} environment (@pxref{figure} or @ref{table}). In this example, @LaTeX{} places a caption below the vertical blank space that is left by the author for the later inclusion of a picture. @example \begin@{figure@} \vspace*@{1cm@} \caption@{Alonzo Cushing, Battery A, 4th US Artillery.@} \label@{fig:CushingPic@} \end@{figure@} @end example @noindent The @code{\caption} command will label the @var{caption-text} with something like @samp{Figure@tie{}1:} for an article or @samp{Figure@tie{}1.1:} for a book. The text is centered if it is shorter than the text width, or set as an unindented paragraph if it takes more than one line. In addition to placing the @var{caption-text} in the output, the @code{\caption} command also saves that information for use in a list of figures or list of tables (@pxref{Table of contents etc.}). Here the @code{\caption} command uses the optional @var{short-caption-text}, so that the shorter text appears in the list of tables, rather than the longer @var{caption-text}. @example \begin@{table@} \centering \begin@{tabular@}@{|*@{3@}@{c@}|@} \hline 4 &9 &2 \\ 3 &5 &7 \\ 8 &1 &6 \\ \hline \end@{tabular@} \caption[\textit@{Lo Shu@} magic square]@{% The \textit@{Lo Shu@} magic square, which is unique among squares of order three up to rotation and reflection.@} \label@{tab:LoShu@} \end@{table@} @end example @noindent @LaTeX{} will label the @var{caption-text} with something like @samp{Table@tie{}1:} for an article or @samp{Table@tie{}1.1:} for a book. The caption can appear at the top of the @code{figure} or @code{table}. For instance, that would happen in the prior example by putting the @code{\caption} between the @code{\centering} and the @code{\begin@{tabular@}}. Different floating environments are numbered separately, by default. It is @code{\caption} that updates the counter, and so any @code{\label} must come after the @code{\caption}. The counter for the @code{figure} environment is named @code{figure}, and similarly the counter for the @code{table} environment is @code{table}. The text that will be put in the list of figures or list of tables is moving argument. If you get the @LaTeX{} error @samp{! Argument of \@@caption has an extra @}} then you must put @code{\protect} in front of any fragile commands. @xref{\protect}. @PkgIndex{caption} The @package{caption} package has many options to adjust how the caption appears, for example changing the font size, making the caption be hanging text rather than set as a paragraph, or making the caption always set as a paragraph rather than centered when it is short. @node Sectioning @chapter Sectioning @cindex sectioning commands @cindex part @cindex chapter @cindex section @cindex subsection @cindex subsubsection @cindex paragraph @cindex subparagraph @findex \part @findex \chapter @findex \section @findex \subsection @findex \subsubsection @findex \paragraph @findex \subparagraph Structure your text into divisions: parts, chapters, sections, etc. All sectioning commands have the same form, one of: @example @var{sectioning-command}@{@var{title}@} @var{sectioning-command}*@{@var{title}@} @var{sectioning-command}[@var{toc-title}]@{@var{title}@} @end example @noindent For instance, declare the start of a subsection as with @code{\subsection@{Motivation@}}. The table has each @var{sectioning-command} in @LaTeX{}. All are available in all of @LaTeX{}'s standard document classes @code{book}, @code{report}, and@tie{}@code{article}, except that @code{\chapter} is not available in @code{article}. @multitable @columnfractions .25 .25 .40 @headitem Sectioning unit @tab Command @tab Level @item Part @tab @code{\part} @tab -1 (@code{book}, @code{report}), 0 (@code{article}) @item Chapter @tab @code{\chapter} @tab 0 @item Section @tab @code{\section} @tab 1 @item Subsection @tab @code{\subsection} @tab 2 @item Subsubsection @tab @code{\subsubsection} @tab 3 @item Paragraph @tab @code{\paragraph} @tab 4 @item Subparagraph @tab @code{\subparagraph} @tab 5 @end multitable @cindex @code{*}-form of sectioning commands All these commands have a @code{*}-form that prints @var{title} as usual but does not number it and does not make an entry in the table of contents. An example of using this is for an appendix in an @code{article}. The input @code{\appendix\section@{Appendix@}} gives the output @samp{A Appendix} (@pxref{\appendix}). You can lose the numbering@tie{}@samp{A} by instead entering @code{\section*@{Appendix@}} (articles often omit a table of contents and have simple page headers so the other differences from the @code{\section} command may not matter). The section title @var{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 (@pxref{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 @var{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 @var{level} is less than or equal to the value of the counter @code{secnumdepth} then the titles for this sectioning command will be numbered (@pxref{Sectioning/secnumdepth}). And, if @var{level} is less than or equal to the value of the counter @code{tocdepth} then the table of contents will have an entry for this sectioning unit (@pxref{Sectioning/tocdepth}). @LaTeX{} expects that before you have a @code{\subsection} you will have a @code{\section} and, in a @code{book} class document, that before a @code{\section} you will have a @code{\chapter}. Otherwise you can get something like a subsection numbered @samp{3.0.1}. @PkgIndex{titlesec} @LaTeX{} lets you change the appearance of the sectional units. As a simple example, you can change the section numbering to upper-case letters with @code{\renewcommand\thesection@{\Alph@{section@}@}} in the preamble (@pxref{\alph \Alph \arabic \roman \Roman \fnsymbol}). CTAN has many packages that make this adjustment easier, notably @package{titlesec}. Two counters relate to the appearance of headings made by sectioning commands. @ftable @code @item secnumdepth @findex secnumdepth @r{counter} @cindex section numbers, printing @anchor{sectioning secnumdepth} @anchor{Sectioning/secnumdepth} Controls which sectioning unit are numbered. Setting the counter with @code{\setcounter@{secnumdepth@}@{@var{level}@}} will suppress numbering of sectioning at any depth greater than @var{level} (@pxref{\setcounter}). See the above table for the level numbers. For instance, if the @code{secnumdepth} is 1 in an @code{article} then a @code{\section@{Introduction@}} command will produce output like @samp{1 Introduction} while @code{\subsection@{Discussion@}} will produce output like @samp{Discussion}, without the number. @LaTeX{}'s default @code{secnumdepth} is@tie{}3 in @file{article} class and @tie{}2 in the @file{book} and @file{report} classes. @item tocdepth @findex tocdepth @r{counter} @cindex table of contents, sectioning numbers printed @anchor{sectioning tocdepth} @anchor{Sectioning/tocdepth} Controls which sectioning units are listed in the table of contents. The setting @code{\setcounter@{tocdepth@}@{@var{level}@}} makes the sectioning units at @var{level} be the smallest ones listed (@pxref{\setcounter}). See the above table for the level numbers. For instance, if @code{tocdepth} is@tie{}1 then the table of contents will list sections but not subsections. @LaTeX{}'s default @code{tocdepth} is@tie{}3 in @file{article} class and @tie{}2 in the @file{book} and @file{report} classes. @end ftable @menu * \part:: Start a part. * \chapter:: Start a chapter. * \section:: Start a section. * \subsection:: Start a subsection. * \subsubsection & \paragraph & \subparagraph:: Lower divisions. * \appendix:: Start appendices. * \frontmatter & \mainmatter & \backmatter:: The three parts of a book. * \@@startsection:: Sectional unit headings. @end menu @node \part @section @code{\part} @findex \part @cindex part @cindex sectioning, part Synopsis, one of: @example \part@{@var{title}@} \part*@{@var{title}@} \part[@var{toc-title}]@{@var{title}@} @end example Start a document part. The standard @LaTeX{} classes @code{book}, @code{report}, and @code{article}, all have this command. This produces a document part, in a book. @example \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. @end example In each standard class the @code{\part} command outputs a part number such as @samp{Part I}, alone on its line, in boldface, and in large type. Then @LaTeX{} outputs @var{title}, also alone on its line, in bold and in even larger type. In class @code{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 @code{report} it is again alone on a page, but @LaTeX{} won't force it onto an odd-numbered page. In an @code{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 @code{*}@tie{}form shows @var{title} but it does not show the part number, does not increment the @code{part} counter, and produces no table of contents entry. The optional argument @var{toc-title} will appear as the part title in the table of contents (@pxref{Table of contents etc.}) and in running headers (@pxref{Page styles}). If it is not present then @var{title} will be there. This example puts a line break in @var{title} but omits the break in the table of contents. @example \part[Up from the bottom; my life]@{Up from the bottom\\ my life@} @end example For determining which sectional units are numbered and which appear in the table of contents, the level number of a part is@tie{}-1 (@pxref{Sectioning/secnumdepth}, and @ref{Sectioning/tocdepth}). @PkgIndex{indentfirst} In the class @code{article}, if a paragraph immediately follows the part title then it is not indented. To get an indent you can use the package @package{indentfirst}. @PkgIndex{titlesec} One package to change the behavior of @code{\part} is @package{titlesec}. See its documentation on CTAN. @node \chapter @section @code{\chapter} @findex \chapter @cindex chapter Synopsis, one of: @example \chapter@{@var{title}@} \chapter*@{@var{title}@} \chapter[@var{toc-title}]@{@var{title}@} @end example Start a chapter. The standard @LaTeX{} classes @code{book} and @code{report} have this command but @code{article} does not. This produces a chapter. @example \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. @end example 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 @samp{Chapter 1} in large boldface type (the size is @code{\huge}). It then puts @var{title} on a fresh line, in boldface type that is still larger (size @code{\Huge}). It also increments the @code{chapter} counter, adds an entry to the table of contents (@pxref{Table of contents etc.}), and sets the running header information (@pxref{Page styles}). The @code{*}@tie{}form shows @var{title} on a fresh line, in boldface. But it does not show the chapter number, does not increment the @code{chapter} counter, produces no table of contents entry, and does not affect the running header. (If you use the page style @code{headings} in a two-sided document then the header will be from the prior chapter.) This example illustrates. @example \chapter*@{Preamble@} @end example The optional argument @var{toc-title} will appear as the chapter title in the table of contents (@pxref{Table of contents etc.}) and in running headers (@pxref{Page styles}). If it is not present then @var{title} will be there. This shows the full name in the chapter title, @example \chapter[Weyl]@{Hermann Klaus Hugo (Peter) Weyl (1885--1955)@} @end example @noindent but only @samp{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 @example \chapter[Given it all; my story]@{Given it all\\ my story@} @end example For determining which sectional units are numbered and which appear in the table of contents, the level number of a chapter is@tie{}0 (@pxref{Sectioning/secnumdepth} and @pxref{Sectioning/tocdepth}). @PkgIndex{indentfirst} The paragraph that follows the chapter title is not indented, as is a standard typographical practice. To get an indent use the package @package{indentfirst}. You can change what is shown for the chapter number. To change it to something like @samp{Lecture 1}, put in the preamble either @code{\renewcommand@{\chaptername@}@{Lecture@}} or this (@pxref{\makeatletter & \makeatother}). @example \makeatletter \renewcommand@{\@@chapapp@}@{Lecture@} \makeatother @end example @PkgIndex{babel} @noindent To make this change because of the primary language for the document, see the package @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@tie{}@ref{\clearpage & \cleardoublepage}. @PkgIndex{titlesec} To change the behavior of the @code{\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 @package{titlesec}. See its documentation, but the example below gives a sense of what it can do. @example \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 @end example @noindent This omits the chapter number @samp{Chapter 1} from the page but unlike @code{\chapter*} it keeps the chapter in the table of contents and the running headers. @node \section @section @code{\section} @findex \section @cindex section Synopsis, one of: @example \section@{@var{title}@} \section*@{@var{title}@} \section[@var{toc-title}]@{@var{title}@} @end example Start a section. The standard @LaTeX{} classes @code{article}, @code{book}, and @code{report} all have this command. This produces a section. @example 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. @end example For the standard @LaTeX{} classes @code{book} and @code{report} the default output is like @samp{1.2 @var{title}} (for chapter@tie{}1, section@tie{}2), alone on its line and flush left, in boldface and a larger type (the type size is @code{\Large}). The same holds in @code{article} except that there are no chapters in that class so it looks like @samp{2 @var{title}}. The @code{*}@tie{}form shows @var{title}. But it does not show the section number, does not increment the @code{section} counter, produces no table of contents entry, and does not affect the running header. (If you use the page style @code{headings} in a two-sided document then the header will be from the prior section.) The optional argument @var{toc-title} will appear as the section title in the table of contents (@pxref{Table of contents etc.}) and in running headers (@pxref{Page styles}). If it is not present then @var{title} will be there. This shows the full name in the title of the section: @example \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.@} @end example @noindent but only @samp{Elizabeth II} on the contents page and in the headers. This has a line break in @var{title} but that does not work with headers so it is omitted from the contents and headers. @example \section[Truth is, I cheated; my life story]@{Truth is, I cheated\\my life story@} @end example For determining which sectional units are numbered and which appear in the table of contents, the level number of a section is@tie{}1 (@pxref{Sectioning/secnumdepth} and @pxref{Sectioning/tocdepth}). @PkgIndex{indentfirst} 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 @package{indentfirst}. @PkgIndex{titlesec} In general, to change the behavior of the @code{\section} command, there are a number of options. One is the @code{\@@startsection} command (@pxref{\@@startsection}). There are also many packages on CTAN that address this, including @package{titlesec}. See the documentation but the example below gives a sense of what they can do. @c credit: egreg https://groups.google.com/forum/#!topic/comp.text.tex/tvc8oM5P4y4 @example \usepackage@{titlesec@} % in preamble \titleformat@{\section@} @{\normalfont\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] @end example @noindent That puts the section number in the margin. @node \subsection @section @code{\subsection} @findex \subsection @cindex subsection Synopsis, one of: @example \subsection@{@var{title}@} \subsection*@{@var{title}@} \subsection[@var{toc-title}]@{@var{title}@} @end example Start a subsection. The standard @LaTeX{} classes @code{article}, @code{book}, and @code{report} all have this command. This produces a subsection. @example 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. @end example For the standard @LaTeX{} classes @code{book} and @code{report} the default output is like @samp{1.2.3 @var{title}} (for chapter@tie{}1, section@tie{}2, subsection@tie{}3), alone on its line and flush left, in boldface and a larger type (the type size is @code{\large}). The same holds in @code{article} except that there are no chapters in that class so it looks like @samp{2.3 @var{title}}. The @code{*}@tie{}form shows @var{title}. But it does not show the subsection number, does not increment the @code{subsection} counter, and produces no table of contents entry. The optional argument @var{toc-title} will appear as the subsection title in the table of contents (@pxref{Table of contents etc.}). If it is not present then @var{title} will be there. This shows the full text in the title of the subsection: @example \subsection[$\alpha,\beta,\gamma$ paper]@{\textit@{The Origin of Chemical Elements@} by R.A.~Alpher, H.~Bethe, and G.~Gamow@} @end example @noindent but only @samp{@BES{03B1,\alpha},@BES{03B2,\beta},@BES{03B3,\gamma} 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@tie{}2 (@pxref{Sectioning/secnumdepth} and @pxref{Sectioning/tocdepth}). @PkgIndex{indentfirst} 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 @package{indentfirst}. @PkgIndex{titlesec} There are a number of ways to change the behavior of the @code{\subsection} command. One is the @code{\@@startsection} command (@pxref{\@@startsection}). There are also many packages on CTAN that address this, including @package{titlesec}. See the documentation but the example below gives a sense of what they can do. @example \usepackage@{titlesec@} % in preamble \titleformat@{\subsection@}[runin] @{\normalfont\normalsize\bfseries@} % format of the title @{\thesubsection@} % label @{0.6em@} % space between label and title @{@} % before-code hook @end example @noindent That puts the subsection number and @var{title} in the first line of text. @node \subsubsection & \paragraph & \subparagraph @section @code{\subsubsection}, @code{\paragraph}, @code{\subparagraph} @findex \subsubsection @cindex subsubsection @findex \paragraph @cindex paragraph @findex \subparagraph @cindex subparagraph Synopsis, one of: @example \subsubsection@{@var{title}@} \subsubsection*@{@var{title}@} \subsubsection[@var{toc-title}]@{@var{title}@} @end example @noindent or one of: @example \paragraph@{@var{title}@} \paragraph*@{@var{title}@} \paragraph[@var{toc-title}]@{@var{title}@} @end example @noindent or one of: @example \subparagraph@{@var{title}@} \subparagraph*@{@var{title}@} \subparagraph[@var{toc-title}]@{@var{title}@} @end example Start a subsubsection, paragraph, or subparagraph. The standard @LaTeX{} classes @code{article}, @code{book}, and @code{report} all have these commands, although they are not commonly used. This produces a subsubsection. @example \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. @end example The default output of each of the three does not change over the standard @LaTeX{} classes @code{article}, @code{book}, and @code{report}. For @code{\subsubsection} the @var{title} is alone on its line, in boldface and normal size type. For @code{\paragraph} the @var{title} is inline with the text, not indented, in boldface and normal size type. For @code{\subparagraph} the @var{title} is inline with the text, with a paragraph indent, in boldface and normal size type (Because an @code{article} has no chapters its subsubsections are numbered and so it looks like @samp{1.2.3 @var{title}}, for section@tie{}1, subsection@tie{}2, and subsubsection@tie{}3. The other two divisions are not numbered.) The @code{*}@tie{}form shows @var{title}. But it does not increment the associated counter and produces no table of contents entry (and does not show the number for @code{\subsubsection}). The optional argument @var{toc-title} will appear as the division title in the table of contents (@pxref{Table of contents etc.}). If it is not present then @var{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@tie{}3, of a paragraph is@tie{}4, and of a subparagraph is@tie{}5 (@pxref{Sectioning/secnumdepth} and @pxref{Sectioning/tocdepth}). @PkgIndex{indentfirst} 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 @package{indentfirst}. @PkgIndex{titlesec} There are a number of ways to change the behavior of the these commands. One is the @code{\@@startsection} command (@pxref{\@@startsection}). There are also many packages on CTAN that address this, including @package{titlesec}. See the documentation on CTAN. @node \appendix @section @code{\appendix} @findex \appendix @cindex appendix @cindex appendices Synopsis: @example \appendix @end example This does not directly produce any output. But in a book or report it declares that subsequent @code{\chapter} commands start an appendix. In an article it does the same, for @code{\section} commands. It also resets the @code{chapter} and @code{section} counters to@tie{}0 in a book or report, and in an article resets the @code{section} and @code{subsection} counters. In this book @example \chapter@{One@} ... \chapter@{Two@} ... ... \appendix \chapter@{Three@} ... \chapter@{Four@} ... @end example @noindent the first two will generate output numbered @samp{Chapter 1} and @samp{Chapter 2}. After the @code{\appendix} the numbering will be @samp{Appendix A} and @samp{Appendix B}. @xref{Larger book template}, for another example. @PkgIndex{appendix} The @package{appendix} package adds the command @code{\appendixpage} to put a separate @samp{Appendices} in the document body before the first appendix, and the command @code{\addappheadtotoc} to do the same in the table of contents. You can reset the name @samp{Appendices} with a command like @code{\renewcommand@{\appendixname@}@{Specification@}}, as well as a number of other features. See the documentation on CTAN. @node \frontmatter & \mainmatter & \backmatter @section @code{\frontmatter}, @code{\mainmatter}, @code{\backmatter} @findex \frontmatter @cindex book, front matter @cindex front matter of a book @findex \mainmatter @cindex book, main matter @cindex main matter of a book @findex \backmatter @cindex book, back matter @cindex book, end matter @cindex back matter of a book @cindex end matter of a book Synopsis, one or more of: @example \frontmatter ... \mainmatter ... \backmatter ... @end example Format a @code{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 @code{\frontmatter} command 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 @code{*}-version (@pxref{Sectioning}). The @code{\mainmatter} command changes the behavior back to the expected version, and resets the page number. The @code{\backmatter} command leaves the page numbering alone but switches the chapters back to being not numbered. @xref{Larger book template}, for an example using these three commands. @node \@@startsection @section @code{\@@startsection}, typesetting sectional unit headings @findex \@@startsection @cindex section, redefining Synopsis: @example \@@startsection@{@var{name}@}@{@var{level}@}@{@var{indent}@}@{@var{beforeskip}@}@{@var{afterskip}@}@{@var{style}@} @end example Used to help redefine the behavior of commands that start sectioning divisions such as @code{\section} or @code{\subsection}. Note that the @package{titlesec} package makes manipulation of sectioning easier. Further, while most requirements for sectioning commands can be satisfied with @code{\@@startsection}, some cannot. For instance, in the standard @LaTeX{} @code{book} and @code{report} classes the commands @code{\chapter} and @code{\report} are not constructed in this way. To make such a command you may want to use the @code{\secdef} command. @c xx define, and make a cross reference to, secdef. Technically, @code{\@@startsection} has the form @example \@@startsection@{@var{name}@} @{@var{level}@} @{@var{indent}@} @{@var{beforeskip}@} @{@var{afterskip}@} @{@var{style}@}*[@var{toctitle}]@{@var{title}@} @end example @noindent so that issuing @example \renewcommand@{\section@}@{\@@startsection@{@var{name}@} @{@var{level}@} @{@var{indent}@} @{@var{beforeskip}@} @{@var{afterskip}@} @{@var{style}@}@} @end example @noindent redefines @code{\section} while keeping its standard calling form @code{\section*[@var{toctitle}]@{@var{title}@}} (in which, for reminder, the star@tie{}@code{*} is optional). @xref{Sectioning}. This implies that when you write a command like @code{\renewcommand@{\section@}@{...@}}, the @code{\@@startsection@{...@}} must come last in the definition. See the examples below. @table @var @item name @anchor{startsection name} @anchor{\@@startsection/name} Name of the counter used to number the sectioning header. This counter must be defined separately. Most commonly this is either @code{section}, @code{subsection}, or @code{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 @code{\the}@var{name} displays the title number and @code{\}@var{name}@code{mark} is for the page headers. See the third example below. @item level @anchor{startsection level} @anchor{\@@startsection/level} An integer giving the depth of the sectioning command. @xref{Sectioning}, for the list of standard level numbers. If @var{level} is less than or equal to the value of the counter @code{secnumdepth} then titles for this sectioning command will be numbered (@pxref{Sectioning/secnumdepth}). For instance, if @code{secnumdepth} is 1 in an @code{article} then the command @code{\section@{Introduction@}} will produce output like ``1 Introduction'' while @code{\subsection@{Discussion@}} will produce output like ``Discussion'', without the number prefix. If @var{level} is less than or equal to the value of the counter @var{tocdepth} then the table of contents will have an entry for this sectioning unit (@pxref{Sectioning/tocdepth}). For instance, in an @code{article}, if @var{tocdepth} is 1 then the table of contents will list sections but not subsections. @item indent @anchor{startsection indent} @anchor{\@@startsection/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 @code{0pt}. A negative indentation such as @code{-\parindent} will move the title into the left margin. @item beforeskip @anchor{startsection beforeskip} @anchor{\@@startsection/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 beginning of a 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 @code{1pt plus 2pt minus 3pt} is @code{-1pt plus -2pt minus -3pt}.) For example, if @var{beforeskip} is @code{-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 @code{plus} and @code{minus}, is good practice here since it gives @LaTeX{} more flexibility in making up the page (@pxref{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 @code{\parskip} of the text font, the @code{\baselineskip} of the title font, and the absolute value of the @var{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.) @item afterskip @anchor{startsection afterskip} @anchor{\@@startsection/afterskip} This is a length. If @var{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 @code{1pt plus 2pt minus 3pt} is @code{-1pt plus -2pt minus -3pt}.) As with @var{beforeskip}, using a rubber length, with @code{plus} and @code{minus} components, is good practice here since it gives @LaTeX{} more flexibility in putting together the page. If @code{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 @code{\parskip} of the title font, the @code{\baselineskip} of the text font, and the value of @var{after}. That space is typically rubber so it may stretch or shrink. (Note that because the sign of @code{afterskip} changes the sectioning unit header's from standalone to run-in, you cannot use a negative @code{afterskip} to cancel part of the @code{\parskip}.) @item style @anchor{startsection style} @anchor{\@@startsection/style} Controls the styling of the title. See the examples below. Typical commands to use here are @code{\centering}, @code{\raggedright}, @code{\normalfont}, @code{\hrule}, or @code{\newpage}. The last command in @var{style} may be one that takes one argument, such as @code{\MakeUppercase} or @code{\fbox} that takes one argument. The section title will be supplied as the argument to this command. For instance, setting @var{style} to @code{\bfseries\MakeUppercase} would produce titles that are bold and uppercase. @end table These are @LaTeX{}'s defaults for the first three sectioning units that are defined with @code{\@@startsection}, for the @file{article}, @file{book}, and @file{report} classes. @itemize @item For @code{section}: @var{level} is 1, @var{indent} is 0@dmn{pt}, @var{beforeskip} is @code{-3.5ex plus -1ex minus -0.2ex}, @var{afterskip} is @code{2.3ex plus 0.2ex}, and @var{style} is @code{\normalfont\Large\bfseries}. @item For @code{subsection}: @var{level} is 2, @var{indent} is 0@dmn{pt}, @var{beforeskip} is @code{-3.25ex plus -1ex minus @w{-0.2ex}}, @var{afterskip} is @code{1.5ex plus 0.2ex}, and @var{style} is @code{\normalfont\large\bfseries}. @item @raggedright For @code{subsubsection}: @var{level} is 3, @var{indent} is 0@dmn{pt}, @var{beforeskip} is @code{-3.25ex plus -1ex minus -0.2ex}, @var{afterskip} is @code{1.5ex plus 0.2ex}, and @var{style} is @code{\normalfont\normalsize\bfseries}. @end raggedright @end itemize Some examples follow. These 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 @code{\makeatletter} command and a @code{\makeatother}. (Probably the error message @code{You can't use `\spacefactor' in vertical mode.} means that you forgot this.) @xref{\makeatletter & \makeatother}. This will put section titles in large boldface type, centered. It says @code{\renewcommand} because @LaTeX{}'s standard classes have already defined a @code{\section}. For the same reason it does not define a @code{section} counter, or the commands @code{\thesection} and @code{\l@@section}. @example \renewcommand\section@{% \@@startsection@{section@}% @ref{\@@startsection/name,@var{name},@var{name}} @{1@}% @ref{\@@startsection/level,@var{level},@var{level}} @{0pt@}% @ref{\@@startsection/indent,@var{indent},@var{indent}} @{-3.5ex plus -1ex minus -.2ex@}% @ref{\@@startsection/beforeskip,@var{beforeskip},@var{beforeskip}} @{2.3ex plus.2ex@}% @ref{\@@startsection/afterskip,@var{afterskip},@var{afterskip}} @{\centering\normalfont\Large\bfseries@}% @ref{\@@startsection/style,@var{style},@var{style}} @} @end example This will put @code{subsection} titles in small caps type, inline with the paragraph. @example \renewcommand\subsection@{% \@@startsection@{subsection@}% @ref{\@@startsection/name,@var{name},@var{name}} @{2@}% @ref{\@@startsection/level,@var{level},@var{level}} @{0em@}% @ref{\@@startsection/indent,@var{indent},@var{indent}} @{-1ex plus 0.1ex minus -0.05ex@}% @ref{\@@startsection/beforeskip,@var{beforeskip},@var{beforeskip}} @{-1em plus 0.2em@}% @ref{\@@startsection/afterskip,@var{afterskip},@var{afterskip}} @{\scshape@}% @ref{\@@startsection/style,@var{style},@var{style}} @} @end example The prior examples redefined existing sectional unit title commands. This defines a new one, illustrating the needed counter and macros to display that counter. @c From https://groups.google.com/forum/#!searchin/comp.text.tex/startsection%7Csort:relevance/comp.text.tex/sB-nTS-oL08/ZZeKYdG0llMJ @example \setcounter@{secnumdepth@}@{6@}% show counters this far down \newcounter@{subsubparagraph@}[subparagraph]% counter for numbering \renewcommand@{\thesubsubparagraph@}% how to display @{\thesubparagraph.\@@arabic\c@@subsubparagraph@}% numbering \newcommand@{\subsubparagraph@}@{\@@startsection @{subsubparagraph@}% @{6@}% @{0em@}% @{\baselineskip@}% @{0.5\baselineskip@}% @{\normalfont\normalsize@}@} \newcommand*\l@@subsubparagraph@{\@@dottedtocline@{6@}@{10em@}@{5em@}@}% for toc \newcommand@{\subsubparagraphmark@}[1]@{@}% for page headers @end example @node Cross references @chapter Cross references @cindex cross references @cindex label We often want something like @samp{See Theorem~31}. But by-hand typing the 31 is poor practice. Instead you should write a @dfn{label} such as @code{\label@{eq:GreensThm@}} and then @dfn{reference} it, as with @code{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. @example 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@}. @end example @LaTeX{} tracks cross reference information in a file having the extension @file{.aux} and with the same base name as the file containing the @code{\label}. So if @code{\label} is in @file{calculus.tex} then the information is in @file{calculus.aux}. @LaTeX{} puts the information in that file every time it runs across a @code{\label}. @cindex forward reference @cindex reference, forward The behavior described in the prior paragraph results in a quirk that happens when your document has a @dfn{forward reference}, a @code{\ref} that appears before the associated @code{\label}. If this is the first time that you are compiling the document then you will get @samp{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@tie{}@samp{??}, 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. @PkgIndex{cleveref} The @package{cleveref} package enhances @LaTeX{}'s cross referencing features. You can arrange that if you enter @code{\begin@{thm@}\label@{th:Nerode@}...\end@{thm@}} then @code{\cref@{th:Nerode@}} will output @samp{Theorem 3.21}, without you having to enter the ``Theorem.'' @menu * \label:: Assign a symbolic name to a piece of text. * \pageref:: Refer to a page number. * \ref:: Refer to a section, figure or similar. * xr package:: References from another document. @end menu @node \label @section @code{\label} @findex \label Synopsis: @example \label@{@var{key}@} @end example Assign a reference number to @var{key}. In ordinary text @code{\label@{@var{key}@}} assigns to @var{key} the number of the current sectional unit. Inside an environment with numbering, such as a @code{table} or @code{theorem} environment, @code{\label@{@var{key}@}} assigns to @var{key} the number of that environment. Retrieve the assigned number with the @code{\ref@{@var{key}@}} command (@pxref{\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, @code{\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: @table @code @item ch for chapters @item sec @itemx subsec for lower-level sectioning commands @item fig for figures @item tab for tables @item eq for equations @end table In the auxiliary file the reference information is kept as the text of a command of the form @code{\newlabel@{@var{label}@}@{@{@var{currentlabel}@}@{@var{pagenumber}@}@}}. Here @var{currentlabel} is the current value of the macro @code{\@@currentlabel} that is usually updated whenever you call @code{\refstepcounter@{@var{counter}@}}. Below, the key @code{sec:test} will get the number of the current section and the key @code{fig:test} will get the number of the figure. (Incidentally, put labels after captions in figures and tables.) @example \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@}. @end example @node \pageref @section @code{\pageref} @findex \pageref @cindex cross referencing with page number @cindex page number, cross referencing Synopsis: @example \pageref@{@var{key}@} @end example Produce the page number of the place in the text where the corresponding @code{\label}@{@var{key}@} command appears. If there is no @code{\label@{@var{key}@}} then you get something like @samp{LaTeX Warning: Reference `th:GrensThm' on page 1 undefined on input line 11.} Below, the @code{\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.) @example The main result is formula~\ref@{eq:main@} on page~\pageref@{eq:main@}. ... \begin@{equation@} \label@{eq:main@} \mathbf@{P@}=\mathbf@{NP@} \end@{equation@} @end example @node \ref @section @code{\ref} @findex \ref @cindex cross referencing, symbolic @cindex section number, cross referencing @cindex equation number, cross referencing @cindex figure number, cross referencing @cindex footnote number, cross referencing Synopsis: @example \ref@{@var{key}@} @end example Produces the number of the sectional unit, equation, footnote, figure, @dots{}, of the corresponding @code{\label} command (@pxref{\label}). It does not produce any text, such as the word `Section' or `Figure', just the bare number itself. If there is no @code{\label@{@var{key}@}} then you get something like @samp{LaTeX Warning: Reference `th:GrensThm' on page 1 undefined on input line 11.} In this example the @code{\ref@{popular@}} produces @samp{2}. Note that it is a forward reference since it comes before @code{\label@{popular@}} so this document would have to be compiled twice. @example 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@} @end example @PkgIndex{cleveref} The @package{cleveref} package includes text such as @samp{Theorem} in the reference. See the documentation on CTAN. @node xr package @section @package{xr} package @PkgIndex{xr} @PkgIndex{xr-hyper} @findex \externaldocument @cindex cross referencing, across documents Synopsis: @example \usepackage@{xr@} \externaldocument@{@var{document-basename}@} @end example @noindent or @example \usepackage@{xr@} \externaldocument[@var{reference-prefix}]@{@var{document-basename}@} @end example Make cross references to the external document @file{@var{document-basename}.tex}. Here is an example. If @file{lectures.tex} has this in the preamble @example \usepackage@{xr@} \externaldocument@{exercises@} \externaldocument[H-]@{hints@} \externaldocument@{answers@} @end example @noindent then it can use cross reference labels from the other three documents. Suppose that @file{exercises.tex} has an enumerated list containing this, @example \item \label@{exer:EulersThm@} What if every vertex has odd degree? @end example @noindent and @file{hints.tex} has an enumerated list with this, @example \item \label@{exer:EulersThm@} Distinguish the case of two vertices. @end example @noindent and @file{answers.tex} has an enumerated list with this, @example \item \label@{ans:EulersThm@} There is no Euler path, except if there are exactly two vertices. @end example After compiling the exercises, hints, and answers documents, entering this in the body of @file{lectures.tex} will result in the lectures getting the reference numbers used in the other documents. @example See Exercise~\ref@{exer:EulersThm@}, with Hint~\ref@{H-exer:EulersThm@}. The solution is Answer~\ref@{ans:EulersThm@}. @end example The prefix @code{H-} for the reference from the hints file is needed because the label in the hints file is the same as the label in the exercises file. Without that prefix, both references would get the number from the later file. Note: if the document uses the @package{hyperref} package then in place of @package{xr}, put @code{\usepackage@{xr-hyper@}} before the @code{\usepackage@{hyperref@}}. Also, if any of the multiple documents uses @package{hyperref} then they all must use it. @node Environments @chapter Environments @cindex environments @findex \begin @findex \end @LaTeX{} provides many environments for delimiting certain behavior. An environment begins with @code{\begin} and ends with @code{\end}, like this: @example \begin@{@var{environment-name}@} ... \end@{@var{environment-name}@} @end example The @var{environment-name} at the beginning must exactly match that at the end. For instance, the input @code{\begin@{table*@}...\end@{table@}} will cause an error like: @samp{! LaTeX Error: \begin@{table*@} on input line 5 ended by \end@{table@}.} @cindex group, and environments Environments are executed within a group. @menu * 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. @end menu @node abstract @section @code{abstract} @EnvIndex{abstract} @cindex abstracts Synopsis: @example \begin@{abstract@} ... \end@{abstract@} @end example Produce an abstract, possibly of multiple paragraphs. This environment is only defined in the @code{article} and @code{report} document classes (@pxref{Document classes}). Using the example below in the @code{article} class produces a displayed paragraph. Document class option @code{titlepage} causes the abstract to be on a separate page (@pxref{Document class options}); this is the default only in the @code{report} class. @example \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@} @end example @PkgIndex abstract The next example produces a one column abstract in a two column document (for a more flexible solution, use the package @file{abstract}). @c Adopted from http://www.tex.ac.uk/FAQ-onecolabs.html @example \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.@} @} @end example @node array @section @code{array} @EnvIndex{array} @cindex arrays, math Synopsis: @example \begin@{array@}@{@var{cols}@} @var{column 1 entry} &@var{column 2 entry} ... &@var{column n entry} \\ ... \end@{array@} @end example @noindent or: @example \begin@{array@}[@var{pos}]@{@var{cols}@} @var{column 1 entry} &@var{column 2 entry} ... &@var{column n entry} \\ ... \end@{array@} @end example Produce a mathematical array. This environment can only be used in math mode (@pxref{Modes}), and normally appears within a displayed mathematics environment such as @code{equation} (@pxref{equation}). Inside of each row the column entries are separated by an ampersand, (@code{&}). Rows are terminated with double-backslashes (@pxref{\\}). This example shows a three by three array. @example \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*@} @end example The required argument @var{cols} describes the number of columns, their alignment, and the formatting of the intercolumn regions. For instance, @code{\begin@{array@}@{rcl@}...\end@{array@}} gives three columns: the first flush right, the second centered, and the third flush left. See @ref{tabular} for the complete description of @var{cols} and of the other common features of the two environments, including the optional @var{pos} argument. There are two ways that @code{array} diverges from @code{tabular}. The first is that @code{array} entries are typeset in math mode, in textstyle (@pxref{Math styles}) except if the @var{cols} definition specifies the column with @code{p@{...@}}, which causes the entry to be typeset in text mode. The second is that, instead of @code{tabular}'s parameter @code{\tabcolsep}, @LaTeX{}'s intercolumn space in an @code{array} is governed by @findex \arraycolsep @code{\arraycolsep}, which gives half the width between columns. The default for this is @samp{5pt} so that between two columns comes 10@dmn{pt} of space. @PkgIndex{amsmath} To obtain arrays with braces the standard is to use the @package{amsmath} package. It comes with environments @code{pmatrix} for an array surrounded by parentheses@tie{}@code{(...)}, @code{bmatrix} for an array surrounded by square brackets@tie{}@code{[...]}, @code{Bmatrix} for an array surrounded by curly braces@tie{}@code{@{...@}}, @code{vmatrix} for an array surrounded by vertical bars@tie{}@code{|...|}, and @code{Vmatrix} for an array surrounded by double vertical bars@tie{}@code{||...||}, along with a number of other array constructs. @PkgIndex{amsmath} The next example uses the @package{amsmath} package. @example \usepackage@{amsmath@} % in preamble \begin@{equation@} \begin@{vmatrix@}@{cc@} % array with vert lines a &b \\ c &d \end@{vmatrix@}=ad-bc \end@{equation@} @end example @PkgIndex{array} @PkgIndex{dcolumn} There are many packages concerning arrays. The @package{array} package has many useful extensions, including more column types. The @package{dcolumn} package adds a column type to center on a decimal point. For both see the documentation on CTAN. @node center @section @code{center} @EnvIndex{center} @cindex centering text, environment for Synopsis: @example \begin@{center@} @var{line1} \\ @var{line2} \\ ... \end@{center@} @end example Create a new paragraph consisting of a sequence of lines that are centered within the left and right margins. Use double-backslash, @code{\\}, to get a line break (@pxref{\\}). @findex \\ @r{(for @code{center})} 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 @ref{\centering} to avoid such space, for example inside a @code{figure} environment. This example produces three centered lines. There is extra vertical space between the last two lines. @example \begin@{center@} A Thesis Submitted in Partial Fufillment \\ of the Requirements of \\[0.5ex] the School of Environmental Engineering \end@{center@} @end example 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. @example \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@} @end example 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. @menu * \centering:: Declaration form of the @code{center} environment. @end menu @node \centering @subsection @code{\centering} @findex \centering @cindex centering text, declaration for Synopsis: @example @{\centering ... @} @end example @noindent or @example \begin@{group@} \centering ... \end@{group@} @end example Center the material in its scope. It is most often used inside an environment such as @code{figure}, or in a @code{parbox}. This example's @code{\centering} declaration causes the graphic to be horizontally centered. @example \begin@{figure@} \centering \includegraphics[width=0.6\textwidth]@{ctan_lion.png@} \caption@{CTAN Lion@} \label@{fig:CTANLion@} \end@{figure@} @end example @noindent The scope of this @code{\centering} ends with the @code{\end@{figure@}}. Unlike the @code{center} environment, the @code{\centering} command does not add vertical space above and below the text. That's its advantage in the above example; there is not an excess of space. It also does not start a new paragraph; it simply changes how @LaTeX{} formats paragraph units. If @code{ww @{\centering xx \\ yy@} zz} is surrounded by blank lines then @LaTeX{} will create a paragraph whose first line @samp{ww xx} is centered and whose second line, not centered, contains @samp{yy zz}. Usually what is desired is for the scope of the declaration to contain a blank line or the @code{\end} command of an environment such as @code{figure} or @code{table} that ends the paragraph unit. Thus, if @code{@{\centering xx \\ yy\par@} zz} is surrounded by blank lines then it makes a new paragraph with two centered lines @samp{xx} and @samp{yy}, followed by a new paragraph with @samp{zz} that is formatted as usual. @node description @section @code{description} @EnvIndex{description} @cindex labelled lists, creating @cindex description lists, creating Synopsis: @example \begin@{description@} \item[@var{label of first item}] @var{text of first item} \item[@var{label of second item}] @var{text of second item} ... \end@{description@} @end example Environment to make a list of labeled items. Each item's @var{label} is typeset in bold and is flush left, so that long labels continue into the first line of the item text. There must be at least one item; having none causes the @LaTeX{} error @samp{Something's wrong--perhaps a missing \item}. This example shows the environment used for a sequence of definitions. @example \begin@{description@} \item[lama] A priest. \item[llama] A beast. \end@{description@} @end example @noindent The labels @samp{lama} and @samp{llama} are output in boldface, with the left edge on the left margin. @findex \item Start list items with the @code{\item} command (@pxref{\item}). Use the optional labels, as in @code{\item[Main point]}, because there is no sensible default. Following the @code{\item} is optional text, which may contain multiple paragraphs. @cindex bold typewriter, avoiding @cindex typewriter labels in lists Since the labels are in bold style, if the label text calls for a font change given in argument style (see @ref{Font styles}) then it will come out bold. For instance, if the label text calls for typewriter with @code{\item[\texttt@{label text@}]} then it will appear in bold typewriter, if that is available. The simplest way around this, in this example to get non-bold typewriter, is to use declarative style: @code{\item[@{\tt label text@}]}. Similarly, get the standard roman font with @code{\item[@{\rm label text@}]}. For other major @LaTeX{} labelled list environments, see @ref{itemize} and @ref{enumerate}. Unlike those environments, nesting @code{description} environments does not change the default label; it is boldface and flush left at all levels. For information about list layout parameters, including the default values, and for information about customizing list layout, see @ref{list}. The package @package{enumitem} is useful for customizing lists. This example changes the description labels to small caps. @example \renewcommand@{\descriptionlabel@}[1]@{% @{\hspace@{\labelsep@}\textsc@{#1@}@}@} @end example @node displaymath @section @code{displaymath} @c http://tex.stackexchange.com/questions/40492/what-are-the-differences-between-align-equation-and-displaymath @EnvIndex{displaymath} Synopsis: @example \begin@{displaymath@} @var{mathematical text} \end@{displaymath@} @end example Environment to typeset the @var{mathematical text} on its own line, in display style and centered. To make the text be flush-left use the global option @code{fleqn}; see @ref{Document class options}. In the @code{displaymath} environment no equation number is added to the math text. One way to get an equation number is to use the @code{equation} environment (@pxref{equation}). @LaTeX{} will not break the @var{math text} across lines. @PkgIndex{amsmath} Note that the @package{amsmath} package has significantly more extensive displayed equation facilities. For example, there are a number of ways in that package for having math text broken across lines. @findex \[...\] @r{display math} The construct @code{\[@var{math}\]} is a synonym for the environment @code{\begin@{displaymath@} @var{math} \end@{displaymath@}} but the latter is easier to work with in the source; for instance, searching for a square bracket may get false positives but the word @code{displaymath} will likely be unique. @findex $$...$$ @r{plain @TeX{} display math} (Aside: The construct @code{$$@var{math}$$} from Plain@tie{}@TeX{} is sometimes mistakenly used as a synonym for @code{displaymath}. It is not a synonym, and is not officially supported in @LaTeX{} at all; @code{$$} doesn't support the @code{fleqn} option (@pxref{Document class options}), has different vertical spacing, and doesn't perform consistency checks.) The output from this example is centered and alone on its line. @example \begin@{displaymath@} \int_1^2 x^2\,dx=7/3 \end@{displaymath@} @end example @noindent Also, the integral sign is larger than the inline version @code{\( \int_1^2 x^2\,dx=7/3 \)} produces. @node document @section @code{document} @EnvIndex{document} The @code{document} environment encloses the entire body of a document. It is required in every @LaTeX{} document. @xref{Starting and ending}. @menu * \AtBeginDocument:: Hook for commands at the start of the document. * \AtEndDocument:: Hook for commands at the end of the document. @end menu @node \AtBeginDocument @subsection @code{\AtBeginDocument} @findex \AtBeginDocument @cindex beginning of document hook Synopsis: @example \AtBeginDocument@{@var{code}@} @end example Save @var{code} and execute it when @code{\begin@{document@}} is executed, at the very end of the preamble. The code is executed after the font selection tables have been set up, so the normal font for the document is the current font. However, the code is executed as part of the preamble so you cannot do any typesetting with it. You can issue this command more than once; the successive code lines will be executed in the order that you gave them. @node \AtEndDocument @subsection @code{\AtEndDocument} @findex \AtEndDocument @cindex end of document hook Synopsis: @example \AtEndDocument@{@var{code}@} @end example Save @var{code} and execute it near the end of the document. Specifically, it is executed when @code{\end@{document@}} is executed, before the final page is finished and before any leftover floating environments are processed. If you want some of the code to be executed after these two processes then include a @code{\clearpage} at the appropriate point in @var{code}. You can issue this command more than once; the successive code lines will be executed in the order that you gave them. @node enumerate @section @code{enumerate} @EnvIndex{enumerate} @cindex lists of items, numbered Synopsis: @example \begin@{enumerate@} \item[@var{optional label of first item}] @var{text of first item} \item[@var{optional label of second item}] @var{text of second item} ... \end@{enumerate@} @end example Environment to produce a numbered list of items. The format of the label numbering depends on the nesting level of this environment; see below. The default top-level numbering is @samp{1.}, @samp{2.}, etc. Each @code{enumerate} list environment must have at least one item; having none causes the @LaTeX{} error @samp{Something's wrong--perhaps a missing \item}. This example gives the first two finishers in the 1908 Olympic marathon. As a top-level list the labels would come out as @samp{1.} and @samp{2.}. @example \begin@{enumerate@} \item Johnny Hayes (USA) \item Charles Hefferon (RSA) \end@{enumerate@} @end example @findex \item Start list items with the @code{\item} command (@pxref{\item}). If you give @code{\item} an optional argument by following it with square brackets, as in @code{\item[Interstitial label]}, then the next item will continue the interrupted sequence (@pxref{\item}). That is, you will get labels like @samp{1.}, then @samp{Interstitial label}, then @samp{2.}. Following the @code{\item} is optional text, which may contain multiple paragraphs. Enumerations may be nested within other @code{enumerate} environments, or within any paragraph-making environment such as @code{itemize} (@pxref{itemize}), up to four levels deep. This gives @LaTeX{}'s default for the format at each nesting level, where 1 is the top level, the outermost level. @enumerate @item arabic number followed by a period: @samp{1.}, @samp{2.},@tie{}@dots{} @item lowercase letter inside parentheses: @samp{(a)}, @samp{(b)}@tie{}@dots{} @item lowercase roman numeral followed by a period: @samp{i.}, @samp{ii.},@tie{}@dots{} @item uppercase letter followed by a period: @samp{A.}, @samp{B.},@tie{}@dots{} @end enumerate @findex \enumi @findex \enumii @findex \enumiii @findex \enumiv @anchor{enumerate enumi} @anchor{enumerate enumii} @anchor{enumerate enumiii} @anchor{enumerate enumiv} The @code{enumerate} environment uses the counters @code{\enumi} through @code{\enumiv} (@pxref{Counters}). For other major @LaTeX{} labeled list environments, see @ref{description} and @ref{itemize}. For information about list layout parameters, including the default values, and for information about customizing list layout, see @ref{list}. The package @package{enumitem} is useful for customizing lists. @findex \labelenumi @findex \labelenumii @findex \labelenumiii @findex \labelenumiv @anchor{enumerate labelenumi} @anchor{enumerate labelenumii} @anchor{enumerate labelenumiii} @anchor{enumerate labelenumiv} To change the format of the label use @code{\renewcommand} (@pxref{\newcommand & \renewcommand}) on the commands @code{\labelenumi} through @code{\labelenumiv}. For instance, this first level list will be labelled with uppercase letters, in boldface, and without a trailing period. @findex \Alph @r{example} @example \renewcommand@{\labelenumi@}@{\textbf@{\Alph@{enumi@}@}@} \begin@{enumerate@} \item Shows as boldface A \item Shows as boldface B \end@{enumerate@} @end example For a list of counter-labeling commands see @ref{\alph \Alph \arabic \roman \Roman \fnsymbol}. @node eqnarray @section @code{eqnarray} @EnvIndex{eqnarray} @cindex equations, aligning @cindex aligning equations @cindex align @r{environment, from @package{amsmath}} @cindex amsmath @r{package, replacing @code{eqnarray}} @cindex Madsen, Lars The @code{eqnarray} environment is obsolete. It has infelicities, including spacing that is inconsistent with other mathematics elements. (See ``Avoid eqnarray!''@: by Lars Madsen @url{https://tug.org/TUGboat/tb33-1/tb103madsen.pdf}). New documents should include the @package{amsmath} package and use the displayed mathematics environments provided there, such as the @code{align} environment. We include a description only for completeness and for working with old documents. Synopsis: @example \begin@{eqnarray@} @var{first formula left} &@var{first formula middle} &@var{first formula right} \\ ... \end@{eqnarray@} @end example @noindent or @example \begin@{eqnarray*@} @var{first formula left} &@var{first formula middle} &@var{first formula right} \\ ... \end@{eqnarray*@} @end example @findex \\ @r{(for @code{eqnarray})} Display a sequence of equations or inequalities. The left and right sides are typeset in display mode, while the middle is typeset in text mode. It is similar to a three-column @code{array} environment, with items within a row separated by an ampersand@tie{}(@code{&}), and with rows separated by double backslash@tie{} @code{\\}). @findex \\* @r{(for @code{eqnarray})} The starred form of line break (@code{\\*}) can also be used to separate equations, and will disallow a page break there (@pxref{\\}). @findex \nonumber @cindex equation numbers, omitting The unstarred form @code{eqnarray} places an equation number on every line (using the @code{equation} counter), unless that line contains a @code{\nonumber} command. The starred form @code{eqnarray*} omits equation numbering, while otherwise being the same. @findex \lefteqn The command @code{\lefteqn} is used for splitting long formulas across lines. It typesets its argument in display style flush left in a box of zero width. This example shows three lines. The first two lines make an inequality, while the third line has not entry on the left side. @example \begin@{eqnarray*@} \lefteqn@{x_1+x_2+\cdots+x_n@} \\ &\leq &y_1+y_2+\cdots+y_n \\ &= &z+y_3+\cdots+y_n \end@{eqnarray*@} @end example @node equation @section @code{equation} @EnvIndex{equation} @cindex equations, environment for @cindex formulas, environment for Synopsis: @example \begin@{equation@} @var{mathematical text} \end@{equation@} @end example The same as a @code{displaymath} environment (@pxref{displaymath}) except that @LaTeX{} puts an equation number flush to the right margin. The equation number is generated using the @code{equation} counter. You should have no blank lines between @code{\begin@{equation@}} and @code{\begin@{equation@}}, or @LaTeX{} will tell you that there is a missing dollar sign. @PkgIndex{amsmath} The package @package{amsmath} package has extensive displayed equation facilities. New documents should include this package. @node figure @section @code{figure} @EnvIndex{figure} @cindex inserting figures @cindex figures, inserting Synopsis: @example \begin@{figure@}[@var{placement}] @var{figure body} \caption[@var{loftitle}]@{@var{title}@} % optional \label@{@var{label@}} % optional \end@{figure@} @end example @noindent or: @example \begin@{figure*@}[@var{placement}] @var{figure body} \caption[@var{loftitle}]@{@var{title}@} % optional \label@{@var{label@}} % optional \end@{figure*@} @end example Figures are for material that is not part of the normal text. An example is material that you cannot have split between two pages, such as a graphic. Because of this, @LaTeX{} does not typeset figures in sequence with normal text but instead ``floats'' them to a convenient place, such as the top of a following page (@pxref{Floats}). The @var{figure body} can consist of imported graphics (@pxref{Graphics}), or text, @LaTeX{} commands, etc. It is typeset in a @code{parbox} of width @code{\textwidth}. The possible values of @var{placement} are @code{h} for @samp{here}, @code{t} for @samp{top}, @code{b} for @samp{bottom}, and @code{p} for @samp{on a separate page of floats}. For the effect of these options on the float placement algorithm, see @ref{Floats}. The starred form @code{figure*} is used when a document is in double-column mode (@pxref{\twocolumn}). It produces a figure that spans both columns, at the top of the page. To add the possibility of placing at a page bottom see the discussion of @var{placement} @code{b} in @ref{Floats}. @findex \caption The label is optional; it is used for cross references (@pxref{Cross references}). The optional @code{\caption} command specifies caption text for the figure (@pxref{\caption}). By default it is numbered. If @var{loftitle} is present, it is used in the list of figures instead of @var{title} (@pxref{Table of contents etc.}). This example makes a figure out of a graphic. @LaTeX{} will place that graphic and its caption at the top of a page or, if it is pushed to the end of the document, on a page of floats. @example \usepackage@{graphicx@} % in preamble ... \begin@{figure@}[t] \centering \includegraphics[width=0.5\textwidth]@{CTANlion.png@} \caption@{The CTAN lion, by Duane Bibby@} \end@{figure@} @end example @node filecontents @section @code{filecontents} @EnvIndex{filecontents} @EnvIndex{filecontents*} @cindex external files, writing @cindex writing external files Synopsis: @example \begin@{filecontents@}[@var{option}]@{@var{filename}@} @var{text} \end@{filecontents@} @end example @noindent or @example \begin@{filecontents*@}[@var{option}]@{@var{filename}@} @var{text} \end@{filecontents*@} @end example Create a file named @var{filename} in the current directory (or the output directory, if specified; @pxref{output directory}) and write @var{text} to it. By default, an existing file is not overwritten. The unstarred version of the environment @code{filecontents} prefixes the content of the created file with a header of @TeX{} comments; see the example below. The starred version @code{filecontents*} does not include the header. The possible options are: @table @code @item force @itemx overwrite @cindex @code{force} option for @code{filecontents} @cindex @code{overwrite} option for @code{filecontents} Overwrite an existing file. @item noheader @cindex @code{noheader} option for @code{filecontents} Omit the header. Equivalent to using @code{filecontents*}. @item nosearch @cindex @code{nosearch} option for @code{filecontents} Only check the current directory (and the output directory, if specified) for an existing file, not the entire search path. @end table These options were added in a 2019 release of @LaTeX{}. @cindex self-contained sources @cindex source files, making self-contained This environment can be used anywhere in the preamble, although it often appears before the @code{\documentclass} command. It is commonly used to create a @code{.bib} or other such data file from the main document source, to make the source file self-contained. Similarly, it can be used to create a custom style or class file, again making the source self-contained. For example, this document: @example \documentclass@{article@} \begin@{filecontents@}@{JH.sty@} \newcommand@{\myname@}@{Jim Hef@{@}feron@} \end@{filecontents@} \usepackage@{JH@} \begin@{document@} Article by \myname. \end@{document@} @end example @noindent produces this file @file{JH.sty}: @example %% LaTeX2e file `JH.sty' %% generated by the `filecontents' environment %% from source `test' on 2015/10/12. %% \newcommand@{\myname@}@{Jim Hef@{@}feron@} @end example @node flushleft @section @code{flushleft} @EnvIndex{flushleft} @cindex left-justifying text, environment for @cindex ragged right text, environment for Synopsis: @example \begin@{flushleft@} @var{line1} \\ @var{line2} \\ ... \end@{flushleft@} @end example @findex \\ @r{for @code{flushleft}} An environment that creates a paragraph whose lines are flush to the left-hand margin, and ragged right. If you have lines that are too long then @LaTeX{} will linebreak them in a way that avoids hyphenation and stretching or shrinking interword spaces. To force a new line use a double backslash, @code{\\}. For the declaration form see@tie{}@ref{\raggedright}. This creates a box of text that is at most 3 inches wide, with the text flush left and ragged right. @example \noindent\begin@{minipage@}@{3in@} \begin@{flushleft@} A long sentence that will be broken by \LaTeX@{@} at a convenient spot. \\ And, a fresh line forced by the double backslash. \end@{flushleft@} \end@{minipage@} @end example @menu * \raggedright:: Declaration form of the @code{flushleft} environment. @end menu @node \raggedright @subsection @code{\raggedright} @findex \raggedright @cindex ragged right text @cindex left-justifying text @cindex justification, ragged right Synopses: @example @{\raggedright ... @} @end example @noindent or @example \begin@{@var{environment}@} \raggedright ... \end@{@var{environment}@} @end example A declaration which causes lines to be flush to the left margin and ragged right. It can be used inside an @var{environment} such as @code{quote} or in a @code{parbox}. For the environment form see@tie{}@ref{flushleft}. Unlike the @code{flushleft} environment, the @code{\raggedright} command does not start a new paragraph; it only changes how @LaTeX{} formats paragraph units. To affect a paragraph unit's format, the scope of the declaration must contain the blank line or @code{\end} command that ends the paragraph unit. Here @code{\raggedright} in each second column keeps @LaTeX{} from doing very awkward typesetting to fit the text into the narrow column. Note that @code{\raggedright} is inside the curly braces @code{@{...@}} to delimit its effect. @example \begin@{tabular@}@{rp@{2in@}@} Team alpha &@{\raggedright This team does all the real work.@} \\ Team beta &@{\raggedright This team ensures that the water cooler is never empty.@} \\ \end@{tabular@} @end example @node flushright @section @code{flushright} @EnvIndex{flushright} @cindex ragged left text, environment for @cindex right-justifying text, environment for @example \begin@{flushright@} @var{line1} \\ @var{line2} \\ ... \end@{flushright@} @end example @findex \\ @r{(for @code{flushright})} An environment that creates a paragraph whose lines are flush to the right-hand margin and ragged left. If you have lines that are too long to fit the margins then @LaTeX{} will linebreak them in a way that avoids hyphenation and stretching or shrinking inter-word spaces. To force a new line use a double backslash, @code{\\}. For the declaration form see@tie{}@ref{\raggedleft}. For an example related to this environment, see@tie{}@ref{flushleft}, where one just have mutatis mutandis to replace @code{flushleft} by @code{flushright}. @menu * \raggedleft:: Declaration form of the @code{flushright} environment. @end menu @node \raggedleft @subsection @code{\raggedleft} @findex \raggedleft @cindex ragged left text @cindex justification, ragged left @cindex right-justifying text Synopses: @example @{\raggedleft ... @} @end example @noindent or @example \begin@{@var{environment}@} \raggedleft ... \end@{@var{environment}@} @end example A declaration which causes lines to be flush to the right margin and ragged left. It can be used inside an @var{environment} such as @code{quote} or in a @code{parbox}. For the environment form see@tie{}@ref{flushright}. Unlike the @code{flushright} environment, the @code{\raggedleft} command does not start a new paragraph; it only changes how @LaTeX{} formats paragraph units. To affect a paragraph unit's format, the scope of the declaration must contain the blank line or @code{\end} command that ends the paragraph unit. For an example related to this environment, see@tie{}@ref{\raggedright}, where one just have mutatis mutandis to replace @code{\raggedright} by @code{\raggedleft}. @node itemize @section @code{itemize} @EnvIndex{itemize} @findex \item @cindex lists of items @cindex unordered lists @cindex bulleted lists @cindex bullet lists Synopsis: @example \begin@{itemize@} \item[@var{optional label of first item}] @var{text of first item} \item[@var{optional label of second item}] @var{text of second item} ... \end@{itemize@} @end example Produce an @dfn{unordered list}, sometimes called a bullet list. There must be at least one @code{\item} within the environment; having none causes the @LaTeX{} error @samp{Something's wrong--perhaps a missing \item}. This gives a two-item list. @example \begin@{itemize@} \item Pencil and watercolor sketch by Cassandra \item Rice portrait \end@{itemize@} @end example @noindent With the default locale---without loading e.g.@: @package{babel} package with another language than USenglish---as a top-level list each label would come out as a bullet, @bullet{}. The format of the labeling depends on the nesting level; see below. @findex \item Start list items with the @code{\item} command (@pxref{\item}). If you give @code{\item} an optional argument by following it with square brackets, as in @code{\item[@var{Optional label}]}, then by default @var{Optional label} will appear in bold and be flush right, so it could extend into the left margin. For labels that are flush left see the @ref{description} environment. Following the @code{\item} is the text of the item, which may be empty or contain multiple paragraphs. Unordered lists can be nested within one another, up to four levels deep. They can also be nested within other paragraph-making environments, such as @code{enumerate} (@pxref{enumerate}). @findex \labelitemi @findex \labelitemii @findex \labelitemiii @findex \labelitemiv @anchor{itemize labelitemi} @anchor{itemize labelitemii} @anchor{itemize labelitemiii} @anchor{itemize labelitemiv} The @code{itemize} environment uses the commands @code{\labelitemi} through @code{\labelitemiv} to produce the default label (note the convention of lowercase roman numerals at the end of the command names that signify the nesting level). These are the default marks at each level. @enumerate @item @bullet{} (bullet, from @code{\textbullet}) @item @b{-@w{-}} (bold en-dash, from @code{\normalfont\bfseries\textendash}) @item * (asterisk, from @code{\textasteriskcentered}) @iftex @item @math{\cdot} (vertically centered dot, from @code{\textperiodcentered}) @end iftex @ifnottex @item . (vertically centered dot, rendered here as a period, from @code{\textperiodcentered}) @end ifnottex @end enumerate Change the labels with @code{\renewcommand}. For instance, this makes the first level use diamonds. @example \renewcommand@{\labelitemi@}@{$\diamond$@} @end example @findex \leftmargin @findex \leftmargini @findex \leftmarginii @findex \leftmarginiii @findex \leftmarginiv @findex \leftmarginv @findex \leftmarginvi @anchor{itemize leftmargin} @anchor{itemize leftmargini} @anchor{itemize leftmarginii} @anchor{itemize leftmarginiii} @anchor{itemize leftmarginiv} @anchor{itemize leftmarginv} @anchor{itemize leftmarginvi} The distance between the left margin of the enclosing environment and the left margin of the @code{itemize} list is determined by the parameters @code{\leftmargini} through @code{\leftmarginvi}. (This also uses the convention of using lowercase roman numerals a the end of the command name to denote the nesting level.) The defaults are: @code{2.5em} in level 1 (@code{2em} in two-column mode), @code{2.2em} in level 2, @code{1.87em} in level 3, and @code{1.7em} in level 4, with smaller values for more deeply nested levels. @PkgIndex{enumitem} For other major @LaTeX{} labeled list environments, see @ref{description} and @ref{enumerate}. The @code{itemize}, @code{enumerate} and @code{description} environment use the same list layout parameters. For a description, including the default values, and for information about customizing list layout, see @ref{list}. The package @package{enumitem} is useful for customizing lists. This example greatly reduces the margin space for outermost itemized lists. @example \setlength@{\leftmargini@}@{1.25em@} % default 2.5em @end example @findex \parskip @r{example} Especially for lists with short items, it may be desirable to elide space between items. Here is an example defining an @code{itemize*} environment with no extra spacing between items, or between paragraphs within a single item (@code{\parskip} is not list-specific, @pxref{\parindent & \parskip}): @example \newenvironment@{itemize*@}% @{\begin@{itemize@}% \setlength@{\itemsep@}@{0pt@}% \setlength@{\parsep@}@{0pt@}@}% \setlength@{\parskip@}@{0pt@}@}% @{\end@{itemize@}@} @end example @node letter @section @code{letter} environment: writing letters @EnvIndex{letter} This environment is used for creating letters. @xref{Letters}. @node list @section @code{list} @EnvIndex{list} @cindex lists of items, generic Synopsis: @example \begin@{list@}@{@var{labeling}@}@{@var{spacing}@} \item[@var{optional label of first item}] @var{text of first item} \item[@var{optional label of second item}] @var{text of second item} ... \end@{list@} @end example An environment for constructing lists. Note that this environment does not typically appear in the document body. Most lists created by @LaTeX{} authors are the ones that come standard: the @code{description}, @code{enumerate}, and @code{itemize} environments (@pxref{description}, @ref{enumerate}, and @ref{itemize}). Instead, the @code{list} environment is most often used in macros. For example, many standard @LaTeX{} environments that do not immediately appear to be lists are in fact constructed using @code{list}, including @code{quotation}, @code{quote}, and @code{center} (@pxref{quotation & quote}, @pxref{center}). This uses the @code{list} environment to define a new custom environment. @example \newcounter@{namedlistcounter@} % number the items \newenvironment@{named@} @{\begin@{list@} @{Item~\Roman@{namedlistcounter@}.@} % labeling @{\usecounter@{namedlistcounter@} % set counter \setlength@{\leftmargin@}@{3.5em@}@} % set spacing @} @{\end@{list@}@} \begin@{named@} \item Shows as ``Item~I.'' \item[Special label.] Shows as ``Special label.'' \item Shows as ``Item~II.'' \end@{named@} @end example The mandatory first argument @var{labeling} specifies the default labeling of list items. It can contain text and @LaTeX{} commands, as above where it contains both @samp{Item} and @samp{\Roman@{@dots{}@}}. @LaTeX{} forms the label by putting the @var{labeling} argument in a box of width @code{\labelwidth}. If the label is wider than that, the additional material extends to the right. When making an instance of a @code{list} you can override the default labeling by giving @code{\item} an optional argument by including square braces and the text, as in the above @code{\item[Special label.]}; @pxref{\item}. The mandatory second argument @var{spacing} has a list of commands. This list can be empty. A command that can go in here is @code{\usecounter@{@var{countername}@}} (@pxref{\usecounter}). Use this to tell @LaTeX{} to number the items using the given counter. The counter will be reset to zero each time @LaTeX{} enters the environment, and the counter is incremented by one each time @LaTeX{} encounters an @code{\item} that does not have an optional argument. @findex \makelabel @anchor{list makelabel} Another command that can go in @var{spacing} is @code{\makelabel}, which constructs the label box. By default it puts the contents flush right. Its only argument is the label, which it typesets in LR mode (@pxref{Modes}). One example of changing its definition is that to the above @code{named} example, before the definition of the environment add @code{\newcommand@{\namedmakelabel@}[1]@{\textsc@{#1@}@}}, and between the @code{\setlength} command and the parenthesis that closes the @var{spacing} argument also add @code{\let\makelabel\namedmakelabel}. Then the labels will be typeset in small caps. Similarly, changing the second code line to @code{\let\makelabel\fbox} puts the labels inside a framed box. Another example of the @code{\makelabel} command is below, in the definition of the @code{redlabel} environment. Also often in @var{spacing} are commands to redefine the spacing for the list. Below are the spacing parameters with their default values. (Default values for derived environments such as @code{itemize} can be different than the values shown here.) See also the figure that follows the list. Each is a length (@pxref{Lengths}). The vertical spaces are normally rubber lengths, with @code{plus} and @code{minus} components, to give @TeX{} flexibility in setting the page. Change each with a command such as @code{\setlength@{itemsep@}@{2pt plus1pt minus1pt@}}. For some effects these lengths should be zero or negative. @ftable @code @item \itemindent @anchor{list itemindent} Extra horizontal space indentation, beyond @code{leftmargin}, of the first line each item. Its default value is @code{0pt}. @item \itemsep @anchor{list itemsep} Vertical space between items, beyond the @code{\parsep}. The defaults for the first three levels in @LaTeX{}'s @samp{article}, @samp{book}, and @samp{report} classes at 10 point size are: @code{4pt plus2pt minus1pt}, @code{\parsep} (that is, @code{2pt plus1pt minus1pt}), and @code{\topsep} (that is, @code{2pt plus1pt minus1pt}). The defaults at 11 point are: @code{4.5pt plus2pt minus1pt}, @code{\parsep} (that is, @code{2pt plus1pt minus1pt}), and @code{\topsep} (that is, @code{2pt plus1pt minus1pt}). The defaults at 12 point are: @code{5pt plus2.5pt minus1pt}, @code{\parsep} (that is, @code{2.5pt plus1pt minus1pt}), and @code{\topsep} (that is, @code{2.5pt plus1pt minus1pt}). @item \labelsep @anchor{list labelsep} Horizontal space between the label and text of an item. The default for @LaTeX{}'s @samp{article}, @samp{book}, and @samp{report} classes is @code{0.5em}. @item \labelwidth @anchor{list labelwidth} Horizontal width. The box containing the label is nominally this wide. If @code{\makelabel} returns text that is wider than this then the first line of the item will be indented to make room for this extra material. If @code{\makelabel} returns text of width less than or equal to @code{\labelwidth} then @LaTeX{}'s default is that the label is typeset flush right in a box of this width. The left edge of the label box is @code{\leftmargin}+@code{\itemindent}-@code{\labelsep}-@code{\labelwidth} from the left margin of the enclosing environment. The default for @LaTeX{}'s @samp{article}, @samp{book}, and @samp{report} classes at the top level is @code{\leftmargini}-@code{\labelsep}, (which is @code{2em} in one column mode and @code{1.5em} in two column mode). At the second level it is @code{\leftmarginii}-@code{\labelsep}, and at the third level it is @code{\leftmarginiii}-@code{\labelsep}. These definitions make the label's left edge coincide with the left margin of the enclosing environment. @item \leftmargin @anchor{list leftmargin} Horizontal space between the left margin of the enclosing environment (or the left margin of the page if this is a top-level list), and the left margin of this list. It must be non-negative. In the standard @LaTeX{} document classes, a top-level list has this set to the value of @code{\leftmargini}, while a list that is nested inside a top-level list has this margin set to @code{\leftmarginii}. More deeply nested lists get the values of @code{\leftmarginiii} through @code{\leftmarginvi}. (Nesting greater than level five generates the error message @samp{Too deeply nested}.) The defaults for the first three levels in @LaTeX{}'s @samp{article}, @samp{book}, and @samp{report} classes are: @code{\leftmargini} is @code{2.5em} (in two column mode, @code{2em}), @code{\leftmarginii} is @code{2.2em}, and @code{\leftmarginiii} is @code{1.87em}. @item \listparindent @anchor{list listparindent} Horizontal space of additional line indentation, beyond @code{\leftmargin}, for second and subsequent paragraphs within a list item. A negative value makes this an ``outdent''. Its default value is @code{0pt}. @item \parsep @anchor{list parsep} Vertical space between paragraphs within an item. The defaults for the first three levels in @LaTeX{}'s @samp{article}, @samp{book}, and @samp{report} classes at 10 point size are: @code{4pt plus2pt minus1pt}, @code{2pt plus1pt minus1pt}, and @code{0pt}. The defaults at 11 point size are: @code{4.5pt plus2pt minus1pt}, @code{2pt plus1pt minus1pt}, and @code{0pt}. The defaults at 12 point size are: @code{5pt plus2.5pt minus1pt}, @code{2.5pt plus1pt minus1pt}, and @code{0pt}. @item \partopsep @anchor{list partopsep} Vertical space added, beyond @code{\topsep}+@code{\parskip}, to the top and bottom of the entire environment if the list instance is preceded by a blank line. (A blank line in the @LaTeX{} source before the list changes spacing at both the top and bottom of the list; whether the line following the list is blank does not matter.) The defaults for the first three levels in @LaTeX{}'s @samp{article}, @samp{book}, and @samp{report} classes at 10 point size are: @code{2pt plus1 minus1pt}, @code{2pt plus1pt minus1pt}, and @code{1pt plus0pt minus1pt}. The defaults at 11 point are: @code{3pt plus1pt minus1pt}, @code{3pt plus1pt minus1pt}, and @code{1pt plus0pt minus1pt}). The defaults at 12 point are: @code{3pt plus2pt minus3pt}, @code{3pt plus2pt minus2pt}, and @code{1pt plus0pt minus1pt}. @item \rightmargin @anchor{list rightmargin} Horizontal space between the right margin of the list and the right margin of the enclosing environment. Its default value is @code{0pt}. It must be non-negative. @item \topsep @anchor{list topsep} Vertical space added to both the top and bottom of the list, in addition to @code{\parskip} (@pxref{\parindent & \parskip}). The defaults for the first three levels in @LaTeX{}'s @samp{article}, @samp{book}, and @samp{report} classes at 10 point size are: @code{8pt plus2pt minus4pt}, @code{4pt plus2pt minus1pt}, and @code{2pt plus1pt minus1pt}. The defaults at 11 point are: @code{9pt plus3pt minus5pt}, @code{4.5pt plus2pt minus1pt}, and @code{2pt plus1pt minus1pt}. The defaults at 12 point are: @code{10pt plus4pt minus6pt}, @code{5pt plus2.5pt minus1pt}, and @code{2.5pt plus1pt minus1pt}. @end ftable This shows the horizontal and vertical distances. @float @image{latex2e-figures/list,3.21in,,,.png} @end float The lengths shown are listed below. The key relationship is that the right edge of the bracket for @var{h1} equals the right edge of the bracket for @var{h4}, so that the left edge of the label box is at @var{h3}+@var{h4}-(@var{h0}+@var{h1}). @table @var @item v0 @math{@code{@\topsep} + @code{@\parskip}} if the list environment does not start a new paragraph, and @code{\topsep}+@code{\parskip}+@code{\partopsep} if it does @item v1 @code{\parsep} @item v2 @code{\itemsep}+@code{\parsep} @item v3 Same as @var{v0}. (This space is affected by whether a blank line appears in the source above the environment; whether a blank line appears in the source below the environment does not matter.) @item h0 @code{\labelwidth} @item h1 @code{\labelsep} @item h2 @code{\listparindent} @item h3 @code{\leftmargin} @item h4 @code{\itemindent} @item h5 @code{\rightmargin} @end table The list's left and right margins, shown above as @var{h3} and @var{h5}, are with respect to the ones provided by the surrounding environment, or with respect to the page margins for a top-level list. The line width used for typesetting the list items is @code{\linewidth} (@pxref{Page layout parameters}). For instance, set the list's left margin to be one quarter of the distance between the left and right margins of the enclosing environment with @code{\setlength@{\leftmargin@}@{0.25\linewidth@}}. Page breaking in a list structure is controlled by the three parameters below. For each, the @LaTeX{} default is @code{-\@@lowpenalty}, that is, @code{-51}. Because it is negative, it somewhat encourages a page break at each spot. Change it with, e.g., @code{\@@beginparpenalty=9999}; a value of 10000 prohibits a page break. @ftable @code @item \@@beginparpenalty @anchor{list beginparpenalty} The page breaking penalty for breaking before the list (default @code{-51}). @item \@@itempenalty @anchor{list itempenalty} The page breaking penalty for breaking before a list item (default @code{-51}). @item \@@endparpenalty @anchor{list endparpenalty} The page breaking penalty for breaking after a list (default @code{-51}). @end ftable @PkgIndex{enumitem} The package @package{enumitem} is useful for customizing lists. This example has the labels in red. They are numbered, and the left edge of the label lines up with the left edge of the item text. @xref{\usecounter}. @example \usepackage@{color@} \newcounter@{cnt@} \newcommand@{\makeredlabel@}[1]@{\textcolor@{red@}@{#1.@}@} \newenvironment@{redlabel@} @{\begin@{list@} @{\arabic@{cnt@}@} @{\usecounter@{cnt@} \setlength@{\labelwidth@}@{0em@} \setlength@{\labelsep@}@{0.5em@} \setlength@{\leftmargin@}@{1.5em@} \setlength@{\itemindent@}@{0.5em@} % equals \labelwidth+\labelsep \let\makelabel=\makeredlabel @} @} @{\end@{list@}@} @end example @menu * \item:: An entry in a list. * trivlist:: A restricted form of @code{list}. @end menu @node \item @subsection @code{\item}: An entry in a list Synopsis: @example \item text of item @end example @noindent or @example \item[@var{optional-label}] text of item @end example An entry in a list. The entries are prefixed by a label, whose default depends on the list type. Because the optional label is surrounded by square brackets @samp{[...]}, if you have an item whose text starts with [, you have to hide the bracket inside curly braces, as in: @code{\item @{[@} is an open square bracket}; otherwise, @LaTeX{} will think it marks the start of an optional label. Similarly, if the item does have the optional label and you need a close square bracket inside that label, you must hide it in the same way: @code{\item[Close square bracket, @{]@}]}. @xref{@LaTeX{} command syntax}. In this example the enumerate list has two items that use the default label and one that uses the optional label. @example \begin@{enumerate@} \item Moe \item[sometimes] Shemp \item Larry \end@{enumerate@} @end example The first item is labelled @samp{1.}, the second item is labelled @samp{sometimes}, and the third item is labelled @samp{2.}. Because of the optional label in the second item, the third item is not labelled@tie{}@samp{3.}. @node trivlist @subsection @code{trivlist}: A restricted form of @code{list} Synopsis: @example \begin@{trivlist@} ... \end@{trivlist@} @end example A restricted version of the list environment, in which margins are not indented and an @code{\item} without an optional argument produces no text. It is most often used in macros, to define an environment where the @code{\item} command is part of the environment's definition. For instance, the @code{center} environment is defined essentially like this: @example \newenvironment@{center@} @{\begin@{trivlist@}\centering\item\relax@} @{\end@{trivlist@}@} @end example Using @code{trivlist} in this way allows the macro to inherit some common code: combining vertical space of two adjacent environments; detecting whether the text following the environment should be considered a new paragraph or a continuation of the previous one; adjusting the left and right margins for possible nested list environments. Specifically, @code{trivlist} uses the current values of the list parameters (@pxref{list}), except that @code{\parsep} is set to the value of @code{\parskip}, and @code{\leftmargin}, @code{\labelwidth}, and @code{\itemindent} are set to zero. This example outputs the items as two paragraphs, except that (by default) they have no paragraph indent and are vertically separated. @example \begin@{trivlist@} \item The \textit@{Surprise@} is not old; no one would call her old. \item She has a bluff bow, lovely lines. \end@{trivlist@} @end example @node math @section @code{math} @EnvIndex{math} @cindex inline formulas Synopsis: @example \begin@{math@} @var{math} \end@{math@} @end example @findex $ @r{inline math} @findex \(...\) @r{inline math} The @code{math} environment inserts given @var{math} material within the running text. @code{\(...\)} and @code{$...$} are synonyms. @xref{Math formulas}. @node minipage @section @code{minipage} @EnvIndex{minipage} @cindex minipage, creating a Synopses: @example \begin@{minipage@}@{@var{width}@} @var{contents} \end@{minipage@} @end example @noindent or @example \begin@{minipage@}[@var{position}][@var{height}][@var{inner-pos}]@{@var{width}@} @var{contents} \end@{minipage@} @end example Put @var{contents} into a box that is @var{width} wide. This is like a small version of a page; it can contain its own footnotes, itemized lists, etc. (There are some restrictions, including that it cannot have floats.) This box will not be broken across pages. So @code{minipage} is similar to @code{\parbox} (@pxref{\parbox}) but here you can have paragraphs. This example will be 3@tie{}inches wide, and has two paragraphs. @example \begin@{minipage@}@{3in@} Stephen Kleene was a founder of the Theory of Computation. He was a student of Church, wrote three influential texts, was President of the Association for Symbolic Logic, and won the National Medal of Science. \end@{minipage@} @end example @noindent See below for a discussion of the paragraph indent inside a @code{minipage}. The required argument @var{width} is a rigid length (@pxref{Lengths}). It gives the width of the box into which @var{contents} are typeset. There are three optional arguments, @var{position}, @var{height}, and @var{inner-pos}. You need not include all three. For example, get the default @var{position} and set the @var{height} with @code{\begin@{minipage@}[c][2.54cm]@{\columnwidth@} @var{contents} \end@{minipage@}}. (Get the natural height with an empty argument, @code{[]}.) The optional argument @var{position} governs how the @code{minipage} vertically aligns with the surrounding material. @table @code @item c @c xx Clarify what it means when adjacent text lines do not have aligned @c vertical center with each other (synonym @code{m}) Default. Positions the @code{minipage} so its vertical center lines up with the center of the adjacent text line. @item t @findex \vtop @r{plain @TeX{}} Align the baseline of the top line in the @code{minipage} with the baseline of the surrounding text (plain @TeX{}'s @code{\vtop}). @item b @findex \vbox @r{(plain @TeX{})} Align the baseline of the bottom line in the @code{minipage} with the baseline of the surrounding text (plain @TeX{}'s @code{\vbox}). @end table To see the effects of these, contrast running this @example ---\begin@{minipage@}[c]@{0.25in@} first\\ second\\ third \end@{minipage@} @end example @noindent with the results of changing @code{c} to @code{b} or@tie{}@code{t}. @c xx Clarify what happens if user enter a rubber length instead of a @c rigid length. The optional argument @var{height} is a rigid length (@pxref{Lengths}). It sets the height of the @code{minipage}. You can enter any value larger than, or equal to, or smaller than the @code{minipage}'s natural height and @LaTeX{} will not give an error or warning. You can also set it to a height of zero or a negative value. The final optional argument @var{inner-pos} controls the placement of @var{contents} inside the box. These are the possible values are (the default is the value of @var{position}). @table @code @item t Place @var{contents} at the top of the box. @item c Place it in the vertical center. @item b Place it at the box bottom. @item s Stretch @var{contents} out vertically; it must contain vertically stretchable space. @end table The @var{inner-pos} argument makes sense when the @var{height} option is set to a value larger than the @code{minipage}'s natural height. To see the effect of the options, run this example with the various choices in place of @code{b}. @example Text before \begin@{center@} ---\begin@{minipage@}[c][3in][b]@{0.25\textwidth@} first\\ second\\ third \end@{minipage@} \end@{center@} Text after @end example @cindex indentation of paragraphs, in minipage @cindex paragraph indentation, in minipage @findex \parindent By default paragraphs are not indented in a @code{minipage}. Change that with a command such as @code{\setlength@{\parindent@}@{1pc@}} at the start of @var{contents}. @cindex footnotes in figures @cindex figures, footnotes in Footnotes in a @code{minipage} environment are handled in a way that is particularly useful for putting footnotes in figures or tables. A @code{\footnote} or @code{\footnotetext} command puts the footnote at the bottom of the minipage instead of at the bottom of the page, and it uses the @code{\mpfootnote} counter instead of the ordinary @code{footnote} counter (@pxref{Counters}). This puts the footnote at the bottom of the table, not the bottom of the page. @example \begin@{center@} % center the minipage on the line \begin@{minipage@}@{2.5in@} \begin@{center@} % center the table inside the minipage \begin@{tabular@}@{ll@} \textsc@{Monarch@} &\textsc@{Reign@} \\ \hline Elizabeth II &63 years\footnote@{to date@} \\ Victoria &63 years \\ George III &59 years \end@{tabular@} \end@{center@} \end@{minipage@} \end@{center@} @end example If you nest minipages then there is an oddness when using footnotes. Footnotes appear at the bottom of the text ended by the next @code{\end@{minipage@}} which may not be their logical place. This puts a table containing data side by side with a map graphic. They are vertically centered. @PkgIndex{siunitx} @example % siunitx to have the S column specifier, % which aligns numbers on their decimal point. \usepackage@{siunitx@} \newcommand*@{\vcenteredhbox@}[1]@{\begin@{tabular@}@{@@@{@}c@@@{@}@}#1\end@{tabular@}@} ... \begin@{center@} \vcenteredhbox@{\includegraphics[width=0.3\textwidth]@{nyc.png@}@} \hspace@{0.1\textwidth@} \begin@{minipage@}@{0.5\textwidth@} \begin@{tabular@}@{r|S@} % \multicolumn to remove vertical bar between column headers \multicolumn@{1@}@{r@}@{Borough@} & % braces to prevent siunitx from misinterpreting the % period as a decimal separator @{Pop. (million)@} \\ \hline The Bronx &1.5 \\ Brooklyn &2.6 \\ Manhattan &1.6 \\ Queens &2.3 \\ Staten Island &0.5 \end@{tabular@} \end@{minipage@} \end@{center@} @end example @node picture @section @code{picture} @EnvIndex{picture} @cindex creating pictures @cindex pictures, creating Synopses: @example \begin@{picture@}(@var{width},@var{height}) @var{picture command} \end@{picture@} @end example @noindent or @example \begin@{picture@}(@var{width},@var{height})(@var{xoffset},@var{yoffset}) @var{picture command} \end@{picture@} @end example @noindent Where there may be any number of @var{picture command}'s. An environment to create simple pictures containing lines, arrows, boxes, circles, and text. This environment is not obsolete, but new documents typically use much more powerful graphics creation systems, such as TikZ, PSTricks, MetaPost, or Asymptote. None of these are covered in this document; see CTAN. To start, here's an example showing the parallelogram law for adding vectors. @findex \unitlength @example \setlength@{\unitlength@}@{1cm@} \begin@{picture@}(6,6) % picture box will be 6cm wide by 6cm tall \put(0,0)@{\vector(2,1)@{4@}@} % for every 2 over this vector goes 1 up \put(2,1)@{\makebox(0,0)[l]@{\ first leg@}@} \put(4,2)@{\vector(1,2)@{2@}@} \put(5,4)@{\makebox(0,0)[l]@{\ second leg@}@} \put(0,0)@{\vector(1,1)@{6@}@} \put(3,3)@{\makebox(0,0)[r]@{sum\ @}@} \end@{picture@} @end example The @code{picture} environment has one required argument, a pair of positive real numbers (@var{width},@var{height}). Multiply these by the value @code{\unitlength} to get the nominal size of the output, i.e.@: the space that @LaTeX{} reserves on the output page. This nominal size need not be how large the picture really is; @LaTeX{} will draw things from the picture outside the picture's box. This environment also has an optional argument (@var{xoffset},@var{yoffset}). It is used to shift the origin. Unlike most optional arguments, this one is not contained in square brackets. As with the required argument, it consists of a pair of two real numbers, but these may also be negative or null. Multiply these by @code{\unitlength} to get the coordinates of the point at the lower-left corner of the picture. For example, if @code{\unitlength} has been set to @code{1mm}, the command @example \begin@{picture@}(100,200)(10,20) @end example @noindent produces a box of width 100 millimeters and height 200 millimeters. The picture's origin is the point (10mm,20mm) and so the lower-left corner is there, and the upper-right corner is at (110mm,220mm). When you first draw a picture you typically omit the optional argument, leaving the origin at the lower-left corner. If you then want to modify your picture by shifting everything, you can just add the appropriate optional argument. @cindex position, in picture Each @var{picture command} tells @LaTeX{} where to put something by providing its position. A @dfn{position} is a pair such as @code{(2.4,-5)} giving the x- and y-coordinates. A @dfn{coordinate} is a not a length, it is a real number (it may have a decimal point or a minus sign). It specifies a length in multiples of the unit length @code{\unitlength}, so if @code{\unitlength} has been set to @code{1cm}, then the coordinate @code{2.54} specifies a length of 2.54 centimeters. @LaTeX{}'s default for @code{\unitlength} is @code{1pt}. It is a rigid length (@pxref{Lengths}). Change it with the @code{\setlength} command (@pxref{\setlength}). Make this change only outside of a @code{picture} environment. The @code{picture} environment supports using standard arithmetic expressions as well as numbers. Coordinates are given with respect to an origin, which is by default at the lower-left corner of the picture. Note that when a position appears as an argument, as with @code{\put(1,2)@{...@}}, it is not enclosed in braces since the parentheses serve to delimit the argument. Also, unlike in some computer graphics systems, larger y-coordinates are further up the page, for example, @math{y = 1} is @emph{above} @math{y = 0}. There are four ways to put things in a picture: @code{\put}, @code{\multiput}, @code{\qbezier}, and @code{\graphpaper}. The most often used is @code{\put}. This @example \put(11.3,-0.3)@{...@} @end example @noindent places the object with its reference point at coordinates @math{(11.3,-0.3)}. The reference points for various objects will be described below. @findex LR box The @code{\put} command creates an @dfn{LR box} (@pxref{Modes}). Anything that can go in an @code{\mbox} (@pxref{\mbox & \makebox}) can go in the text argument of the @code{\put} command. The reference point will be the lower left corner of the box. In this picture @example \setlength@{\unitlength@}@{1cm@} ...\begin@{picture@}(1,1) \put(0,0)@{\line(1,0)@{1@}@} \put(0,0)@{\line(1,1)@{1@}@} \end@{picture@} @end example @noindent the three dots are just slightly left of the point of the angle formed by the two lines. (Also, @code{\line(1,1)@{1@}} does not call for a line of length one; rather the line has a change in the x coordinate of 1.) The @code{\multiput}, @code{qbezier}, and @code{graphpaper} commands are described below. You can also use this environment to place arbitrary material at an exact location. For example: @example \usepackage@{color,graphicx@} % in preamble ... \begin@{center@} \setlength@{\unitlength@}@{\textwidth@} \begin@{picture@}(1,1) % leave space, \textwidth wide and tall \put(0,0)@{\includegraphics[width=\textwidth]@{desertedisland.jpg@}@} \put(0.25,0.35)@{\textcolor@{red@}@{X Treasure here@}@} \end@{picture@} \end@{center@} @end example @noindent The red@tie{}X will be precisely a quarter of the @code{\textwidth} from the left margin, and @code{0.35\textwidth} up from the bottom of the picture. Another example of this usage is to put similar code in the page header to get repeat material on each of a document's pages. @menu * \put:: Place an object at a specified place. * \multiput:: Draw multiple instances of an object. * \qbezier:: Draw a quadratic B@'ezier curve. * \graphpaper:: Draw graph paper. * \line:: Draw a straight line. * \linethickness:: Set thickness of horizontal and vertical lines. * \thinlines:: The default line thickness. * \thicklines:: A heavier line thickness. * \circle:: Draw a circle. * \oval:: Draw an oval. * \shortstack:: Make a stack of objects. * \vector:: Draw a line with an arrow. * \makebox (picture):: Draw a box of the specified size. * \framebox (picture):: Draw a box with a frame around it. * \frame:: Draw a frame around an object. * \dashbox:: Draw a dashed box. @end menu @node \put @subsection @code{\put} @findex \put Synopsis: @example \put(@var{xcoord},@var{ycoord})@{@var{content}@} @end example Place @var{content} at the coordinate (@var{xcoord},@var{ycoord}). See the discussion of coordinates and @code{\unitlength} in @ref{picture}. The @var{content} is processed in LR mode (@pxref{Modes}) so it cannot contain line breaks. This includes the text into the @code{picture}. @example \put(4.5,2.5)@{Apply the \textit@{unpoke@} move@} @end example The reference point, the location (4.5,2.5), is the lower left of the text, at the bottom left of the @samp{A}. @node \multiput @subsection @code{\multiput} @findex \multiput Synopsis: @example \multiput(@var{x},@var{y})(@var{delta_x},@var{delta_y})@{@var{num-copies}@}@{@var{obj}@} @end example Copy @var{obj} a total of @var{num-copies} times, with an increment of @var{delta_x,delta_y}. The @var{obj} first appears at position @math{(x,y)}, then at @math{(x+\delta_x,y+\delta_y)}, and so on. This draws a simple grid with every fifth line in bold (see also @ref{\graphpaper}). @example \begin@{picture@}(10,10) \linethickness@{0.05mm@} \multiput(0,0)(1,0)@{10@}@{\line(0,1)@{10@}@} \multiput(0,0)(0,1)@{10@}@{\line(1,0)@{10@}@} \linethickness@{0.5mm@} \multiput(0,0)(5,0)@{3@}@{\line(0,1)@{10@}@} \multiput(0,0)(0,5)@{3@}@{\line(1,0)@{10@}@} \end@{picture@} @end example @node \qbezier @subsection @code{\qbezier} @findex \qbezier Synopsis: @example \qbezier(@var{x1},@var{y1})(@var{x2},@var{y2})(@var{x3},@var{y3}) \qbezier[@var{num}](@var{x1},@var{y1})(@var{x2},@var{y2})(@var{x3},@var{y3}) @end example Draw a quadratic Bezier curve whose control points are given by the three required arguments @code{(@var{x1},@var{y1})}, @code{(@var{x2},@var{y2})}, and @code{(@var{x3},@var{y3})}. That is, the curve runs from @var{(x1,y1)} to @var{(x3,y3)}, is quadratic, and is such that the tangent line at @var{(x1,y1)} passes through @var{(x2,y2)}, as does the tangent line at @var{(x3,y3)}. This draws a curve from the coordinate (1,1) to (1,0). @example \qbezier(1,1)(1.25,0.75)(1,0) @end example @noindent The curve's tangent line at (1,1) contains (1.25,0.75), as does the curve's tangent line at (1,0). The optional argument @var{num} gives the number of calculated intermediate points. The default is to draw a smooth curve whose maximum number of points is @code{\qbeziermax} (change this value with @code{\renewcommand}). This draws a rectangle with a wavy top, using @code{\qbezier} for that curve. @example \begin@{picture@}(8,4) \put(0,0)@{\vector(1,0)@{8@}@} % x axis \put(0,0)@{\vector(0,1)@{4@}@} % y axis \put(2,0)@{\line(0,1)@{3@}@} % left side \put(4,0)@{\line(0,1)@{3.5@}@} % right side \qbezier(2,3)(2.5,2.9)(3,3.25) \qbezier(3,3.25)(3.5,3.6)(4,3.5) \thicklines % below here, lines are twice as thick \put(2,3)@{\line(4,1)@{2@}@} \put(4.5,2.5)@{\framebox@{Trapezoidal Rule@}@} \end@{picture@} @end example @node \graphpaper @subsection @code{\graphpaper} @findex \graphpaper Synopsis: @example \graphpaper(@var{x_init},@var{y_init})(@var{x_dimen},@var{y_dimen}) \graphpaper[@var{spacing}](@var{x_init},@var{y_init})(@var{x_dimen},@var{y_dimen}) @end example @PkgIndex{graphpap} Draw a coordinate grid. Requires the @package{graphpap} package. The grid's origin is @code{(@var{x_init},@var{y_init})}. Grid lines come every @var{spacing} units (the default is 10). The grid extends @var{x_dimen} units to the right and @var{y_dimen} units up. All arguments must be positive integers. This make a grid with seven vertical lines and eleven horizontal lines. @example \usepackage@{graphpap@} % in preamble ... \begin@{picture@}(6,20) % in document body \graphpaper[2](0,0)(12,20) \end@{picture@} @end example @noindent The lines are numbered every ten units. @node \line @subsection @code{\line} @findex \line Synopsis: @example \line(@var{x_run},@var{y_rise})@{@var{travel}@} @end example Draw a line. It slopes such that it vertically rises @var{y_rise} for every horizontal @var{x_run}. The @var{travel} is the total horizontal change---it is not the length of the vector, it is the change in @math{x}. In the special case of vertical lines, where (@var{x_run},@var{y_rise})=(0,1), the @var{travel} gives the change in @math{y}. This draws a line starting at coordinates (1,3). @example \put(1,3)@{\line(2,5)@{4@}@} @end example @noindent For every over 2, this line will go up 5. Because @var{travel} specifies that this goes over 4, it must go up@tie{}10. Thus its endpoint is @math{(1,3)+(4,10)=(5,13)}. In particular, note that @math{@var{travel}=4} is not the length of the line, it is the change in @math{x}. The arguments @var{x_run} and @var{y_rise} are integers that can be positive, negative, or zero. (If both are 0 then @LaTeX{} treats the second as 1.) With @code{\put(@var{x_init},@var{y_init})@{\line(@var{x_run},@var{y_rise})@{@var{travel}@}@}}, if @var{x_run} is negative then the line's ending point has a first coordinate that is less than @var{x_init}. If @var{y_rise} is negative then the line's ending point has a second coordinate that is less than @var{y_init}. If @var{travel} is negative then you get @code{LaTeX Error: Bad \line or \vector argument.} @cindex graphics packages @PkgIndex{pict2e} @PkgIndex{TikZ} @PkgIndex{PSTricks} @PkgIndex{MetaPost} @PkgIndex{Asymptote} Standard @LaTeX{} can only draw lines with a limited range of slopes because these lines are made by putting together line segments from pre-made fonts. The two numbers @var{x_run} and @var{y_rise} must have integer values from @minus{}6 through@tie{}6. Also, they must be relatively prime, so that @var{(x_run,y_rise)} can be (2,1) but not (4,2) (if you choose the latter then instead of lines you get sequences of arrowheads; the solution is to switch to the former). To get lines of arbitrary slope and plenty of other shapes in a system like @code{picture}, see the package @package{pict2e} (@url{https://ctan.org/pkg/pict2e}). Another solution is to use a full-featured graphics system such as TikZ, PSTricks, MetaPost, or Asymptote. @node \linethickness @subsection @code{\linethickness} @findex \linethickness Synopsis: @example \linethickness@{@var{dim}@} @end example Declares the thickness of subsequent horizontal and vertical lines in a picture to be @var{dim}, which must be a positive length (@pxref{Lengths}). It differs from @code{\thinlines} and @code{\thicklines} in that it does not affect the thickness of slanted lines, circles, or ovals (@pxref{\oval}). @node \thinlines @subsection @code{\thinlines} @findex \thinlines Declaration to set the thickness of subsequent lines, circles, and ovals in a picture environment to be 0.4@dmn{pt}. This is the default thickness, so this command is unnecessary unless the thickness has been changed with either @ref{\linethickness} or @ref{\thicklines}. @node \thicklines @subsection @code{\thicklines} @findex \thicklines Declaration to set the thickness of subsequent lines, circles, and ovals in a picture environment to be 0.8@dmn{pt}. See also @ref{\linethickness} and @ref{\thinlines}. This command is illustrated in the Trapezoidal Rule example of @ref{\qbezier}. @node \circle @subsection @code{\circle} @findex \circle Synopsis: @example \circle@{@var{diameter}@} \circle*@{@var{diameter}@} @end example Produces a circle with a diameter as close as possible to the specified one. The @code{*}@tie{}form produces a filled-in circle. This draws a circle of radius 6, centered at @code{(5,7)}. @example \put(5,7)@{\circle@{6@}@} @end example The available radii for @code{\circle} are, in points, the even numbers from 2 to 20, inclusive. For @code{\circle*} they are all the integers from 1 to 15. @node \oval @subsection @code{\oval} @findex \oval Synopsis: @example \oval(@var{width},@var{height}) \oval(@var{width},@var{height})[@var{portion}] @end example Produce a rectangle with rounded corners, hereinafter referred to as an @dfn{oval}. The optional argument @var{portion} allows you to produce only half or a quarter of the oval. For half an oval take @var{portion} to be one of these. @table @code @item t top half @item b bottom half @item r right half @item l left half @end table Produce only one quarter of the oval by setting @var{portion} to @code{tr}, @code{br}, @code{bl}, or @code{tl}. This draws the top half of an oval that is 3 wide and 7 tall. @example \put(5,7)@{\oval(3,7)[t]@} @end example @noindent The (5,7) is the center of the entire oval, not just the center of the top half. These shapes are not ellipses. They are rectangles whose corners are made with quarter circles. These circles have a maximum radius of 20@dmn{pt} (@pxref{\circle} for the sizes). Thus large ovals are just frames with a small amount of corner rounding. @node \shortstack @subsection @code{\shortstack} @findex \shortstack Synopsis: @example \shortstack[@var{position}]@{@var{line 1} \\ ... @} @end example Produce a vertical stack of objects. This labels the @math{y} axis by writing the word @samp{@math{y}} above the word @samp{axis}. @example \setlength@{\unitlength@}@{1cm@} \begin@{picture@}(5,2.5)(-0.75,0) \put(0,0)@{\vector(1,0)@{4@}@} % x axis \put(0,0)@{\vector(0,1)@{2@}@} % y \put(-0.2,2)@{\makebox(0,0)[r]@{\shortstack[r]@{$y$\\ axis@}@}@} \end@{picture@} @end example @noindent For a short stack, the reference point is the lower left of the stack. In the above example the @code{\makebox} (@pxref{\mbox & \makebox}) puts the stack flush right in a zero width box so in total the short stack sits slightly to the left of the @math{y}@tie{}axis. The valid positions are: @table @code @item r Make objects flush right @item l Make objects flush left @item c Center objects (default) @end table @findex \\ @r{(for @code{\shortstack} objects)} Separate objects into lines with @code{\\}. These stacks are short in that, unlike in a @code{tabular} or @code{array} environment, here the rows are not spaced out to be of even baseline skips. Thus, in @code{\shortstack@{X\\o\\o\\X@}} the first and last rows are taller than the middle two, and therefore the baseline skip between the two middle rows is smaller than that between the third and last row. You can adjust row heights and depths either by putting in the usual interline spacing with @code{\shortstack@{X\\ \strut o\\o\\X@}} (@pxref{\strut}), or explicitly, via an zero-width box @code{\shortstack@{X \\ \rule@{0pt@}@{12pt@} o\\o\\X@}} or by using @code{\\}'s optional argument @code{\shortstack@{X\\[2pt] o\\o\\X@}}. The @code{\shortstack} command is also available outside the @code{picture} environment. @node \vector @subsection @code{\vector} @findex \vector Synopsis: @example \vector(@var{x_run},@var{y_rise})@{@var{travel}@} @end example Draw a line ending in an arrow. The slope of that line is: it vertically rises @var{y_rise} for every horizontal @var{x_run}. The @var{travel} is the total horizontal change---it is not the length of the vector, it is the change in @math{x}. In the special case of vertical vectors, if (@var{x_run},@var{y_rise})=(0,1), then @var{travel} gives the change in @math{y}. For an example see @ref{picture}. For elaboration on @var{x_run} and @var{y_rise} see @ref{\line}. As there, the values of @var{x_run} and @var{y_rise} are limited. For @code{\vector} you must chooses integers between @minus{}4 and 4, inclusive. Also, the two you choose must be relatively prime. Thus, @code{\vector(2,1)@{4@}} is acceptable but @code{\vector(4,2)@{4@}} is not (if you use the latter then you get a sequence of arrowheads). @node \makebox (picture) @subsection @code{\makebox} (picture) @findex \makebox @r{(for @code{picture})} Synopsis: @example \makebox(@var{rec-width},@var{rec-height})@{@var{text}@} \makebox(@var{rec-width},@var{rec-height})[@var{position}]@{@var{text}@} @end example Make a box to hold @var{text}. This command fits with the @code{picture} environment, although you can use it outside of there, because @var{rec-width} and @var{rec-height} are numbers specifying distances in terms of the @code{\unitlength} (@pxref{picture}). This command is similar to the normal @code{\makebox} command (@pxref{\mbox & \makebox}) except here that you must specify the width and height. This command is fragile (@pxref{\protect}). This makes a box of length 3.5 times @code{\unitlength} and height 4 times @code{\unitlength}. @example \put(1,2)@{\makebox(3.5,4)@{...@}@} @end example The optional argument @code{@var{position}} specifies where in the box the @var{text} appears. The default is to center it, both horizontally and vertically. To place it somewhere else, use a string with one or two of these letters. @table @code @item t Puts @var{text} the top of the box. @item b Put @var{text} at the bottom. @item l Put @var{text} on the left. @item r Put @var{text} on the right. @end table @node \framebox (picture) @subsection @code{\framebox} (picture) @findex \framebox Synopsis: @example \framebox(@var{rec-width},@var{rec-height})@{@var{text}@} \framebox(@var{rec-width},@var{rec-height})[@var{position}]@{@var{text}@} @end example This is the same as @ref{\makebox (picture)} except that it puts a frame around the outside of the box that it creates. The reference point is the bottom left corner of the frame. This command fits with the @code{picture} environment, although you can use it outside of there, because lengths are numbers specifying the distance in terms of the @code{\unitlength} (@pxref{picture}). This command is fragile (@pxref{\protect}). This example creates a frame 2.5@tie{}inches by 3@tie{}inches and puts the text in the center. @example \setlength@{\unitlength@}@{1in@} \framebox(2.5,3)@{test text@} @end example The required arguments are that the rectangle has overall width @var{rect-width} units and height @var{rect-height} units. The optional argument @var{position} specifies the position of @var{text}; see @ref{\makebox (picture)} for the values that it can take. @findex \fboxrule @findex \fboxsep The rule has thickness @code{\fboxrule} and there is a blank space @code{\fboxsep} between the frame and the contents of the box. For this command, you must specify the @var{width} and @var{height}. If you want to just put a frame around some contents whose dimension is determined in some other way then either use @code{\fbox} (@pxref{\fbox & \framebox}) or @code{\frame} (@pxref{\frame}). @node \frame @subsection @code{\frame} @findex \frame Synopsis: @example \frame@{@var{contents}@} @end example Puts a rectangular frame around @var{contents}. The reference point is the bottom left corner of the frame. In contrast to @code{\framebox} (@pxref{\framebox (picture)}), this command puts no extra space is put between the frame and the object. It is fragile (@pxref{\protect}). @node \dashbox @subsection @code{\dashbox} @findex \dashbox Synopsis: @example \dashbox@{@var{dash-len}@}(@var{rect-width},@var{rect-height})@{@var{text}@} \dashbox@{@var{dash-len}@}(@var{rect-width},@var{rect-height})[@var{position}]@{@var{text}@} @end example Create a dashed rectangle around @var{text}. This command fits with the @code{picture} environment, although you can use it outside of there, because lengths are numbers specifying the distance in terms of the @code{\unitlength} (@pxref{picture}). The required arguments are: dashes are @var{dash-len} units long, with the same length gap, and the rectangle has overall width @var{rect-width} units and height @var{rect-height} units. The optional argument @var{position} specifies the position of @var{text}; see @ref{\makebox (picture)} for the values that it can take. This shows that you can use non-integer value for @var{dash-len}. @example \put(0,0)@{\dashbox@{0.1@}(5,0.5)@{My hovercraft is full of eels.@}@} @end example @noindent Each dash will be @code{0.1\unitlength} long, the box's width is @code{5\unitlength} and its height is @code{0.5\unitlength}. As in that example, a dashed box looks best when @var{rect-width} and @var{rect-height} are multiples of the @var{dash-len}. @node quotation & quote @section @code{quotation} & @code{quote} @EnvIndex{quotation} @cindex quoted text with paragraph indentation, displaying @cindex displaying quoted text with paragraph indentation @cindex paragraph indentations in quoted text @EnvIndex{quote} @cindex quoted text without paragraph indentation, displaying @cindex displaying quoted text without paragraph indentation @cindex paragraph indentations in quoted text, omitting Synopsis: @example \begin@{quotation@} @var{text} \end@{quotation@} @end example @noindent or @example \begin@{quote@} @var{text} \end@{quote@} @end example Include a quotation. Both environments indent margins on both sides by @code{\leftmargin} and the text is right-justified. They differ in how they treat paragraphs. In the @code{quotation} environment, paragraphs are indented by 1.5@dmn{em} and the space between paragraphs is small, @code{0pt plus 1pt}. In the @code{quote} environment, paragraphs are not indented and there is vertical space between paragraphs (it is the rubber length @code{\parsep}). @example \begin@{quotation@} \small\it Four score and seven years ago ... shall not perish from the earth. \hspace@{1em plus 1fill@}---Abraham Lincoln \end@{quotation@} @end example @node tabbing @section @code{tabbing} @c xx TODO align on the French which is more precise and has more illustrative examples. @EnvIndex{tabbing} @cindex tab stops, using @cindex lining text up using tab stops @cindex alignment via tabbing Synopsis: @example \begin@{tabbing@} @var{row1col1} \= @var{row1col2} ... \\ @var{row2col1} \> @var{row2col2} ... \\ ... \end@{tabbing@} @end example Align text in columns, by setting tab stops and tabbing to them much as was done on a typewriter. This is less often used than the environments @code{tabular} (@pxref{tabular}) or @code{array} (@pxref{array}) because in those the width of each column need not be constant and need not be known in advance. This example has a first line where the tab stops are set to explicit widths, ended by a @code{\kill} command (which is described below): @example \begin@{tabbing@} \hspace@{1.2in@}\=\hspace@{1in@}\=\kill Ship \>Guns \>Year \\ \textit@{Sophie@} \>14 \>1800 \\ \textit@{Polychrest@} \>24 \>1803 \\ \textit@{Lively@} \>38 \>1804 \\ \textit@{Surprise@} \>28 \>1805 \\ \end@{tabbing@} @end example Both the @code{tabbing} environment and the more widely-used @code{tabular} environment put text in columns. The most important distinction is that in @code{tabular} the width of columns is determined automatically by @LaTeX{}, while in @code{tabbing} the user sets the tab stops. Another distinction is that @code{tabular} generates a box, but @code{tabbing} can be broken across pages. Finally, while @code{tabular} can be used in any mode, @code{tabbing} can be used only in paragraph mode and it always starts a new paragraph, without indentation. Moreover, as shown in the example above, there is no need to use the starred form of the @code{\hspace} command at the beginning of a tabbed row. The right margin of the @code{tabbing} environment is the end of line, so that the width of the environment is @code{\linewidth}. @cindex row, @r{tabbing} The @code{tabbing} environment contains a sequence of @dfn{tabbed rows}. The first tabbed row begins immediately after @code{\begin@{tabbing@}} and each row ends with @code{\\} or @code{\kill}. The last row may omit the @code{\\} and end with just @code{\end@{tabbing@}}. @cindex pattern, current tab stops, @r{tabbing} At any point the @code{tabbing} environment has a @dfn{current tab stop pattern}, a sequence of @math{@var{n} > 0} tab stops, numbered 0, 1, etc. These create @var{n} corresponding columns. Tab stop@tie{}0 is always the left margin, defined by the enclosing environment. Tab stop number@tie{}@var{i} is set if it is assigned a horizontal position on the page. Tab stop number@tie{}@var{i} can only be set if all the stops 0, @dots{}, @math{i-1} have already been set; normally later stops are to the right of earlier ones. By default any text typeset in a @code{tabbing} environment is typeset ragged right and left-aligned on the current tab stop. Typesetting is done in LR mode (@pxref{Modes}). The following commands can be used inside a @code{tabbing} environment. They are all fragile (@pxref{\protect}). @ftable @code @item \\ @r{(tabbing)} End a tabbed line and typeset it. @item \= @r{(tabbing)} Sets a tab stop at the current position. @item \> @r{(tabbing)} @findex \> Advances to the next tab stop. @item \< Put following text to the left of the local margin (without changing the margin). Can only be used at the start of the line. @item \+ Moves the left margin of the next and all the following commands one tab stop to the right, beginning tabbed line if necessary. @item \- Moves the left margin of the next and all the following commands one tab stop to the left, beginning tabbed line if necessary. @item \' @r{(tabbing)} Moves everything that you have typed so far in the current column, i.e., everything from the most recent @code{\>}, @code{\<}, @code{\'}, @code{\\}, or @code{\kill} command, to the previous column and aligned to the right, flush against the current column's tab stop. @item \` @r{(tabbing)} Allows you to put text flush right against any tab stop, including tab stop@tie{}0. However, it can't move text to the right of the last column because there's no tab stop there. The @code{\`} command moves all the text that follows it, up to the @code{\\} or @code{\end@{tabbing@}} command that ends the line, to the right margin of the @code{tabbing} environment. There must be no @code{\>} or @code{\'} command between the @code{\`} and the @code{\\} or @code{\end@{tabbing@}} command that ends the line. @item \a @r{(tabbing)} @findex \a' @r{(acute accent in tabbing)} @findex \a` @r{(grave accent in tabbing)} @findex \a= @r{(macron accent in tabbing)} In a @code{tabbing} environment, the commands @code{\=}, @code{\'} and @code{\`} do not produce accents as usual (@pxref{Accents}). Instead, use the commands @code{\a=}, @code{\a'} and @code{\a`}. @item \kill Sets tab stops without producing text. Works just like @code{\\} except that it throws away the current line instead of producing output for it. Any @code{\=}, @code{\+} or @code{\-} commands in that line remain in effect. @item \poptabs @findex \poptabs Restores the tab stop positions saved by the last @code{\pushtabs}. @item \pushtabs Saves all current tab stop positions. Useful for temporarily changing tab stop positions in the middle of a @code{tabbing} environment. @item \tabbingsep Distance of the text moved by @code{\'} to left of current tab stop. @end ftable This example typesets a Pascal function: @example \begin@{tabbing@} function \= fact(n : integer) : integer;\\ \> begin \= \+ \\ \> if \= n > 1 then \+ \\ fact := n * fact(n-1) \- \\ else \+ \\ fact := 1; \-\- \\ end;\\ \end@{tabbing@} @end example @noindent The output looks like this. @example function fact(n : integer) : integer; begin if n > 1 then fact := n * fact(n-1); else fact := 1; end; @end example @PkgIndex{algorithm2e} @PkgIndex{listings} @PkgIndex{minted} @PkgIndex{fancyvrb} @noindent This example is just for illustration of the environment. To actually typeset computer code in typewriter like this, a verbatim environment (@pxref{verbatim}) would normally be best. For pretty-printed code, there are quite a few packages, including @package{algorithm2e}, @package{fancyvrb}, @package{listings}, and @package{minted}. @node table @section @code{table} @EnvIndex{table} @cindex tables, creating @cindex creating tables Synopsis: @example \begin@{table@}[@var{placement}] @var{table body} \caption[@var{loftitle}]@{@var{title}@} % optional \label@{@var{label@}} % also optional \end@{table@} @end example A class of floats (@pxref{Floats}). They cannot be split across pages and so they are not typeset in sequence with the normal text but instead are floated to a convenient place, such as the top of a following page. This example @code{table} environment contains a @code{tabular} @example \begin@{table@} \centering\small \begin@{tabular@}@{ll@} \multicolumn@{1@}@{c@}@{\textit@{Author@}@} &\multicolumn@{1@}@{c@}@{\textit@{Piece@}@} \\ \hline Bach &Cello Suite Number 1 \\ Beethoven &Cello Sonata Number 3 \\ Brahms &Cello Sonata Number 1 \end@{tabular@} \caption@{Top cello pieces@} \label@{tab:cello@} \end@{table@} @end example @noindent but you can put many different kinds of content in a @code{table}: the @var{table body} may contain text, @LaTeX{} commands, graphics, etc. It is typeset in a @code{parbox} of width @code{\textwidth}. For the possible values of @var{placement} and their effect on the float placement algorithm, see @ref{Floats}. The label is optional; it is used for cross references (@pxref{Cross references}). @findex \caption The @code{\caption} command is also optional. It specifies caption text @var{title} for the table (@pxref{\caption}). By default it is numbered. If its optional @var{lottitle} is present then that text is used in the list of tables instead of @var{title} (@pxref{Table of contents etc.}). In this example the table and caption will float to the bottom of a page, unless it is pushed to a float page at the end. @example \begin@{table@}[b] \centering \begin@{tabular@}@{r|p@{2in@}@} \hline One &The loneliest number \\ Two &Can be as sad as one. It's the loneliest number since the number one. \end@{tabular@} \caption@{Cardinal virtues@} \label@{tab:CardinalVirtues@} \end@{table@} @end example @node tabular @section @code{tabular} @EnvIndex{tabular} @cindex lines in tables @cindex lining text up in tables Synopsis: @example \begin@{tabular@}[@var{pos}]@{@var{cols}@} @var{column 1 entry} &@var{column 2 entry} ... &@var{column n entry} \\ ... \end@{tabular@} @end example @noindent or @example \begin@{tabular*@}@{@var{width}@}[@var{pos}]@{@var{cols}@} @var{column 1 entry} &@var{column 2 entry} ... &@var{column n entry} \\ ... \end@{tabular*@} @end example Produce a table, a box consisting of a sequence of horizontal rows. Each row consists of items that are aligned vertically in columns. This illustrates many of the features. @example \begin@{tabular@}@{l|l@} \textit@{Player name@} &\textit@{Career home runs@} \\ \hline Hank Aaron &755 \\ Babe Ruth &714 \end@{tabular@} @end example @noindent The output will have two left-aligned columns with a vertical bar between them. This is specified in @code{tabular}'s argument @code{@{l|l@}}. @findex & @r{for table cells} Put the entries into different columns by separating them with an ampersand, @code{&}. The end of each row is marked with a double backslash, @code{\\}. Put a horizontal rule below a row, after a double backslash, with @code{\hline}. @findex \\ @r{for @code{tabular}} After the last row the @code{\\} is optional, unless an @code{\hline} command follows to put a rule below the table. The required and optional arguments to @code{tabular} consist of: @table @var @item pos Optional. Specifies the table's vertical position. The default is to align the table so its vertical center matches the baseline of the surrounding text. There are two other possible alignments: @code{t} aligns the table so its top row matches the baseline of the surrounding text, and @code{b} aligns on the bottom row. This only has an effect if there is other text. In the common case of a @code{tabular} alone in a @code{center} environment this option makes no difference. @item cols Required. Specifies the formatting of columns. It consists of a sequence of the following specifiers, corresponding to the types of column and intercolumn material. @table @code @item l A column of left-aligned items. @item r A column of right-aligned items. @item c A column of centered items. @item | A vertical line the full height and depth of the environment. @item @@@{@var{text or space}@} Insert @var{text or space} at this location in every row. The @var{text or space} material is typeset in LR mode. This text is fragile (@pxref{\protect}). If between two columns there is no @@-expression then @LaTeX{}'s @code{book}, @code{article}, and @code{report} classes will put on either side of each column a space of length @code{\tabcolsep}, which by default is 6@dmn{pt}. That is, by default adjacent columns are separated by 12@dmn{pt} (so @code{\tabcolsep} is misleadingly named since it is only half of the separation between tabular columns). In addition, a space of 6@dmn{pt} also comes before the first column and after the final column, unless you put a @code{@@@{...@}} or @code{|} there. If you override the default and use an @@-expression then @LaTeX{} does not insert @code{\tabcolsep} so you must insert any desired space yourself, as in @code{@@@{\hspace@{1em@}@}}. An empty expression @code{@@@{@}} will eliminate the space. In particular, sometimes you want to eliminate the space before the first column or after the last one, as in the example below where the tabular lines need to lie on the left margin. @example \begin@{flushleft@} \begin@{tabular@}@{@@@{@}l@} ... \end@{tabular@} \end@{flushleft@} @end example The next example shows text, a decimal point between the columns, arranged so the numbers in the table are aligned on it. @example \begin@{tabular@}@{r@@@{$.$@}l@} $3$ &$14$ \\ $9$ &$80665$ \end@{tabular@} @end example @findex \extracolsep An @code{\extracolsep@{@var{wd}@}} command in an @@-expression causes an extra space of width @var{wd} to appear to the left of all subsequent columns, until countermanded by another @code{\extracolsep}. Unlike ordinary intercolumn space, this extra space is not suppressed by an @@-expression. An @code{\extracolsep} command can be used only in an @@-expression in the @code{cols} argument. Below, @LaTeX{} inserts the right amount of intercolumn space to make the entire table 4 inches wide. @example \begin@{tabular*@}@{4in@}@{l@@@{\extracolsep@{\fill@}@}l@} Seven times down, eight times up \ldots &such is life! \end@{tabular*@} @end example To insert commands that are automatically executed before a given column, load the @code{array} package and use the @code{>@{...@}} specifier. @c xx should fully explain array, tabularx, and all other base packages... @item p@{@var{wd}@} Each item in the column is typeset in a parbox of width @var{wd}, as if it were the argument of a @code{\parbox[t]@{wd@}@{...@}} command. A line break double backslash @code{\\} may not appear in the item, except inside an environment like @code{minipage}, @code{array}, or @code{tabular}, or inside an explicit @code{\parbox}, or in the scope of a @code{\centering}, @code{\raggedright}, or @code{\raggedleft} declaration (when used in a @code{p}-column element these declarations must appear inside braces, as with @code{@{\centering .. \\ ..@}}). Otherwise @LaTeX{} will misinterpret the double backslash as ending the tabular row. Instead, to get a line break in there use @code{\newline} (@pxref{\newline}). @item *@{@var{num}@}@{@var{cols}@} Equivalent to @var{num} copies of @var{cols}, where @var{num} is a positive integer and @var{cols} is a list of specifiers. Thus the specifier @code{\begin@{tabular@}@{|*@{3@}@{l|r@}|@}} is equivalent to the specifier @code{\begin@{tabular@}@{|l|rl|rl|r|@}}. Note that @var{cols} may contain another @code{*}-expression. @end table @item width Required for @code{tabular*}, not allowed for @code{tabular}. Specifies the width of the @code{tabular*} environment. The space between columns should be rubber, as with @code{@@@{\extracolsep@{\fill@}@}}, to allow the table to stretch or shrink to make the specified width, or else you are likely to get the @code{Underfull \hbox (badness 10000) in alignment ...} warning. @end table Parameters that control formatting: @c xx defaults, own node (xref from array)? @ftable @code @item \arrayrulewidth @anchor{tabular arrayrulewidth} A length that is the thickness of the rule created by @code{|}, @code{\hline}, and @code{\vline} in the @code{tabular} and @code{array} environments. The default is @samp{.4pt}. Change it as in @code{\setlength@{\arrayrulewidth@}@{0.8pt@}}. @item \arraystretch @anchor{tabular arraystrech} A factor by which the spacing between rows in the @code{tabular} and @code{array} environments is multiplied. The default is @samp{1}, for no scaling. Change it as @code{\renewcommand@{\arraystretch@}@{1.2@}}. @item \doublerulesep @anchor{tabular doublerulesep} A length that is the distance between the vertical rules produced by the @code{||} specifier. The default is @samp{2pt}. @item \tabcolsep @anchor{tabular tabcolsep} A length that is half of the space between columns. The default is @samp{6pt}. Change it with @code{\setlength}. @end ftable The following commands can be used inside the body of a @code{tabular} environment, the first two inside an entry and the second two between lines: @menu * \multicolumn:: Make an item spanning several columns. * \vline:: Draw a vertical line. * \cline:: Draw a horizontal line spanning some columns. * \hline:: Draw a horizontal line spanning all columns. @end menu @node \multicolumn @subsection @code{\multicolumn} @findex \multicolumn Synopsis: @example \multicolumn@{@var{numcols}@}@{@var{cols}@}@{@var{text}@} @end example Make an @code{array} or @code{tabular} entry that spans several columns. The first argument @var{numcols} gives the number of columns to span. The second argument @var{cols} specifies the formatting of the entry, with @code{c} for centered, @code{l} for flush left, or @code{r} for flush right. The third argument @var{text} gives the contents of that entry. In this example, in the first row, the second and third columns are spanned by the single heading @samp{Name}. @example \begin@{tabular@}@{lccl@} \textit@{ID@} &\multicolumn@{2@}@{c@}@{\textit@{Name@}@} &\textit@{Age@} \\ \hline 978-0-393-03701-2 &O'Brian &Patrick &55 \\ ... \end@{tabular@} @end example What counts as a column is:@tie{}the column format specifier for the @code{array} or @code{tabular} environment is broken into parts, where each part (except the first) begins with @code{l}, @code{c}, @code{r}, or@tie{}@code{p}. So from @code{\begin@{tabular@}@{|r|ccp@{1.5in@}|@}} the parts are @code{|r|}, @code{c}, @code{c}, and@tie{}@code{p@{1.5in@}|}. The @var{cols} argument overrides the @code{array} or @code{tabular} environment's intercolumn area default adjoining this multicolumn entry. To affect that area, this argument can contain vertical bars @code{|} indicating the placement of vertical rules, and @code{@@@{...@}} expressions. Thus if @var{cols} is @samp{|c|} then this multicolumn entry will be centered and a vertical rule will come in the intercolumn area before it and after it. This table details the exact behavior. @example \begin@{tabular@}@{|cc|c|c|@} \multicolumn@{1@}@{r@}@{w@} % entry one &\multicolumn@{1@}@{|r|@}@{x@} % entry two &\multicolumn@{1@}@{|r@}@{y@} % entry three &z % entry four \end@{tabular@} @end example @noindent Before the first entry the output will not have a vertical rule because the @code{\multicolumn} has the @var{cols} specifier @samp{r} with no initial vertical bar. Between entry one and entry two there will be a vertical rule; although the first @var{cols} does not have an ending vertical bar, the second @var{cols} does have a starting one. Between entry two and entry three there is a single vertical rule; despite that the @var{cols} in both of the surrounding @code{multicolumn}'s call for a vertical rule, you only get one rule. Between entry three and entry four there is no vertical rule; the default calls for one but the @var{cols} in the entry three @code{\multicolumn} leaves it out, and that takes precedence. Finally, following entry four there is a vertical rule because of the default. The number of spanned columns @var{numcols} can be 1. Besides giving the ability to change the horizontal alignment, this also is useful to override for one row the @code{tabular} definition's default intercolumn area specification, including the placement of vertical rules. In the example below, in the @code{tabular} definition the first column is specified to default to left justified but in the first row the entry is centered with @code{\multicolumn@{1@}@{c@}@{\textsc@{Period@}@}}. Also in the first row, the second and third columns are spanned by a single entry with @code{\multicolumn@{2@}@{c@}@{\textsc@{Span@}@}}, overriding the specification to center those two columns on the page range en-dash. @example \begin@{tabular@}@{l|r@@@{--@}l@} \multicolumn@{1@}@{c@}@{\textsc@{Period@}@} &\multicolumn@{2@}@{c@}@{\textsc@{Span@}@} \\ \hline Baroque &1600 &1760 \\ Classical &1730 &1820 \\ Romantic &1780 &1910 \\ Impressionistic &1875 &1925 \end@{tabular@} @end example @noindent Although the @code{tabular} specification by default puts a vertical rule between the first and second columns, no such vertical rule appears in the first row here. That's because there is no vertical bar in the @var{cols} part of the first row's first @code{\multicolumn} command. @node \vline @subsection @code{\vline} @findex \vline Draw a vertical line in a @code{tabular} or @code{array} environment extending the full height and depth of an entry's row. Can also be used in an @@-expression, although its synonym vertical bar@tie{}@code{|} is more common. This command is rarely used in the body of a table; typically a table's vertical lines are specified in @code{tabular}'s @var{cols} argument and overridden as needed with @code{\multicolumn} (@pxref{tabular}). The example below illustrates some pitfalls. In the first row's second entry the @code{\hfill} moves the @code{\vline} to the left edge of the cell. But that is different than putting it halfway between the two columns, so between the first and second columns there are two vertical rules, with the one from the @code{@{c|cc@}} specifier coming before the one produced by the @code{\vline\hfill}. In contrast, the first row's third entry shows the usual way to put a vertical bar between two columns. In the second row, the @code{ghi} is the widest entry in its column so in the @code{\vline\hfill} the @code{\hfill} has no effect and the vertical line in that entry appears immediately next to the @code{g}, with no whitespace. @example \begin@{tabular@}@{c|cc@} x &\vline\hfill y &\multicolumn@{1@}@{|r@}@{z@} \\ % row 1 abc &def &\vline\hfill ghi % row 2 \end@{tabular@} @end example @node \cline @subsection @code{\cline} @findex \cline Synopsis: @example \cline@{@var{i}-@var{j}@} @end example In an @code{array} or @code{tabular} environment, draw a horizontal rule beginning in column@tie{}@var{i} and ending in column@tie{}@var{j}. The dash, @code{-}, must appear in the mandatory argument. To span a single column use the number twice, as with @code{\cline@{2-2@}}. This example puts two horizontal lines between the first and second rows, one line in the first column only, and the other spanning the third and fourth columns. The two lines are side-by-side, at the same height. @example \begin@{tabular@}@{llrr@} a &b &c &d \\ \cline@{1-1@} \cline@{3-4@} e &f &g &h \end@{tabular@} @end example @node \hline @subsection @code{\hline} @findex \hline Draw a horizontal line the width of the enclosing @code{tabular} or @code{array} environment. It's most commonly used to draw a line at the top, bottom, and between the rows of a table. In this example the top of the table has two horizontal rules, one above the other, that span both columns. The bottom of the table has a single rule spanning both columns. Because of the @code{\hline}, the @code{tabular} second row's line ending double backslash@tie{}@code{\\} is required. @example \begin@{tabular@}@{ll@} \hline\hline Baseball &Red Sox \\ Basketball &Celtics \\ \hline \end@{tabular@} @end example @node thebibliography @section @code{thebibliography} @EnvIndex{thebibliography} @cindex bibliography, creating (manually) Synopsis: @example \begin@{thebibliography@}@{@var{widest-label}@} \bibitem[@var{label}]@{@var{cite_key@}} ... \end@{thebibliography@} @end example Produce a bibliography or reference list. There are two ways to produce bibliographic lists. This environment is suitable when you have only a few references and can maintain the list by hand. @xref{Using BibTeX}, for a more sophisticated approach. This shows the environment with two entries. @example This work is based on \cite@{latexdps@}. Together they are \cite@{latexdps, texbook@}. ... \begin@{thebibliography@}@{9@} \bibitem@{latexdps@} Leslie Lamport. \textit@{\LaTeX@{@}: a document preparation system@}. Addison-Wesley, Reading, Massachusetts, 1993. \bibitem@{texbook@} Donald Ervin Knuth. \textit@{The \TeX book@}. Addison-Wesley, Reading, Massachusetts, 1983. \end@{thebibliography@} @end example @noindent This styles the first reference as @samp{[1] Leslie ...}, and so that @code{... based on \cite@{latexdps@}} produces the matching @samp{... based on [1]}. The second @code{\cite} produces @samp{[1, 2]}. You must compile the document twice to resolve these references. The mandatory argument @var{widest-label} is text that, when typeset, is as wide as the widest item label produced by the @code{\bibitem} commands. The tradition is to use @code{9} for bibliographies with less than 10 references, @code{99} for ones with less than 100, etc. @findex \bibname @findex \refname The bibliographic list is headed by a title such as @samp{Bibliography}. To change it there are two cases. In the @file{book} and @file{report} classes, where the top level sectioning is @code{\chapter} and the default title is @samp{Bibliography}, that title is in the macro @code{\bibname}. For @file{article}, where the class's top level sectioning is @code{\section} and the default is @samp{References}, the title is in macro @code{\refname}. Change it by redefining the command, as with @code{\renewcommand@{\refname@}@{Cited references@}}, after @code{\begin@{document@}}. @PkgIndex{babel} Language support packages such as @package{babel} will automatically redefine @code{\refname} or @code{\bibname} to fit the selected language. @xref{list}, for the list layout control parameters. @menu * \bibitem:: Specify a bibliography item. * \cite:: Refer to a bibliography item. * \nocite:: Include an item in the bibliography. * Using BibTeX:: Automatic generation of bibliographies. @end menu @node \bibitem @subsection @code{\bibitem} @findex \bibitem Synopsis: @example \bibitem@{@var{cite_key}@} @end example @noindent or @example \bibitem[@var{label}]@{@var{cite_key}@} @end example Generate an entry labeled by default by a number generated using the @code{enumi} counter. The @dfn{citation key} @cindex citation key @var{cite_key} can be any string of letters, numbers, and punctuation symbols (but not comma). @xref{thebibliography}, for an example. When provided, the optional @var{label} becomes the entry label and the @code{enumi} counter is not incremented. With this @example \begin@{thebibliography@} \bibitem[Lamport 1993]@{latexdps@} Leslie Lamport. \textit@{\LaTeX@{@}: a document preparation system@}. Addison-Wesley, Reading, Massachusetts, 1993. \bibitem@{texbook@} Donald Ervin Knuth. \textit@{The \TeX book@}. Addison-Wesley, Reading, Massachusetts, 1983. \end@{thebibliography@} @end example @noindent the first entry will be styled as @samp{[Lamport 1993] Leslie ...} (The amount of horizontal space that @LaTeX{} leaves for the label depends on the @var{widest-label} argument of the @code{thebibliography} environment; see @ref{thebibliography}.) Similarly, @code{... based on \cite@{latexdps@}} will produce @samp{... based on [Lamport 1994]}. If you mix @code{\bibitem} entries having a @var{label} with those that do not then @LaTeX{} will number the unlabelled ones sequentially. In the example above the @code{texbook} entry will appear as @samp{[1] Donald ...}, despite that it is the second entry. If you use the same @var{cite_key} twice then you get @samp{LaTeX Warning: There were multiply-defined labels}. Under the hood, @LaTeX{} remembers the @var{cite_key} and @var{label} information because @code{\bibitem} writes it to the auxiliary file @file{@var{jobname}.aux} (@pxref{Jobname}). For instance, the above example causes the two @code{\bibcite@{latexdps@}@{Lamport, 1993@}} and @code{\bibcite@{texbook@}@{1@}} to appear in that file. The @file{.aux} file is read by the @code{\begin@{document@}} command and then the information is available for @code{\cite} commands. This explains why you need to run @LaTeX{} twice to resolve references: once to write it out and once to read it in. Because of this two-pass algorithm, when you add a @code{\bibitem} or change its @var{cite_key} you may get @samp{LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right}. Fix it by recompiling. @node \cite @subsection @code{\cite} @findex \cite Synopsis: @example \cite@{@var{keys}@} @end example @noindent or @example \cite[@var{subcite}]@{@var{keys}@} @end example Generate as output a citation to the references associated with @var{keys}. The mandatory @var{keys} is a citation key, or a comma-separated list of citation keys (@pxref{\bibitem}). This @example The ultimate source is \cite@{texbook@}. ... \begin@{thebibliography@} \bibitem@{texbook@} Donald Ervin Knuth. \textit@{The \TeX book@}. Addison-Wesley, Reading, Massachusetts, 1983. \end@{thebibliography@} @end example @noindent produces output like @samp{... source is [1]}. You can change the appearance of the citation and of the reference by using bibliography styles if you generate automatically the @code{thebibliography} environment. More information in @ref{Using BibTeX}. The optional argument @var{subcite} is appended to the citation. For example, @code{See 14.3 in \cite[p.~314]@{texbook@}} might produce @samp{See 14.3 in [1, p.@tie{}314]}. In addition to what appears in the output, @code{\cite} writes information to the auxiliary file @file{@var{jobname}.aux} (@pxref{Jobname}). For instance, @code{\cite@{latexdps@}} writes @samp{\citation@{latexdps@}} to that file. This information is used by Bib@TeX{} to include in your reference list only those works that you have actually cited; see @ref{\nocite} also. If @var{keys} is not in your bibliography information then you get @samp{LaTeX Warning: There were undefined references}, and in the output the citation shows as a boldface question mark between square brackets. There are two possible causes. If you have mistyped something, as in @code{\cite@{texbok@}} then you need to correct the spelling. On the other hand, if you have just added or modified the bibliographic information and so changed the @file{.aux} file (@pxref{\bibitem}) then the fix may be to run @LaTeX{} again. @node \nocite @subsection @code{\nocite} @findex \nocite Synopsis: @example @code{\nocite@{@var{keys}@}} @end example Produces no output but writes @var{keys} to the auxiliary file @file{@var{jobname}.aux} (@pxref{Jobname}). The mandatory argument @var{keys} is a comma-separated list of one or more citation keys (@pxref{\bibitem}). This information is used by Bib@TeX{} to include these works in your reference list even though you have not explicitly cited them (@pxref{\cite}). @node Using BibTeX @subsection Using Bib@TeX{} @cindex using Bib@TeX{} @cindex bib@TeX{}, using @cindex bibliography, creating (automatically) @findex \bibliographystyle @findex \bibliography As described in @code{thebibliography} (@pxref{thebibliography}), a sophisticated approach to managing bibliographies is provided by the Bib@TeX{} program. This is only an introduction; see the full documentation on CTAN (@pxref{CTAN}). With Bib@TeX{}, you don't use the @code{thebibliography} environment directly (@pxref{thebibliography}). Instead, include these lines: @example \bibliographystyle@{@var{bibstyle}@} \bibliography@{@var{bibfile1}, @var{bibfile2}, ...@} @end example @noindent The @var{bibstyle} refers to a file @file{@var{bibstyle}.bst}, which defines how your citations will look. The standard @var{bibstyle}'s distributed with Bib@TeX{} are: @table @code @item alpha Labels are formed from name of author and year of publication. The bibliographic items are sorted alphabetically. @item plain Labels are integers. Sort the bibliographic items alphabetically. @item unsrt Like @code{plain}, but entries are in order of citation. @item abbrv Like @code{plain}, but more compact labels. @end table @noindent Many, many other Bib@TeX{} style files exist, tailored to the demands of various publications. See the CTAN topic @url{https://ctan.org/topic/bibtex-sty}. The @code{\bibliography} command is what actually produces the bibliography. Its argument is a comma-separated list, referring to files named @file{@var{bibfile1}.bib}, @file{@var{bibfile2}.bib}, @dots{} These contain your database in Bib@TeX{} format. This shows a typical couple of entries in that format. @example @@book@{texbook, title = @{The @{@{\TeX@}@}book@}, author = @{D.E. Knuth@}, isbn = @{0201134489@}, series = @{Computers \& typesetting@}, year = @{1983@}, publisher = @{Addison-Wesley@} @} @@book@{sexbook, author = @{W.H. Masters and V.E. Johnson@}, title = @{Human Sexual Response@}, year = @{1966@}, publisher = @{Bantam Books@} @} @end example Only the bibliographic entries referred to via @code{\cite} and @code{\nocite} will be listed in the document's bibliography. Thus you can keep all your sources together in one file, or a small number of files, and rely on Bib@TeX{} to include in this document only those that you used. @cindex @samp{*}, to @code{\nocite} all keys @findex \nocite @r{@{*@}, for all keys} With Bib@TeX{}, the @var{keys} argument to @code{\nocite} can also be the single character @samp{*}. This means to implicitly cite all entries from all given bibliographies. @menu * Bib@TeX{} error messages:: @end menu @node Bib@TeX{} error messages @subsubsection Bib@TeX{} error messages @cindex Bib@TeX{} error messages @cindex error messages, from Bib@TeX{} @findex .aux @r{file and Bib@TeX{} commands} If you forget to use @code{\bibliography} or @code{\bibliographystyle} in your document (or, less likely, any @code{\cite} or @code{\nocite} command), Bib@TeX{} will issue an error message. Because Bib@TeX{} can be used with any program, not just @LaTeX{}, the error messages refer to the internal commands read by Bib@TeX{} (from the @file{.aux} file), rather than the user-level commands described above. Here is a table showing internal commands mentioned in the Bib@TeX{} errors, and the corresponding user-level commands. @ftable @code @item \bibdata @findex \bibliography @r{and internal @code{\bibdata}} @code{\bibliography} @item \bibstyle @findex \bibliographystyle @r{and internal @code{\bibstyle}} @code{\bibliographystyle} @item \citation @findex \cite @r{and internal @code{\citation}} @findex \nocite @r{and internal @code{\citation}} @code{\cite}, @code{\nocite} @end ftable For example, if your document has no @code{\bibliographystyle} command, Bib@TeX{} complains as follows: @example I found no \bibstyle command---while reading file @var{document}.aux @end example @node theorem @section @code{theorem} @EnvIndex{theorem} @cindex theorems, typesetting Synopsis: @example \begin@{theorem@} @var{theorem body} \end@{theorem@} @end example Produces @samp{Theorem @var{n}} in boldface followed by @var{theorem body} in italics. The numbering possibilities for @var{n} are described under @code{\newtheorem} (@pxref{\newtheorem}). @example \newtheorem@{lem@}@{Lemma@} % in preamble \newtheorem@{thm@}@{Theorem@} ... \begin@{lem@} % in document body text of lemma \end@{lem@} The next result follows immediately. \begin@{thm@}[Gauss] % put `Gauss' in parens after theorem head text of theorem \end@{thm@} @end example @PkgIndex{amsmath} @PkgIndex{amsthm} Most new documents use the packages @package{amsthm} and @package{amsmath} from the American Mathematical Society. Among other things these packages include a large number of options for theorem environments, such as styling options. @node titlepage @section @code{titlepage} @EnvIndex{titlepage} @cindex making a title page @cindex title pages, creating Synopsis: @example \begin@{titlepage@} ... text and spacing ... \end@{titlepage@} @end example Create a title page, a page with no printed page number or heading and with succeeding pages numbered starting with page one. In this example all formatting, including vertical spacing, is left to the author. @example \begin@{titlepage@} \vspace*@{\stretch@{1@}@} \begin@{center@} @{\huge\bfseries Thesis \\[1ex] title@} \\[6.5ex] @{\large\bfseries Author name@} \\ \vspace@{4ex@} Thesis submitted to \\[5pt] \textit@{University name@} \\[2cm] in partial fulfilment for the award of the degree of \\[2cm] \textsc@{\Large Doctor of Philosophy@} \\[2ex] \textsc@{\large Mathematics@} \\[12ex] \vfill Department of Mathematics \\ Address \\ \vfill \today \end@{center@} \vspace@{\stretch@{2@}@} \end@{titlepage@} @end example To instead produce a standard title page without a @code{titlepage} environment, use @code{\maketitle} (@pxref{\maketitle}). @node verbatim @section @code{verbatim} @EnvIndex{verbatim} @cindex verbatim text @cindex simulating typed text @cindex typed text, simulating @cindex code, typesetting @cindex computer programs, typesetting Synopsis: @example \begin@{verbatim@} @var{literal-text} \end@{verbatim@} @end example A paragraph-making environment in which @LaTeX{} produces as output exactly what you type as input. For instance inside @var{literal-text} the backslash@tie{}@code{\} character does not start commands, it produces a printed @samp{\}, and carriage returns and blanks are taken literally. The output appears in a monospaced typewriter-like font (@code{\tt}). @example \begin@{verbatim@} Symbol swearing: %&$#?@!. \end@{verbatim@} @end example The only restriction on @code{literal-text} is that it cannot include the string @code{\end@{verbatim@}}. @PkgIndex{cprotect} You cannot use the verbatim environment in the argument to macros, for instance in the argument to a @code{\section}. This is not the same as commands being fragile (@pxref{\protect}), instead it just cannot work, as the @code{verbatim} environment changes the catcode regime before processing its contents, and restore it immediately afterward, nevertheless with a macro argument the content of the argument has already be converted to a token list along the catcode regime in effect when the macro was called. However, the @package{cprotect} package can help with this. @PkgIndex{listings} @PkgIndex{minted} One common use of verbatim input is to typeset computer code. There are packages that are an improvement the @code{verbatim} environment. For instance, one improvement is to allow the verbatim inclusion of external files, or parts of those files. Such packages include @package{listings}, and @package{minted}. @PkgIndex{fancyvrb} @PkgIndex{verbatimbox} A package that provides many more options for verbatim environments is @package{fancyvrb}. Another is @package{verbatimbox}. For a list of all the relevant packages, see CTAN (@pxref{CTAN}). @menu * \verb:: The macro form of the @code{verbatim} environment. @end menu @node \verb @subsection @code{\verb} @findex \verb @cindex verbatim text, inline Synopsis: @example \verb @var{char} @var{literal-text} @var{char} \verb* @var{char} @var{literal-text} @var{char} @end example Typeset @var{literal-text} as it is input, including special characters and spaces, using the typewriter (@code{\tt}) font. This example shows two different invocations of @code{\verb}. @example This is \verb!literally! the biggest pumpkin ever. And this is the best squash, \verb+literally!+ @end example @noindent The first @code{\verb} has its @var{literal-text} surrounded with exclamation point, @code{!}. The second instead uses plus, @code{+}, because the exclamation point is part of @code{literal-text}. The single-character delimiter @var{char} surrounds @var{literal-text}---it must be the same character before and after. No spaces come between @code{\verb} or @code{\verb*} and @var{char}, or between @var{char} and @var{literal-text}, or between @var{literal-text} and the second occurrence of @var{char} (the synopsis shows a space only to distinguish one component from the other). The delimiter must not appear in @var{literal-text}. The @var{literal-text} cannot include a line break. @cindex visible space The @code{*}-form differs only in that spaces are printed with a visible space character. @tex (Namely, {\tt\char`\ }.) @end tex The output from this will include a visible space on both side of word @samp{with}: @example The command's first argument is \verb*!filename with extension! and ... @end example @PkgIndex{url} For typesetting Internet addresses, urls, the package @package{url} is a better option than the @code{\verb} command, since it allows line breaks. @PkgIndex{listings} @PkgIndex{minted} For computer code there are many packages with advantages over @code{\verb}. One is @package{listings}, another is @package{minted}. @PkgIndex{cprotect} You cannot use @code{\verb} in the argument to a macro, for instance in the argument to a @code{\section}. It is not a question of @code{\verb} being fragile (@pxref{\protect}), instead it just cannot work, as the @code{\verb} command changes the catcode regime before reading its argument, and restore it immediately afterward, nevertheless with a macro argument the content of the argument has already be converted to a token list along the catcode regime in effect when the macro was called. However, the @package{cprotect} package can help with this. @node verse @section @code{verse} @EnvIndex{verse} @cindex poetry, an environment for Synopsis: @example \begin@{verse@} @var{line1} \\ @var{line2} \\ ... \end@{verse@} @end example An environment for poetry. Here are two lines from Shakespeare's Romeo and Juliet. @example Then plainly know my heart's dear love is set \\ On the fair daughter of rich Capulet. @end example @findex \\ @r{for @code{verse}} Separate the lines of each stanza with @code{\\}, and use one or more blank lines to separate the stanzas. @example \begin@{verse@} \makebox[\linewidth][c]@{\textit@{Shut Not Your Doors@} ---Walt Whitman@} \\[1\baselineskip] Shut not your doors to me proud libraries, \\ For that which was lacking on all your well-fill'd shelves, \\ \qquad yet needed most, I bring, \\ Forth from the war emerging, a book I have made, \\ The words of my book nothing, the drift of it every thing, \\ A book separate, not link'd with the rest nor felt by the intellect, \\ But you ye untold latencies will thrill to every page. \end@{verse@} @end example @noindent The output has margins indented on the left and the right, paragraphs are not indented, and the text is not right-justified. @node Line breaking @chapter Line breaking @cindex line breaking @cindex breaking lines The first thing @LaTeX{} does when processing ordinary text is to translate your input file into a sequence of glyphs and spaces. To produce a printed document, this sequence must be broken into lines (and these lines must be broken into pages). @LaTeX{} usually does the line (and page) breaking in the text body for you but in some environments you manually force line breaks. A common workflow is to get a final version of the document content before taking a final pass through and considering line breaks (and page breaks). This differs from word processing, where you are formatting text as you input it. Putting these off until the end prevents a lot of fiddling with breaks that will change anyway. @c Alernative text proposed here: https://tug.org/pipermail/latexrefman/2021q3/000803.html @c this text is that of the French version. @ignore A common workflow with LaTeX is to get a final version of the document content before taking a final pass through and considering line breaks (and page breaks). Most people do not consider LaTeX as a word processor, because it does not show the output instantly. However differing the output encourages the user to put off until the end formatting adjustments, and thus it prevents a lot of fiddling with breaks that will change anyway. @noindent Differing the output has other advantages: it enables to make no compromise about the typesetting, which ensures that what you see it exactly what you get, and it also helps authors concentrate their mind on either writing or reading rather than distract it by doing both a the same time. @end ignore @menu * \\:: Start a new line. * \obeycr & \restorecr:: Make each input line start a new output line. * \newline:: Break the line * \- (hyphenation):: Insert explicit hyphenation. * \discretionary:: Explicit control of the hyphen character. * \fussy & \sloppy:: Be more or less particular with line breaking. * \hyphenation:: Tell @LaTeX{} how to hyphenate a word. * \linebreak & \nolinebreak:: Forcing & avoiding line breaks. @end menu @node \\ @section @code{\\} @findex \\ @r{force line break} @cindex new line, starting @cindex line break, forcing Synopsis, one of: @example \\ \\[@var{morespace}] @end example @noindent or one of: @example \\* \\*[@var{morespace}] @end example End the current line. The optional argument @var{morespace} specifies extra vertical space to be inserted before the next line. This is a rubber length (@pxref{Lengths}) and can be negative. The text before the line break is set at its normal length, that is, it is not stretched to fill out the line width. This command is fragile (@pxref{\protect}). @example \title@{My story: \\[0.25in] a tale of woe@} @end example @noindent The starred form, @code{\\*}, tells @LaTeX{} not to start a new page between the two lines, by issuing a @code{\nobreak}. Explicit line breaks in the main text body are unusual in @LaTeX{}. In particular, don't start new paragraphs with @code{\\}. Instead leave a blank line between the two paragraphs. And don't put in a sequence of @code{\\}'s to make vertical space. Instead use @code{\vspace@{@var{length}@}}, or @code{\leavevmode\vspace@{@var{length}@}}, or @code{\vspace*@{@var{length}@}} if you want the space to not be thrown out at the top of a new page (@pxref{\vspace}). The @code{\\} command is mostly used outside of the main flow of text such as in a @code{tabular} or @code{array} environment or in an equation environment. The @code{\\} command is a synonym for @code{\newline} (@pxref{\newline}) under ordinary circumstances (an example of an exception is the @code{p@{...@}} column in a @code{tabular} environment; @pxref{tabular}). @c credit: David Carlisle https://tex.stackexchange.com/a/82666 The @code{\\} command is a macro, and its definition changes by context so that its definition in normal text, a @code{center} environment, a @code{flushleft} environment, and a @code{tabular} are all different. In normal text when it forces a linebreak it is essentially a shorthand for @code{\newline}. It does not end horizontal mode or end the paragraph, it just inserts some glue and penalties so that when the paragraph does end a linebreak will occur at that point, with the short line padded with white space. You get @samp{LaTeX Error: There's no line here to end} if you use @code{\\} to ask for a new line, rather than to end the current line. An example is if you have @code{\begin@{document@}\\} or, more likely, something like this. @example \begin@{center@} \begin@{minipage@}@{0.5\textwidth@} \\ In that vertical space put your mark. \end@{minipage@} \end@{center@} @end example @noindent Fix it by replacing the double backslash with something like @code{\vspace@{\baselineskip@}}. @node \obeycr & \restorecr @section @code{\obeycr} & @code{\restorecr} @findex \obeycr @findex \restorecr @cindex new line, output as input The @code{\obeycr} command makes a return in the input file (@samp{^^M}, internally) the same as @code{\\}, followed by @code{\relax}. So each new line in the input will also be a new line in the output. The @code{\restorecr} command restores normal line-breaking behavior. This is not the way to show verbatim text or computer code. Use @code{verbatim} (@pxref{verbatim}) instead. With @LaTeX{}'s usual defaults, this @example aaa bbb \obeycr ccc ddd eee \restorecr fff ggg hhh iii @end example @noindent produces output like this. @example aaa bbb ccc ddd eee fff ggg hhh iii @end example @noindent The indents are paragraph indents. @node \newline @section @code{\newline} @findex \newline @cindex new line, starting (paragraph mode) In ordinary text, this ends a line in a way that does not right-justify it, so the text before the end of line is not stretched. That is, in paragraph mode (@pxref{Modes}), the @code{\newline} command is equivalent to double-backslash (@pxref{\\}). This command is fragile (@pxref{\protect}). However, the two commands are different inside a @code{tabular} or @code{array} environment. In a column with a specifier producing a paragraph box such as typically @code{p@{...@}}, @code{\newline} will insert a line end inside of the column; that is, it does not break the entire tabular row. To break the entire row use @code{\\} or its equivalent @code{\tabularnewline}. This will print @samp{Name:} and @samp{Address:} as two lines in a single cell of the table. @example \begin@{tabular@}@{p@{1in@}@@@{\hspace@{2in@}@}p@{1in@}@} Name: \newline Address: &Date: \\ \hline \end@{tabular@} @end example @noindent The @samp{Date:} will be baseline-aligned with @samp{Name:}. @node \- (hyphenation) @section @code{\-} (discretionary hyphen) @findex \- @r{(hyphenation)} @cindex hyphenation, forcing Tell @LaTeX{} that it may hyphenate the word at that point. When you insert @code{\-} commands in a word, the word will only be hyphenated at those points and not at any of the other hyphenation points that @LaTeX{} might otherwise have chosen. This command is robust (@pxref{\protect}). @LaTeX{} is good at hyphenating and usually finds most of the correct hyphenation points, while almost never using an incorrect one. The @code{\-} command is for exceptional cases. For example, @LaTeX{} does not ordinarily hyphenate words containing a hyphen. Below, the long and hyphenated word means @LaTeX{} has to put in unacceptably large spaces to set the narrow column. @example \begin@{tabular@}@{rp@{1.75in@}@} Isaac Asimov &The strain of anti-intellectualism % an\-ti-in\-tel\-lec\-tu\-al\-ism has been a constant thread winding its way through our political and cultural life, nurtured by the false notion that democracy means that `my ignorance is just as good as your knowledge'. \end@{tabular@} @end example @noindent Commenting out the third line and uncommenting the fourth makes a much better fit. The @code{\-} command only allows @LaTeX{} to break there, it does not require that it break there. You can force a split with something like @code{Hef-\linebreak feron}. Of course, if you later change the text then this forced break may look very odd, so this approach requires care. @node \discretionary @section @code{\discretionary} (generalized hyphenation point) @cindex hyphenation, discretionary @cindex discretionary hyphenation Synopsis: @example \discretionary@{@var{pre-break}@}@{@var{post-break}@}@{@var{no-break}@} @end example Handle word changes around hyphens. This command is not often used in @LaTeX{} documents. If a line break occurs at the point where @code{\discretionary} appears then @TeX{} puts @var{pre-break} at the end of the current line and puts @var{post-break} at the start of the next line. If there is no line break here then @TeX{} puts @var{no-break}. In @samp{difficult} the three letters @code{ffi} form a ligature. But @TeX{} can nonetheless break between the two @samp{f}'s with this. @example di\discretionary@{f-@}@{fi@}@{ffi@}cult @end example Note that users do not have to do this. It is typically handled automatically by @TeX{}'s hyphenation algorithm. @c xxx TODO, complete this node, see LaTeX-fr (copied & pasted below, @c with accented letter escaped) @ignore @c Les arguments de @code{\discretionary} ne peuvent contenir que des @c caract@`eres, des bo@^{@dotless{i}}tes ou des cr@'enages. @c @c La commande @code{\discretionary} permet de contr@^oler @c finement la c@'esure dans les cas o@`u ne suffisent ni le contr@^ole standard @c de la c@'esure fait l'algorithme de c@'esure de @TeX{} et les r@`egles de @c c@'esures donn@'ees par les paquetages de gestion linguistiques, ni les @c moyens de contr@^ole explicites offerts par les commandes @c @code{\hyphenation} (@pxref{\hyphenation}) et @code{\-} (@pxref{\- @c (hyphenation),\- (c@'esure @`a gr@'e)}). @c @c L'usage typique de @code{\discretionary} est par exemple de contr@^oler la @c c@'esure au sein d'une formule math@'ematique en mode ligne (voir aussi @c @ref{Math miscellany,Miscellan@'ees math@'ematique (entr@'ee \*)}). Ci-dessous @c un exemple de contr@^ole de la c@'esure au sein d'une adresse r@'eticulaire, @c o@`u l'on autorise la c@'esure sur les obliques mais en utilisant une @c contr'oblique violette en lieu de trait d'union@tie{}: @c @c @example @c \documentclass@{article@} @c \usepackage[T1]@{fontenc@} @c \usepackage[utf8]@{inputenc@} @c \usepackage@{xcolor@} @c \usepackage@{hyperref@} @c \usepackage@{french@} @c \newcommand*\DiscrSlash@{\discretionary@{\mbox@{\textcolor @c @{purple@}@{\textbackslash@}@}@}@{/@}@{/@}@} @c \begin@{document@} @c Allez donc @`a \href@{http://une/tr\%c3\%A8s/tr\%c3\%A8s/longue% @c /mais/vraiment/tr\%c3\%A8s/longue/adresse/r\%C3\%A9ticulaire% @c /index.html@}@{http://une\DiscrSlash tr@`es\DiscrSlash tr@`es\DiscrSlash @c longue\DiscrSlash mais\DiscrSlash vraiment\DiscrSlash @c tr@`es\DiscrSlash longue\DiscrSlash adresse\DiscrSlash @c r@'eticulaire\DiscrSlash index.html@} @c \end@{document@} @c @end example @end ignore @node \fussy & \sloppy @section @code{\fussy} & @code{\sloppy} @findex \fussy @findex \sloppy @cindex line breaks, changing Declarations to make @TeX{} more picky or less picky about line breaking. Declaring @code{\fussy} usually avoids too much space between words, at the cost of an occasional overfull box. Conversely, @code{\sloppy} avoids overfull boxes while suffering loose interword spacing. The default is @code{\fussy}. Line breaking in a paragraph is controlled by whichever declaration is current at the end of the paragraph, i.e., at the blank line or @code{\par} or displayed equation ending that paragraph. So to affect the line breaks, include that paragraph-ending material in the scope of the command. @menu * sloppypar:: Environment version of \sloppy command. @end menu @node sloppypar @subsection @code{sloppypar} @EnvIndex{sloppypar} @cindex sloppypar environment Synopsis: @example \begin@{sloppypar@} ... paragraphs ... \end@{sloppypar@} @end example Typeset the paragraphs with @code{\sloppy} in effect (@pxref{\fussy & \sloppy}). Use this to locally adjust line breaking, to avoid @samp{Overfull box} or @samp{Underfull box} errors. The example is simple. @example \begin@{sloppypar@} Her plan for the morning thus settled, she sat quietly down to her book after breakfast, resolving to remain in the same place and the same employment till the clock struck one; and from habitude very little incommoded by the remarks and ejaculations of Mrs.\ Allen, whose vacancy of mind and incapacity for thinking were such, that as she never talked a great deal, so she could never be entirely silent; and, therefore, while she sat at her work, if she lost her needle or broke her thread, if she heard a carriage in the street, or saw a speck upon her gown, she must observe it aloud, whether there were anyone at leisure to answer her or not. \end@{sloppypar@} @end example @node \hyphenation @section @code{\hyphenation} @findex \hyphenation @cindex hyphenation, defining Synopsis: @example \hyphenation@{@var{word1} ...@} @end example Declares allowed hyphenation points within the words in the list. The words in that list are separated by spaces. Show permitted points for hyphenation with a dash character, @code{-}. Here is an example: @example \hyphenation@{hat-er il-lit-e-ra-ti tru-th-i-ness@} @end example Use lowercase letters. @TeX{} will only hyphenate if the word matches exactly, no inflections are tried. Multiple @code{\hyphenation} commands accumulate. @c xx Re-align on LaTeX-fr which also mentions fontenc, and that @c babel/polyglossia already load hyphenation patterns, and you have to @c declare only non existing words. @node \linebreak & \nolinebreak @section @code{\linebreak} & @code{\nolinebreak} @findex \linebreak @findex \nolinebreak @cindex line breaks, forcing @cindex line breaks, preventing Synopses, one of: @example \linebreak \linebreak[@var{zero-to-four}] @end example @noindent or one of these. @example \nolinebreak \nolinebreak[@var{zero-to-four}] @end example Encourage or discourage a line break. The optional @var{zero-to-four} is an integer lying between 0 and 4 that allows you to soften the instruction. The default is 4, so that without the optional argument these commands entirely force or prevent the break. But for instance, @code{\nolinebreak[1]} is a suggestion that another place may be better. The higher the number, the more insistent the request. Both commands are fragile (@pxref{\protect}). Here we tell @LaTeX{} that a good place to put a linebreak is after the standard legal text. @example \boilerplatelegal@{@} \linebreak[2] We especially encourage applications from members of traditionally underrepresented groups. @end example When you issue @code{\linebreak}, the spaces in the line are stretched out so that the break point reaches the right margin. @xref{\\} and@tie{}@ref{\newline}, to have the spaces not stretched out. @node Page breaking @chapter Page breaking @cindex page breaking @cindex breaking pages Ordinarily @LaTeX{} automatically takes care of breaking output into pages with its usual aplomb. But if you are writing commands, or tweaking the final version of a document, then you may need to understand how to influence its actions. @c credit: H Vogt https://tex.stackexchange.com/a/115563 @LaTeX{}'s algorithm for splitting a document into pages is more complex than just waiting until there is enough material to fill a page and outputting the result. Instead, @LaTeX{} typesets more material than would fit on the page and then chooses a break that is optimal in some way (it has the smallest badness). An example of the advantage of this approach is that if the page has some vertical space that can be stretched or shrunk, such as with rubber lengths between paragraphs, then @LaTeX{} can use that to avoid widow lines (where a new page starts with the last line of a paragraph; @LaTeX{} can squeeze the extra line onto the first page) and orphans (where the first line of paragraph is at the end of a page; @LaTeX{} can stretch the material of the first page so the extra line falls on the second page). Another example is where @LaTeX{} uses available vertical shrinkage to fit on a page not just the header for a new section but also the first two lines of that section. But @LaTeX{} does not optimize over the entire document's set of page breaks. So it can happen that the first page break is great but the second one is lousy; to break the current page @LaTeX{} doesn't look as far ahead as the next page break. So occasionally you may want to influence page breaks while preparing a final version of a document. @xref{Layout}, for more material that is relevant to page breaking. @menu * \clearpage & \cleardoublepage:: Start a new page; eject floats. * \newpage:: Start a new page. * \enlargethispage:: Enlarge the current page a bit. * \pagebreak & \nopagebreak:: Forcing & avoiding page breaks. @end menu @node \clearpage & \cleardoublepage @section @code{\clearpage} & @code{\cleardoublepage} @findex \clearpage @cindex flushing floats and starting a page @cindex starting a new page and clearing floats @findex \cleardoublepage @cindex starting on a right-hand page Synopsis: @example \clearpage @end example @noindent or @example \cleardoublepage @end example End the current page and output all of the pending floating figures and tables (@pxref{Floats}). If there are too many floats to fit on the page then @LaTeX{} will put in extra pages containing only floats. In two-sided printing, @code{\cleardoublepage} also makes the next page of content a right-hand page, an odd-numbered page, if necessary inserting a blank page. The @code{\clearpage} command is robust while @code{\cleardoublepage} is fragile (@pxref{\protect}). @LaTeX{}'s page breaks are optimized so ordinarily you only use this command in a document body to polish the final version, or inside commands. @c credit: https://www.tex.ac.uk/FAQ-reallyblank.html The @code{\cleardoublepage} command will put in a blank page, but it will have the running headers and footers. To get a really blank page, use this command. @example \let\origdoublepage\cleardoublepage \newcommand@{\clearemptydoublepage@}@{% \clearpage @{\pagestyle@{empty@}\origdoublepage@}% @} @end example @noindent If you want @LaTeX{}'s standard @code{\chapter} command to do this then add the line @code{\let\cleardoublepage\clearemptydoublepage}. The command @code{\newpage} (@pxref{\newpage}) also ends the current page, but without clearing pending floats. And, if @LaTeX{} is in two-column mode then @code{\newpage} ends the current column while @code{\clearpage} and @code{\cleardoublepage} end the current page. @node \newpage @section @code{\newpage} @findex \newpage @cindex new page, starting @cindex starting a new page Synopsis: @example \newpage @end example End the current page. This command is robust (@pxref{\protect}). @LaTeX{}'s page breaks are optimized so ordinarily you only use this command in a document body to polish the final version, or inside commands. While the commands @code{\clearpage} and @code{\cleardoublepage} also end the current page, in addition they clear pending floats (@pxref{\clearpage & \cleardoublepage}). And, if @LaTeX{} is in two-column mode then @code{\clearpage} and @code{\cleardoublepage} end the current page, possibly leaving an empty column, while @code{\newpage} only ends the current column. In contrast with @code{\pagebreak} (@pxref{\pagebreak & \nopagebreak}), the @code{\newpage} command will cause the new page to start right where requested. This @example Four score and seven years ago our fathers brought forth on this continent, \newpage \noindent a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. @end example @noindent makes a new page start after @samp{continent}, and the cut-off line is not right justified. In addition, @code{\newpage} does not vertically stretch out the page, as @code{\pagebreak} does. @node \enlargethispage @section @code{\enlargethispage} @findex \enlargethispage @cindex enlarge current page Synopsis, one of: @example \enlargethispage@{size@} \enlargethispage*@{size@} @end example Enlarge the @code{\textheight} for the current page. The required argument @var{size} must be a rigid length (@pxref{Lengths}). It may be positive or negative. This command is fragile (@pxref{\protect}). A common strategy is to wait until you have the final text of a document, and then pass through it tweaking line and page breaks. This command allows you some page size leeway. This will allow one extra line on the current page. @example \enlargethispage@{\baselineskip@} @end example The starred form @code{\enlargesthispage*} tries to squeeze the material together on the page as much as possible, for the common use case of getting one more line on the page. This is often used together with an explicit @code{\pagebreak}. @node \pagebreak & \nopagebreak @section @code{\pagebreak} & @code{\nopagebreak} @findex \pagebreak @findex \nopagebreak @cindex page break, forcing @cindex page break, preventing Synopses: @example \pagebreak \pagebreak[@var{zero-to-four}] @end example @noindent or @example \nopagebreak \nopagebreak[@var{zero-to-four}] @end example Encourage or discourage a page break. The optional @var{zero-to-four} is an integer that allows you to soften the request. The default is 4, so that without the optional argument these commands entirely force or prevent the break. But for instance @code{\nopagebreak[1]} suggests to @LaTeX{} that another spot might be preferable. The higher the number, the more insistent the request. Both commands are fragile (@pxref{\protect}). @LaTeX{}'s page endings are optimized so ordinarily you only use this command in a document body to polish the final version, or inside commands. If you use these inside a paragraph, they apply to the point following the line in which they appear. So this @example Four score and seven years ago our fathers brought forth on this continent, \pagebreak a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. @end example @noindent does not give a page break at @samp{continent}, but instead at @samp{nation}, since that is where @LaTeX{} breaks that line. In addition, with @code{\pagebreak} the vertical space on the page is stretched out where possible so that it extends to the normal bottom margin. This can look strange, and if @code{\flushbottom} is in effect this can cause you to get @samp{Underfull \vbox (badness 10000) has occurred while \output is active}. @xref{\newpage}, for a command that does not have these effects. @findex \samepage @findex samepage @r{environment} (There is an obsolete declaration @code{\samepage}, which tries to only allow a break between two paragraphs. There is a related environment @code{samepage}, also obsolete. Neither of these work reliably. For more on keeping material on the same page, see the FAQ entry @url{https://texfaq.org/FAQ-nopagebrk}.) @node Footnotes @chapter Footnotes @cindex footnotes, creating Place a footnote at the bottom of the current page, as here. @example No@"{e}l Coward quipped that having to read a footnote is like having to go downstairs to answer the door, while in the midst of making love.\footnote@{% I wouldn't know, I don't read footnotes.@} @end example You can put multiple footnotes on a page. If the footnote text becomes too long then it will flow to the next page. You can also produce footnotes by combining the @code{\footnotemark} and the @code{\footnotetext} commands, which is useful in special circumstances. To make bibliographic references come out as footnotes you need to include a bibliographic style with that behavior (@pxref{Using BibTeX}). @menu * \footnote:: Insert a footnote. * \footnotemark:: Insert footnote mark only. * \footnotetext:: Insert footnote text only. * Footnotes in section headings:: Chapter or section titles. * Footnotes in a table:: Table footnotes. * Footnotes of footnotes:: Multiple classes of footnotes. @end menu @node \footnote @section @code{\footnote} @findex \footnote Synopsis, one of: @example \footnote@{@var{text}@} \footnote[@var{number}]@{@var{text}@} @end example Place a footnote @var{text} at the bottom of the current page. @example There are over a thousand footnotes in Gibbon's \textit@{Decline and Fall of the Roman Empire@}.\footnote@{% After reading an early version with endnotes David Hume complained, ``One is also plagued with his Notes, according to the present Method of printing the Book'' and suggested that they ``only to be printed at the Margin or the Bottom of the Page.''@} @end example The optional argument @var{number} allows you to specify the number of the footnote. If you use this then @LaTeX{} does not increment the @code{footnote} counter. @cindex footnotes, symbols instead of numbers @findex \fnsymbol@r{, and footnotes} @findex \@@fnsymbol By default, @LaTeX{} uses arabic numbers as footnote markers. Change this with something like @code{\renewcommand@{\thefootnote@}@{\fnsymbol@{footnote@}@}}, which uses a sequence of symbols (@pxref{\alph \Alph \arabic \roman \Roman \fnsymbol}). To make this change global put that in the preamble. If you make the change local then you may want to reset the counter with @code{\setcounter@{footnote@}@{0@}}. @LaTeX{} determines the spacing of footnotes with two parameters. @cindex footnote parameters @cindex parameters, for footnotes @ftable @code @item \footnoterule @anchor{footnote footnoterule} Produces the rule separating the main text on a page from the page's footnotes. Default dimensions in the standard document classes (except @code{slides}, where it does not appear) is: vertical thickness of @code{0.4pt}, and horizontal size of @code{0.4\columnwidth} long. Change the rule with something like this. @c Credit egreg: https://tex.stackexchange.com/a/21917 @example \renewcommand@{\footnoterule@}@{% Kerns avoid vertical space \kern -3pt % This -3 is negative \hrule width \textwidth height 1pt % of the sum of this 1 \kern 2pt@} % and this 2 @end example @item \footnotesep @anchor{footnote footnotesep} @cindex strut The height of the strut placed at the beginning of the footnote (@pxref{\strut}). By default, this is set to the normal strut for @code{\footnotesize} fonts (@pxref{Font sizes}), therefore there is no extra space between footnotes. This is @samp{6.65pt} for @samp{10pt}, @samp{7.7pt} for @samp{11pt}, and @samp{8.4pt} for @samp{12pt}. Change it as with @code{\setlength@{\footnotesep@}@{11pt@}}. @end ftable The @code{\footnote} command is fragile (@pxref{\protect}). @LaTeX{}'s default puts many restrictions on where you can use a @code{\footnote}; for instance, you cannot use it in an argument to a sectioning command such as @code{\chapter} (it can only be used in outer paragraph mode; @pxref{Modes}). There are some workarounds; see following sections. @cindex footnotes, in a minipage @cindex mpfootnote counter In a @code{minipage} environment the @code{\footnote} command uses the @code{mpfootnote} counter instead of the @code{footnote} counter, so they are numbered independently. They are shown at the bottom of the environment, not at the bottom of the page. And by default they are shown alphabetically. @xref{minipage} and @ref{Footnotes in a table}. @node \footnotemark @section @code{\footnotemark} @findex \footnotemark Synopsis, one of: @example \footnotemark \footnotemark[@var{number}] @end example Put the current footnote mark in the text. To specify associated text for the footnote see@tie{}@ref{\footnotetext}. The optional argument @var{number} causes the command to use that number to determine the footnote mark. This command can be used in inner paragraph mode (@pxref{Modes}). If you use @code{\footnotemark} without the optional argument then it increments the @code{footnote} counter, but if you use the optional @var{number} then it does not. The next example produces several consecutive footnote markers referring to the same footnote. @example The first theorem\footnote@{Due to Gauss.@} and the second theorem\footnotemark[\value@{footnote@}] and the third theorem.\footnotemark[\value@{footnote@}] @end example If there are intervening footnotes then you must remember the value of the number of the common mark. This example gives the same institutional affiliation to both the first and third authors (@code{\thanks} is a version of @code{\footnote}), by-hand giving the number of the footnote. @example \title@{A Treatise on the Binomial Theorem@} \author@{J Moriarty\thanks@{University of Leeds@} \and A C Doyle\thanks@{Durham University@} \and S Holmes\footnotemark[1]@} \begin@{document@} \maketitle @end example This uses a counter to remember the footnote number. The third sentence is followed by the same footnote marker as the first. @example \newcounter@{footnoteValueSaver@} All babies are illogical.\footnote@{% Lewis Carroll.@}\setcounter@{footnoteValueSaver@}@{\value@{footnote@}@} Nobody is despised who can manage a crocodile.\footnote@{% Captain Hook.@} Illogical persons are despised.\footnotemark[\value@{footnoteValueSaver@}] Therefore, anyone who can manage a crocodile is not a baby. @end example @PkgIndex{cleveref} @PkgIndex{hyperref} This example accomplishes the same by using the package @package{cleveref}. @c from SE user Jake http://tex.stackexchange.com/a/10116/339 @example \usepackage@{cleveref@}[2012/02/15] % in preamble \crefformat@{footnote@}@{#2\footnotemark[#1]#3@} ... The theorem is from Evers.\footnote@{\label@{fn:TE@}Tinker, Evers, 1994.@} The corollary is from Chance.\footnote@{Evers, Chance, 1990.@} But the key lemma is from Tinker.\cref@{fn:TE@} @end example @PkgIndex{hyperref} It will work with the package @package{hyperref}. @node \footnotetext @section @code{\footnotetext} @findex \footnotetext Synopsis, one of: @example \footnotetext@{@var{text}@} \footnotetext[@var{number}]@{@var{text}@} @end example Place @var{text} at the bottom of the page as a footnote. It pairs with @code{\footnotemark} (@pxref{\footnotemark}) and can come anywhere after that command, but must appear in outer paragraph mode (@pxref{Modes}). The optional argument @var{number} changes the number of the footnote mark. @xref{\footnotemark} and@tie{}@ref{Footnotes in a table}, for usage examples. @node Footnotes in section headings @section Footnotes in section headings @cindex footnote, in section headings @cindex table of contents, avoiding footnotes Putting a footnote in a section heading, as in: @example \section@{Full sets\protect\footnote@{This material due to ...@}@} @end example @noindent causes the footnote to appear at the bottom of the page where the section starts, as usual, but also at the bottom of the table of contents, where it is not likely to be desired. The simplest way to have it not appear on the table of contents is to use the optional argument to @code{\section} @example \section[Please]@{Please\footnote@{% Don't footnote in chapter and section headers!@}@} @end example @noindent No @code{\protect} is needed in front of @code{\footnote} here because what gets moved to the table of contents is the optional argument. @node Footnotes in a table @section Footnotes in a table @cindex footnote, in a table Inside a @code{tabular} or @code{array} environment the @code{\footnote} command does not work; there is a footnote mark in the table cell but the footnote text does not appear. The solution is to use a @code{minipage} environment as here (@pxref{minipage}). @example \begin@{center@} \begin@{minipage@}@{\textwidth@} \centering \begin@{tabular@}@{l|l@} \textsc@{Ship@} &\textsc@{Book@} \\ \hline \textit@{HMS Sophie@} &Master and Commander \\ \textit@{HMS Polychrest@} &Post Captain \\ \textit@{HMS Lively@} &Post Captain \\ \textit@{HMS Surprise@} &A number of books\footnote@{% Starting with \textit@{HMS Surprise@}.@} \end@{tabular@} \end@{minipage@} \end@{center@} @end example Inside a @code{minipage}, footnote marks are lowercase letters. Change that with something like @code{\renewcommand@{\thempfootnote@}@{\arabic@{mpfootnote@}@}} (@pxref{\alph \Alph \arabic \roman \Roman \fnsymbol}). The footnotes in the prior example appear at the bottom of the @code{minipage}. To have them appear at the bottom of the main page, as part of the regular footnote sequence, use the @code{\footnotemark} and @code{\footnotetext} pair and make a new counter. @example \newcounter@{mpFootnoteValueSaver@} \begin@{center@} \begin@{minipage@}@{\textwidth@} \setcounter@{mpFootnoteValueSaver@}@{\value@{footnote@}@} \centering \begin@{tabular@}@{l|l@} \textsc@{Woman@} &\textsc@{Relationship@} \\ \hline Mona &Attached\footnotemark \\ Diana Villiers &Eventual wife \\ Christine Hatherleigh Wood &Fiance\footnotemark \end@{tabular@} \end@{minipage@}% percent sign keeps footnote text close to minipage \stepcounter@{mpFootnoteValueSaver@}% \footnotetext[\value@{mpFootnoteValueSaver@}]@{% Little is known other than her death.@}% \stepcounter@{mpFootnoteValueSaver@}% \footnotetext[\value@{mpFootnoteValueSaver@}]@{% Relationship is unresolved in XXI.@} \end@{center@} @end example @PkgIndex{tablefootnote} For a floating @code{table} environment (@pxref{table}), use the @package{tablefootnote} package. @example \usepackage@{tablefootnote@} % in preamble ... \begin@{table@} \centering \begin@{tabular@}@{l|l@} \textsc@{Date@} &\textsc@{Campaign@} \\ \hline 1862 &Fort Donelson \\ 1863 &Vicksburg \\ 1865 &Army of Northern Virginia\tablefootnote@{% Ending the war.@} \end@{tabular@} \caption@{Forces captured by US Grant@} \end@{table@} @end example @noindent The footnote appears at the page bottom and is numbered in sequence with other footnotes. @node Footnotes of footnotes @section Footnotes of footnotes @cindex footnote, of a footnote @PkgIndex{bigfoot} Particularly in the humanities, authors can have multiple classes of footnotes, including having footnotes of footnotes. The package @package{bigfoot} extends @LaTeX{}'s default footnote mechanism in many ways, including allow these two, as in this example. @example \usepackage@{bigfoot@} % in preamble \DeclareNewFootnote@{Default@} \DeclareNewFootnote@{from@}[alph] % create class \footnotefrom@{@} ... The third theorem is a partial converse of the second.\footnotefrom@{% Noted in Wilson.\footnote@{Second edition only.@}@} @end example @node Definitions @chapter Definitions @cindex definitions @LaTeX{} has support for making new commands of many different kinds. @menu * \newcommand & \renewcommand:: (Re)define a new command. * \providecommand:: Define a new command, if name not used. * \makeatletter & \makeatother:: Change the status of the at-sign character. * \@@ifstar:: Define your own commands with *-variants. * \newcounter:: Define a new counter. * \newlength:: Define a new length. * \newsavebox:: Define a new box. * \newenvironment & \renewenvironment:: Define a new environment. * \newtheorem:: Define a new theorem-like environment. * \newfont:: Define a new font name. * \protect:: Using tricky commands. * \ignorespaces & \ignorespacesafterend:: Discard extra spaces. * xspace package:: Space after a macro, conditionally. @end menu @node \newcommand & \renewcommand @section @code{\newcommand} & @code{\renewcommand} @findex \newcommand @cindex commands, defining new ones @cindex commands, redefining @cindex defining a new command @cindex new commands, defining Synopses, one of: @example \newcommand@{\@var{cmd}@}@{@var{defn}@} \newcommand@{\@var{cmd}@}[@var{nargs}]@{@var{defn}@} \newcommand@{\@var{cmd}@}[@var{nargs}][@var{optargdefault}]@{@var{defn}@} \newcommand*@{\@var{cmd}@}@{@var{defn}@} \newcommand*@{\@var{cmd}@}[@var{nargs}]@{@var{defn}@} \newcommand*@{\@var{cmd}@}[@var{nargs}][@var{optargdefault}]@{@var{defn}@} @end example @noindent or one of these. @example \renewcommand@{\@var{cmd}@}[@var{nargs}]@{@var{defn}@} \renewcommand@{\@var{cmd}@}[@var{nargs}]@{@var{defn}@} \renewcommand@{\@var{cmd}@}[@var{nargs}][@var{optargdefault}]@{@var{defn}@} \renewcommand*@{\@var{cmd}@}@{@var{defn}@} \renewcommand*@{\@var{cmd}@}[@var{nargs}]@{@var{defn}@} \renewcommand*@{\@var{cmd}@}[@var{nargs}][@var{optargdefault}]@{@var{defn}@} @end example Define or redefine a command (see also the discussion of @code{\DeclareRobustCommand} in @ref{Class and package commands}). @cindex starred form, defining new commands @cindex *-form, defining new commands @findex \long The starred form of these two forbids the arguments from containing multiple paragraphs of text (in plain @TeX{} terms, the commands are not @code{\long}). With the default form, arguments can be multiple paragraphs. These are the parameters: @table @var @item cmd Required; @code{\@var{cmd}} is the command name. It must begin with a backslash, @code{\}, and must not begin with the four character string @code{\end}. For @code{\newcommand}, it must not be already defined. For @code{\renewcommand}, this name must already be defined. @item nargs Optional; an integer from 0 to 9, specifying the number of arguments that the command takes, including any optional argument. Omitting this argument is the same as specifying 0, meaning that the command has no arguments. If you redefine a command, the new version can have a different number of arguments than the old version. @item optargdefault Optional; if this argument is present then the first argument of @code{\@var{cmd}} is optional, with default value @var{optargdefault} (which may be the empty string). If @var{optargsdefault} is not present then @code{\@var{cmd}} does not take an optional argument. @cindex positional parameter That is, if @code{\@var{cmd}} is used with square brackets, as in @code{\@var{cmd}[@var{optval}]@{...@}...}, then within @var{defn} the parameter@tie{}@code{#1} is set to the value of @var{optval}. On the other hand, if @code{\@var{cmd}} is called without the square brackets then within @var{defn} the parameter @code{#1} is set to the value of @var{optargdefault}. In either case, the required arguments start with @code{#2}. Omitting @code{[@var{optargdefault}]} is different from having the square brackets with no contents, as in @code{[]}. The former sets @code{#1} to the value of @var{optargdefault}; the latter sets @code{#1} to the empty string. @item defn Required; the text to be substituted for every occurrence of @code{\@var{cmd}}. The parameters @code{#1}, @code{#2}, ... @code{#@var{nargs}} are replaced by the values that you supply when you call the command (or by the default value if there is an optional argument and you don't exercise the option). @end table @TeX{} ignores blanks in the source following a control word (@pxref{Control sequences}), as in @samp{\cmd }. If you actually want a space there, one solution is to type @code{@{@}} after the command (@samp{\cmd@{@} }, and another solution is to use an explicit control space (@samp{\cmd\ }). A simple example of defining a new command: @code{\newcommand@{\RS@}@{Robin Smith@}} results in @code{\RS} being replaced by the longer text. Redefining an existing command is similar: @code{\renewcommand@{\qedsymbol@}@{@{\small QED@}@}}. If you try to define a command and the name has already been used then you get something like @samp{LaTeX Error: Command \fred already defined. Or name \end... illegal, see p.192 of the manual}. If you try to redefine a command and the name has not yet been used then you get something like @samp{LaTeX Error: \hank undefined}. Here the first definition creates a command with no arguments, and the second, one with one required argument. @example \newcommand@{\student@}@{Ms~O'Leary@} \newcommand@{\defref@}[1]@{Definition~\ref@{#1@}@} @end example @noindent Use the first as in @code{I highly recommend \student@{@} to you}. The second has a variable argument, so that @code{\defref@{def:basis@}} expands to @code{Definition~\ref@{def:basis@}}, which ultimately expands to something like @samp{Definition~3.14}. Similarly, but with two required arguments: @code{\newcommand@{\nbym@}[2]@{$#1 \times #2$@}} is invoked as @code{\nbym@{2@}@{k@}}. This example has an optional argument. @example \newcommand@{\salutation@}[1][Sir or Madam]@{Dear #1:@} @end example @noindent Then @code{\salutation} gives @samp{Dear Sir or Madam:} while @code{\salutation[John]} gives @samp{Dear John:}. And @code{\salutation[]} gives @samp{Dear :}. This example has an optional argument and two required arguments. @example \newcommand@{\lawyers@}[3][company]@{#2, #3, and~#1@} I employ \lawyers[Howe]@{Dewey@}@{Cheatem@}. @end example @noindent The output is @samp{I employ Dewey, Cheatem, and Howe}. The optional argument, the @code{Howe}, is associated with @code{#1}, while @code{Dewey} and @code{Cheatem} are associated with @code{#2} and@tie{}@code{#3}. Because of the optional argument, @code{\lawyers@{Dewey@}@{Cheatem@}} will give the output @samp{I employ Dewey, Cheatem, and company}. The braces around @var{defn} do not define a group, that is, they do not delimit the scope of the result of expanding @var{defn}. For example, with @code{\newcommand@{\shipname@}[1]@{\it #1@}}, in this sentence, @example The \shipname@{Monitor@} met the \shipname@{Merrimac@}. @end example @noindent the words @samp{met the} would incorrectly be in italics. The solution is to put another pair of braces inside the definition: @code{\newcommand@{\shipname@}[1]@{@{\it #1@}@}}. @menu * Control sequences:: Control sequence, control word and control symbol. @end menu @node Control sequences @subsection Control sequence, control word and control symbol When reading input @TeX{} converts the sequences of read characters into a sequence of @dfn{tokens}. When @TeX{} sees a backslash @code{\}, it will handle the following characters in a special way in order to make a @dfn{control sequence} token. The control sequences fall into two categories: @itemize @item @dfn{control word}, when the control sequence is gathered from a @code{\} followed by at least one ASCII letter, followed by at least one blank. The sequence of at least one ASCII letter is called the @dfn{control sequence name}. @item @dfn{control symbol}, when the control sequence is gathered from a @code{\} followed by one non-letter character. @end itemize Blanks after a control word are ignored and do not produce any whitespace in the output (@pxref{\newcommand & \renewcommand} and @ref{\(SPACE)}). Just as the @code{\relax} command does nothing, the following will print @samp{Hello!}@inlinefmt{tex,---where we used visible spaces @samp{@visiblespace{}} instead of blanks,}@inlinefmt{info,---if you use the Emacs info viewer@comma{} turn on the whitespace-mode minor mode to see the trailing spaces}: @example Hel\relax@visiblespace{}@visiblespace{}@visiblespace{} @visiblespace{}@visiblespace{}@visiblespace{}lo! @end example @noindent This is because blanks after @code{\relax}, including the newline are ignored, and blanks at the beginning of a line are also ignored (@pxref{Leading blanks}). @node \providecommand @section @code{\providecommand} @findex \providecommand @cindex commands, defining new ones @cindex defining a new command @cindex new commands, defining Synopses, one of: @example \providecommand@{\@var{cmd}@}@{@var{defn}@} \providecommand@{\@var{cmd}@}[@var{nargs}]@{@var{defn}@} \providecommand@{\@var{cmd}@}[@var{nargs}][@var{optargdefault}]@{@var{defn}@} \providecommand*@{\@var{cmd}@}@{@var{defn}@} \providecommand*@{\@var{cmd}@}[@var{nargs}]@{@var{defn}@} \providecommand*@{\@var{cmd}@}[@var{nargs}][@var{optargdefault}]@{@var{defn}@} @end example Defines a command, as long as no command of this name already exists. If no command of this name already exists then this has the same effect as @code{\newcommand}. If a command of this name already exists then this definition does nothing. This is particularly useful in a file that may be loaded more than once, such as a style file. @xref{\newcommand & \renewcommand}, for the description of the arguments. This example @example \providecommand@{\myaffiliation@}@{Saint Michael's College@} \providecommand@{\myaffiliation@}@{Lyc\'ee Henri IV@} From \myaffiliation. @end example @noindent outputs @samp{From Saint Michael's College}. Unlike @code{\newcommand}, the repeated use of @code{\providecommand} does not give an error. @node \makeatletter & \makeatother @section @code{\makeatletter} & @code{\makeatother} Synopsis: @example \makeatletter ... definition of commands with @@ in their name .. \makeatother @end example Use this pair when you redefine @LaTeX{} commands that are named with an at-sign character@tie{}@samp{@code{@@}}. The @code{\makeatletter} declaration makes the at-sign character have the category code of a letter, code@tie{}11. The @code{\makeatother} declaration sets the category code of the at-sign to code@tie{}12, its default value. As @TeX{} reads characters, it assigns each one a category code, or @cindex catcode @cindex character category code @cindex category code, character @dfn{catcode}. For instance, it assigns the backslash character@tie{}@samp{@code{\}} the catcode@tie{}0. Command names consist of a category@tie{}0 character, ordinarily backslash, followed by letters, category@tie{}11 characters (except that a command name can also consist of a category@tie{}0 character followed by a single non-letter symbol). @LaTeX{}'s source code has the convention that some commands use @code{@@} in their name. These commands are mainly intended for package or class writers. The convention prevents authors who are just using a package or class from accidentally replacing such a command with one of their own, because by default the at-sign has catcode@tie{}12. Use the pair @code{\makeatletter} and @code{\makeatother} inside a @file{.tex} file, typically in the preamble, when you are defining or redefining commands named with @code{@@}, by having them surround your definition. Don't use these inside @file{.sty} or @file{.cls} files since the @code{\usepackage} and @code{\documentclass} commands already arrange that the at-sign has the character code of a letter, catcode@tie{}11. @PkgIndex{macros2e} For a comprehensive list of macros with an at-sign in their names see @url{https://ctan.org/pkg/macros2e}. In this example the class file has a command @code{\thesis@@universityname} that the user wants to change. These three lines should go in the preamble, before the @code{\begin@{document@}}. @example \makeatletter \renewcommand@{\thesis@@universityname@}@{Saint Michael's College@} \makeatother @end example @node \@@ifstar @section @code{\@@ifstar} @findex \@@ifstar @cindex commands, star-variants @cindex star-variants, commands Synopsis: @example \newcommand@{\mycmd@}@{\@@ifstar@{\mycmd@@star@}@{\mycmd@@nostar@}@} \newcommand@{\mycmd@@nostar@}[@var{nostar-num-args}]@{@var{nostar-body}@} \newcommand@{\mycmd@@star@}[@var{star-num-args}]@{@var{star-body}@} @end example Many standard @LaTeX{} environments or commands have a variant with the same name but ending with a star character@tie{}@code{*}, an asterisk. Examples are the @code{table} and @code{table*} environments and the @code{\section} and @code{\section*} commands. When defining environments, following this pattern is straightforward because @code{\newenvironment} and @code{\renewenvironment} allow the environment name to contain a star. So you just have to write @code{\newenvironment@{@var{myenv}@}} or @code{\newenvironment@{@var{myenv}*@}} and continue the definition as usual. For commands the situation is more complex as the star not being a letter cannot be part of the command name. As in the synopsis above, there will be a user-called command, given above as @code{\mycmd}, which peeks ahead to see if it is followed by a star. For instance, @LaTeX{} does not really have a @code{\section*} command; instead, the @code{\section} command peeks ahead. This command does not accept arguments but instead expands to one of two commands that do accept arguments. In the synopsis these two are @code{\mycmd@@nostar} and @code{\mycmd@@star}. They could take the same number of arguments or a different number, or no arguments at all. As always, in a @LaTeX{} document a command using an at-sign@tie{}@code{@@} in its name must be enclosed inside a @code{\makeatletter ... \makeatother} block (@pxref{\makeatletter & \makeatother}). This example of @code{\@@ifstar} defines the command @code{\ciel} and a variant @code{\ciel*}. Both have one required argument. A call to @code{\ciel@{blue@}} will return "not starry blue sky" while @code{\ciel*@{night@}} will return "starry night sky". @example \makeatletter \newcommand*@{\ciel@@unstarred@}[1]@{not starry #1 sky@} \newcommand*@{\ciel@@starred@}[1]@{starry #1 sky@} \newcommand*@{\ciel@}@{\@@ifstar@{\ciel@@starred@}@{\ciel@@unstarred@}@} \makeatother @end example In the next example, the starred variant takes a different number of arguments than the unstarred one. With this definition, Agent 007's @code{``My name is \agentsecret*@{Bond@}, \agentsecret@{James@}@{Bond@}.''} is equivalent to entering the commands @code{``My name is \textsc@{Bond@}, \textit@{James@} textsc@{Bond@}.''} @example \newcommand*@{\agentsecret@@unstarred@}[2]@{\textit@{#1@} \textsc@{#2@}@} \newcommand*@{\agentsecret@@starred@}[1]@{\textsc@{#1@}@} \newcommand*@{\agentsecret@}@{% \@@ifstar@{\agentsecret@@starred@}@{\agentsecret@@unstarred@}@} @end example After a command name, a star is handled similarly to an optional argument. (This differs from environment names in which the star is part of the name itself and as such could be in any position.) Thus, it is technically possible to put any number of spaces between the command and the star. Thus @code{\agentsecret*@{Bond@}} and @code{\agentsecret@w{ *}@{Bond@}} are equivalent. However, the standard practice is not to insert any such spaces. @PkgIndex{suffix} @PkgIndex{xparse} There are two alternative ways to accomplish the work of @code{\@@ifstar}. (1)@tie{}The @package{suffix} package allows the construct @code{\newcommand\mycommand@{@var{unstarred-variant}@}} followed by @code{\WithSuffix\newcommand\mycommand*@{@var{starred-variant}@}}. (2)@tie{}@LaTeX{} provides the @package{xparse} package, which allows this code: @example \NewDocumentCommand\foo@{s@}@{\IfBooleanTF#1 @{@var{starred-variant}@}% @{@var{unstarred-variant}@}% @} @end example @node \newcounter @section @code{\newcounter}: Allocating a counter @findex \newcounter @cindex counters, defining new Synopsis, one of: @example \newcounter@{@var{countername}@} \newcounter@{@var{countername}@}[@var{supercounter}] @end example Globally defines a new counter named @var{countername} and initialize it to zero (@pxref{Counters}). The name @var{countername} must consist of letters only. It does not begin with a backslash. This name must not already be in use by another counter. When you use the optional argument @code{[@var{supercounter}]} then the counter @var{countername} will be reset to zero whenever @var{supercounter} is incremented. For example, ordinarily @code{subsection} is numbered within @code{section} so that any time you increment @var{section}, either with @code{\stepcounter} (@pxref{\stepcounter}) or @code{\refstepcounter} (@pxref{\refstepcounter}), then @LaTeX{} will reset @var{subsection} to zero. This example @example \newcounter@{asuper@} \setcounter@{asuper@}@{1@} \newcounter@{asub@}[asuper] \setcounter@{asub@}@{3@} % Note `asuper' The value of asuper is \arabic@{asuper@} and of asub is \arabic@{asub@}. \stepcounter@{asuper@} Now asuper is \arabic@{asuper@} while asub is \arabic@{asub@}. @end example produces @samp{The value of asuper is 1 and that of asub is 3} and @samp{Now asuper is 2 while asub is 0}. If the counter already exists, for instance by entering @code{asuper} twice, then you get something like @samp{LaTeX Error: Command \c@@asuper already defined. Or name \end... illegal, see p.192 of the manual.}. If you use the optional argument then the super counter must already exist. Entering @code{\newcounter@{jh@}[lh]} when @code{lh} is not a defined counter will get you @samp{LaTeX Error: No counter 'lh' defined.} @node \newlength @section @code{\newlength} @findex \newlength @cindex lengths, allocating new @cindex rubber lengths, defining new @cindex skip register, plain @TeX{} @cindex glue register, plain @TeX{} Synopsis: @example \newlength@{\@var{len}@} @end example Allocate a new length register (@pxref{Lengths}). The required argument @code{\@var{len}} has to be a control sequence (@pxref{Control sequences}), and as such must begin with a backslash, @code{\} under normal circumstances. The new register holds rubber lengths such as @code{72.27pt} or @code{1in plus.2in minus.1in} (a @LaTeX{} length register is what plain @TeX{} calls a @code{skip} register). The initial value is zero. The control sequence @code{\@var{len}} must not be already defined. An example: @example \newlength@{\graphichgt@} @end example If you forget the backslash then you get @samp{Missing control sequence inserted}. If the control sequence already exists then you get something like @samp{LaTeX Error: Command \graphichgt already defined. Or name \end... illegal, see p.192 of the manual}. @node \newsavebox @section @code{\newsavebox} @findex \newsavebox @cindex box, allocating new Synopsis: @example \newsavebox@{\@var{cmd}@} @end example Define \@var{cmd}, the string consisting of a backslash followed by @var{cmd}, to refer to a new bin for storing material. These bins hold material that has been typeset, to use multiple times or to measure or manipulate (@pxref{Boxes}). The bin name \@var{cmd} is required, must start with a backslash, \, and must not already be a defined command. This command is fragile (@pxref{\protect}). This allocates a bin and then puts typeset material into it. @example \newsavebox@{\logobox@} \savebox@{\logobox@}@{LoGo@} Our logo is \usebox@{\logobox@}. @end example @noindent The output is @samp{Our logo is LoGo}. If there is an already defined bin then you get something like @samp{LaTeX Error: Command \logobox already defined. Or name \end... illegal, see p.192 of the manual}. The allocation of a box is global. @node \newenvironment & \renewenvironment @section @code{\newenvironment} & @code{\renewenvironment} @findex \newenvironment @findex \renewenvironment @cindex environments, defining @cindex defining new environments @cindex redefining environments Synopses, one of: @example \newenvironment@{@var{env}@}@{@var{begdef}@}@{@var{enddef}@} \newenvironment@{@var{env}@}[@var{nargs}]@{@var{begdef}@}@{@var{enddef}@} \newenvironment@{@var{env}@}[@var{nargs}][@var{optargdefault}]@{@var{begdef}@}@{@var{enddef}@} \newenvironment*@{@var{env}@}@{@var{begdef}@}@{@var{enddef}@} \newenvironment*@{@var{env}@}[@var{nargs}]@{@var{begdef}@}@{@var{enddef}@} \newenvironment*@{@var{env}@}[@var{nargs}][@var{optargdefault}]@{@var{begdef}@}@{@var{enddef}@} @end example @noindent or one of these. @example \renewenvironment@{@var{env}@}@{@var{begdef}@}@{@var{enddef}@} \renewenvironment@{@var{env}@}[@var{nargs}]@{@var{begdef}@}@{@var{enddef}@} \renewenvironment@{@var{env}@}[@var{nargs}][@var{optargdefault}]@{@var{begdef}@}@{@var{enddef}@} \renewenvironment*@{@var{env}@}@{@var{begdef}@}@{@var{enddef}@} \renewenvironment*@{@var{env}@}[@var{nargs}]@{@var{begdef}@}@{@var{enddef}@} \renewenvironment*@{@var{env}@}[@var{nargs}][@var{optargdefault}]@{@var{begdef}@}@{@var{enddef}@} @end example Define or redefine the environment @var{env}, that is, create the construct @code{\begin@{@var{env}@} ... @var{body} ... \end@{@var{env}@}}. @cindex @code{*}-form of environment commands The starred form of these commands requires that the arguments not contain multiple paragraphs of text. However, the body of these environments can contain multiple paragraphs. @table @var @item env Required; the environment name. It consists only of letters or the @code{*} character, and thus does not begin with backslash, @code{\}. It must not begin with the string @code{end}. For @code{\newenvironment}, the name @var{env} must not be the name of an already existing environment, and also the command @code{\@var{env}} must be undefined. For @code{\renewenvironment}, @var{env} must be the name of an existing environment. @item nargs Optional; an integer from 0 to 9 denoting the number of arguments of that the environment takes. When you use the environment these arguments appear after the @code{\begin}, as in @code{\begin@{@var{env}@}@{@var{arg1}@} ... @{@var{argn}@}}. Omitting this is equivalent to setting it to 0; the environment will have no arguments. When redefining an environment, the new version can have a different number of arguments than the old version. @item optargdefault Optional; if this is present then the first argument of the defined environment is optional, with default value @var{optargdefault} (which may be the empty string). If this is not in the definition then the environment does not take an optional argument. That is, when @var{optargdefault} is present in the definition of the environment then you can start the environment with square brackets, as in @code{\begin@{@var{env}@}[@var{optval}]@{...@} ... \end@{@var{env}@}}. In this case, within @var{begdefn} the parameter @code{#1} is set to the value of @var{optval}. If you call @code{\begin@{@var{env}@}} without square brackets, then within @var{begdefn} the parameter @code{#1} is set to the value of the default @var{optargdefault}. In either case, any required arguments start with @code{#2}. Omitting @code{[@var{myval}]} in the call is different than having the square brackets with no contents, as in @code{[]}. The former results in @code{#1} expanding to @var{optargdefault}; the latter results in @code{#1} expanding to the empty string. @item begdef Required; the text expanded at every occurrence of @code{\begin@{@var{env}@}}. Within @var{begdef}, the parameters @code{#1}, @code{#2}, ... @code{#@var{nargs}}, are replaced by the values that you supply when you call the environment; see the examples below. @item enddef Required; the text expanded at every occurrence of @code{\end@{@var{env}@}}. This may not contain any parameters, that is, you cannot use @code{#1}, @code{#2}, etc., here (but see the final example below). @end table All environments, that is to say the @var{begdef} code, the environment body, and the @var{enddef} code, are processed within a group. Thus, in the first example below, the effect of the @code{\small} is limited to the quote and does not extend to material following the environment. If you try to define an environment and the name has already been used then you get something like @samp{LaTeX Error: Command \fred already defined. Or name \end... illegal, see p.192 of the manual}. If you try to redefine an environment and the name has not yet been used then you get something like @samp{LaTeX Error: Environment hank undefined.}. This example gives an environment like @LaTeX{}'s @code{quotation} except that it will be set in smaller type. @example \newenvironment@{smallquote@}@{% \small\begin@{quotation@} @}@{% \end@{quotation@} @} @end example This has an argument, which is set in boldface at the start of a paragraph. @example \newenvironment@{point@}[1]@{% \noindent\textbf@{#1@} @}@{% @} @end example This one shows the use of a optional argument; it gives a quotation environment that cites the author. @example \newenvironment@{citequote@}[1][Shakespeare]@{% \begin@{quotation@} \noindent\textit@{#1@}: @}@{% \end@{quotation@} @} @end example @noindent The author's name is optional, and defaults to @samp{Shakespeare}. In the document, use the environment like this. @example \begin@{citequote@}[Lincoln] ... \end@{citequote@} @end example The final example shows how to save the value of an argument to use in @var{enddef}, in this case in a box (@pxref{\sbox & \savebox}). @example \newsavebox@{\quoteauthor@} \newenvironment@{citequote@}[1][Shakespeare]@{% \sbox\quoteauthor@{#1@}% \begin@{quotation@} @}@{% \hspace@{1em plus 1fill@}---\usebox@{\quoteauthor@} \end@{quotation@} @} @end example @node \newtheorem @section @code{\newtheorem} @findex \newtheorem @cindex theorems, defining @cindex defining new theorems @cindex theorem-like environment @cindex environment, theorem-like Synopses: @example \newtheorem@{@var{name}@}@{@var{title}@} \newtheorem@{@var{name}@}@{@var{title}@}[@var{numbered_within}] \newtheorem@{@var{name}@}[@var{numbered_like}]@{@var{title}@} @end example Define a new theorem-like environment. You can specify one of @var{numbered_within} and @var{numbered_like}, or neither, but not both. The first form, @code{\newtheorem@{@var{name}@}@{@var{title}@}}, creates an environment that will be labelled with @var{title}; see the first example below. The second form, @code{\newtheorem@{@var{name}@}@{@var{title}@}[@var{numbered_within}]}, creates an environment whose counter is subordinate to the existing counter @var{numbered_within}, so this counter will be reset when @var{numbered_within} is reset. See the second example below. The third form @code{\newtheorem@{@var{name}@}[@var{numbered_like}]@{@var{title}@}}, with optional argument between the two required arguments, creates an environment whose counter will share the previously defined counter @var{numbered_like}. See the third example. This command creates a counter named @var{name}. In addition, unless the optional argument @var{numbered_like} is used, inside of the theorem-like environment the current @code{\ref} value will be that of @code{\the@var{numbered_within}} (@pxref{\ref}). This declaration is global. It is fragile (@pxref{\protect}). Arguments: @table @var @item name The name of the environment. It is a string of letters. It must not begin with a backslash, @code{\}. It must not be the name of an existing environment, and the command name @code{\@var{name}} must not already be defined. @item title The text to be printed at the beginning of the environment, before the number. For example, @samp{Theorem}. @item numbered_within Optional; the name of an already defined counter, usually a sectional unit such as @code{chapter} or @code{section}. When the @var{numbered_within} counter is reset then the @var{name} environment's counter will also be reset. If this optional argument is not used then the command @code{\the@var{name}} is set to @code{\arabic@{@var{name}@}}. @item numbered_like Optional; the name of an already defined theorem-like environment. The new environment will be numbered in sequence with @var{numbered_like}. @end table Without any optional arguments the environments are numbered sequentially. The example below has a declaration in the preamble that results in @samp{Definition@tie{}1} and @samp{Definition@tie{}2} in the output. @example \newtheorem@{defn@}@{Definition@} \begin@{document@} \section@{...@} \begin@{defn@} First def \end@{defn@} \section@{...@} \begin@{defn@} Second def \end@{defn@} @end example This example has the same document body as the prior one. But here @code{\newtheorem}'s optional argument @var{numbered_within} is given as @code{section}, so the output is like @samp{Definition@tie{}1.1} and @samp{Definition@tie{}2.1}. @example \newtheorem@{defn@}@{Definition@}[section] \begin@{document@} \section@{...@} \begin@{defn@} First def \end@{defn@} \section@{...@} \begin@{defn@} Second def \end@{defn@} @end example In the next example there are two declarations in the preamble, the second of which calls for the new @code{thm} environment to use the same counter as @code{defn}. It gives @samp{Definition@tie{}1.1}, followed by @samp{Theorem@tie{}2.1} and @samp{Definition@tie{}2.2}. @example \newtheorem@{defn@}@{Definition@}[section] \newtheorem@{thm@}[defn]@{Theorem@} \begin@{document@} \section@{...@} \begin@{defn@} First def \end@{defn@} \section@{...@} \begin@{thm@} First thm \end@{thm@} \begin@{defn@} Second def \end@{defn@} @end example @node \newfont @section @code{\newfont} @findex \newfont @cindex fonts, new commands for @cindex defining new fonts @c @findex .fd @r{file} This command is obsolete. This description is here only to help with old documents. New documents should define fonts in families through the New Font Selection Scheme which allows you to, for example, associate a boldface with a roman (@pxref{Fonts}). @c This is done either by using @c @file{.fd} files or through the use of an engine that can access system @c fonts such as Xe@LaTeX{} (@pxref{@TeX{} engines}). Synopsis: @example \newfont@{\@var{cmd}@}@{@var{font description}@} @end example Define a command @code{\@var{cmd}} that will change the current font. The control sequence must not already be defined. It must begin with a backslash, @code{\}. @cindex at clause, in font definitions @cindex design size, in font definitions The @var{font description} consists of a @var{fontname} and an optional @dfn{at clause}. @LaTeX{} will look on your system for a file named @file{@var{fontname}.tfm}. The at clause can have the form either @code{at @var{dimen}} or @code{scaled @var{factor}}, where a @var{factor} of @samp{1000} means no scaling. For @LaTeX{}'s purposes, all this does is scale all the character and other font dimensions relative to the font's design size, which is a value defined in the @file{.tfm} file. This defines two equivalent fonts and typesets a few characters in each. @example \newfont@{\testfontat@}@{cmb10 at 11pt@} \newfont@{\testfontscaled@}@{cmb10 scaled 1100@} \testfontat abc \testfontscaled abc @end example @node \protect @section @code{\protect} @findex \protect @cindex fragile commands @cindex robust commands All @LaTeX{} commands are either @dfn{fragile} or @dfn{robust}. A fragile command can break when it is used in the argument to certain other commands. Commands that contain data that @LaTeX{} writes to an auxiliary file and re-reads later are fragile. This includes material that goes into a table of contents, list of figures, list of tables, etc. Fragile commands also include line breaks, any command that has an optional argument, and many more. To prevent such commands from breaking, one solution is to preceded them with the command @code{\protect}. For example, when @LaTeX{} runs the @code{\section@{@var{section name}@}} command it writes the @var{section name} text to the @file{.aux} auxiliary file, moving it there for use elsewhere in the document such as in the table of contents. Any argument that is internally expanded by @LaTeX{} without typesetting it directly is referred to as a @cindex moving arguments @dfn{moving argument}. A command is fragile if it can expand during this process into invalid @TeX{} code. Some examples of moving arguments are those that appear in the @code{\caption@{...@}} command (@pxref{figure}), in the @code{\thanks@{...@}} command (@pxref{\maketitle}), and in @@-expressions in the @code{tabular} and @code{array} environments (@pxref{tabular}). If you get strange errors from commands used in moving arguments, try preceding it with @code{\protect}. Every fragile commands must be protected with their own @code{\protect}. Although usually a @code{\protect} command doesn't hurt, length commands are robust and should not be preceded by a @code{\protect} command. Nor can a @code{\protect} command be used in the argument to @code{\addtocounter} or @code{\setcounter} command. In this example the @code{\caption} command gives a mysterious error about an extra curly brace. Fix the problem by preceding each @code{\raisebox} command with @code{\protect}. @example \begin@{figure@} ... \caption@{Company headquarters of A\raisebox@{1pt@}@{B@}\raisebox@{-1pt@}@{C@}@} \end@{figure@} @end example In the next example the @code{\tableofcontents} command gives an error because the @code{\(..\)} in the section title expands to illegal @TeX{} in the @file{.toc} file. You can solve this by changing @code{\(..\)} to @code{\protect\(..\protect\)}. @example \begin@{document@} \tableofcontents ... \section@{Einstein's \( e=mc^2 \)@} ... @end example @node \ignorespaces & \ignorespacesafterend @section @code{\ignorespaces & \ignorespacesafterend} @findex \ignorespaces @findex \ignorespacesafterend @cindex spaces, ignore around commands @cindex commands, ignore spaces Synopsis: @example \ignorespaces @end example @noindent or @example \ignorespacesafterend @end example Both commands cause @LaTeX{} to ignore blanks (that is, characters of catcode@tie{}10 such as space or tabulation) after the end of the command up to the first box or non-blank character. The first is a command from plain @TeX{}, and the second is @LaTeX{}-specific. The @code{\ignorespaces} is often used when defining commands via @code{\newcommand}, or @code{\newenvironment}, or @code{\def}. The example below illustrates. It allows a user to show the points values for quiz questions in the margin but it is inconvenient because, as shown in the @code{enumerate} list, users must not put any space between the command and the question text. @example \newcommand@{\points@}[1]@{\makebox[0pt]@{\makebox[10em][l]@{#1~pts@}@} \begin@{enumerate@} \item\points@{10@}no extra space output here \item\points@{15@} extra space between the number and the `extra' \end@{enumerate@} @end example @noindent The solution is to change to this. @example \newcommand@{\points@}[1]@{% \makebox[0pt]@{\makebox[10em][l]@{#1~pts@}@}\ignorespaces@} @end example A second example shows blanks being removed from the front of text. The commands below allow a user to uniformly attach a title to names. But, as given, if a title accidentally starts with a space then @code{\fullname} will reproduce that. @example \newcommand@{\honorific@}[1]@{\def\honorific@{#1@}@} % remember title \newcommand@{\fullname@}[1]@{\honorific~#1@} % put title before name \begin@{tabular@}@{|l|@} \honorific@{Mr/Ms@} \fullname@{Jones@} \\ % no extra space here \honorific@{ Mr/Ms@} \fullname@{Jones@} % extra space before title \end@{tabular@} @end example @noindent To fix this, change to @code{\newcommand@{\fullname@}[1]@{\ignorespaces\honorific~#1@}}. The @code{\ignorespaces} is also often used in a @code{\newenvironment} at the end of the @var{begin} clause, as in @code{\begin@{newenvironment@}@{@var{env name}@}@{... \ignorespaces@}@{...@}}. To strip blanks off the end of an environment use @code{\ignorespacesafterend}. An example is that this will show a much larger vertical space between the first and second environments than between the second and third. @example \newenvironment@{eq@}@{\begin@{equation@}@}@{\end@{equation@}@} \begin@{eq@} e=mc^2 \end@{eq@} \begin@{equation@} F=ma \end@{equation@} \begin@{equation@} E=IR \end@{equation@} @end example Putting a comment character@tie{}@code{%} immediately after the @code{\end@{eq@}} will make the vertical space disappear, but that is inconvenient. The solution is to change to @code{\newenvironment@{eq@}@{\begin@{equation@}@}@{\end@{equation@}\ignorespacesafterend@}}. @node xspace package @section xspace package @findex \xspace @PkgIndex{xspace} @cindex spaces, ignore around commands @cindex commands, ignore spaces Synopsis: @example \usepackage@{xspace@} ... \newcommand@{...@}@{...\xspace@} @end example The @code{\xspace} macro, when used at the end of a command definition, adds a space unless the command is followed by certain punctuation characters. After a command control sequence that is a control word (@pxref{Control sequences}, as opposed to control symbols such as @code{\$}), @TeX{} gobbles blank characters. Thus, in the first sentence below, the output has @samp{Vermont} placed snugly against the period, without any intervening space. @example \newcommand@{\VT@}@{Vermont@} Our college is in \VT . The \VT@{@} summers are nice. @end example But because of the gobbling, the second sentence needs the empty curly braces or else there would be no space separating @samp{Vermont} from @samp{summers}. (Many authors instead use a backslash-space @code{\ } for this. @xref{\(SPACE)}.) The @package{xspace} package provides @code{\xspace}. It is for writing commands which are designed to be used mainly in text. It must be place at the very end of the definition of these commands. It inserts a space after that command unless what immediately follows is in a list of exceptions. In this example, the empty braces are not needed. @example \newcommand@{\VT@}@{Vermont\xspace@} Our college is in \VT . \VT summers are nice. @end example The default exception list contains the characters @code{,.'/?;:!~-)}, the open curly brace and the backslash-space command discussed above, and the commands @code{\footnote} or @code{\footnotemark}. Add to that list as with @code{\xspaceaddexceptions@{\myfni \myfnii@}} which adds @code{\myfni} and@tie{}@code{\myfnii} to the list, and remove from that list as with @code{\xspaceremoveexception@{!@}}. @c David Carlisle https://tex.stackexchange.com/a/86620/339 A comment: many experts prefer not to use @code{\xspace}. Putting it in a definition means that the command will usually get the spacing right. But it isn't easy to predict when to enter empty braces because @code{\xspace} will get it wrong, such as when it is followed by another command, and so @code{\xspace} can make editing material harder and more error-prone than instead always inserting the empty braces. @node Counters @chapter Counters @cindex counters, a list of @cindex variables, a list of Everything @LaTeX{} numbers for you has a counter associated with it. The name of the counter is often the same as the name of the environment or command associated with the number, except that the counter's name has no backslash@tie{}@code{\}. Thus, associated with the @code{\chapter} command is the @code{chapter} counter that keeps track of the chapter number. Below is a list of the counters used in @LaTeX{}'s standard document classes to control numbering. @findex part counter @findex chapter counter @findex section counter @findex subsection counter @findex subsubsection counter @findex paragraph counter @findex subparagraph counter @findex page counter @findex equation counter @findex figure counter @findex table counter @findex footnote counter @findex mpfootnote counter @findex enumi counter @findex enumii counter @findex enumiii counter @findex enumiv counter @example part paragraph figure enumi chapter subparagraph table enumii section page footnote enumiii subsection equation mpfootnote enumiv subsubsection @end example The @code{mpfootnote} counter is used by the @code{\footnote} command inside of a minipage (@pxref{minipage}). The counters @code{enumi} through @code{enumiv} are used in the @code{enumerate} environment, for up to four levels of nesting (@pxref{enumerate}). Counters can have any integer value but they are typically positive. New counters are created with @code{\newcounter}. @xref{\newcounter}. @menu * \alph \Alph \arabic \roman \Roman \fnsymbol:: Print value of a counter. * \usecounter:: Use a specified counter in a list environment. * \value:: Use the value of a counter in an expression. * \setcounter:: Set the value of a counter. * \addtocounter:: Add a quantity to a counter. * \refstepcounter:: Add to a counter. * \stepcounter:: Add to a counter, resetting subsidiary counters. * \day & \month & \year:: Numeric date values. @end menu @node \alph \Alph \arabic \roman \Roman \fnsymbol @section @code{\alph \Alph \arabic \roman \Roman \fnsymbol}: Printing counters @cindex counters, printing Print the value of a counter, in a specified style. For instance, if the counter @var{counter} has the value 1 then a @code{\alph@{@var{counter}@}} in your source will result in a lowercase letter@tie{}a appearing in the output. All of these commands take a single counter as an argument, for instance, @code{\alph@{enumi@}}. Note that the counter name does not start with a backslash. @ftable @code @item \alph@{@var{counter}@} Print the value of @var{counter} in lowercase letters: `a', `b', @enddots{} If the counter's value is less than 1 or more than 26 then you get @samp{LaTeX Error: Counter too large.} @item \Alph@{@var{counter}@} Print in uppercase letters: `A', `B', @enddots{} If the counter's value is less than 1 or more than 26 then you get @samp{LaTeX Error: Counter too large.} @item \arabic@{@var{counter}@} Print in Arabic numbers such as @samp{5} or @samp{-2}. @item \roman@{@var{counter}@} Print in lowercase roman numerals: `i', `ii', @enddots{} If the counter's value is less than 1 then you get no warning or error but @LaTeX{} does not print anything in the output. @item \Roman@{@var{counter}@} Print in uppercase roman numerals: `I', `II', @enddots{} If the counter's value is less than 1 then you get no warning or error but @LaTeX{} does not print anything in the output. @item \fnsymbol@{@var{counter}@} Prints the value of @var{counter} using a sequence of nine symbols that are traditionally used for labeling footnotes. The value of @var{counter} should be between@tie{}1 and@tie{}9, inclusive. If the counter's value is less than 0 or more than 9 then you get @samp{LaTeX Error: Counter too large}, while if it is 0 then you get no error or warning but @LaTeX{} does not output anything. Here are the symbols: @multitable @columnfractions .11 .30 .30 .29 @headitem Number@tab Name@tab Command@tab Symbol @item 1@tab asterisk@tab@code{\ast}@tab@iftexthenelse{@math{\ast},*} @item 2@tab dagger@tab@code{\dagger}@tab@BES{2020,\dagger} @item 3@tab ddagger@tab@code{\ddagger}@tab@BES{2021,\ddagger} @item 4@tab section-sign@tab@code{\S}@tab@BES{00A7,\S} @item 5@tab paragraph-sign@tab@code{\P}@tab@BES{00B6,\P} @item 6@tab double-vert@tab@code{\parallel}@tab@BES{2016,\parallel} @item 7@tab double-asterisk@tab@code{\ast\ast}@tab@iftexthenelse{@math{\ast\ast},**} @item 8@tab double-dagger@tab@code{\dagger\dagger}@tab@BES{2020,\dagger}@BES{2020,\dagger} @item 9@tab double-ddagger@tab@code{\ddagger\ddagger}@tab@BES{2021,\ddagger}@BES{2021,\ddagger} @end multitable @end ftable @node \usecounter @section @code{\usecounter} @findex \usecounter @cindex list items, specifying counter @cindex numbered items, specifying counter Synopsis: @example \usecounter@{@var{counter}@} @end example Used in the second argument of the @code{list} environment (@pxref{list}), this declares that list items will be numbered by @var{counter}. It initializes @var{counter} to zero, and arranges that when @code{\item} is called without its optional argument then @var{counter} is incremented by @code{\refstepcounter}, making its value be the current @code{ref} value (@pxref{\ref}). This command is fragile (@pxref{\protect}). Put in the document preamble, this example makes a new list environment enumerated with @var{testcounter}: @example \newcounter@{testcounter@} \newenvironment@{test@}@{% \begin@{list@}@{@}@{% \usecounter@{testcounter@} @} @}@{% \end@{list@} @} @end example @node \value @section @code{\value} @findex \value @cindex counters, getting value of Synopsis: @example \value@{@var{counter}@} @end example Expands to the value of the counter @var{counter}. (Note that the name of a counter does not begin with a backslash.) This example outputs @samp{Test counter is@tie{}6. Other counter is@tie{}5.}. @example \newcounter@{test@} \setcounter@{test@}@{5@} \newcounter@{other@} \setcounter@{other@}@{\value@{test@}@} \addtocounter@{test@}@{1@} Test counter is \arabic@{test@}. Other counter is \arabic@{other@}. @end example The @code{\value} command is not used for typesetting the value of the counter. For that, see @ref{\alph \Alph \arabic \roman \Roman \fnsymbol}. It is often used in @code{\setcounter} or @code{\addtocounter} but @code{\value} can be used anywhere that @LaTeX{} expects a number, such as in @code{\hspace@{\value@{foo@}\parindent@}}. It must not be preceded by @code{\protect} (@pxref{\protect}). This example inserts @code{\hspace@{4\parindent@}}. @example \setcounter@{myctr@}@{3@} \addtocounter@{myctr@}@{1@} \hspace@{\value@{myctr@}\parindent@} @end example @node \setcounter @section @code{\setcounter} @findex \setcounter @cindex counters, setting @cindex setting counters Synopsis: @example \setcounter@{@var{counter}@}@{@var{value}@} @end example Globally set the counter @var{counter} to have the value of the @var{value} argument, which must be an integer. Thus, you can set a counter's value as @code{\setcounter@{section@}@{5@}}. Note that the counter name does not start with a backslash. In this example if the counter @code{theorem} has value 12 then the second line will print @samp{XII}. @example \setcounter@{exercise@}@{\value@{theorem@}@} Here it is in Roman: \Roman@{exercise@}. @end example @node \addtocounter @section @code{\addtocounter} @findex \addtocounter Synopsis: @example \addtocounter@{@var{counter}@}@{@var{value}@} @end example Globally increment @var{counter} by the amount specified by the @var{value} argument, which may be negative. In this example the section value appears as @samp{VII}. @example \setcounter@{section@}@{5@} \addtocounter@{section@}@{2@} Here it is in Roman: \Roman@{section@}. @end example @node \refstepcounter @section @code{\refstepcounter} @findex \refstepcounter Synopsis: @example \refstepcounter@{@var{counter}@} @end example Globally increments the value of @var{counter} by one, as does @code{\stepcounter} (@pxref{\stepcounter}). The difference is that this command resets the value of any counter numbered within it. (For the definition of ``counters numbered within'', @pxref{\newcounter}.) In addition, this command also defines the current @code{\ref} value to be the result of @code{\thecounter}. While the counter value is set globally, the @code{\ref} value is set locally, i.e., inside the current group. @node \stepcounter @section @code{\stepcounter} @findex \stepcounter Synopsis: @example \stepcounter@{@var{counter}@} @end example Globally adds one to @var{counter} and resets all counters numbered within it. (For the definition of ``counters numbered within'', @pxref{\newcounter}.) This command differs from @code{\refstepcounter} in that this one does not influence references; that is, it does not define the current @code{\ref} value to be the result of @code{\thecounter} (@pxref{\refstepcounter}). @node \day & \month & \year @section @code{\day} & @code{\month} & @code{\year} @findex \day @findex \month @findex \year @LaTeX{} defines the counter @code{\day} for the day of the month (nominally with value between 1 and 31), @code{\month} for the month of the year (nominally with value between 1 and 12), and @code{\year} for the year. When @TeX{} starts up, they are set from the current values on the system. The related command @code{\today} produces a string representing the current day (@pxref{\today}). They counters are not updated as the job progresses so in principle they could be incorrect by the end. In addition, @TeX{} does no sanity check: @example \day=-2 \month=13 \year=-4 \today @end example @noindent gives no error or warning and results in the output @samp{-2, -4} (the bogus month value produces no output). @xref{Command line input}, to force the date to a given value from the command line. @node Lengths @chapter Lengths @cindex lengths, defining and using A @dfn{length} is a measure of distance. Many @LaTeX{} commands take a length as an argument. @cindex rigid lengths @cindex rubber lengths @cindex dimen @r{plain @TeX{}} @cindex skip @r{plain @TeX{}} @cindex glue @r{plain @TeX{}} Lengths come in two types. A @dfn{rigid length} such as @code{10pt} does not contain a @code{plus} or @code{minus} component. (Plain @TeX{} calls this a @dfn{dimen}.) A @dfn{rubber length} (what plain @TeX{} calls a @dfn{skip} or @dfn{glue}) such as with @code{1cm plus0.05cm minus0.01cm} can contain either or both of those components. In that rubber length, the @code{1cm} is the @dfn{natural length} while the other two, the @code{plus} and @code{minus} components, allow @TeX{} to stretch or shrink the length to optimize placement. The illustrations below use these two commands. @example % make a black bar 10pt tall and #1 wide \newcommand@{\blackbar@}[1]@{\rule@{#1@}@{10pt@}@} % Make a box around #2 that is #1 wide (excluding the border) \newcommand@{\showhbox@}[2]@{% \fboxsep=0pt\fbox@{\hbox to #1@{#2@}@}@} @end example @noindent This example uses those commands to show a black bar 100@tie{}points long between @samp{XXX} and @samp{YYY}. This length is rigid. @example XXX\showhbox@{100pt@}@{\blackbar@{100pt@}@}YYY @end example As for rubber lengths, shrinking is simpler one: with @code{1cm minus 0.05cm}, the natural length is 1@dmn{cm} but @TeX{} can shrink it down as far as 0.95@dmn{cm}. Beyond that, @TeX{} refuses to shrink any more. Thus, below the first one works fine, producing a space of 98@tie{}points between the two bars. @example XXX\showhbox@{300pt@}@{% \blackbar@{101pt@}\hspace@{100pt minus 2pt@}\blackbar@{101pt@}@}YYY XXX\showhbox@{300pt@}@{% \blackbar@{105pt@}\hspace@{100pt minus 1pt@}\blackbar@{105pt@}@}YYY @end example @noindent But the second one gets a warning like @samp{Overfull \hbox (1.0pt too wide) detected at line 17}. In the output the first @samp{Y} is overwritten by the end of the black bar, because the box's material is wider than the 300@dmn{pt} allocated, as @TeX{} has refused to shrink the total to less than 309@tie{}points. Stretching is like shrinking except that if @TeX{} is asked to stretch beyond the given amount, it will do it. Here the first line is fine, producing a space of 110@tie{}points between the bars. @example XXX\showhbox@{300pt@}@{% \blackbar@{95pt@}\hspace@{100pt plus 10pt@}\blackbar@{95pt@}@}YYY XXX\showhbox@{300pt@}@{% \blackbar@{95pt@}\hspace@{100pt plus 1pt@}\blackbar@{95pt@}@}YYY @end example @noindent In the second line @TeX{} needs a stretch of 10@tie{}points and only 1@tie{}point was specified. @TeX{} stretches the space to the required length but it gives you a warning like @samp{Underfull \hbox (badness 10000) detected at line 22}. (We won't discuss badness.) You can put both stretch and shrink in the same length, as in @code{1ex plus 0.05ex minus 0.02ex}. If @TeX{} is setting two or more rubber lengths then it allocates the stretch or shrink in proportion. @example XXX\showhbox@{300pt@}@{% \blackbar@{100pt@}% left \hspace@{0pt plus 50pt@}\blackbar@{80pt@}\hspace@{0pt plus 10pt@}% middle \blackbar@{100pt@}@}YYY % right @end example @noindent The left and right bars take up 100@tie{}points, so the middle needs another 100. The middle bar is 80@tie{}points so the two @code{\hspace}'s must stretch 20@tie{}points. Because the two are @code{plus 50pt} and @code{plus 10pt}, @TeX{} gets 5/6 of the stretch from the first space and 1/6 from the second. The @code{plus} or @code{minus} component of a rubber length can contain a @dfn{fill} component, as in @code{1in plus2fill}. This gives the length infinite stretchability or shrinkability so that @TeX{} could set it to any distance. Here the two figures will be equal-spaced across the page. @example \begin@{minipage@}@{\linewidth@} \hspace@{0pt plus 1fill@}\includegraphics@{godel.png@}% \hspace@{0pt plus 1fill@}\includegraphics@{einstein.png@}% \hspace@{0pt plus 1fill@} \end@{minipage@} @end example @TeX{} has three levels of infinity for glue components: @code{fil}, @code{fill}, and @code{filll}. The later ones are more infinite than the earlier ones. Ordinarily document authors only use the middle one (@pxref{\hfill} and @pxref{\vfill}). Multiplying a rubber length by a number turns it into a rigid length, so that after @code{\setlength@{\ylength@}@{1in plus 0.2in@}} and @code{\setlength@{\zlength@}@{3\ylength@}} then the value of @code{\zlength} is @code{3in}. @menu * Units of length:: The units that @LaTeX{} knows. * \setlength:: Set the value of a length. * \addtolength:: Add a quantity to a length. * \settodepth:: Set a length to the depth of something. * \settoheight:: Set a length to the height of something. * \settowidth:: Set a length to the width of something. * \stretch:: Add infinite stretchability. * Expressions:: Compute with lengths and integers. @end menu @node Units of length @section Units of length @cindex units, of length @TeX{} and @LaTeX{} know about these units both inside and outside of math mode. @ftable @code @item pt @cindex point @anchor{units of length pt} Point, 1/72.27 inch. The (approximate) conversion to metric units is 1@dmn{point} = .35146@dmn{mm} = .035146@dmn{cm}. @item pc @cindex pica @anchor{units of length pc} Pica, 12 pt @item in @cindex inch @anchor{units of length in} Inch, 72.27 pt @item bp @cindex big point @cindex PostScript point @anchor{units of length bp} Big point, 1/72 inch. This length is the definition of a point in PostScript and many desktop publishing systems. @item mm @cindex millimeter @anchor{units of length mm} Millimeter, 2.845 pt @item cm @cindex centimeter @anchor{units of length cm} Centimeter, 10 mm @item dd @cindex didot point @anchor{units of length dd} Didot point, 1.07 pt @item cc @cindex cicero @anchor{units of length cc} Cicero, 12 dd @item sp @cindex scaled point @anchor{units of length sp} Scaled point, 1/65536 pt @end ftable Three other units are defined according to the current font, rather than being an absolute dimension. @ftable @code @item ex @cindex x-height @cindex ex @anchor{Lengths/ex} @anchor{units of length ex} The x-height of the current font @dfn{ex}, traditionally the height of the lowercase letter x, is often used for vertical lengths. @item em @cindex m-width @cindex em @anchor{Lengths/em} @anchor{units of length em} Similarly @dfn{em}, traditionally the width of the capital letter M, is often used for horizontal lengths. This is also often the size of the current font, e.g., a nominal 10@dmn{pt} font will have 1@dmn{em} = 10@dmn{pt}. @LaTeX{} has several commands to produce horizontal spaces based on the em (@pxref{\enspace & \quad & \qquad}). @item mu @cindex mu, math unit @anchor{units of length mu} Finally, in math mode, many definitions are expressed in terms of the math unit @dfn{mu}, defined by 1@dmn{em} = 18@dmn{mu}, where the em is taken from the current math symbols family. @xref{Spacing in math mode}. @end ftable Using these units can help make a definition work better across font changes. For example, a definition of the vertical space between list items given as @code{\setlength@{\itemsep@}@{1ex plus 0.05ex minus 0.01ex@}} is more likely to still be reasonable if the font is changed than a definition given in points. @node \setlength @section @code{\setlength} @findex \setlength @cindex lengths, setting Synopsis: @example \setlength@{\@var{len}@}@{@var{amount}@} @end example Set the length \@var{len} to @var{amount}. The length name @code{\@var{len}} has to be a control sequence (@pxref{Control sequences}), and as such must begin with a backslash, @code{\} under normal circumstances. The @var{amount} can be a rubber length (@pxref{Lengths}). It can be positive, negative or zero, and can be in any units that @LaTeX{} understands (@pxref{Units of length}). Below, with @LaTeX{}'s defaults the first paragraph will be indented while the second will not. @example I told the doctor I broke my leg in two places. \setlength@{\parindent@}@{0em@} He said stop going to those places. @end example If you did not declare \@var{len} with @code{\newlength}, for example if you mistype it as in @code{\newlength@{\specparindent@}\setlength@{\sepcparindent@}@{...@}}, then you get an error like @samp{Undefined control sequence.