Unofficial LaTeX reference manual.
\LaTeX
. Where use of the logo is not
sensible, such as in plain text, write it as LaTeX.
\documentclass{article} \begin{document} Hello, \LaTeX\ world. \end{document}
\begin{document}
line and an
\end{document}
line.
\documentclass
and the \begin{document}
commands.
This area is called the preamble.
\begin{document}
, \end{document}
pair defines an
.lof
file that is used to make a list of
figures, a .lot
file used to make a list of tables, and a
.toc
file used to make a table of contents (.fmt
) files.fmt
) files.fmt
file, which can
be read much more quickly than the corresponding &tex; source.
.xdv
file, a variant of DVI,
and translates that to PDF using the (x
)dvipdfmx
program, but this process is automatic. The .xdv
file is only
useful for debugging.
u
variant supports Unicode. See
-dev
command and format for
all of the above:
-dev
formats make it easy for anyone to help test
documents and code: you can run, say, pdflatex-dev
instead of
pdflatex
, without changing anything else in your environment.
Indeed, it is easiest and most helpful to always run the -dev
versions instead of bothering to switch back and forth. During quiet
times after a release, the commands will be equivalent.
dev
formats&textrdquo; by Frank Mittelbach, TUGboat 40:2,
\
. The name itself then consists of either
(a) a string of letters or (b) a single non-letter.
\pagebreak
differs from \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.
{...}
. Optional arguments are
contained in square brackets, [...]
. Generally, but not
universally, if the command accepts an optional argument, it comes
first, before any required arguments.
]
) hide it inside curly braces, as
in \item[closing bracket {]}]
. Similarly, if an optional
argument comes last, with no required argument after it, then to make
the first character of the following text be an open square bracket,
hide it inside curly braces.
*
form that
is related to the form without a *
, such as \chapter
and
\chapter*
. The exact difference in behavior varies from command
to command.
*
-forms for the
commands it covers (barring unintentional omissions, a.k.a.&noeos; bugs).
expl3
expl3
xparse
xparse
expl3
and
xparse
packages are part of the &latex;2e format. They
provide a completely different underlying programming language
syntax. We won&textrsquo;t try to cover them in this document; see the related
package documentation and other &latex; manuals.
\begin{environment-name} ... \end{environment-name}
\begin{verse}
and \end{verse}
.
\begin{verse} There once was a man from Nantucket \\ ... \end{verse}
document
environment,
a \begin{document} ... \end{document}
pair.
*
); both the \begin
and \end
texts must
include the star.
\begin{tabular}[t]{r|l} ... rows of table ... \end{tabular}
ctan.org
web site
offers features such as search by name or by functionality.
\documentclass[options]{class}
\documentclass
command by enclosing them in square brackets. To
specify more than one option, separate them with a comma.
\documentclass[option1,option2,...]{class}
slides
accept the following
options for selecting the typeface size (default is 10pt
):
10pt 11pt 12pt
geometry
geometry
letterpaper
set
the print area but you must also set the physical paper size. One way
to do that is to put \pdfpagewidth=\paperwidth
and
\pdfpageheight=\paperheight
in your document&textrsquo;s preamble.
geometry
geometry
geometry
package provides flexible ways of setting the print
area and physical page size.
slides
class.
slides
classslides
class offers the option clock
for printing
the time at the bottom of each note.
\usepackage[options]{pkg}.
\usepackage{pkg1,pkg2,...}
, or use multiple
\usepackage
commands.
\documentclass
command that are unknown
to the selected document class are passed on to the packages loaded with
\usepackage
.
smcmemo.cls
and begin your documents with
\documentclass{smcmemo}
.
Memo from the
SMC Math Department
is for a class.
&arobase;
as a
character in command names without having to surround the code
containing that command with \makeatletter
and
\makeatother
. smcmemo
might have commands
\smc&arobase;tolist
, \smc&arobase;fromlist
, etc.
\NeedsTeXFormat
and \ProvidesClass
or \ProvidesPackage
commands.
smcmemo
class might be called with an option to read in a file with a list of
people for the to-head, as \documentclass[mathto]{smcmemo}
, and
therefore needs to define a command
\newcommand{\setto}[1]{\def\&arobase;tolist{#1}}
used in that
file.
\documentclass[option list]{class
name}
, to modify the behavior of the class. An example is when you
declare \documentclass[11pt]{article}
to set the default
document font size.
\NeedsTeXFormat{LaTeX2e} \ProvidesClass{stub}[2017/07/06 stub to start building classes from] \DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}} \ProcessOptions\relax \LoadClass{article}
article
class, and then loads the
article
class to provide the basis for this class&textrsquo;s code.
\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
fontenc
package\usepackage[font_encoding]{fontenc}
\usepackage[font_encoding1, font_encoding2, ...]{fontenc}
fontspec
fontspec
pdflatex
engine
(fontspec
package.
\accent
(\usepackage[T1]{fontenc}
lmodern
lmodern
cm-super
cm-super
T1
and the characters appear
blurry or do not magnify well then your fonts may be bitmapped,
sometimes called raster or Type 3. You want vector fonts. Use a
package such as lmodern
or cm-super
to get a font that
extends &latex;&textrsquo;s default using vector fonts.
\encodingdefault
to be the last encoding in the option list.
OML
, T1
, OT1
, and
then OMS
, and set the default to OT1
.
T1
encoded fonts other than the default Computer
Modern family then you may need to load the package that selects your
fonts before loading T1
encoded fonts from the default.
\DeclareFontEncoding
\DeclareFontEncoding{encoding}{text-settings}{math-settings}
\LastDeclaredEncoding
(\DeclareFontEncoding{T1}{}{}
\selectfont
and \fontencoding
commands. The
math-settings are the commands that &latex; will use whenever the
font is accessed as a math alphabet.
\newcommand
may cause an error. In addition, such
files should contain \ProvidesFile
line (\...Default
commands only in a
package, not in the encoding definition files, since those files
should only contain declarations specific to that encoding.
\DeclareTextAccent
\DeclareTextAccent{cmd}{encoding}{slot}
\^A
, the system will put the accent in slot 2
over the A character, which is represented in ASCII as 65.
(This holds unless there is a relevant DeclareTextComposite
or
\DeclareTextCompositeCommand
declaration;
\DeclareTextAccent{\^}{T1}{2}
\DeclareTextAccent
does not give an error but it does log the redefinition in the
transcript file.
\DeclareTextAccentDefault
\DeclareTextAccentDefault{\cmd}{encoding}
\DeclareTextAccent
for that encoding then this
command will pick up the slack, by saying to use it as described for
encoding.
OT1
be the default encoding for
the accent \"
, declare this.
\DeclareTextAccentDefault{\"}{OT1}
\"
when the current encoding does not have a
definition for that accent then &latex; will use the definition from
OT1
\DeclareTextCommandDefault[1]{\cmd} {\UseTextAccent{encoding}{\cmd}{#1}}
\DeclareTextAccentDefault
works for any one-argument
\DeclareTextCommand
& \ProvideTextCommand
\DeclareTextCommand{\cmd}{encoding}{defn} \DeclareTextCommand{\cmd}{encoding}[nargs]{defn} \DeclareTextCommand{\cmd}{encoding}[nargs][optargdefault]{defn}
\ProvideTextCommand{\cmd}{encoding}{defn} \ProvideTextCommand{\cmd}{encoding}[nargs]{defn} \ProvideTextCommand{\cmd}{encoding}[nargs][optargdefault]{defn}
\cmd
, which will be specific to one
encoding. The command name cmd must be preceded by a backslash,
\
. These commands can only appear in the preamble. Redefining
\cmd does not cause an error. The defined command will be robust
even if the code in defn is fragile (\DeclareTextCommand{\textperthousand}{T1}{\%\char 24 }
\usepackage[T1]{fontenc} % in preamble ... Legal limit is \( 0.8 \)\textperthousand.
OT1
then you get an error like
LaTeX Error: Command \textperthousand unavailable in encoding
OT1.
\ProvideTextCommand
variant does the same, except that it
does nothing if \cmd
is already defined. The
\DeclareTextSymbol
command is faster than this one for simple
slot-to-glyph association (\newcommand
(\cmd
takes. This number includes any optional argument.
Omitting this argument is the same as specifying 0, meaning that
\cmd
will have no arguments. And, if optargdefault
is present then the first argument of \cmd
is optional,
with default value optargdefault (which may be the empty string).
If optargdefault is not present then \cmd
does not
take an optional argument.
\DeclareTextCommandDefault
& \ProvideTextCommandDefault
\DeclareTextCommandDefault{\cmd}{defn}
\ProvideTextCommandDefault{\cmd}{defn}
\cmd
, for when that command
is not defined in the encoding currently in force. This default should
only use encodings known to be available.
\copyright
available.
\DeclareTextCommandDefault{\copyright}{\textcircled{c}}
\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.
\ProvideTextCommandDefault
has exactly the same behavior as
\DeclareTextCommandDefault
except that it does nothing if
\cmd
is already defined (\DeclareTextComposite
\DeclareTextComposite{\cmd}{encoding}{simple_object}{slot}
\^o
will cause
&latex; to typeset lowercase o by taking the character
directly from slot 224 in the font.
\DeclareTextComposite{\^}{T1}{o}{244}
\DeclareTextAccent
or with a one-argument
\DeclareTextCommand
. In \DeclareTextAccent{\^}{T1}{2}
command.
\DeclareTextCompositeCommand
\DeclareTextCompositeCommand{\cmd}{encoding}{arg}{code}
\DeclareTextComposite
that runs
arbitrary code with \cmd
.
\i
.
\DeclareTextCompositeCommand{\'}{OT1}{i}{\'\i}
\cmd
will have already been declared with \DeclareTextAccent
or as a one argument \DeclareTextCommand
.
\DeclareTextSymbol
\DeclareTextSymbol{\cmd}{encoding}{slot}
\DeclareTextSymbol{\guillemotleft}{T1}{19}
\DeclareTextCommand{\guillemotleft}{T1}{\char
19}
has the same effect but is slower ('023
), or
hexadecimal (as in "13
), although decimal has the advantage that
single quote or double quote could be redefined by another package.
\cmd
has already been defined then
\DeclareTextSymbol
does not give an error but it does log the
redefinition in the transcript file.
\DeclareTextSymbolDefault
\DeclareTextSymbolDefault{\cmd}{encoding}
\cmd
but
there is no associated \DeclareTextSymbol
for that encoding, then
this command will pick up the slack, by saying to get the symbol as
described for encoding.
\textdollar
then use the one from OT1
, declare this.
\DeclareTextSymbolDefault{\textdollar}{OT1}
\DeclareTextCommandDefault{\cmd} {\UseTextSymbol{encoding}{\cmd}}
\DeclareTextSymbolDefault
can be used to define a
default for any zero-argument \LastDeclaredEncoding
\LastDeclaredEncoding
\DeclareFontEncoding
command stores the name so that it can be
retrieved with this command (\LastDeclaredEncoding
rather than give the
name of the encoding explicitly.
\DeclareFontEncoding{JH1}{}{} \DeclareTextAccent{\'}{\LastDeclaredEncoding}{0}
\UseTextSymbol
& \UseTextAccent
\UseTextSymbol{encoding}{\cmd}
\UseTextAccent{encoding}{\cmd}{text}
\UseTextSymbol{OT1}{\ss}
\ss
):
{\fontencoding{OT1}\selectfont\ss}
\UseTextAccent{OT1}{\'}{a}
{fontencoding{OT1}\selectfont\'{\fontencoding{enc_in_use}\selectfont a}}
OT1
.
\text...
commands,
are used with an argument as in \textit{text}
. This is
the preferred form. But shown after it in parenthesis is the
corresponding declaration form, which is often useful. This
form takes no arguments, as in {\itshape text}
. The
scope of the declaration form lasts until the next type style command
or the end of the current group. In addition, each has an environment
form such as \begin{itshape}...\end{itshape}
, which we&textrsquo;ll
describe further at the end of the section.
\sffamily\bfseries
or \bfseries\sffamily
.
\nocorrlist
, which by default consists of period and comma.
To suppress the automatic insertion of italic correction, use
\nocorr
at the start or end of the command argument, such as
\textit{\nocorr text}
or \textsc{text \nocorr}
.
\emph{text}
command
is semantic, for text to be emphasized, and should not be used as a
substitute for \textit
. For example, \emph{start
text \emph{middle text} end text}
will result in the
start text and end text in italics, but middle text
will be in roman.
{\cmd...}
instead of
\cmd{...}
.
\em
command is the unconditional version of \emph
.
\mathbf{\mathit{symbol}}
does not
create a boldface and italic symbol; instead, it will just be in
italics. This is because typically math symbols need consistent
typographic treatment, regardless of the surrounding environment.
\mathversion{bold}
can be used for
switching to bold letters and symbols in
formulas. \mathversion{normal}
restores the default.
\oldstylenums{numerals}
will
typeset so-called &textldquo;old-style&textrdquo; numerals, which have differing heights
and depths (and sometimes widths) from the standard &textldquo;lining&textrdquo;
numerals, which all have the same height as uppercase letters.
&latex;&textrsquo;s default fonts support this, and will respect \textbf
(but not other styles; there are no italic old-style numerals in
Computer Modern). Many other fonts have old-style numerals also;
sometimes package options are provided to make them the default. FAQ
entry: \normalsize
(default)10pt
11pt
12pt
\tiny
\scriptsize
\footnotesize
\small
\normalsize
(default)
\large
\Large
\LARGE
\huge
\Huge
\begin{quotation} \small The Tao that can be named is not the eternal Tao. \end{quotation}
\small
lasts until the end of the
quotation
environment. It would also end at the next type
style command or the end of the current group, so you could enclose it
in curly braces {\small This text is typeset in the small font.}
.
$\small mv^2/2$
,
results in LaTeX Font Warning: Command \small
invalid in math mode, and the font size doesn&textrsquo;t
change. To work with a too-large formula, often the best option is to
use the displaymath
environment (amsmath
package. For inline
mathematics, such as in a table of formulas, an alternative is something
like {\small $mv^2/2$}
. (Sometimes \scriptsize
and
\scriptstyle
are confused. Both change the font size, but the
latter also changes a number of other aspects of how mathematics is
typeset. \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&textrsquo;s
generally less error-prone to stick to the declaration form.
\begin
and
\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.)
\onecolumn
\onecolumn
onecolumn
then this is the default
behavior (\twocolumn
\twocolumn \twocolumn[prelim one column text]
twocolumn
then this is the default
(\setlength{\columnsep}{40pt}
. You must change
it before the two column mode starts; in the preamble is a good
place.
\setlength{\columnseprule}{0.4pt}
, before the two-column
mode starts.
\textwidth
. In two-column mode by default &latex; sets the
width of each of the two columns, \columnwidth
, to be half of
\textwidth
minus \columnsep
.
table*
and
figure*
are two columns wide, whereas the unstarred environments
table
and figure
take up only one column (table*
or figure*
environment must not
exceed 0.7\textheight
. If the height of your starred float
environment exceeds this then you can take one of the following actions
to prevent it from floating all the way to the back of the document:
[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.
[t!]
location specifier to override the effect of
\dbltopfraction
for this particular float.
\dbltopfraction
to a suitably large number,
to avoid going to float pages so soon.
\renewcommand{\dbltopfraction}{0.9}
.
0.5
. Change it with \renewcommand
.
12pt plus2pt minus2pt
for a document set at 10pt
or
11pt
, and 14pt plus2pt minus4pt
for a document set at
12pt
.
20pt plus2pt
minus4pt
.
2
.
\twocolumn
&textrsquo;s optional argument of to create a
title that spans the two-column article:
\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}&arobase;{\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.
\flushbottom
\raggedbottom
(textheight
to make compatible pages, or you
can add some vertical stretch glue between lines or between paragraphs,
as in \setlength{\parskip}{0ex plus0.1ex}
. Your last option
is to, in a final editing stage, adjust the height of individual pages
(\flushbottom
state is the default only if you select the
twoside
document class option (\raggedbottom
twoside
document class
option (twocolumn
is in effect (article
, report
, and book
classes is 12pt,
at all type sizes.
article
and report
classes is 25pt. In the book
class the default is: if the
document is set at 10pt then it is 0.25in, and at 11pt or 12pt
it is 0.275in.
article
and report
classes is 30pt. In the book
class the default is: when
the type size is 10pt the default is 0.35in, while at 11pt it is
0.38in, and at 12pt it is 30pt.
list
(\linewidth
is to
equal \textwidth
but for each nested list the \linewidth
is decreased by the sum of that list&textrsquo;s \leftmargin
and
\rightmargin
(\reversemarginpar
changes that (and
\normalmarginpar
changes it back).
\marginparpush
in both book
and
article
classes are: 7pt if the document is set at 12pt,
and 5pt if the document is set at 11pt or 10pt.
\marginsep
, in article
class the default is
10pt except if the document is set at 10pt and in two-column mode
where the default is 11pt.
\marginsep
in book
class the default is 10pt in
two-column mode and 7pt in one-column mode.
\marginparwidth
in both book
and article
classes, in two-column mode the default is 60% of \paperwidth
− \textwidth
, while in one-column mode it is 50% of that
distance.
\oddsidemargin
length is the extra distance between the left side of
the page and the text&textrsquo;s left margin, on odd-numbered pages when the
document class option twoside
is chosen and on all pages when
oneside
is in effect. When twoside
is in effect, on
even-numbered pages the extra distance on the left is
\evensidemargin
.
\oddsidemargin
is 40% of the
difference between \paperwidth
and \textwidth
, and
\evensidemargin
is the remainder.
\documentclass[a4paper]{article}
(\documentclass[a4paper]{article}
(article
or report
the default is 43\baselineskip, while for a book
it is
41\baselineskip. At a type size of 11pt the default is
38\baselineskip for all document classes. At 12pt it is
36\baselineskip for all classes.
article
or report
document, the default is 345pt
when the chosen type size is 10pt, the default is 360pt at 11pt,
and it is 390pt at 12pt. For a book
document, the default
is 4.5in at a type size of 10pt, and 5in at 11pt or 12pt.
\textwidth
remains the width of the
entire page body, while \columnwidth
is the width of one column
(\textwidth
remains the width of the
entire page body (and \columnwidth
the width of the entire
column), while \linewidth
may decrease for nested lists.
\parbox
(minipage
or \parbox
.
\hsize
is the &tex;
primitive parameter used when text is broken into lines. It should not
be used in normal &latex; documents.
\paperheight − 2in −
\headheight − \headsep − \textheight − \footskip
,
and then divided by two.
\baselineskip
& \baselinestretch
\baselineskip
is a rubber length (\baselineskip
while writing. Instead, it is set by the low level font selection
command \fontsize
(\baselineskip
&textrsquo;s value is reset every time a font change
happens and so any direct change to \baselineskip
would vanish
the next time there was a font switch. For how to influence line
spacing, see the discussion of \baselinestretch
below.
\fontsize{10pt}{12pt}
then that does not mean that the characters in the font are 10\baselineskip
is about twenty percent larger than the font size.)
\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 {\Huge Q}
, will be squashed into its line.
&tex; will make sure it doesn&textrsquo;t scrape up against the line above but
won&textrsquo;t change the \baselineskip
for that one line to make extra
room above. For the fix, use a \strut
(\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.
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$$}
\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 \lineskiplimit
,
then &tex; instead uses \lineskip
as the interline glue. The
second is that &tex; doesn&textrsquo;t actually use the depth of the previous
line. Instead it uses \prevdepth
, which usually contains that
depth. But at the beginning of the paragraph (or any vertical list) or
just after a rule, \prevdepth
has the value -1000\lineskiplimit
is 0\lineskip
is 1\baselinestretch
. It scales
\baselineskip
, and has a default value of 1.0. It is a command,
not a length, so change the scale factor as in
\renewcommand{\baselinestretch}{1.5}\selectfont
.
\linespread{factor}
in the preamble.
For double spacing, take factor to be 1.6 and for one-and-a-half
spacing use 1.3. These number are rough: for instance, since the
\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
\linespread
command is defined as
\renewcommand{\baselinestretch}{factor}
so it won&textrsquo;t
take effect until a font setting happens. But that always takes place at
the start of a document, so there you don&textrsquo;t need to follow it with
\selectfont
.)
setspace
setspace
setspace
package. The basic example:
\usepackage{setspace} \doublespacing % or \onehalfspacing for 1.5
\singlespacing
to return the spacing to normal. In the
document body, a better practice than using the declarations is to use
environments, such as \begin{doublespace}
... \end{doublespace}
. The package also has commands to do
arbitrary spacing: \setstretch{factor}
and
\begin{spacing}{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.
figure
(table
(float
.
figure
and table
, in
both article
and book
classes, is tbp
.
btp
has the same effect as tbp
. All that
placement does is that if a letter is not present then the
algorithm does not try that location. Thus, &latex;&textrsquo;s default of
tbp
is to try every location except placing the float where it
occurs in the source.
\clearpage
command to start a new page and
insert all pending floats. If a pagebreak is undesirable then you can
use the \afterpage{\clearpage}
. This will wait until the current page
is finished and then flush all outstanding floats.
flafter
flafter
t
specifier in
the placement parameter. If this is not desired, and deleting
the t
is not acceptable as it keeps the float from being placed
at the top of the next page, then you can prevent it by either using
the flafter
package or using the command
\suppressfloats[t]
, which causes floats for the top position on
this page to moved to the next page.
\renewcommand{parameter}{decimal between 0 and 1}
):
\setlength{parameter}{length
expression}
):
\setcounter{ctrname}{natural
number}
):
\caption
\caption{caption-text}
\caption[short-caption-text]{caption-text}
figure
or
table
environment (\begin{figure} \vspace*{1cm} \caption{Alonzo Cushing, Battery A, 4th US Artillery.} \label{fig:CushingPic} \end{figure}
\caption
command will label the caption-text with
something like Figure 1: for an article or
Figure 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.
\caption
command also saves that information for use in a list of
figures or list of tables (\caption
command uses the optional
short-caption-text, so that the shorter text appears in the list
of tables, rather than the longer caption-text.
\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}
figure
or table
.
For instance, that would happen in the prior example by putting the
\caption
between the \centering
and the
\begin{tabular}
.
\caption
that updates the counter, and so any \label
must come after the \caption
. The counter for the figure
environment is named figure
, and similarly the counter for the
table
environment is table
.
\protect
in front
of any fragile commands. caption
caption
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.
sectioning-command{title} sectioning-command*{title} sectioning-command[toc-title]{title}
\subsection{Motivation}
.
book
,
report
, and article
, except that \chapter
is
not available in article
.
\part
book
, report
), 0 (article
)
\chapter
\section
\subsection
\subsubsection
\paragraph
\subparagraph
*
-form of sectioning commands*
-form that prints 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 article
. The
input \appendix\section{Appendix}
gives the output A
Appendix (\section*{Appendix}
(articles often omit a
table of contents and have simple page headers so the other differences
from the \section
command may not matter).
secnumdepth
then the titles for this sectioning command will be
numbered (tocdepth
then the table
of contents will have an entry for this sectioning unit
(\subsection
you will have
a \section
and, in a book
class document, that before a
\section
you will have a \chapter
. Otherwise you can get
something like a subsection numbered 3.0.1.
titlesec
titlesec
\renewcommand\thesection{\Alph{section}}
in the
preamble (titlesec
.
\setcounter{secnumdepth}{level}
will suppress
numbering of sectioning at any depth greater than level
(secnumdepth
is 1 in an article
then
a \section{Introduction}
command will produce output like
1 Introduction while \subsection{Discussion}
will
produce output like Discussion, without the number. &latex;&textrsquo;s
default secnumdepth
is 3 in \setcounter{tocdepth}{level}
makes the
sectioning units at level be the smallest ones listed
(tocdepth
is 1 then the table of contents will
list sections but not subsections. &latex;&textrsquo;s default
tocdepth
is 3 in \part
\part{title} \part*{title} \part[toc-title]{title}
book
,
report
, and article
, all have this command.
\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.
\part
command outputs a part number
such as Part I, alone on its line, in boldface, and in large
type. Then &latex; outputs title, also alone on its line, in
bold and in even larger type. In class book
, the &latex;
default puts each part alone on its own page. If the book is two-sided
then &latex; will skip a page if needed to have the new part on an
odd-numbered page. In report
it is again alone on a page, but
&latex; won&textrsquo;t force it onto an odd-numbered page. In an article
&latex; does not put it on a fresh page, but instead outputs the part
number and part title onto the main document page.
*
form shows title
but it does not show the part number, does not increment the
part
counter, and produces no table of contents entry.
\part[Up from the bottom; my life]{Up from the bottom\\ my life}
indentfirst
indentfirst
article
, if a paragraph immediately follows the part
title then it is not indented. To get an indent you can use the package
indentfirst
.
titlesec
titlesec
\part
is titlesec
.
See its documentation on CTAN.
\chapter
\chapter{title} \chapter*{title} \chapter[toc-title]{title}
book
and
report
have this command but article
does not.
\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.
\huge
). It then puts title on a fresh line, in boldface
type that is still larger (size \Huge
). It also increments the
chapter
counter, adds an entry to the table of contents
(*
form shows title on a fresh line, in boldface.
But it does not show the chapter number, does not increment the
chapter
counter, produces no table of contents entry, and does
not affect the running header. (If you use the page style
headings
in a two-sided document then the header will be from the
prior chapter.) This example illustrates.
\chapter*{Preamble}
\chapter[Weyl]{Hermann Klaus Hugo (Peter) Weyl (1885--1955)}
\chapter[Given it all; my story]{Given it all\\ my story}
indentfirst
indentfirst
indentfirst
.
\renewcommand{\chaptername}{Lecture}
or this
(\makeatletter \renewcommand{\&arobase;chapapp}{Lecture} \makeatother
babel
babel
babel
.
titlesec
titlesec
\chapter
command, you can copy its
definition from the &latex; format file and make adjustments. But
there are also many packages on CTAN that address this. One is
titlesec
. See its documentation, but the example below gives a
sense of what it can do.
\usepackage{titlesec} % in preamble \titleformat{\chapter} {\Huge\bfseries} % format of title {} % label, such as 1.2 for a subsection {0pt} % length of separation between label and title {} % before-code hook
\chapter*
it keeps the chapter in the table of contents and the
running headers.
\section
\section{title} \section*{title} \section[toc-title]{title}
article
,
book
, and report
all have this command.
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.
book
and report
the
default output is like 1.2 title (for chapter 1,
section 2), alone on its line and flush left, in boldface and a
larger type (the type size is \Large
). The same holds in
article
except that there are no chapters in that class so it
looks like 2 title.
*
form shows title.
But it does not show the section number, does not increment the
section
counter, produces no table of contents entry, and does
not affect the running header. (If you use the page style
headings
in a two-sided document then the header will be from the
prior section.)
\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.}
\section[Truth is, I cheated; my life story]{Truth is, I cheated\\my life story}
indentfirst
indentfirst
indentfirst
.
titlesec
titlesec
\section
command, there
are a number of options. One is the \&arobase;startsection
command
(titlesec
. See the documentation but the
example below gives a sense of what they can do.
\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]
\subsection
\subsection{title} \subsection*{title} \subsection[toc-title]{title}
article
,
book
, and report
all have this command.
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.
book
and report
the
default output is like 1.2.3 title (for chapter 1,
section 2, subsection 3), alone on its line and flush left, in
boldface and a larger type (the type size is \large
). The same
holds in article
except that there are no chapters in that class
so it looks like 2.3 title.
*
form shows title.
But it does not show the subsection number, does not increment the
subsection
counter, and produces no table of contents entry.
\subsection[$\alpha,\beta,\gamma$ paper]{\textit{The Origin of Chemical Elements} by R.A.~Alpher, H.~Bethe, and G.~Gamow}
indentfirst
indentfirst
indentfirst
.
titlesec
titlesec
\subsection
command. One is the \&arobase;startsection
command
(titlesec
. See the documentation but the
example below gives a sense of what they can do.
\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
\subsubsection
, \paragraph
, \subparagraph
\subsubsection{title} \subsubsection*{title} \subsubsection[toc-title]{title}
\paragraph{title} \paragraph*{title} \paragraph[toc-title]{title}
\subparagraph{title} \subparagraph*{title} \subparagraph[toc-title]{title}
article
, book
, and report
all have
these commands, although they are not commonly used.
\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.
article
, book
, and
report
. For \subsubsection
the title is alone on
its line, in boldface and normal size type. For \paragraph
the
title is inline with the text, not indented, in boldface and
normal size type. For \subparagraph
the title is inline
with the text, with a paragraph indent, in boldface and normal size type
(Because an article
has no chapters its subsubsections are
numbered and so it looks like 1.2.3 title, for
section 1, subsection 2, and subsubsection 3. The other
two divisions are not numbered.)
*
form shows title. But it does not increment the
associated counter and produces no table of contents entry (and does not
show the number for \subsubsection
).
indentfirst
indentfirst
indentfirst
.
titlesec
titlesec
\&arobase;startsection
command (titlesec
. See the documentation on CTAN.
\appendix
\appendix
\chapter
commands start an appendix. In
an article it does the same, for \section
commands. It also
resets the chapter
and section
counters to 0 in a
book or report, and in an article resets the section
and
subsection
counters.
\chapter{One} ... \chapter{Two} ... ... \appendix \chapter{Three} ... \chapter{Four} ...
\appendix
the numbering will be
Appendix A and Appendix B. appendix
appendix
appendix
package adds the command
\appendixpage
to put a separate Appendices in the document
body before the first appendix, and the command \addappheadtotoc
to do the same in the table of contents. You can reset the name
Appendices with a command like
\renewcommand{\appendixname}{Specification}
, as well as a
number of other features. See the documentation on CTAN.
\frontmatter
, \mainmatter
, \backmatter
\frontmatter ... \mainmatter ... \backmatter ...
book
class document differently according to which part
of the document is being produced. All three commands are optional.
\frontmatter
command makes the pages numbered in lowercase
roman, and makes chapters not numbered, although each chapter&textrsquo;s title
appears in the table of contents; if you use other sectioning commands
here, use the *
-version (\mainmatter
command changes the behavior back to the expected
version, and resets the page number.
\backmatter
command leaves the page numbering alone but
switches the chapters back to being not numbered.
\&arobase;startsection
, typesetting sectional unit headings\&arobase;startsection{name}{level}{indent}{beforeskip}{afterskip}{style}
\section
or \subsection
.
titlesec
package makes manipulation of sectioning
easier. Further, while most requirements for sectioning commands can be
satisfied with \&arobase;startsection
, some cannot. For instance, in
the standard &latex; book
and report
classes the commands
\chapter
and \report
are not constructed in this way. To
make such a command you may want to use the \secdef
command.
\&arobase;startsection
has the form
\&arobase;startsection{name} {level} {indent} {beforeskip} {afterskip} {style}*[toctitle]{title}
\renewcommand{\section}{\&arobase;startsection{name} {level} {indent} {beforeskip} {afterskip} {style}}
\section
while keeping its standard calling form
\section*[toctitle]{title}
(in which, for reminder,
the star *
is optional). \renewcommand{\section}{...}
, the
\&arobase;startsection{...}
must come last in the definition. See the
examples below.
\&arobase;startsection
, for the section
: level is 1, indent is 0-3.5ex plus -1ex minus -0.2ex
,
afterskip is 2.3ex plus 0.2ex
, and style is
\normalfont\Large\bfseries
.
subsection
: level is 2, indent is 0-3.25ex plus -1ex minus -0.2ex
,
afterskip is 1.5ex plus 0.2ex
, and style is
\normalfont\large\bfseries
.
subsubsection
: level is 3, indent is 0-3.25ex plus -1ex minus -0.2ex
,
afterskip is 1.5ex plus 0.2ex
, and style is
\normalfont\normalsize\bfseries
.
\makeatletter
command and a
\makeatother
. (Probably the error message You can't use
`\spacefactor' in vertical mode.
means that you forgot this.)
\renewcommand
because &latex;&textrsquo;s standard classes have already
defined a \section
. For the same reason it does not define a
section
counter, or the commands \thesection
and
\l&arobase;section
.
\renewcommand\section{% \&arobase;startsection{section}%\&arobase;startsection/name name name {1}%\&arobase;startsection/level level level {0pt}%\&arobase;startsection/indent indent indent {-3.5ex plus -1ex minus -.2ex}%\&arobase;startsection/beforeskip beforeskip beforeskip {2.3ex plus.2ex}%\&arobase;startsection/afterskip afterskip afterskip {\centering\normalfont\Large\bfseries}%\&arobase;startsection/style style style }
subsection
titles in small caps type, inline with the paragraph.
\renewcommand\subsection{% \&arobase;startsection{subsection}%\&arobase;startsection/name name name {2}%\&arobase;startsection/level level level {0em}%\&arobase;startsection/indent indent indent {-1ex plus 0.1ex minus -0.05ex}%\&arobase;startsection/beforeskip beforeskip beforeskip {-1em plus 0.2em}%\&arobase;startsection/afterskip afterskip afterskip {\scshape}%\&arobase;startsection/style style style }
\setcounter{secnumdepth}{6}% show counters this far down \newcounter{subsubparagraph}[subparagraph]% counter for numbering \renewcommand{\thesubsubparagraph}% how to display {\thesubparagraph.\&arobase;arabic\c&arobase;subsubparagraph}% numbering \newcommand{\subsubparagraph}{\&arobase;startsection {subsubparagraph}% {6}% {0em}% {\baselineskip}% {0.5\baselineskip}% {\normalfont\normalsize}} \newcommand*\l&arobase;subsubparagraph{\&arobase;dottedtocline{6}{10em}{5em}}% for toc \newcommand{\subsubparagraphmark}[1]{}% for page headers
\label{eq:GreensThm}
and then reference it, as with
See equation~\ref{eq:GreensThm}
. &latex; will automatically
work out the number, put it into the output, and will change that number
later if needed.
We will see this with Theorem~\ref{th:GreensThm}. % forward reference ... \begin{theorem} \label{th:GreensThm} ... \end{theorem} ... See Theorem~\ref{th:GreensThm} on page~\pageref{th:GreensThm}.
\label
. So if \label
is in \label
.
\ref
that appears before the associated \label
. If this is the first
time that you are compiling the document then you will get LaTeX
Warning: Label(s) may have changed. Rerun to get cross references right
and in the output the forward reference will appear as two question
marks ??, in boldface. A similar thing happens if you
change some things so the references changes; you get the same warning
and the output contains the old reference information. In both cases,
resolve this by compiling the document a second time.
cleveref
cleveref
cleveref
package enhances &latex;&textrsquo;s
cross referencing features. You can arrange that if you enter
\begin{thm}\label{th:Nerode}...\end{thm}
then
\cref{th:Nerode}
will output Theorem 3.21, without you
having to enter the &textldquo;Theorem.&textrdquo;
\label
\label{key}
\label{key}
assigns to key the number of the
current sectional unit. Inside an environment with numbering, such as a
table
or theorem
environment, \label{key}
assigns to key the number of that environment. Retrieve the
assigned number with the \ref{key}
command
(\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:
\newlabel{label}{{currentlabel}{pagenumber}}
.
Here currentlabel is the current value of the macro
\&arobase;currentlabel
that is usually updated whenever you call
\refstepcounter{counter}
.
sec:test
will get the number of the current
section and the key fig:test
will get the number of the figure.
(Incidentally, put labels after captions in figures and tables.)
\section{section name} \label{sec:test} This is Section~\ref{sec:test}. \begin{figure} ... \caption{caption text} \label{fig:test} \end{figure} See Figure~\ref{fig:test}.
\pageref
\pageref{key}
\label
{key} command appears.
\label{key}
then you get something like
LaTeX Warning: Reference `th:GrensThm' on page 1 undefined on
input line 11.
\label{eq:main}
is used both for the formula number
and for the page number. (Note that the two references are forward
references so this document would need to be compiled twice to resolve
those.)
The main result is formula~\ref{eq:main} on page~\pageref{eq:main}. ... \begin{equation} \label{eq:main} \mathbf{P}=\mathbf{NP} \end{equation}
\ref
\ref{key}
\label
command (\label{key}
then you get something like
LaTeX Warning: Reference `th:GrensThm' on page 1 undefined on
input line 11.
\ref{popular}
produces 2. Note that
it is a forward reference since it comes before \label{popular}
so this document would have to be compiled twice.
The most widely-used format is item number~\ref{popular}. \begin{enumerate} \item Plain \TeX \item \label{popular} \LaTeX \item Con\TeX t \end{enumerate}
cleveref
cleveref
cleveref
package includes text such as Theorem in the
reference. See the documentation on CTAN.
xr
packagexr
xr
xr-hyper
xr-hyper
\usepackage{xr} \externaldocument{document-basename}
\usepackage{xr} \externaldocument[reference-prefix]{document-basename}
\usepackage{xr} \externaldocument{exercises} \externaldocument[H-]{hints} \externaldocument{answers}
\item \label{exer:EulersThm} What if every vertex has odd degree?
\item \label{exer:EulersThm} Distinguish the case of two vertices.
\item \label{ans:EulersThm} There is no Euler path, except if there are exactly two vertices.
See Exercise~\ref{exer:EulersThm}, with Hint~\ref{H-exer:EulersThm}. The solution is Answer~\ref{ans:EulersThm}.
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.
hyperref
package then in place of
xr
, put \usepackage{xr-hyper}
before the
\usepackage{hyperref}
. Also, if any of the multiple documents
uses hyperref
then they all must use it.
\begin
and ends with \end
,
like this:
\begin{environment-name} ... \end{environment-name}
\begin{table*}...\end{table}
will cause an error like:
! LaTeX Error: \begin{table*} on input line 5 ended by
\end{table}.
abstract
abstract
abstract
\begin{abstract} ... \end{abstract}
article
and report
document classes
(article
class produces a displayed
paragraph. Document class option titlepage
causes the abstract
to be on a separate page (report
class.
\begin{abstract} We compare all known accounts of the proposal made by Porter Alexander to Robert E Lee at the Appomattox Court House that the army continue in a guerrilla war, which Lee refused. \end{abstract}
abstract
abstract
\documentclass[twocolumn]{article} ... \begin{document} \title{Babe Ruth as Cultural Progenitor: a Atavistic Approach} \author{Smith \\ Jones \\ Robinson\thanks{Railroad tracking grant.}} \twocolumn[ \begin{&arobase;twocolumnfalse} \maketitle \begin{abstract} Ruth was not just the Sultan of Swat, he was the entire swat team. \end{abstract} \end{&arobase;twocolumnfalse} ] { % by-hand insert a footnote at page bottom \renewcommand{\thefootnote}{\fnsymbol{footnote}} \footnotetext[1]{Thanks for all the fish.} }
array
array
array
\begin{array}{cols} column 1 entry &column 2 entry ... &column n entry \\ ... \end{array}
\begin{array}[pos]{cols} column 1 entry &column 2 entry ... &column n entry \\ ... \end{array}
equation
(&
). Rows are terminated with double-backslashes (\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*}
\begin{array}{rcl}...\end{array}
gives three columns: the
first flush right, the second centered, and the third flush left. See
array
diverges from tabular
. The
first is that array
entries are typeset in math mode, in
textstyle (p{...}
, which causes the entry to be typeset in
text mode. The second is that, instead of tabular
&textrsquo;s parameter
\tabcolsep
, &latex;&textrsquo;s intercolumn space in an array
is
governed by
\arraycolsep
, which gives half the width between columns. The
default for this is 5pt so that between two columns comes
10amsmath
amsmath
amsmath
package. It comes with environments pmatrix
for an array
surrounded by parentheses (...)
, bmatrix
for an array
surrounded by square brackets [...]
, Bmatrix
for an
array surrounded by curly braces {...}
, vmatrix
for
an array surrounded by vertical bars |...|
, and
Vmatrix
for an array surrounded by double vertical
bars ||...||
, along with a number of other array constructs.
amsmath
amsmath
amsmath
package.
\usepackage{amsmath} % in preamble \begin{equation} \begin{vmatrix}{cc} % array with vert lines a &b \\ c &d \end{vmatrix}=ad-bc \end{equation}
array
array
dcolumn
dcolumn
array
package has
many useful extensions, including more column types. The dcolumn
package adds a column type to center on a decimal point. For both see
the documentation on CTAN.
center
center
center
\begin{center} line1 \\ line2 \\ ... \end{center}
\\
, to get a line break (center
)figure
environment.
\begin{center} A Thesis Submitted in Partial Fufillment \\ of the Requirements of \\[0.5ex] the School of Environmental Engineering \end{center}
\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}
\centering
{\centering ... }
\begin{group} \centering ... \end{group}
figure
, or in a parbox
.
\centering
declaration causes the graphic to be
horizontally centered.
\begin{figure} \centering \includegraphics[width=0.6\textwidth]{ctan_lion.png} \caption{CTAN Lion} \label{fig:CTANLion} \end{figure}
\centering
ends with the \end{figure}
.
center
environment, the \centering
command does
not add vertical space above and below the text. That&textrsquo;s its advantage
in the above example; there is not an excess of space.
ww {\centering xx \\ yy} zz
is
surrounded by blank lines then &latex; will create a paragraph whose
first line ww xx is centered and whose second line, not centered,
contains yy zz. Usually what is desired is for the scope of the
declaration to contain a blank line or the \end
command of an
environment such as figure
or table
that ends the
paragraph unit. Thus, if {\centering xx \\ yy\par} zz
is
surrounded by blank lines then it makes a new paragraph with two
centered lines xx and yy, followed by a new paragraph with
zz that is formatted as usual.
description
description
description
\begin{description} \item[label of first item] text of first item \item[label of second item] text of second item ... \end{description}
\begin{description} \item[lama] A priest. \item[llama] A beast. \end{description}
\item
command (\item[Main point]
, because there is
no sensible default. Following the \item
is optional text, which
may contain multiple paragraphs.
\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:
\item[{\tt label text}]
. Similarly, get the standard roman
font with \item[{\rm label text}]
.
description
environments does not change the default label; it is
boldface and flush left at all levels.
enumitem
is useful for customizing
lists.
\renewcommand{\descriptionlabel}[1]{% {\hspace{\labelsep}\textsc{#1}}}
displaymath
displaymath
displaymath
\begin{displaymath} mathematical text \end{displaymath}
fleqn
; see displaymath
environment no equation number is added to the
math text. One way to get an equation number is to use the
equation
environment (amsmath
amsmath
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.
\[math\]
is a synonym for the environment
\begin{displaymath} 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
displaymath
will likely be unique.
$$math$$
from Plain &tex; is
sometimes mistakenly used as a synonym for displaymath
. It is
not a synonym, and is not officially supported in &latex; at all;
$$
doesn&textrsquo;t support the fleqn
option (\begin{displaymath} \int_1^2 x^2\,dx=7/3 \end{displaymath}
\( \int_1^2 x^2\,dx=7/3 \)
produces.
document
document
document
document
environment encloses the entire body of a document.
It is required in every &latex; document. \AtBeginDocument
\AtBeginDocument{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.
\AtEndDocument
\AtEndDocument{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 \clearpage
at the
appropriate point in code.
enumerate
enumerate
enumerate
\begin{enumerate} \item[optional label of first item] text of first item \item[optional label of second item] text of second item ... \end{enumerate}
enumerate
list environment must have at least one item;
having none causes the &latex; error Something's wrong--perhaps a
missing \item.
\begin{enumerate} \item Johnny Hayes (USA) \item Charles Hefferon (RSA) \end{enumerate}
\item
command (\item
an optional argument by following it with square
brackets, as in \item[Interstitial label]
, then the next item
will continue the interrupted sequence (\item
is optional text, which may
contain multiple paragraphs.
enumerate
environments,
or within any paragraph-making environment such as itemize
(enumerate
environment uses the counters \enumi
through
\enumiv
(enumitem
is
useful for customizing lists.
\renewcommand
(\labelenumi
through \labelenumiv
. For instance, this first level list will be
labelled with uppercase letters, in boldface, and without a trailing
period.
\renewcommand{\labelenumi}{\textbf{\Alph{enumi}}} \begin{enumerate} \item Shows as boldface A \item Shows as boldface B \end{enumerate}
eqnarray
eqnarray
eqnarray
amsmath
eqnarray
eqnarray
environment is obsolete. It has infelicities,
including spacing that is inconsistent with other mathematics elements.
(See &textldquo;Avoid eqnarray!&textrdquo;&noeos; by Lars Madsen
amsmath
package and use the displayed
mathematics environments provided there, such as the align
environment. We include a description only for completeness and for
working with old documents.
\begin{eqnarray} first formula left &first formula middle &first formula right \\ ... \end{eqnarray}
\begin{eqnarray*} first formula left &first formula middle &first formula right \\ ... \end{eqnarray*}
eqnarray
)array
environment, with items
within a row separated by an ampersand (&
), and with rows
separated by double backslash \\
).
eqnarray
)\\*
) can also be used to separate
equations, and will disallow a page break there (eqnarray
places an equation number on every
line (using the equation
counter), unless that line contains a
\nonumber
command. The starred form eqnarray*
omits
equation numbering, while otherwise being the same.
\lefteqn
is used for splitting long formulas across
lines. It typesets its argument in display style flush left in a box of
zero width.
\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*}
equation
equation
equation
\begin{equation} mathematical text \end{equation}
displaymath
environment (equation
counter.
\begin{equation}
and
\begin{equation}
, or &latex; will tell you that there is a
missing dollar sign.
amsmath
amsmath
amsmath
package has extensive displayed equation
facilities. New documents should include this package.
figure
figure
figure
\begin{figure}[placement] figure body \caption[loftitle]{title} % optional \label{label} % optional \end{figure}
\begin{figure*}[placement] figure body \caption[loftitle]{title} % optional \label{label} % optional \end{figure*}
parbox
of width \textwidth
.
h
for here,
t
for top, b
for bottom, and p
for
on a separate page of floats. For the effect of these options on
the float placement algorithm, see figure*
is used when a document is in
double-column mode (b
in \caption
command specifies caption
text for the figure (\usepackage{graphicx} % in preamble ... \begin{figure}[t] \centering \includegraphics[width=0.5\textwidth]{CTANlion.png} \caption{The CTAN lion, by Duane Bibby} \end{figure}
filecontents
filecontents
filecontents
filecontents*
filecontents*
\begin{filecontents}[option]{filename} text \end{filecontents}
\begin{filecontents*}[option]{filename} text \end{filecontents*}
filecontents
prefixes the content of the created file with a
header of &tex; comments; see the example below. The starred
version filecontents*
does not include the header.
\documentclass
command. It is
commonly used to create a .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.
\documentclass{article} \begin{filecontents}{JH.sty} \newcommand{\myname}{Jim Hef{}feron} \end{filecontents} \usepackage{JH} \begin{document} Article by \myname. \end{document}
%% LaTeX2e file `JH.sty' %% generated by the `filecontents' environment %% from source `test' on 2015/10/12. %% \newcommand{\myname}{Jim Hef{}feron}
flushleft
flushleft
flushleft
\begin{flushleft} line1 \\ line2 \\ ... \end{flushleft}
flushleft
\\
. For the declaration form
see \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}
\raggedright
{\raggedright ... }
\begin{environment} \raggedright ... \end{environment}
quote
or in a parbox
. For the environment form
see flushleft
environment, the \raggedright
command does not start a new paragraph; it only changes how &latex;
formats paragraph units. To affect a paragraph unit&textrsquo;s format, the
scope of the declaration must contain the blank line or \end
command that ends the paragraph unit.
\raggedright
in each second column keeps &latex; from doing
very awkward typesetting to fit the text into the narrow column. Note
that \raggedright
is inside the curly braces {...}
to
delimit its effect.
\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}
flushright
flushright
flushright
\begin{flushright} line1 \\ line2 \\ ... \end{flushright}
flushright
)\\
. For the declaration form
see flushleft
by
flushright
.
\raggedleft
{\raggedleft ... }
\begin{environment} \raggedleft ... \end{environment}
quote
or in a parbox
. For the environment form
see flushright
environment, the \raggedleft
command does not start a new paragraph; it only changes how &latex;
formats paragraph units. To affect a paragraph unit&textrsquo;s format, the
scope of the declaration must contain the blank line or \end
command that ends the paragraph unit.
\raggedright
by
\raggedleft
.
itemize
itemize
itemize
\begin{itemize} \item[optional label of first item] text of first item \item[optional label of second item] text of second item ... \end{itemize}
\item
within the environment; having none causes the
&latex; error Something's wrong--perhaps a missing \item.
\begin{itemize} \item Pencil and watercolor sketch by Cassandra \item Rice portrait \end{itemize}
babel
package
with another language than USenglish&textmdash;as a top-level list each label
would come out as a bullet, •. The format of the labeling
depends on the nesting level; see below.
\item
command (\item
an optional argument by following it with square
brackets, as in \item[Optional label]
, then by default
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
\item
is the text of
the item, which may be empty or contain multiple paragraphs.
enumerate
(itemize
environment uses the commands \labelitemi
through \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.
\textbullet
)
\normalfont\bfseries\textendash
)
\textasteriskcentered
)
\textperiodcentered
)
\renewcommand
. For instance, this makes
the first level use diamonds.
\renewcommand{\labelitemi}{$\diamond$}
itemize
list is determined by the
parameters \leftmargini
through \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:
2.5em
in level 1 (2em
in two-column mode), 2.2em
in
level 2, 1.87em
in level 3, and 1.7em
in level 4, with
smaller values for more deeply nested levels.
enumitem
enumitem
itemize
,
enumerate
and description
environment use the same list
layout parameters. For a description, including the default values, and
for information about customizing list layout, see enumitem
is useful for customizing lists.
\setlength{\leftmargini}{1.25em} % default 2.5em
itemize*
environment with no extra spacing between items, or between paragraphs
within a single item (\parskip
is not list-specific,
\newenvironment{itemize*}% {\begin{itemize}% \setlength{\itemsep}{0pt}% \setlength{\parsep}{0pt}}% \setlength{\parskip}{0pt}}% {\end{itemize}}
letter
environment: writing lettersletter
letter
list
list
list
\begin{list}{labeling}{spacing} \item[optional label of first item] text of first item \item[optional label of second item] text of second item ... \end{list}
description
, enumerate
, and itemize
environments (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 list
, including
quotation
, quote
, and center
(list
environment to define a new custom
environment.
\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}
\labelwidth
. If the label is wider than that, the
additional material extends to the right. When making an instance of a
list
you can override the default labeling by giving \item
an
optional argument by including square braces and the text, as in the
above \item[Special label.]
; \usecounter{countername}
(\item
that does not have an optional argument.
\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 (named
example, before the
definition of the environment add
\newcommand{\namedmakelabel}[1]{\textsc{#1}}
, and between
the \setlength
command and the parenthesis that closes the
spacing argument also add \let\makelabel\namedmakelabel
.
Then the labels will be typeset in small caps. Similarly, changing the
second code line to \let\makelabel\fbox
puts the labels inside a
framed box. Another example of the \makelabel
command is below,
in the definition of the redlabel
environment.
itemize
can be
different than the values shown here.) See also the figure that follows
the list. Each is a length (plus
and minus
components,
to give &tex; flexibility in setting the page. Change each with a
command such as \setlength{itemsep}{2pt plus1pt minus1pt}
.
For some effects these lengths should be zero or negative.
leftmargin
, of the
first line each item. Its default value is 0pt
.
\parsep
. The defaults
for the first three levels in &latex;&textrsquo;s article, book,
and report classes at 10 point size are: 4pt plus2pt
minus1pt
, \parsep
(that is, 2pt plus1pt minus1pt
), and
\topsep
(that is, 2pt plus1pt minus1pt
). The defaults at
11 point are: 4.5pt plus2pt minus1pt
, \parsep
(that is,
2pt plus1pt minus1pt
), and \topsep
(that is, 2pt
plus1pt minus1pt
). The defaults at 12 point are: 5pt plus2.5pt
minus1pt
, \parsep
(that is, 2.5pt plus1pt minus1pt
), and
\topsep
(that is, 2.5pt plus1pt minus1pt
).
0.5em
.
\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 \makelabel
returns text of width less than or equal to
\labelwidth
then &latex;&textrsquo;s default is that the label is typeset
flush right in a box of this width.
\leftmargin
+\itemindent
-\labelsep
-\labelwidth
from the left margin of the enclosing environment.
\leftmargini
-\labelsep
, (which is 2em
in one column
mode and 1.5em
in two column mode). At the second level it is
\leftmarginii
-\labelsep
, and at the third level it is
\leftmarginiii
-\labelsep
. These definitions make the
label&textrsquo;s left edge coincide with the left margin of the enclosing
environment.
\leftmargini
, while a list that is nested inside
a top-level list has this margin set to \leftmarginii
. More
deeply nested lists get the values of \leftmarginiii
through
\leftmarginvi
. (Nesting greater than level five generates the
error message Too deeply nested.)
\leftmargini
is
2.5em
(in two column mode, 2em
), \leftmarginii
is
2.2em
, and \leftmarginiii
is 1.87em
.
\leftmargin
, for second and subsequent paragraphs within a list
item. A negative value makes this an &textldquo;outdent&textrdquo;. Its default value
is 0pt
.
4pt
plus2pt minus1pt
, 2pt plus1pt minus1pt
, and 0pt
. The
defaults at 11 point size are: 4.5pt plus2pt minus1pt
,
2pt plus1pt minus1pt
, and 0pt
. The defaults at 12 point
size are: 5pt plus2.5pt minus1pt
, 2.5pt plus1pt
minus1pt
, and 0pt
.
\topsep
+\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.)
2pt
plus1 minus1pt
, 2pt plus1pt minus1pt
, and 1pt plus0pt
minus1pt
. The defaults at 11 point are: 3pt plus1pt minus1pt
,
3pt plus1pt minus1pt
, and 1pt plus0pt minus1pt
). The
defaults at 12 point are: 3pt plus2pt minus3pt
, 3pt plus2pt
minus2pt
, and 1pt plus0pt minus1pt
.
0pt
.
It must be non-negative.
\parskip
(8pt plus2pt minus4pt
,
4pt plus2pt minus1pt
, and 2pt plus1pt minus1pt
. The
defaults at 11 point are: 9pt plus3pt minus5pt
, 4.5pt
plus2pt minus1pt
, and 2pt plus1pt minus1pt
. The defaults at 12
point are: 10pt plus4pt minus6pt
, 5pt plus2.5pt minus1pt
,
and 2.5pt plus1pt minus1pt
.
\linewidth
(\setlength{\leftmargin}{0.25\linewidth}
.
-\&arobase;lowpenalty
, that is, -51
. Because it is negative,
it somewhat encourages a page break at each spot. Change it with,
e.g., \&arobase;beginparpenalty=9999
; a value of 10000 prohibits a
page break.
-51
).
-51
).
-51
).
enumitem
enumitem
enumitem
is useful for customizing lists.
\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}}
\item
: An entry in a list\item text of item
\item[optional-label] text of item
\item
{[} is an open square bracket
; otherwise, &latex; will think it
marks the start of an optional label.
\item[Close square bracket, {]}]
. \begin{enumerate} \item Moe \item[sometimes] Shemp \item Larry \end{enumerate}
trivlist
: A restricted form of list
\begin{trivlist} ... \end{trivlist}
\item
without an optional argument produces no
text. It is most often used in macros, to define an environment where
the \item
command is part of the environment&textrsquo;s definition. For
instance, the center
environment is defined essentially like
this:
\newenvironment{center} {\begin{trivlist}\centering\item\relax} {\end{trivlist}}
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.
trivlist
uses the current values of the list
parameters (\parsep
is set to the
value of \parskip
, and \leftmargin
, \labelwidth
,
and \itemindent
are set to zero.
\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}
math
math
math
\begin{math} math \end{math}
math
environment inserts given math material within
the running text. \(...\)
and $...$
are synonyms.
minipage
minipage
minipage
\begin{minipage}{width} contents \end{minipage}
\begin{minipage}[position][height][inner-pos]{width} contents \end{minipage}
minipage
is similar to \parbox
(\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}
minipage
.
\begin{minipage}[c][2.54cm]{\columnwidth} contents
\end{minipage}
. (Get the natural height with an empty argument,
[]
.)
minipage
vertically aligns with the surrounding material.
---\begin{minipage}[c]{0.25in} first\\ second\\ third \end{minipage}
c
to b
or t
.
minipage
. You can enter any value
larger than, or equal to, or smaller than the minipage
&textrsquo;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.
minipage
&textrsquo;s natural height. To
see the effect of the options, run this example with the various choices
in place of b
.
Text before \begin{center} ---\begin{minipage}[c][3in][b]{0.25\textwidth} first\\ second\\ third \end{minipage} \end{center} Text after
minipage
. Change
that with a command such as \setlength{\parindent}{1pc}
at
the start of contents.
minipage
environment are handled in a way that is
particularly useful for putting footnotes in figures or tables. A
\footnote
or \footnotetext
command puts the footnote at
the bottom of the minipage instead of at the bottom of the page, and it
uses the \mpfootnote
counter instead of the ordinary
footnote
counter (\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{minipage}
which may not be their logical place.
siunitx
siunitx
% siunitx to have the S column specifier, % which aligns numbers on their decimal point. \usepackage{siunitx} \newcommand*{\vcenteredhbox}[1]{\begin{tabular}{&arobase;{}c&arobase;{}}#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}
picture
picture
picture
\begin{picture}(width,height) picture command \end{picture}
\begin{picture}(width,height)(xoffset,yoffset) picture command \end{picture}
\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}
picture
environment has one required argument, a pair of
positive real numbers (width,height). Multiply these by the
value \unitlength
to get the nominal size of the output, i.e.&noeos;
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&textrsquo;s box.
\unitlength
to get the coordinates of the point at the
lower-left corner of the picture.
\unitlength
has been set to 1mm
, the
command
\begin{picture}(100,200)(10,20)
(2.4,-5)
giving the x- and y-coordinates. A 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 \unitlength
,
so if \unitlength
has been set to 1cm
, then the coordinate
2.54
specifies a length of 2.54 centimeters.
\unitlength
is 1pt
. It is a rigid
length (\setlength
command
(picture
environment.
picture
environment supports using standard arithmetic
expressions as well as numbers.
\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, is \put
,
\multiput
, \qbezier
, and \graphpaper
. The most
often used is \put
. This
\put(11.3,-0.3){...}
\put
command creates an LR box (\mbox
(\put
command. The reference point
will be the lower left corner of the box. In this picture
\setlength{\unitlength}{1cm} ...\begin{picture}(1,1) \put(0,0){\line(1,0){1}} \put(0,0){\line(1,1){1}} \end{picture}
\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.)
\multiput
, qbezier
, and graphpaper
commands are
described below.
\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}
\textwidth
from
the left margin, and 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&textrsquo;s pages.
\put
\put(xcoord,ycoord){content}
\unitlength
in picture
.
\put(4.5,2.5){Apply the \textit{unpoke} move}
\multiput
\multiput(x,y)(delta_x,delta_y){num-copies}{obj}
\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}
\qbezier
\qbezier(x1,y1)(x2,y2)(x3,y3) \qbezier[num](x1,y1)(x2,y2)(x3,y3)
(x1,y1)
,
(x2,y2)
, and (x3,y3)
. That is,
the curve runs from (x1,y1) to (x3,y3), is quadratic, and is
such that the tangent line at (x1,y1) passes through
(x2,y2), as does the tangent line at (x3,y3).
\qbezier(1,1)(1.25,0.75)(1,0)
\qbeziermax
(change this value with
\renewcommand
).
\qbezier
for
that curve.
\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}
\graphpaper
\graphpaper(x_init,y_init)(x_dimen,y_dimen) \graphpaper[spacing](x_init,y_init)(x_dimen,y_dimen)
graphpap
graphpap
graphpap
package.
The grid&textrsquo;s origin is (x_init,y_init)
.
Grid lines come every spacing units (the default is 10).
The grid extends x_dimen units to the right and y_dimen units up.
All arguments must be positive integers.
\usepackage{graphpap} % in preamble ... \begin{picture}(6,20) % in document body \graphpaper[2](0,0)(12,20) \end{picture}
\line
\line(x_run,y_rise){travel}
\put(1,3){\line(2,5){4}}
\put(x_init,y_init){\line(x_run,y_rise){travel}}
,
if x_run is negative then the line&textrsquo;s ending point has a first
coordinate that is less than x_init. If y_rise is negative
then the line&textrsquo;s ending point has a second coordinate that is less than
y_init.
LaTeX Error: Bad \line or
\vector argument.
pict2e
pict2e
TikZ
TikZ
PSTricks
PSTricks
MetaPost
MetaPost
Asymptote
Asymptote
picture
, see the package pict2e
(\linethickness
\linethickness{dim}
\thinlines
and
\thicklines
in that it does not affect the thickness of slanted
lines, circles, or ovals (\thinlines
\thicklines
\circle
\circle{diameter} \circle*{diameter}
*
form produces a filled-in circle.
(5,7)
.
\put(5,7){\circle{6}}
\circle
are, in points, the even
numbers from 2 to 20, inclusive. For \circle*
they are all the
integers from 1 to 15.
\oval
\oval(width,height) \oval(width,height)[portion]
tr
, br
, bl
, or tl
.
\put(5,7){\oval(3,7)[t]}
\shortstack
\shortstack[position]{line 1 \\ ... }
\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}
\makebox
(\shortstack
objects)\\
. These stacks are short in
that, unlike in a tabular
or array
environment, here the
rows are not spaced out to be of even baseline skips. Thus, in
\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 \shortstack{X\\ \strut o\\o\\X}
(\shortstack{X \\
\rule{0pt}{12pt} o\\o\\X}
or by using \\
&textrsquo;s optional
argument \shortstack{X\\[2pt] o\\o\\X}
.
\shortstack
command is also available outside the
picture
environment.
\vector
\vector(x_run,y_rise){travel}
\vector
you must chooses integers between −4 and 4,
inclusive. Also, the two you choose must be relatively prime. Thus,
\vector(2,1){4}
is acceptable but \vector(4,2){4}
is
not (if you use the latter then you get a sequence of arrowheads).
\makebox
(picture)picture
)\makebox(rec-width,rec-height){text} \makebox(rec-width,rec-height)[position]{text}
picture
environment, although you can use it outside of there,
because rec-width and rec-height are numbers specifying
distances in terms of the \unitlength
(\makebox
command (\unitlength
and height 4
times \unitlength
.
\put(1,2){\makebox(3.5,4){...}}
position
specifies where in the box
the 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.
\framebox
(picture)\framebox(rec-width,rec-height){text} \framebox(rec-width,rec-height)[position]{text}
picture
environment, although you can use it outside of there,
because lengths are numbers specifying the distance in terms of the
\unitlength
(\setlength{\unitlength}{1in} \framebox(2.5,3){test text}
\fboxrule
and there is a blank space
\fboxsep
between the frame and the contents of the box.
\fbox
(\frame
(\frame
\frame{contents}
\framebox
(\dashbox
\dashbox{dash-len}(rect-width,rect-height){text} \dashbox{dash-len}(rect-width,rect-height)[position]{text}
picture
environment, although you can use it outside of there,
because lengths are numbers specifying the distance in terms of the
\unitlength
(\put(0,0){\dashbox{0.1}(5,0.5){My hovercraft is full of eels.}}
0.1\unitlength
long, the box&textrsquo;s width is
5\unitlength
and its height is 0.5\unitlength
.
quotation
& quote
quotation
quotation
quote
quote
\begin{quotation} text \end{quotation}
\begin{quote} text \end{quote}
\leftmargin
and the text is right-justified.
quotation
environment, paragraphs are indented by 1.50pt plus 1pt
. In the quote
environment, paragraphs are not indented and there is vertical space
between paragraphs (it is the rubber length \parsep
).
\begin{quotation} \small\it Four score and seven years ago ... shall not perish from the earth. \hspace{1em plus 1fill}---Abraham Lincoln \end{quotation}
tabbing
tabbing
tabbing
\begin{tabbing} row1col1 \= row1col2 ... \\ row2col1 \> row2col2 ... \\ ... \end{tabbing}
tabular
(array
(\kill
command (which is described below):
\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}
tabbing
environment and the more widely-used
tabular
environment put text in columns. The most important
distinction is that in tabular
the width of columns is
determined automatically by &latex;, while in tabbing
the user
sets the tab stops. Another distinction is that tabular
generates a box, but tabbing
can be broken across pages.
Finally, while tabular
can be used in any mode, tabbing
can be used only in paragraph mode and it always starts a new paragraph,
without indentation.
\hspace
command at the beginning
of a tabbed row. The right margin of the tabbing
environment is
the end of line, so that the width of the environment is
\linewidth
.
tabbing
environment contains a sequence of tabbed
rows. The first tabbed row begins immediately after
\begin{tabbing}
and each row ends with \\
or
\kill
. The last row may omit the \\
and end with just
\end{tabbing}
.
tabbing
environment has a current tab stop
pattern, a sequence of tab stops, numbered 0, 1,
etc. These create n corresponding columns. Tab stop 0 is
always the left margin, defined by the enclosing environment. Tab
stop number i is set if it is assigned a horizontal
position on the page. Tab stop number i can only be set if
all the stops 0, &dots;, have already been set; normally
later stops are to the right of earlier ones.
tabbing
environment is typeset
ragged right and left-aligned on the current tab stop. Typesetting is
done in LR mode (tabbing
environment.
They are all fragile (\>
, \<
, \'
,
\\
, or \kill
command, to the previous column and aligned
to the right, flush against the current column&textrsquo;s tab stop.
\`
command moves
all the text that follows it, up to the \\
or
\end{tabbing}
command that ends the line, to the right margin
of the tabbing
environment. There must be no \>
or
\'
command between the \`
and the \\
or
\end{tabbing}
command that ends the line.
tabbing
environment, the commands \=
, \'
and
\`
do not produce accents as usual (\a=
, \a'
and \a`
.
\\
except
that it throws away the current line instead of producing output for it.
Any \=
, \+
or \-
commands in that line remain in
effect.
\pushtabs
.
tabbing
environment.
\'
to left of current tab stop.
\begin{tabbing} function \= fact(n : integer) : integer;\\ \> begin \= \+ \\ \> if \= n > 1 then \+ \\ fact := n * fact(n-1) \- \\ else \+ \\ fact := 1; \-\- \\ end;\\ \end{tabbing}
function fact(n : integer) : integer; begin if n > 1 then fact := n * fact(n-1); else fact := 1; end;
algorithm2e
algorithm2e
listings
listings
minted
minted
fancyvrb
fancyvrb
algorithm2e
,
fancyvrb
, listings
, and minted
.
table
table
table
\begin{table}[placement] table body \caption[loftitle]{title} % optional \label{label} % also optional \end{table}
table
environment contains a tabular
\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}
table
:
the table body may contain text, &latex; commands, graphics, etc. It is
typeset in a parbox
of width \textwidth
.
\caption
command is also optional. It specifies caption
text title for the table (\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}
tabular
tabular
tabular
\begin{tabular}[pos]{cols} column 1 entry &column 2 entry ... &column n entry \\ ... \end{tabular}
\begin{tabular*}{width}[pos]{cols} column 1 entry &column 2 entry ... &column n entry \\ ... \end{tabular*}
\begin{tabular}{l|l} \textit{Player name} &\textit{Career home runs} \\ \hline Hank Aaron &755 \\ Babe Ruth &714 \end{tabular}
tabular
&textrsquo;s argument
{l|l}
.
&
. The end of each row is marked with a double
backslash, \\
. Put a horizontal rule below a row, after a double
backslash, with \hline
.
tabular
\\
is optional, unless an \hline
command follows to put a rule below the table.
tabular
consist of:
tabular*
, not allowed for tabular
. Specifies
the width of the tabular*
environment. The space between columns
should be rubber, as with &arobase;{\extracolsep{\fill}}
, to allow
the table to stretch or shrink to make the specified width, or else you
are likely to get the Underfull \hbox (badness 10000) in alignment
...
warning.
|
,
\hline
, and \vline
in the tabular
and array
environments. The default is .4pt. Change it as in
\setlength{\arrayrulewidth}{0.8pt}
.
tabular
and
array
environments is multiplied. The default is 1, for
no scaling. Change it as \renewcommand{\arraystretch}{1.2}
.
||
specifier. The default is 2pt.
\setlength
.
tabular
environment, the first two inside an entry and the second two between
lines:
\multicolumn
\multicolumn{numcols}{cols}{text}
array
or tabular
entry that spans several columns.
The first argument numcols gives the number of columns to span.
The second argument cols specifies the formatting of the entry,
with c
for centered, l
for flush left, or r
for
flush right. The third argument text gives the contents of that
entry.
\begin{tabular}{lccl} \textit{ID} &\multicolumn{2}{c}{\textit{Name}} &\textit{Age} \\ \hline 978-0-393-03701-2 &O'Brian &Patrick &55 \\ ... \end{tabular}
array
or tabular
environment is broken into parts, where
each part (except the first) begins with l
, c
, r
,
or p
. So from \begin{tabular}{|r|ccp{1.5in}|}
the parts are |r|
, c
, c
,
and p{1.5in}|
.
array
or tabular
environment&textrsquo;s intercolumn area default adjoining this multicolumn
entry. To affect that area, this argument can contain vertical bars
|
indicating the placement of vertical rules, and &arobase;{...}
expressions. Thus if cols is |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.
\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}
\multicolumn
has the cols specifier r with no
initial vertical bar. Between entry one and entry two there will be a
vertical rule; although the first cols does not have an ending
vertical bar, the second cols does have a starting one. Between
entry two and entry three there is a single vertical rule; despite that
the cols in both of the surrounding multicolumn
&textrsquo;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
cols in the entry three \multicolumn
leaves it out, and
that takes precedence. Finally, following entry four there is a
vertical rule because of the default.
tabular
definition&textrsquo;s default intercolumn
area specification, including the placement of vertical rules.
tabular
definition the first column
is specified to default to left justified but in the first row the entry
is centered with \multicolumn{1}{c}{\textsc{Period}}
.
Also in the first row, the second and third columns are spanned by a
single entry with \multicolumn{2}{c}{\textsc{Span}}
,
overriding the specification to center those two columns on the page
range en-dash.
\begin{tabular}{l|r&arobase;{--}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}
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&textrsquo;s because there is no vertical bar in the
cols part of the first row&textrsquo;s first \multicolumn
command.
\vline
tabular
or array
environment
extending the full height and depth of an entry&textrsquo;s row. Can also be
used in an &arobase;-expression, although its synonym vertical
bar |
is more common. This command is rarely used in the
body of a table; typically a table&textrsquo;s vertical lines are specified in
tabular
&textrsquo;s cols argument and overridden as needed with
\multicolumn
(\hfill
moves the \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 {c|cc}
specifier coming before the
one produced by the \vline\hfill
. In contrast, the first row&textrsquo;s
third entry shows the usual way to put a vertical bar between two
columns. In the second row, the ghi
is the widest entry in its
column so in the \vline\hfill
the \hfill
has no effect and
the vertical line in that entry appears immediately next to the
g
, with no whitespace.
\begin{tabular}{c|cc} x &\vline\hfill y &\multicolumn{1}{|r}{z} \\ % row 1 abc &def &\vline\hfill ghi % row 2 \end{tabular}
\cline
\cline{i-j}
array
or tabular
environment, draw a horizontal rule
beginning in column i and ending in column j. The
dash, -
, must appear in the mandatory argument. To span a single
column use the number twice, as with \cline{2-2}
.
\begin{tabular}{llrr} a &b &c &d \\ \cline{1-1} \cline{3-4} e &f &g &h \end{tabular}
\hline
tabular
or
array
environment. It&textrsquo;s most commonly used to draw a line at the
top, bottom, and between the rows of a table.
\hline
, the
tabular
second row&textrsquo;s line ending double backslash \\
is required.
\begin{tabular}{ll} \hline\hline Baseball &Red Sox \\ Basketball &Celtics \\ \hline \end{tabular}
thebibliography
thebibliography
thebibliography
\begin{thebibliography}{widest-label} \bibitem[label]{cite_key} ... \end{thebibliography}
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}
... based on \cite{latexdps}
produces the matching
... based on [1]. The second \cite
produces [1,
2]. You must compile the document twice to resolve these references.
\bibitem
commands. The tradition is to use 9
for bibliographies with less
than 10 references, 99
for ones with less than 100, etc.
\chapter
and the
default title is Bibliography, that title is in the macro
\bibname
. For \section
and the default is References, the
title is in macro \refname
. Change it by redefining the command,
as with \renewcommand{\refname}{Cited references}
, after
\begin{document}
.
babel
babel
babel
will automatically
redefine \refname
or \bibname
to fit the selected
language.
\bibitem
\bibitem{cite_key}
\bibitem[label]{cite_key}
enumi
counter. The citation key
enumi
counter is not incremented. With this
\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}
thebibliography
environment; see ... based on
\cite{latexdps}
will produce ... based on [Lamport 1994].
\bibitem
entries having a label with those that
do not then &latex; will number the unlabelled ones sequentially. In
the example above the texbook
entry will appear as [1]
Donald ..., despite that it is the second entry.
\bibitem
writes it to the auxiliary file
\bibcite{latexdps}{Lamport, 1993}
and
\bibcite{texbook}{1}
to appear in that file. The \begin{document}
command and then the
information is available for \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.
\bibitem
or
change its cite_key you may get LaTeX Warning: Label(s) may
have changed. Rerun to get cross-references right. Fix it by
recompiling.
\cite
\cite{keys}
\cite[subcite]{keys}
The ultimate source is \cite{texbook}. ... \begin{thebibliography} \bibitem{texbook} Donald Ervin Knuth. \textit{The \TeX book}. Addison-Wesley, Reading, Massachusetts, 1983. \end{thebibliography}
thebibliography
environment. More information in See 14.3 in \cite[p.~314]{texbook}
might produce
See 14.3 in [1, p. 314].
\cite
writes
information to the auxiliary file \cite{latexdps}
writes
\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 \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 \nocite
\nocite{keys}
thebibliography
(thebibliography
environment
directly (\bibliographystyle{bibstyle} \bibliography{bibfile1, bibfile2, ...}
\bibliography
command is what actually produces the
bibliography. Its argument is a comma-separated list, referring to
files named &arobase;book{texbook, title = {The {{\TeX}}book}, author = {D.E. Knuth}, isbn = {0201134489}, series = {Computers \& typesetting}, year = {1983}, publisher = {Addison-Wesley} } &arobase;book{sexbook, author = {W.H. Masters and V.E. Johnson}, title = {Human Sexual Response}, year = {1966}, publisher = {Bantam Books} }
\cite
and
\nocite
will be listed in the document&textrsquo;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.
\nocite
all keys\nocite
can also be
the single character *. This means to implicitly cite all
entries from all given bibliographies.
\bibliography
or \bibliographystyle
in your document (or, less likely, any \cite
or \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 \bibdata
\bibliography
\bibstyle
\bibliographystyle
\citation
\citation
\cite
, \nocite
\bibliographystyle
command, Bib&tex; complains as follows:
I found no \bibstyle command---while reading file document.aux
theorem
theorem
theorem
\begin{theorem} theorem body \end{theorem}
\newtheorem
(\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}
amsmath
amsmath
amsthm
amsthm
amsthm
and amsmath
from the American Mathematical Society. Among other things these
packages include a large number of options for theorem environments,
such as styling options.
titlepage
titlepage
titlepage
\begin{titlepage} ... text and spacing ... \end{titlepage}
\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}
titlepage
environment, use \maketitle
(verbatim
verbatim
verbatim
\begin{verbatim} literal-text \end{verbatim}
\
character does not start commands, it
produces a printed \, and carriage returns and blanks are taken
literally. The output appears in a monospaced typewriter-like font
(\tt
).
\begin{verbatim} Symbol swearing: %&$#?&eosexcl;. \end{verbatim}
literal-text
is that it cannot include
the string \end{verbatim}
.
cprotect
cprotect
\section
. This is not the same as
commands being fragile (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 cprotect
package can
help with this.
listings
listings
minted
minted
verbatim
environment. For
instance, one improvement is to allow the verbatim inclusion of external
files, or parts of those files. Such packages include listings
,
and minted
.
fancyvrb
fancyvrb
verbatimbox
verbatimbox
fancyvrb
. Another is verbatimbox
.
\verb
\verb char literal-text char \verb* char literal-text char
\tt
) font.
\verb
.
This is \verb!literally! the biggest pumpkin ever. And this is the best squash, \verb+literally!+
\verb
has its literal-text surrounded with
exclamation point, !
. The second instead uses plus, +
,
because the exclamation point is part of literal-text
.
\verb
or \verb*
and char,
or between char and literal-text, or between
literal-text and the second occurrence of char (the
synopsis shows a space only to distinguish one component from the
other). The delimiter must not appear in literal-text. The
literal-text cannot include a line break.
*
-form differs only in that spaces are printed with a visible
space character.
The command's first argument is \verb*!filename with extension! and ...
url
url
url
is a better option than the \verb
command, since
it allows line breaks.
listings
listings
minted
minted
\verb
. One is listings
, another is minted
.
cprotect
cprotect
\verb
in the argument to a macro, for instance in
the argument to a \section
. It is not a question of \verb
being fragile (\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 cprotect
package can help with this.
verse
verse
verse
\begin{verse} line1 \\ line2 \\ ... \end{verse}
Then plainly know my heart's dear love is set \\ On the fair daughter of rich Capulet.
verse
\\
, and use one or more
blank lines to separate the stanzas.
\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}
\\
\\ \\[morespace]
\\* \\*[morespace]
\title{My story: \\[0.25in] a tale of woe}
\\*
, tells &latex; not to start a new page
between the two lines, by issuing a \nobreak
.
\\
. Instead leave a
blank line between the two paragraphs. And don&textrsquo;t put in a sequence of
\\
&textrsquo;s to make vertical space. Instead use
\vspace{length}
, or
\leavevmode\vspace{length}
, or
\vspace*{length}
if you want the space to not be thrown
out at the top of a new page (\\
command is mostly used outside of the main flow of text
such as in a tabular
or array
environment or in an
equation environment.
\\
command is a synonym for \newline
(p{...}
column in a tabular
environment; \\
command is a macro, and its definition changes by context
so that its definition in normal text, a center
environment, a
flushleft
environment, and a tabular
are all different.
In normal text when it forces a linebreak it is essentially a shorthand
for \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.
\\
to ask for a new line, rather than to end the current line.
An example is if you have \begin{document}\\
or, more likely,
something like this.
\begin{center} \begin{minipage}{0.5\textwidth} \\ In that vertical space put your mark. \end{minipage} \end{center}
\vspace{\baselineskip}
.
\obeycr
& \restorecr
\obeycr
command makes a return in the input file (^^M,
internally) the same as \\
, followed by \relax
. So each
new line in the input will also be a new line in the output. The
\restorecr
command restores normal line-breaking behavior.
verbatim
(aaa bbb \obeycr ccc ddd eee \restorecr fff ggg hhh iii
aaa bbb ccc ddd eee fff ggg hhh iii
\newline
\newline
command is
equivalent to double-backslash (tabular
or
array
environment. In a column with a specifier producing a
paragraph box such as typically p{...}
, \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 \\
or its
equivalent \tabularnewline
.
\begin{tabular}{p{1in}&arobase;{\hspace{2in}}p{1in}} Name: \newline Address: &Date: \\ \hline \end{tabular}
\-
(discretionary hyphen)\-
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
(\-
command is for exceptional cases.
\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}
\-
command only allows &latex; to break there, it does not
require that it break there. You can force a split with something like
Hef-\linebreak feron
. Of course, if you later change the text
then this forced break may look very odd, so this approach requires
care.
\discretionary
(generalized hyphenation point)\discretionary{pre-break}{post-break}{no-break}
\discretionary
appears
then &tex; puts pre-break at the end of the current line and puts
post-break at the start of the next line. If there is no line
break here then &tex; puts no-break.
ffi
form a ligature. But
&tex; can nonetheless break between the two f&textrsquo;s with this.
di\discretionary{f-}{fi}{ffi}cult
\fussy
& \sloppy
\fussy
usually avoids too much space between
words, at the cost of an occasional overfull box. Conversely,
\sloppy
avoids overfull boxes while suffering loose interword
spacing.
\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 \par
or displayed
equation ending that paragraph. So to affect the line breaks, include
that paragraph-ending material in the scope of the command.
sloppypar
sloppypar
sloppypar
\begin{sloppypar} ... paragraphs ... \end{sloppypar}
\sloppy
in effect (\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}
\hyphenation
\hyphenation{word1 ...}
-
.
\hyphenation{hat-er il-lit-e-ra-ti tru-th-i-ness}
\hyphenation
commands accumulate.
\linebreak
& \nolinebreak
\linebreak \linebreak[zero-to-four]
\nolinebreak \nolinebreak[zero-to-four]
\nolinebreak[1]
is a suggestion that another place may be better.
The higher the number, the more insistent the request. Both commands
are fragile (\boilerplatelegal{} \linebreak[2] We especially encourage applications from members of traditionally underrepresented groups.
\linebreak
, the spaces in the line are stretched
out so that the break point reaches the right margin. \clearpage
& \cleardoublepage
\clearpage
\cleardoublepage
\cleardoublepage
also makes the next page of
content a right-hand page, an odd-numbered page, if necessary inserting
a blank page. The \clearpage
command is robust while
\cleardoublepage
is fragile (\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.
\let\origdoublepage\cleardoublepage \newcommand{\clearemptydoublepage}{% \clearpage {\pagestyle{empty}\origdoublepage}% }
\chapter
command to do this then
add the line \let\cleardoublepage\clearemptydoublepage
.
\newpage
(\newpage
ends the current column while
\clearpage
and \cleardoublepage
end the current page.
\newpage
\newpage
\clearpage
and \cleardoublepage
also
end the current page, in addition they clear pending floats
(\clearpage
and \cleardoublepage
end
the current page, possibly leaving an empty column, while
\newpage
only ends the current column.
\pagebreak
(\newpage
command will cause the new page to start right where
requested. This
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.
\newpage
does not vertically
stretch out the page, as \pagebreak
does.
\enlargethispage
\enlargethispage{size} \enlargethispage*{size}
\textheight
for the current page. The required
argument size must be a rigid length (\enlargethispage{\baselineskip}
\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 \pagebreak
.
\pagebreak
& \nopagebreak
\pagebreak \pagebreak[zero-to-four]
\nopagebreak \nopagebreak[zero-to-four]
\nopagebreak[1]
suggests to
&latex; that another spot might be preferable. The higher the number,
the more insistent the request. Both commands are fragile
(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.
\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 \flushbottom
is in effect
this can cause you to get Underfull \vbox (badness 10000) has
occurred while \output is active. \samepage
, which tries to only
allow a break between two paragraphs. There is a related environment
samepage
, also obsolete. Neither of these work reliably. For
more on keeping material on the same page, see the FAQ entry
Noe 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.}
\footnotemark
and
the \footnotetext
commands, which is useful in special
circumstances.
\footnote
\footnote{text} \footnote[number]{text}
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.''}
footnote
counter.
\renewcommand{\thefootnote}{\fnsymbol{footnote}}
, which
uses a sequence of symbols (\setcounter{footnote}{0}
.
slides
, where it does not appear) is: vertical thickness of
0.4pt
, and horizontal size of 0.4\columnwidth
long.
Change the rule with something like this.
\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
\footnotesize
fonts (\setlength{\footnotesep}{11pt}
.
\footnote
command is fragile (\footnote
; for instance, you cannot use it in an argument to a
sectioning command such as \chapter
(it can only be used in outer
paragraph mode; minipage
environment the \footnote
command uses the
mpfootnote
counter instead of the 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. \footnotemark
\footnotemark \footnotemark[number]
\footnotemark
without the optional argument then it
increments the footnote
counter, but if you use the optional
number then it does not. The next example produces several
consecutive footnote markers referring to the same footnote.
The first theorem\footnote{Due to Gauss.} and the second theorem\footnotemark[\value{footnote}] and the third theorem.\footnotemark[\value{footnote}]
\thanks
is a version of \footnote
), by-hand giving the
number of the footnote.
\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
\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.
cleveref
cleveref
hyperref
hyperref
cleveref
.
\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}
hyperref
hyperref
hyperref
.
\footnotetext
\footnotetext{text} \footnotetext[number]{text}
\footnotemark
(\section{Full sets\protect\footnote{This material due to ...}}
\section
\section[Please]{Please\footnote{% Don't footnote in chapter and section headers!}}
\protect
is needed in front of \footnote
here because
what gets moved to the table of contents is the optional argument.
tabular
or array
environment the \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
minipage
environment as here (\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}
minipage
, footnote marks are lowercase letters. Change
that with something like
\renewcommand{\thempfootnote}{\arabic{mpfootnote}}
(minipage
. To have them appear at the bottom of the main page, as
part of the regular footnote sequence, use the \footnotemark
and
\footnotetext
pair and make a new counter.
\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}
tablefootnote
tablefootnote
table
environment (tablefootnote
package.
\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}
bigfoot
bigfoot
bigfoot
extends &latex;&textrsquo;s default footnote mechanism in many
ways, including allow these two, as in this 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.}}
\newcommand
& \renewcommand
\newcommand{\cmd}{defn} \newcommand{\cmd}[nargs]{defn} \newcommand{\cmd}[nargs][optargdefault]{defn} \newcommand*{\cmd}{defn} \newcommand*{\cmd}[nargs]{defn} \newcommand*{\cmd}[nargs][optargdefault]{defn}
\renewcommand{\cmd}[nargs]{defn} \renewcommand{\cmd}[nargs]{defn} \renewcommand{\cmd}[nargs][optargdefault]{defn} \renewcommand*{\cmd}{defn} \renewcommand*{\cmd}[nargs]{defn} \renewcommand*{\cmd}[nargs][optargdefault]{defn}
\DeclareRobustCommand
in \long
). With the default form, arguments can be
multiple paragraphs.
{}
after the command
(\cmd{} , and another solution is to use an explicit control
space (\cmd\ ).
\newcommand{\RS}{Robin Smith}
results in \RS
being
replaced by the longer text. Redefining an existing command is similar:
\renewcommand{\qedsymbol}{{\small QED}}
.
\newcommand{\student}{Ms~O'Leary} \newcommand{\defref}[1]{Definition~\ref{#1}}
I highly recommend \student{} to you
. The
second has a variable argument, so that \defref{def:basis}
expands to
Definition~\ref{def:basis}
, which ultimately expands to
something like Definition~3.14.
\newcommand{\nbym}[2]{$#1 \times #2$}
is invoked as
\nbym{2}{k}
.
\newcommand{\salutation}[1][Sir or Madam]{Dear #1:}
\salutation
gives Dear Sir or Madam: while
\salutation[John]
gives Dear John:. And
\salutation[]
gives Dear :.
\newcommand{\lawyers}[3][company]{#2, #3, and~#1} I employ \lawyers[Howe]{Dewey}{Cheatem}.
Howe
, is associated with #1
, while
Dewey
and Cheatem
are associated with #2
and #3
. Because of the optional argument,
\lawyers{Dewey}{Cheatem}
will give the output I employ
Dewey, Cheatem, and company.
\newcommand{\shipname}[1]{\it #1}
, in this sentence,
The \shipname{Monitor} met the \shipname{Merrimac}.
\newcommand{\shipname}[1]{{\it #1}}
.
\
, it
will handle the following characters in a special way in order to make a
control sequence token.
\
followed by at least one ASCII letter, followed by at least one
blank. The sequence of at least one ASCII letter is called the
control sequence name.
\
followed by one non-letter character.
\relax
command does nothing, the following will print
Hello!Hel\relaxlo!
\relax
, including the newline are
ignored, and blanks at the beginning of a line are also ignored
(\providecommand
\providecommand{\cmd}{defn} \providecommand{\cmd}[nargs]{defn} \providecommand{\cmd}[nargs][optargdefault]{defn} \providecommand*{\cmd}{defn} \providecommand*{\cmd}[nargs]{defn} \providecommand*{\cmd}[nargs][optargdefault]{defn}
\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.
\providecommand{\myaffiliation}{Saint Michael's College} \providecommand{\myaffiliation}{Lyc\'ee Henri IV} From \myaffiliation.
\newcommand
,
the repeated use of \providecommand
does not give an error.
\makeatletter
& \makeatother
\makeatletter ... definition of commands with &arobase; in their name .. \makeatother
&arobase;
. The \makeatletter
declaration makes the at-sign character have the category code of a
letter, code 11. The \makeatother
declaration sets the
category code of the at-sign to code 12, its default value.
\
the catcode 0. Command names
consist of a category 0 character, ordinarily backslash, followed
by letters, category 11 characters (except that a command name can
also consist of a category 0 character followed by a single
non-letter symbol).
&arobase;
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 12.
\makeatletter
and \makeatother
inside a
&arobase;
, by having them surround your
definition. Don&textrsquo;t use these inside \usepackage
and \documentclass
commands already
arrange that the at-sign has the character code of a letter,
catcode 11.
macros2e
macros2e
\thesis&arobase;universityname
that the user wants to change. These
three lines should go in the preamble, before the
\begin{document}
.
\makeatletter \renewcommand{\thesis&arobase;universityname}{Saint Michael's College} \makeatother
\&arobase;ifstar
\newcommand{\mycmd}{\&arobase;ifstar{\mycmd&arobase;star}{\mycmd&arobase;nostar}} \newcommand{\mycmd&arobase;nostar}[nostar-num-args]{nostar-body} \newcommand{\mycmd&arobase;star}[star-num-args]{star-body}
*
, an asterisk.
Examples are the table
and table*
environments and the
\section
and \section*
commands.
\newenvironment
and \renewenvironment
allow the
environment name to contain a star. So you just have to write
\newenvironment{myenv}
or
\newenvironment{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 \mycmd
, which
peeks ahead to see if it is followed by a star. For instance, &latex;
does not really have a \section*
command; instead, the
\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 \mycmd&arobase;nostar
and
\mycmd&arobase;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 &arobase;
in its name must be
enclosed inside a \makeatletter ... \makeatother
block
(\&arobase;ifstar
defines the command \ciel
and a
variant \ciel*
. Both have one required argument. A call to
\ciel{blue}
will return "not starry blue sky" while
\ciel*{night}
will return "starry night sky".
\makeatletter \newcommand*{\ciel&arobase;unstarred}[1]{not starry #1 sky} \newcommand*{\ciel&arobase;starred}[1]{starry #1 sky} \newcommand*{\ciel}{\&arobase;ifstar{\ciel&arobase;starred}{\ciel&arobase;unstarred}} \makeatother
``My name is \agentsecret*{Bond},
\agentsecret{James}{Bond}.''
is equivalent to entering the commands
``My name is \textsc{Bond}, \textit{James} textsc{Bond}.''
\newcommand*{\agentsecret&arobase;unstarred}[2]{\textit{#1} \textsc{#2}} \newcommand*{\agentsecret&arobase;starred}[1]{\textsc{#1}} \newcommand*{\agentsecret}{% \&arobase;ifstar{\agentsecret&arobase;starred}{\agentsecret&arobase;unstarred}}
\agentsecret*{Bond}
and
\agentsecret * {Bond}
are equivalent. However, the
standard practice is not to insert any such spaces.
suffix
suffix
xparse
xparse
\&arobase;ifstar
. (1) The suffix
package allows the
construct \newcommand\mycommand{unstarred-variant}
followed by
\WithSuffix\newcommand\mycommand*{starred-variant}
.
(2) &latex; provides the xparse
package, which allows
this code:
\NewDocumentCommand\foo{s}{\IfBooleanTF#1 {starred-variant}% {unstarred-variant}% }
\newcounter
: Allocating a counter\newcounter{countername} \newcounter{countername}[supercounter]
[supercounter]
then the
counter countername will be reset to zero whenever
supercounter is incremented. For example, ordinarily
subsection
is numbered within section
so that any time you
increment section, either with \stepcounter
(\refstepcounter
(\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}.
asuper
twice, then you get something like LaTeX Error: Command \c&arobase;asuper
already defined. Or name \end... illegal, see p.192 of the manual..
\newcounter{jh}[lh]
when lh
is not a
defined counter will get you LaTeX Error: No counter 'lh'
defined.
\newlength
\newlength{\len}
\len
has to be a control sequence (\
under
normal circumstances. The new register holds rubber lengths such as
72.27pt
or 1in plus.2in minus.1in
(a &latex; length
register is what plain &tex; calls a skip
register). The
initial value is zero. The control sequence \len
must not
be already defined.
\newlength{\graphichgt}
\newsavebox
\newsavebox{\cmd}
\newsavebox{\logobox} \savebox{\logobox}{LoGo} Our logo is \usebox{\logobox}.
\newenvironment
& \renewenvironment
\newenvironment{env}{begdef}{enddef} \newenvironment{env}[nargs]{begdef}{enddef} \newenvironment{env}[nargs][optargdefault]{begdef}{enddef} \newenvironment*{env}{begdef}{enddef} \newenvironment*{env}[nargs]{begdef}{enddef} \newenvironment*{env}[nargs][optargdefault]{begdef}{enddef}
\renewenvironment{env}{begdef}{enddef} \renewenvironment{env}[nargs]{begdef}{enddef} \renewenvironment{env}[nargs][optargdefault]{begdef}{enddef} \renewenvironment*{env}{begdef}{enddef} \renewenvironment*{env}[nargs]{begdef}{enddef} \renewenvironment*{env}[nargs][optargdefault]{begdef}{enddef}
\begin{env} ... body ... \end{env}
.
*
-form of environment commands\small
is limited to
the quote and does not extend to material following the environment.
quotation
except that it will be set in smaller type.
\newenvironment{smallquote}{% \small\begin{quotation} }{% \end{quotation} }
\newenvironment{point}[1]{% \noindent\textbf{#1} }{% }
\newenvironment{citequote}[1][Shakespeare]{% \begin{quotation} \noindent\textit{#1}: }{% \end{quotation} }
\begin{citequote}[Lincoln] ... \end{citequote}
\newsavebox{\quoteauthor} \newenvironment{citequote}[1][Shakespeare]{% \sbox\quoteauthor{#1}% \begin{quotation} }{% \hspace{1em plus 1fill}---\usebox{\quoteauthor} \end{quotation} }
\newtheorem
\newtheorem{name}{title} \newtheorem{name}{title}[numbered_within] \newtheorem{name}[numbered_like]{title}
\newtheorem{name}{title}
, creates
an environment that will be labelled with title; see the first
example below.
\newtheorem{name}{title}[numbered_within]
,
creates an environment whose counter is subordinate to the existing
counter numbered_within, so this counter will be reset when
numbered_within is reset. See the second example below.
\newtheorem{name}[numbered_like]{title}
,
with optional argument between the two required arguments, creates an
environment whose counter will share the previously defined counter
numbered_like. See the third example.
\ref
value will be that of
\thenumbered_within
(\newtheorem{defn}{Definition} \begin{document} \section{...} \begin{defn} First def \end{defn} \section{...} \begin{defn} Second def \end{defn}
\newtheorem
&textrsquo;s optional argument numbered_within is given as
section
, so the output is like Definition 1.1 and
Definition 2.1.
\newtheorem{defn}{Definition}[section] \begin{document} \section{...} \begin{defn} First def \end{defn} \section{...} \begin{defn} Second def \end{defn}
thm
environment to use the same
counter as defn
. It gives Definition 1.1, followed
by Theorem 2.1 and Definition 2.2.
\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}
\newfont
\newfont{\cmd}{font description}
\cmd
that will change the current font.
The control sequence must not already be defined. It must begin with a
backslash, \
.
at dimen
or scaled factor
, where a
factor of 1000 means no scaling. For &latex;&textrsquo;s purposes,
all this does is scale all the character and other font dimensions
relative to the font&textrsquo;s design size, which is a value defined in the
\newfont{\testfontat}{cmb10 at 11pt} \newfont{\testfontscaled}{cmb10 scaled 1100} \testfontat abc \testfontscaled abc
\protect
\protect
.
\section{section
name}
command it writes the section name text to the
\caption{...}
command (\thanks{...}
command
(tabular
and
array
environments (\protect
. Every fragile commands must be
protected with their own \protect
.
\protect
command doesn&textrsquo;t hurt, length
commands are robust and should not be preceded by a \protect
command. Nor can a \protect
command be used in the argument to
\addtocounter
or \setcounter
command.
\caption
command gives a mysterious error
about an extra curly brace. Fix the problem by preceding each
\raisebox
command with \protect
.
\begin{figure} ... \caption{Company headquarters of A\raisebox{1pt}{B}\raisebox{-1pt}{C}} \end{figure}
\tableofcontents
command gives an error
because the \(..\)
in the section title expands to illegal &tex;
in the \(..\)
to \protect\(..\protect\)
.
\begin{document} \tableofcontents ... \section{Einstein's \( e=mc^2 \)} ...
\ignorespaces & \ignorespacesafterend
\ignorespaces
\ignorespacesafterend
\ignorespaces
is often used when defining commands via
\newcommand
, or \newenvironment
, or \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 enumerate
list, users must not put any space between
the command and the question text.
\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}
\newcommand{\points}[1]{% \makebox[0pt]{\makebox[10em][l]{#1~pts}}\ignorespaces}
\fullname
will reproduce that.
\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}
\newcommand{\fullname}[1]{\ignorespaces\honorific~#1}
.
\ignorespaces
is also often used in a \newenvironment
at the end of the begin clause, as in
\begin{newenvironment}{env
name}{... \ignorespaces}{...}
.
\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.
\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}
%
immediately after the
\end{eq}
will make the vertical space disappear, but that is
inconvenient. The solution is to change to
\newenvironment{eq}{\begin{equation}}{\end{equation}\ignorespacesafterend}
.
xspace
xspace
\usepackage{xspace} ... \newcommand{...}{...\xspace}
\xspace
macro, when used at the end of a command definition,
adds a space unless the command is followed by certain punctuation
characters.
\$
), &tex;
gobbles blank characters. Thus, in the first sentence below, the output
has Vermont placed snugly against the period, without any
intervening space.
\newcommand{\VT}{Vermont} Our college is in \VT . The \VT{} summers are nice.
\
for this. xspace
package provides \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.
\newcommand{\VT}{Vermont\xspace} Our college is in \VT . \VT summers are nice.
,.'/?;:!~-)
,
the open curly brace and the backslash-space command discussed above,
and the commands \footnote
or \footnotemark
. Add to that
list as with \xspaceaddexceptions{\myfni \myfnii}
which adds
\myfni
and \myfnii
to the list, and remove from that
list as with \xspaceremoveexception{!}
.
\xspace
. Putting it in
a definition means that the command will usually get the spacing right.
But it isn&textrsquo;t easy to predict when to enter empty braces because
\xspace
will get it wrong, such as when it is followed by another
command, and so \xspace
can make editing material harder and more
error-prone than instead always inserting the empty braces.
\
. Thus, associated with
the \chapter
command is the chapter
counter that keeps
track of the chapter number.
part paragraph figure enumi chapter subparagraph table enumii section page footnote enumiii subsection equation mpfootnote enumiv subsubsection
mpfootnote
counter is used by the \footnote
command
inside of a minipage (enumi
through enumiv
are used in the enumerate
environment, for
up to four levels of nesting (\newcounter
. \alph \Alph \arabic \roman \Roman \fnsymbol
: Printing counters\alph{counter}
in your source will result in a lowercase
letter a appearing in the output.
\alph{enumi}
. Note that the counter name does not
start with a backslash.
\ast
\dagger
\ddagger
\S
\P
\parallel
\ast\ast
\dagger\dagger
\ddagger\ddagger
\usecounter
\usecounter{counter}
list
environment
(\item
is called without its optional argument then
counter is incremented by \refstepcounter
, making its value
be the current ref
value (\newcounter{testcounter} \newenvironment{test}{% \begin{list}{}{% \usecounter{testcounter} } }{% \end{list} }
\value
\value{counter}
\newcounter{test} \setcounter{test}{5} \newcounter{other} \setcounter{other}{\value{test}} \addtocounter{test}{1} Test counter is \arabic{test}. Other counter is \arabic{other}.
\value
command is not used for typesetting the value of the
counter. For that, see \setcounter
or \addtocounter
but
\value
can be used anywhere that &latex; expects a number, such
as in \hspace{\value{foo}\parindent}
. It must not be
preceded by \protect
(\hspace{4\parindent}
.
\setcounter{myctr}{3} \addtocounter{myctr}{1} \hspace{\value{myctr}\parindent}
\setcounter
\setcounter{counter}{value}
\setcounter{section}{5}
. Note that the
counter name does not start with a backslash.
theorem
has value 12 then the
second line will print XII.
\setcounter{exercise}{\value{theorem}} Here it is in Roman: \Roman{exercise}.
\addtocounter
\addtocounter{counter}{value}
\setcounter{section}{5} \addtocounter{section}{2} Here it is in Roman: \Roman{section}.
\refstepcounter
\refstepcounter{counter}
\stepcounter
(\ref
value
to be the result of \thecounter
.
\ref
value is set
locally, i.e., inside the current group.
\stepcounter
\stepcounter{counter}
\refstepcounter
in that this one does
not influence references; that is, it does not define the current
\ref
value to be the result of \thecounter
(\day
& \month
& \year
\day
for the day of the month
(nominally with value between 1 and 31), \month
for the month of
the year (nominally with value between 1 and 12), and \year
for
the year. When &tex; starts up, they are set from the current values
on the system. The related command \today
produces a string
representing the current day (\day=-2 \month=13 \year=-4 \today
10pt
does not contain a plus
or minus
component. (Plain
&tex; calls this a dimen.) A rubber length (what plain
&tex; calls a skip or glue) such as with 1cm
plus0.05cm minus0.01cm
can contain either or both of those
components. In that rubber length, the 1cm
is the natural
length while the other two, the plus
and minus
components, allow &tex; to stretch or shrink the length to optimize
placement.
% 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}}}
XXX\showhbox{100pt}{\blackbar{100pt}}YYY
1cm minus
0.05cm
, the natural length is 1XXX\showhbox{300pt}{% \blackbar{101pt}\hspace{100pt minus 2pt}\blackbar{101pt}}YYY XXX\showhbox{300pt}{% \blackbar{105pt}\hspace{100pt minus 1pt}\blackbar{105pt}}YYY
XXX\showhbox{300pt}{% \blackbar{95pt}\hspace{100pt plus 10pt}\blackbar{95pt}}YYY XXX\showhbox{300pt}{% \blackbar{95pt}\hspace{100pt plus 1pt}\blackbar{95pt}}YYY
1ex plus 0.05ex minus 0.02ex
.
XXX\showhbox{300pt}{% \blackbar{100pt}% left \hspace{0pt plus 50pt}\blackbar{80pt}\hspace{0pt plus 10pt}% middle \blackbar{100pt}}YYY % right
\hspace
&textrsquo;s must stretch 20 points. Because the two are
plus 50pt
and plus 10pt
, &tex; gets 5/6 of the stretch
from the first space and 1/6 from the second.
plus
or minus
component of a rubber length can contain
a fill component, as in 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.
\begin{minipage}{\linewidth} \hspace{0pt plus 1fill}\includegraphics{godel.png}% \hspace{0pt plus 1fill}\includegraphics{einstein.png}% \hspace{0pt plus 1fill} \end{minipage}
fil
,
fill
, and filll
. The later ones are more infinite than
the earlier ones. Ordinarily document authors only use the middle one
(\setlength{\ylength}{1in plus 0.2in}
and
\setlength{\zlength}{3\ylength}
then the value of
\zlength
is 3in
.
\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.
\setlength
\setlength{\len}{amount}
\len
has to be a control sequence (\
under
normal circumstances. The amount can be a rubber length
(I told the doctor I broke my leg in two places. \setlength{\parindent}{0em} He said stop going to those places.
\newlength
, for example if
you mistype it as in
\newlength{\specparindent}\setlength{\sepcparindent}{...}
,
then you get an error like Undefined control sequence. <argument>
\sepcindent. If you omit the backslash at the start of the length name
then you get an error like Missing number, treated as zero..
\addtolength
\addtolength{\len}{amount}
\len
has to be a control sequence (\
under
normal circumstances. The amount is a rubber length
(\parskip
starts with the value 0pt plus 1pt
Doctor: how is the boy who swallowed the silver dollar? \addtolength{\parskip}{1pt} Nurse: no change.
1pt plus 1pt
for the second paragraph.
\newlength
, for example if
you mistype it as in
\newlength{\specparindent}\addtolength{\sepcparindent}{...}
,
then you get an error like Undefined control sequence. <argument>
\sepcindent. If the amount uses some length that has not been
declared, for instance if for example you mistype the above as
\addtolength{\specparindent}{0.6\praindent}
, then you get
something like Undefined control sequence. <argument> \praindent.
If you leave off the backslash at the start of \len, as in
\addtolength{parindent}{1pt}
, then you get something like
You can't use `the letter p' after \advance.
\settodepth
\settodepth{\len}{text}
\len
has to be a control sequence (\
under normal circumstances.
\newlength{\alphabetdepth} \settodepth{\alphabetdepth}{abcdefghijklmnopqrstuvwxyz} \the\alphabetdepth
\newlength
, if for example you
mistype the above as \settodepth{\aplhabetdepth}{abc...}
,
then you get something like Undefined control sequence. <argument>
\aplhabetdepth. If you leave the backslash out of \len, as in
\settodepth{alphabetdepth}{...}
then you get something like
Missing number, treated as zero. <to be read again> \setbox.
\settoheight
\settoheight{\len}{text}
text
argument. The length name \len
has to be a control sequence (\
under normal circumstances.
\newlength{\alphabetheight} \settoheight{\alphabetheight}{abcdefghijklmnopqrstuvwxyz} \the\alphabetheight
\newlength
, if
for example you mistype as
\settoheight{\aplhabetheight}{abc...}
, then you get something
like Undefined control sequence. <argument> \alphabetheight. If
you leave the backslash out of \len, as in
\settoheight{alphabetheight}{...}
then you get something like
Missing number, treated as zero. <to be read again> \setbox.
\settowidth
\settowidth{\len}{text}
\len
has to be a control sequence (\
under normal circumstances.
\newlength{\alphabetwidth} \settowidth{\alphabetwidth}{abcdefghijklmnopqrstuvwxyz} \the\alphabetwidth
\newlength
,
if for example you mistype the above as
\settowidth{\aplhabetwidth}{abc...}
, then you get something
like Undefined control sequence. <argument> \aplhabetwidth. If
you leave the backslash out of \len, as in
\settoheight{alphabetwidth}{...}
then you get something like
Missing number, treated as zero. <to be read again> \setbox.
\stretch
\stretch{number}
\fill
units of stretchability (\rule{0.4pt}{1ex}\hspace{\stretch{1.5}}% \rule{0.4pt}{1ex}\hspace{\stretch{1}}% \rule{0.4pt}{1ex}
\newenvironment{dedication}{% in document preamble \clearpage\thispagestyle{empty}% \vspace*{\stretch{1}} % stretchable space at top \it }{% \vspace{\stretch{3}} % space at bot is 3x as at top \clearpage } ... \begin{dedication} % in document body We dedicate this book to our wives. \end{dedication}
\numexpr expression \dimexpr expression \glueexpr expression \muglue expression
\the\dimexpr\linewidth-4pt\relax
will
produce as output the length that is four points less than width of a
line (the only purpose of \the
is to show the result in the
document). Analogously, \romannumeral\numexpr6+3\relax
will
produce ix, and \the\glueexpr 5pt plus 1pt * 2 \relax
will produce 10.0pt plus 2.0pt.
\advance
, etc., is that the evaluation of expressions
does not involve assignments and can therefore be performed in places
where assignments are not allowed. The next example computes the width
of the \parbox
.
\newlength{\offset}\setlength{\offset}{2em} \begin{center} \parbox{\dimexpr\linewidth-\offset*3}{With malice toward none with charity for all with firmness in the right as God gives us to see the right let us strive on to finish the work we are in to bind up the nation's wounds, to care for him who shall have borne the battle and for his widow and his orphan \textasciitilde\ to do all which may achieve and cherish a just and lasting peace among ourselves and with all nations. ---Abraham Lincoln, Second Inaugural Address, from the memorial} \end{center}
\numexpr
produces an integer, \dimexpr
produces a dimension, etc.
\dimexpr\linewidth-3*\offset
gives the error Illegal unit
of measure (pt inserted)
. This is because for \dimexpr
and
\glueexpr
, the input consists of a dimension or glue value
followed by an optional multiplication factor, and not the other way
around. Thus \the\dimexpr 1pt*10\relax
is valid and produces
10.0pt, but \the\dimexpr 10*1pt\relax
gives the
Illegal unit
error.
\relax
(which will be absorbed), or up to the first
non-valid token. Thus, \the\numexpr2+3px
will print
5px, because &latex; reads the \numexpr2+3
, which is
made up of numbers, and then finds the letter p
, which cannot
be part of a number. It therefore terminates the expression and
produces the 5, followed by the regular text px.
\ifnum\numexpr\parindent*2 < 10pt Yes\else No\fi
, the less than
sign terminates the expression and the result is No (in a
standard &latex; article).
+
, -
, *
and
/
along with parentheses for subexpressions, (...)
. In
glue expressions the plus
and minus
parts do not need
parentheses to be affected by a factor. So \the\glueexpr 5pt plus
1pt * 2 \relax
results in 10pt plus 2pt.
\the\numexpr\dimexpr
1pt\relax\relax
will result in 65536, which is 1pt
converted to scaled points (sp
\glueexpr
here, the stretch and shrink would be dropped. Going
the other way, a \numexpr
inside a \dimexpr
or
\glueexpr
will need appropriate units, as in
\the\dimexpr\numexpr 1 + 2\relax pt\relax
, which produces
3.0pt.
mu
, or fil
, etc. The
arithmetic operations are performed individually, except for a scaling
operation (a multiplication immediately followed by a division) which
is done as one combined operation with a 64-bit product as
intermediate value. The result of each operation is again checked to
be in the allowed range.
\divide
, which truncates). Thus
\the\dimexpr 5pt*(3/2)\relax
puts 10.0pt in the document,
because it rounds 3/2
to 2
, while
\the\dimexpr 5pt*(4/3)\relax
produces 5.0pt.
It is a truth universally acknowledged, that a single man in possession of a good fortune, must be in want of a wife. However little known the feelings or views of such a man may be on his first entering a neighbourhood, this truth is so well fixed in the minds of the surrounding families, that he is considered the rightful property of some one or other of their daughters. ``My dear Mr. Bennet,'' said his lady to him one day, ``have you heard that Netherfield Park is let at last?''
%
and
span up to the end of line. In the following example the two columns
are identical:
\documentclass[twocolumn]{article} \begin{document} First paragraph. Second paragraph. \newpage First paragraph. % separator lines may contain blank characters. Second paragraph. \end{document}
\end{equation}
\begin{equation} 2^{|S|} > |S| \end{equation}
\section
argument
\section{aaa bbb}
\par
\par
, \par
\par
command is entirely equivalent. This
command is robust (\par
rather than a blank line simply for
readability.
\newcommand{\syllabusLegalese}{% \whatCheatingIs\par\whatHappensWhenICatchYou}
\par
command does nothing and is ignored. In
paragraph mode, the \par
command terminates paragraph mode,
switching &latex; to vertical mode (\par
command in a math mode. You also cannot
use it in the argument of many commands, such as the sectioning
commands, e.g.&noeos; \section
(\par
command is not the same as the \paragraph
command. The latter is, like \section
or \subsection
, a
sectioning command used by the &latex; document standard classes
(\par
command is not the same as \newline
or the line
break double backslash, \\
. The difference is that \par
ends the paragraph, not just the line, and also triggers the addition of
the between-paragraph vertical space \parskip
(xyz \setlength{\parindent}{3in} \setlength{\parskip}{5in} \noindent test\indent test1\par test2
\indent
& \noindent
\indent
\noindent
\indent
command
first outputs an empty box whose width is \parindent
. These
commands are robust (\par
. To
start a paragraph without an indent, or to continue an interrupted
paragraph, use \noindent
.
\noindent
command has no effect,
because &latex; is already in horizontal mode there. The
\indent
command&textrsquo;s only effect is to output a space.
... end of the prior paragraph. \noindent This paragraph is not indented.
The data \begin{center} \begin{tabular}{rl} ... \end{tabular} \end{center} \noindent shows this clearly.
\setlength{\parindent}{0pt}
in the preamble. If you do that,
you may want to also set the length of spaces between paragraphs,
\parskip
(indentfirst
indentfirst
indentfirst
.
\parindent
& \parskip
\setlength{\parindent}{horizontal len} \setlength{\parskip}{vertical len}
\setlength{\parindent}{0em} \setlength{\parskip}{1ex}
\parindent
in one-column documents is 15pt
when the
default text size is 10pt
, 17pt
for 11pt
, and
1.5em
for 12pt
. In two-column documents it is 1em
.
(These values are set before &latex; calls \normalfont
so
em
is derived from the default font, Computer Modern. If you use
a different font then to set \parindent
to 1\AtBeginDocument{\setlength{\parindent}{1em}}
in the
preamble.)
\parskip
in &latex;&textrsquo;s standard document
classes is 0pt plus1pt
.
\marginpar{right} \marginpar[left]{right}
\marginpar
occurs.
\reversemarginpar
(see below). If you are using one-sided layout (document option
oneside
) then it goes in the right margin. If you are using
two-sided layout (document option twoside
) then it goes in the
outside margin. If you are in two-column layout (document option
twocolumn
) then it goes in the nearest margin.
\reversemarginpar
then &latex; will place
subsequent marginal notes in the opposite margin to that given in the
prior paragraph. Revert that to the default position with
\normalmarginpar
.
\hspace{0pt}
.
math
math
displaymath
displaymath
equation
equation
The wave equation for \( u \) is \begin{displaymath} \frac{\partial^2u}{\partial t^2} = c^2\nabla^2u \end{displaymath} where \( \nabla^2 \) is the spatial Laplacian and \( c \) is constant.
\(
and finished by the matching ending \)
.
Display math mode is for displayed equations and here is invoked by the
displaymath
environment. Note that any mathematical text
whatever, including mathematical text consisting of just one character,
is handled in math mode.
contrast x+y with \( x+y \)
\( mathematical material \) $ mathematical material $ \begin{math} mathematical material \end{math}
\(x\) and $y$
. You can use these in paragraph
mode or in LR mode (\begin{displaymath} mathematical material \end{displaymath}
\begin{equation} mathematical material \end{equation}
equation
environment, &latex; puts a formula number
alongside the formula. The construct \[ math \]
is
equivalent to \begin{displaymath} math
\end{displaymath}
. These environments can only be used in paragraph
mode (amsmath
amsmath
amsfonts
amsfonts
mathtools
mathtools
amsmath
and amssymb
(also be aware of the mathtools
package that is an extension to, and loads, amsmath
). New
documents that will have mathematical text should use these packages.
Descriptions of these packages is outside the scope of this document;
see their documentation on CTAN.
base^exp base^{exp}
base_exp base_{exp}
^
) or a subscript (with
underscore, _
).
0
&textrsquo;s and 1
&textrsquo;s are subscripts while the
2
&textrsquo;s are superscripts.
\( (x_0+x_1)^2 \leq (x_0)^2+(x_1)^2 \)
e^{-2x}
.
This example&textrsquo;s fourth line shows curly braces used to group an expression
for the exponent.
\begin{displaymath} (3^3)^3=27^3=19\,683 \qquad 3^{(3^3)}=3^{27}=7\,625\,597\,484\,987 \end{displaymath}
e^{x^2}
and x_{i_0}
give correct
output. Note the use in those expressions of curly braces to give the
base a determined exp. If you enter \(3^3^3\)
then
you get Double superscript.
\begin{displaymath} \int_{x=a}^b f'(x)\,dx = f(b)-f(a) \end{displaymath}
x=a
to make the entire expression a
subscript.
{}_t K^2
. The empty curly braces {}
give the
subscript something to attach to and keeps it from accidentally
attaching to a prior symbols.
the expression x^2
, will get you
the error Missing $ inserted.
mhchem
mhchem
mhchem
; see CTAN.
comprehensive
comprehensive
$\pi$
in your source,
you will get the pi symbol 03C0. See the &textldquo;Comprehensive
&latex; Symbol List&textrdquo; package at
\parallel
.
<
and angle bracket \langle
.
*
, which is often a superscript or
subscript, as in the Kleene star. Similar: \star
, which is
five-pointed, and is sometimes used as a general binary operation, and
sometimes reserved for cross-correlation.
\setminus
, and
\textbackslash
for backslash outside of math mode.
\cap
.
\circ
.
\cup
.
\top
.
amssymb
package.
\cdot
.
\bigcap
.
\bullet
.
\bigcirc
.
$S^\complement$
(ordinary). Not available in plain &tex;. In &latex; you need to load the amssymb
package. Also used:
$S^{\mathsf{c}}$
or $\bar{S}$
.
\bigcup
.
\vdash
.
amssymb
package.
\Diamond
, circle bullet \bullet
.
\Doteq
.
\Downarrow
double line down arrow.
\downarrow
single line down arrow.
\varnothing
.
\varepsilon
03B5. Related:
the set membership relation \in
2208.
\geq
.
\ge
.
\leftarrow
.
\ll
.
\Longleftrightarrow
with a \thickmuskip
on either side.
\Re
.
\epsilon
03F5 and small letter script
epsilon \varepsilon
.
\wedge
.
See also logical or \lor
.
<
. Matches \rangle
.
\{
. Matches \rbrace
.
[
. Matches \rbrack
.
\rceil
.
\leq
.
\newcommand*{\Leadsto}{\ensuremath{\leadsto}}
in the
preamble and then use \Leadsto
instead.
\leftarrow
.
\gets
. Similar: double-line left
arrow \Leftarrow
.
\leftrightarrow
.
\Leftrightarrow
.
\le
.
\floor
.
amssymb
and use \vartriangleleft
(which is a relation
and so gives better spacing).
\gg
.
\neg
.
\Longleftarrow
.
\Longleftrightarrow
.
\mapsto
.
\Longrightarrow
.
\vee
.
See also logical and \land
.
\longmapsto
.
\mid
is for a set \{\, x \mid x\geq 5 \,\}
.
\vert
and |
produce the same single-line
vertical bar symbol but without any spacing (they fall in class
ordinary) and you should not use them as relations but instead only as
ordinals, i.e., footnote symbols. For absolute value, see the entry
for \vert
and for norm see the entry for \Vert
.
\vDash
.
\neq
.
\lnot
. Sometimes instead used for
negation: \sim
.
\ne
.
\owns
. Similar: is a member
of \in
.
\not
,
particularly with the amssymb
package. For example, \notin
is typographically preferable to \not\in
.
\nsubseteq
.
\bigodot
.
\bigoplus
.
\bigotimes
.
\ni
. Similar: is a member
of \in
.
\|
.
\bot
uses the
same glyph but the spacing is different because it is in the class
ordinary.
\varphi
03C6.
\varpi
03D6.
<
.
\leq
.
$f^\prime$
; $f^\prime$
and $f'$
produce the same result. An advantage of the second
is that $f'''$
produces the desired symbol, that is, the same
result as $f^{\prime\prime\prime}$
, but uses rather less
typing. You can only use \prime
in math mode. Using the right
single quote '
in text mode produces a different character
(apostrophe).
>
. Matches:\langle
.
\}
. Matches \lbrace
.
]
. Matches \lbrack
.
\lceil
.
\mathbb{R}
; to access
this, load the amsfonts
package.
\upharpoonright
. Not available in plain &tex;. In &latex; you need to load the amssymb
package.
\varnothing
. Not available in plain &tex;. In &latex; you need to load the \lfloor
.
amssymb
and use \vartriangleright
(which is a
relation and so gives better spacing).
\varrho
03F1.
\rightarrow
.
\to
. Similar: right double line
arrow \Rightarrow
.
\backslash
and also
\textbackslash
outside of math mode.
\varsigma
03C2.
cap
.
cup
. Related: variable-sized
operator \bigsqcup
.
\subset
. Not available in plain &tex;. In &latex; you need to load the amssymb
package.
\subseteq
.
\supset
. Not available in plain &tex;. In &latex; you need to load the amssymb
package.
\supseteq
.
*
and \ast
, which
are six-pointed, and more often appear as a superscript or subscript,
as with the Kleene star.
>
.
\leq
.
\Sigma
.
\sqrt{...}
typesets the square root of the argument, with a bar
that extends to cover the argument.
\vartheta
03D1.
\cdot
.
\rightarrow
.
\bot
.
\lhd
. For the normal subgroup symbol you
should load amssymb
and use \vartriangleleft
(which
is a relation and so gives better spacing).
amssymb
and use \vartriangleright
(which is a
relation and so gives better spacing).
amssymb
and
use \vartrianglelefteq
(which is a relation and so gives
better spacing).
amssymb
and
use \vartrianglerighteq
(which is a relation and so gives
better spacing).
\uparrow
.
\Uparrow
.
\updownarrow
.
\Updownarrow
.
&backslashchar;restriction
.
Not available in plain &tex;. In &latex; you need to load the amssymb
package.
\cup
. Related:
variable-sized operator \biguplus
.
\epsilon
03F5. Related: set
membership \in
.
\emptyset
. Related:
\revemptyset
. Not available in plain &tex;. In &latex; you need to load the amssymb
package.
\phi
03D5.
\pi
03C0.
\rho
03C1.
\sigma
03C3.
\theta
03B8.
\dashv
.
\wedge
. Similar: variable-sized
operator \bigvee
.
mathtools
package to create flexibly-sized
norm symbols.
\mid
because it
is a relation. mathtools
package to create flexibly-sized absolute-value symbols.
\land
. See also
logical or \vee
. Similar: variable-sized
operator \bigwedge
.
amsfonts
amsfonts
latexsym
latexsym
latexsym
and amsfonts
packages contain many more.
\Downarrow
\downarrow
\hookleftarrow
\hookrightarrow
\leftarrow
\Leftarrow
\Leftrightarrow
\leftrightarrow
\longleftarrow
\Longleftarrow
\longleftrightarrow
\Longleftrightarrow
\longmapsto
\Longrightarrow
\longrightarrow
\mapsto
\nearrow
\nwarrow
\Rightarrow
\rightarrow
, or \to
\searrow
\swarrow
\uparrow
\Uparrow
\updownarrow
\Updownarrow
\to
and \mapsto
is: \( f\colon D\to C \) given by \( n\mapsto n^2 \)
.
amscd
amscd
tikz-cd
tikz-cd
tikz-cd
and amscd
.
\boldmath
& \unboldmath
\boldmath \( math \)
\unboldmath \( math \)
\boldmath
command takes place inside an
\mbox
,
we have $\mbox{\boldmath \( v \)} = 5\cdot\mbox{\boldmath \( u \)$}$
\boldmath
is only called in a text mode, here LR
mode, and explains why &latex; must switch to math mode to set v
and u
.
Trouble: \(
\boldmath x \)
, then you get something like LaTeX Font Warning:
Command \boldmath invalid in math mode on input line 11 and LaTeX
Font Warning: Command \mathversion invalid in math mode on input line
11.
bm
bm
\boldmath
. New documents should use
the bm
package provided by the &latex; Project team. A complete
description is outside the scope of this document (see the full
documentation on CTAN) but even this small example
\usepackage{bm} % in preamble ... we have $\bm{v} = 5\cdot\bm{u}$
\boldmath
.
\usepackage{amssymb} % in preamble ... \mathbb{uppercase-letter}
\( \forall n \in \mathbb{N}, n^2 \geq 0 \)
\mathbb{N}
gives blackboard bold symbol 2115,
representing the natural numbers.
\mathcal{uppercase-letters}
Let the graph be \( \mathcal{G} \).
\mathcal{g}
outputs a close curly brace symbol.
(z-z_0)^2 = (x-x_0)^2 + (y-y_0)^2
\( [0,1) \)
.
(
)
{
or \lbrace
}
or \rbrace
[
or \lbrack
]
or \rbrack
\lfloor
\rfloor
\lceil
\rceil
\langle
\rangle
/
\backslash
|
or \vert
\|
or \Vert
mathtools
mathtools
mathtools
package allows you to create commands for paired
delimiters. For instance, if you put
\DeclarePairedDelimiter\abs{\lvert}{\rvert}
in your preamble
then you get two commands for single-line vertical bars (they only work
in math mode). The starred form, such as
\abs*{\frac{22}{7}}
, has the height of the vertical bars
match the height of the argument. The unstarred form, such as
\abs{\frac{22}{7}}
, has the bars fixed at a default height.
This form accepts an optional argument, as in \abs[size
command]{\frac{22}{7}}
, where the height of the bars is given in
size command, such as \Bigg
. Using instead \lVert
and \rVert
as the symbols will give you a norm symbol with the
same behavior.
\left
& \right
\left delimiter1 ... \right delimiter2
\begin{equation} \left(\begin{array}{c} 1 \\ 0 \\ \end{array}\right) \end{equation}
\left
must have a matching \right
. In the above
example, leaving out the \left(
gets the error message
Extra \right. Leaving out the \right)
gets You
can't use `\eqno' in math mode.
amsmath
amsmath
mathtools
mathtools
\begin{equation} f(n)=\left\{\begin{array}{ll} 1 &\mbox{--if \(n=0\)} \\ f(n-1)+3n^2 &\mbox{--else} \end{array}\right. \end{equation}
\{
(amsmath
and mathtools
allow you to get the above
construct through in a cases
environment.)
\left ... \right
pair make a group. One consequence is that
the formula enclosed in the \left ... \right
pair cannot have
line breaks in the output. This includes both manual line breaks and
&latex;-generated automatic ones. In this example, &latex; breaks the
equation to make the formula fit the margins.
Lorem ipsum dolor sit amet \( (a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+w+x+y+z) \)
\left
and \right
Lorem ipsum dolor sit amet \( \left(a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+w+x+y+z\right) \)
\left ... \right
make a group, all the usual grouping
rules hold. Here, the value of \testlength
set inside the
equation will be forgotten, and the output is 1.2pt.
\newlength{\testlength} \setlength{\testlength}{1.2pt} \begin{equation} \left( a+b=c \setlength{\testlength}{3.4pt} \right) \the\testlength \end{equation}
\left ... \right
pair affect the horizontal spacing of the
enclosed formula, in two ways. The first is that in \( \sin(x) =
\sin\left(x\right) \)
the one after the equals sign has more space
around the x
. That&textrsquo;s because \left( ... \right)
inserts
an inner node while ( ... )
inserts an opening node. The second
way that the pair affect the horizontal spacing is that because they
form a group, the enclosed subformula will be typeset at its natural
width, with no stretching or shrinking to make the line fit better.
\begin{equation} \left[ \int_{x=r_0}^{\infty} -G\frac{Mm}{r^2}\, dr \right] \end{equation}
\begin{equation} \left( \rule{1pt}{1cm} \right) \end{equation}
\( \left|
|x|+|y| \right| \)
. It can also choose delimiters that are too large,
as here.
\begin{equation} \left( \sum_{0\leq i<n} i^k \right) \end{equation}
\left
on the first line and
\right
on the last because they must be paired.
\bigl
, \bigr
, etc.\bigldelimiter1 ... \bigr info delimiter2 \Bigl info delimiter1 ... \bigr info delimiter2 \biggl info delimiter1 ... \biggr info delimiter2 \Biggl info delimiter1 ... \Biggr info delimiter2 info
\bigl[...\bigr]
; strictly speaking they need not be
paired, see below), or one of:
\bigmdelimiter \Bigm info delimiter \biggm info delimiter \Biggm info delimiter info
\bigm|
), or one of:
\bigdelimiter \Big info delimiter \bigg info delimiter \Bigg info delimiter info
\big[
).
\bigl| |x|+|y| \bigr|
\bigl...\bigr
in a paragraph without
causing &latex; to spread the lines apart. The larger sizes are meant
for displayed equations.
\begin{tabular}{l} \(\displaystyle \sin\biggl(\frac{1}{2}\biggr) \) \\ % good \(\displaystyle \sin\bigg(\frac{1}{2}\bigg) \) \\ % bad \end{tabular}
\sin
and the open parenthesis.
\begin{equation} \int_{x=a}^b x^2\,dx = \frac{1}{3} x^3 \Big|_{x=a}^b \end{equation}
amsmath
amsmath
\frac
with the \tfrac
command
from the amsmath
package), and as with this larger slash.
\begin{equation} \lim_{n\to\infty}\pi(n) \big/ (n/\log n) = 1 \end{equation}
\left...\right
pair (\begin{equation} \Biggl[ \pi/6 ] \end{equation}
\begin{equation} \biggl\{ a\in B \biggm| a=\sum_{0\leq i<n}3i^2+4 \biggr\} \end{equation}
\begin{array}{cccc} a_{0,0} &a_{0,1} &a_{0,2} &\ldots \\ a_{1,0} &\ddots \\ \vdots \end{array}
\( a_0\cdot a_1\cdots a_{n-1}
\)
.
\(
x_0,\ldots x_{n-1} \)
. Another example is the above array example. A
synonym is \mathellipsis
. A synonym from the amsmath
package is \hdots
.
The gears, brakes, \ldots{} are all broken
. (In a paragraph
mode or LR mode a synonym for \ldots
is \dots
.)
amsmath
amsmath
amsmath
package has the command \dots
to semantically
mark up ellipses. This example produces two different-looking outputs
for the first two uses of the \dots
command.
\usepackage{amsmath} % in preamble ... Suppose that \( p_0, p_1, \dots, p_{n-1} \) lists all of the primes. Observe that \( p_0\cdot p_1 \dots \cdot p_{n-1} +1 \) is not a multiple of any \( p_i \). Conclusion: there are infinitely many primes \( p_0, p_1, \dotsc \).
\dots
to
determine that it should output an ellipsis on the baseline. The second
line has a \cdot
following \dots
so &latex; outputs an
ellipsis that is on the math axis, vertically centered. However, the
third usage has no follow-on character so you have to tell &latex; what
to do. You can use one of the commands: \dotsc
if you need the
ellipsis appropriate for a comma following, \dotsb
if you need
the ellipses that fits when the dots are followed by a binary operator
or relation symbol, \dotsi
for dots with integrals, or
\dotso
for others.
\alpha
\beta
\gamma
, \Gamma
\delta
, \Delta
\varepsilon
, \epsilon
\zeta
\eta
\theta
, \vartheta
\iota
\kappa
\lambda
, \Lambda
\mu
\nu
\xi
, \Xi
\pi
, \Pi
\rho
, \varrho
\sigma
, \Sigma
\tau
\phi
, \varphi
, \Phi
\chi
\psi
, \Psi
\omega
, \Omega
unicode-math
unicode-math
\newcommand\omicron{o}
. The package unicode-math
has
\upomicron
for upright omicron and \mitomicron
for math
italic.
\in
is related to epsilon, it is never used for a variable.
\( 5\bmod 3=2 \)
\( 5\equiv 2\pmod 3 \)
amsmath
amsmath
amsmath
package adds improvements on some of these, and also
allows you to define your own. The full documentation is on CTAN, but
briefly, you can define an identity operator with
\DeclareMathOperator{\identity}{id}
that is like the ones
above but prints as id. The starred form
\DeclareMathOperator*{\op}{op}
sets any limits above and
below, as is traditional with \lim
, \sup
, or \max
.
\imath
or jmath
(\(\underline{y}\)
the line is lower than in
\(\underline{x}\)
. This command is fragile (ulem
ulem
ulem
does text mode underlining and allows
line breaking as well as a number of other features. See the
documentation on CTAN. See also \overline{x+y}
.
Note that this differs from the command \bar
((1-\underbrace{1/2)+(1/2}-1/3)
emphasizes the telescoping part.
Attach text to the brace by using subscript, _
, or superscript,
^
, as here.
\begin{displaymath} 1+1/2+\underbrace{1/3+1/4}_{>1/2}+ \underbrace{1/5+1/6+1/7+1/8}_{>1/2}+\cdots \end{displaymath}
\overbrace{x+x+\cdots+x}^{\mbox{\(k\) times}}
. See also
\underbrace
.
mathtools
mathtools
mathtools
adds an over- and underbrace, as well as
some improvements on the braces. See the documentation on CTAN.
y=m x
then
&latex; ignores the space and in the output the m is next to the x,
as .
f(x)
and the dx
, here done with the \,
command:
\int_0^1 f(x)\,dx
\thickspace
is something like 5/18 times the width of
a M.
\smash
\smash{subformula}
\smash
command &latex; would separate its line from the line
above it, and the uneven line spacing might be unsightly.
To compute the tetration $\smash{2^{2^{2^2}}}$, evaluate from the top down, as $2^{2^4}=2^{16}=65536$.
\smash
the printed expression could run into the
line above so you may want to wait until the final version of the
document to make such adjustments.)
\smash
by using \fbox
to
surround the box that &latex; will put on the line. The
\blackbar
command makes a bar extending from 10 points below
the baseline to 20 points above.
\newcommand{\blackbar}{\rule[-10pt]{5pt}{30pt}} \fbox{\blackbar} \fbox{\smash{\blackbar}}
\smash
command appears often in mathematics to adjust the
size of an element that surrounds a subformula. Here the first radical
extends below the baseline while the second lies just on the baseline.
\begin{equation} \sqrt{\sum_{0\leq k< n} f(k)} \sqrt{\vphantom{\sum}\smash{\sum_{0\leq k< n}} f(k)} \end{equation}
\vphantom
to give the \sqrt
command an
argument with the height of the \sum
(\smash
command can
appear in other contexts. However, it doesn&textrsquo;t change into horizontal
mode. So if it starts a paragraph then you should first put a
\leavevmode
, as in the bottom line below.
xxx xxx xxx \smash{yyy} % no paragraph indent \leavevmode\smash{zzz} % usual paragraph indent
mathtools
mathtools
mathtools
has operators that provide even finer
control over smashing a subformula box.
\phantom
& \vphantom
& \hphantom
\phantom{subformula}
\vphantom{subformula}
\hphantom{subformula}
\phantom
command creates a box with the same height, depth,
and width as subformula, but empty. That is, this command causes
&latex; to typeset the space but not fill it with the material. Here
&latex; will put a blank line that is the correct width for the answer,
but will not show that answer.
\begin{displaymath} \int x^2\,dx=\mbox{\underline{$\phantom{(1/3)x^3+C}$}} \end{displaymath}
\vphantom
variant produces an invisible box with the same
vertical size as subformula, the same height and depth, but having
zero width. And \hphantom
makes a box with the same width as
subformula but with zero height and depth.
\vphantom
in the first expression tells
&tex; to leave as much vertical room as it does for the tower, so the
two expressions come out at the same level.
\begin{displaymath} \sum_{j\in\{0,\ldots\, 10\}\vphantom{3^{3^{3^j}}}} \sum_{i\in\{0,\ldots\, 3^{3^{3^j}}\}} i\cdot j \end{displaymath}
\smash
.
\vphantom
.
mathtools
mathtools
\makebox
(\settodepth
(\settoheight
(\settowidth
(mathtools
package has many commands that offer
fine-grained control over spacing.
amsmath
amsmath
\operatorname
command from the package amsmath
.
\leavevmode
.
\mathstrut
\mathstrut
\mathstrut
\strut
for mathematics. $\sqrt{x} + \sqrt{x^i}$
gives output where the
second radical is taller than the first. To add extra vertical space
without any horizontal space, so that the two have the same height, use
$\sqrt{x\mathstrut} + \sqrt{x^i\mathstrut}$
.
\mathstrut
command adds the vertical height of an open
parenthesis, (
, but no horizontal space. It is defined as
\vphantom{(}
, so see \strut
is that \mathstrut
adds no
depth, which is often the right thing for formulas. Using the height of
an open parenthesis is just a convention; for complete control over the
amount of space, use \rule
with a width of zero. \sum_{0\leq
i<n}k^m=\frac{n^{m+1}}{m+1}+\mbox{lower order terms}
will give
output with the summation index centered below the summation symbol.
But if that input is inline then the summation index is off to the right
rather than below, so it won&textrsquo;t push the lines apart. Similarly, in a
displayed context, the symbols in the numerator and denominator will be
larger than for an inline context, and in display math subscripts and
superscripts are further apart then they are in inline math.
\begin{equation} ... \end{equation}
.
\displaystyle
, or \textstyle
, or
\scriptstyle
, or \scriptscriptstyle
.
\begin{tabular}{r|cc} \textsc{Name} &\textsc{Series} &\textsc{Sum} \\ \hline Arithmetic &$a+(a+b)+(a+2b)+\cdots+(a+(n-1)b)$ &$na+(n-1)n\cdot\frac{b}{2}$ \\ Geometric &$a+ab+ab^2+\cdots+ab^{n-1}$ &$\displaystyle a\cdot\frac{1-b^n}{1-b}$ \\ \end{tabular}
\displaystyle
declaration,
the Geometric line&textrsquo;s fraction will be easy to read, with
characters the same size as in the rest of the line.
we get $\pi=2\cdot{\displaystyle\int_{x=0}^1 \sqrt{1-x^2}\,dx}$
\displaystyle
applies to only part of the formula, and it is
delimited by being inside curly braces, as {\displaystyle ...}.
\begin{equation} a_0+\frac{1}{ \displaystyle a_1+\frac{\mathstrut 1}{ \displaystyle a_2+\frac{\mathstrut 1}{ \displaystyle a_3}}} \end{equation}
\displaystyle
declarations, the denominators would be
set in script style and scriptscript style. (The \mathstrut
improves the height of the denominators; :
& \colon
: \colon
:
, is a relation.
With side ratios \( 3:4 \) and \( 4:5 \), the triangle is right.
amsmath
amsmath
\colon
to produce the colon character
with the spacing appropriate for punctuation, as in set-builder notation
\{x\colon 0\leq x<1\}
.
amsmath
amsmath
amsmath
package defines \colon
for use
in the definition of functions f\colon D\to C
. So if you want
the colon character as a punctuation then use \mathpunct{:}
.
\*
\*
\times
symbol, 00D7, before
that break.
\( A_1\* A_2\* A_3\* A_4 \)
, if there is no line break then
&latex; outputs it as though it were \( A_1 A_2 A_3 A_4 \)
. If
a line break does happen, for example between the two middle ones, then
&latex; sets it like \( A_1 A_2 \times \)
, followed by the
break, followed by \( A_3 A_4 \)
.
\frac
\frac{numerator}{denominator}
\begin{displaymath}
\frac{1}{\sqrt{2\pi\sigma}} \end{displaymath}
. In inline math
mode it comes out small; see the discussion of \displaystyle
(\sqrt
\sqrt{arg} \sqrt[root-number]{arg}
x+y
as \sqrt[3]{x+y}
.
The radical grows with the size of arg (as the height of the
radical grows, the angle on the leftmost part gets steeper, until for
a large enough arg
, it is vertical).
\surd
character (\stackrel
\stackrel{text}{relation}
\stackrel{f}{\longrightarrow}
.
\mbox
command. As in paragraph mode,
&latex;&textrsquo;s output is a string of words with spaces between them. Unlike
in paragraph mode, in LR mode &latex; never starts a new line, it just
keeps going from left to right. (Although &latex; will not complain
that the LR box is too long, when it is finished and next tries to put
that box into a line, it could very well complain that the finished LR
box won&textrsquo;t fit there.)
\int
differs in the two situations.)
\vbox
. It has not such thing as page breaks, and as such is the
vertical analogue of LR mode.
\parbox
command
or a minipage
then &latex; is put into paragraph mode. But it
will not put a page break here. Inside one of these boxes, called a
parbox, &latex; is in inner paragraph mode. Its more usual
situation, where it can put page breaks, is outer paragraph mode
(\ensuremath
\ensuremath{formula}
\newcommand{\dx}{\ensuremath{dx}} In $\int f(x)\, \dx$, the \dx{} is an infinitesimal.
\ensuremath
command is useful but not a panacea.
\newcommand{\alf}{\ensuremath{\alpha}} You get an alpha in text mode: \alf. But compare the correct spacing in $\alf+\alf$ with that in \alf+\alf.
fancyhdr
fancyhdr
fancyhdr
is very helpful for constructing page
styles. See its documentation on CTAN.
\maketitle
\maketitle
article
class where it is at the top
of the first page. (titlepage
document class option.)
\maketitle
appearing in its usual place,
immediately after \begin{document}
.
\documentclass{article} \title{Constructing a Nuclear Reactor Using Only Coconuts} \author{Jonas Grumby\thanks{% With the support of a Ginger Grant from the Roy Hinkley Society.} \\ Skipper, \textit{Minnow} \and Willy Gilligan\thanks{% Thanks to the Mary Ann Summers foundation and to Thurston and Lovey Howell.} \\ Mate, \textit{Minnow} } \date{1964-Sep-26} \begin{document} \maketitle Just sit right back and you'll hear a tale, a tale of a fateful trip. That started from this tropic port, aboard this tiny ship. The mate was a mighty sailin' man, the Skipper brave and sure. Five passengers set sail that day for a three hour tour. A three hour tour. ...
\maketitle
, either in the preamble or in the document body.
\author
\author
\and
commands. To separate lines
within a single author&textrsquo;s entry, for instance to give the author&textrsquo;s
institution or address, use a double backslash, \\
. If you omit
the \author
declaration then you get LaTeX Warning: No
\author given.
\date
then &latex; uses the current date (\date{}
.
\title
\\
. If you
omit the \title
declaration then you get LaTeX Error: No
\title given.
\maketitle
command. (Many publishers will provide a class to use
in place of article
that formats the title according to their
house requirements.)
\pagenumbering
\pagenumbering{number-style}
\begin{document}\pagenumbering{alph} ... \section{Main}\pagenumbering{arabic} ...
page
counter (\pagestyle
\pagestyle{style}
fancyhdr
fancyhdr
fancyhdr
is now the standard way to manipulate headers and
footers. New documents that need to do anything other than one of the
standard options below should use this package. See its documentation
on CTAN.
headings
or myheadings
. The
document source below produces an article, two-sided, with the pagestyle
headings
. On this document&textrsquo;s left hand pages, &latex; wants (in
addition to the page number) the title of the current section. On its
right hand pages &latex; wants the title of the current subsection.
When it makes up a page, &latex; gets this information from the
commands \leftmark
and \rightmark
. So it is up to
\section
and \subsection
to store that information there.
\documentclass[twoside]{article} \pagestyle{headings} \begin{document} ... \section{Section 1} ... \subsection{Subsection 1.1} ... \section{Section 2} ... \subsection{Subsection 2.1} ... \subsection{Subsection 2.2} ...
\section
issue a command \markboth
, setting \leftmark
to Section 2 and setting \rightmark
to blank.
And, &latex; has \subsection
issue a command \markright
,
setting \rightmark
to Subsection 2.1, etc.
\markboth
and \markright
:
headings
or myheadings
. A left hand page
heading left-head is generated by the last \markboth
command before the end of the page. A right hand page heading
right-head is generated by the first \markboth
or
\markright
that comes on the page if there is one, otherwise by
the last one that came before that page.
\thispagestyle
\thispagestyle{style}
\pagestyle
(plain
style, as is the default (\documentclass{book} \pagestyle{headings} \begin{document} \chapter{First chapter} ... \chapter{Second chapter}\thispagestyle{empty} ...
plain
style has a page number on it, centered in the footer.
To make the page entirely empty, the command
\thispagestyle{empty}
immediately follows the second
\chapter
.
\enspace
& \quad
& \qquad
\enspace \quad \qquad
\begin{center} \includegraphics{womensmile.png}% \qquad\includegraphics{mensmile.png} \end{center}
\quad
and \qquad
. These
are lengths from centuries of typesetting and so may be a better choice
in many circumstances than arbitrary lengths, such as you get with
\hspace
.
\hspace
\hspace{length} \hspace*{length}
plus
or minus
component, or both (\noindent\makebox[\linewidth][r]{Name:\hspace{1in}}
*
-form inserts horizontal space that is non-discardable. More
precisely, when &tex; breaks a paragraph into lines any white
space&textmdash;glues and kerns&textmdash;that come at a line break are discarded. The
*
-form avoids that (technically, it adds a non-discardable
invisible item in front of the space).
\parbox{0.8\linewidth}{% Fill in each blank: Four \hspace*{1in} and seven years ago our fathers brought forth on this continent, a new \hspace*{1in}, conceived in \hspace*{1in}, and dedicated to the proposition that all men are created \hspace*{1in}.}
*
then &latex; discards the blank.
\hspace
separates the three graphics.
\begin{center} \includegraphics{lion.png}% comment keeps out extra space \hspace{1cm minus 0.25cm}\includegraphics{tiger.png}% \hspace{1cm minus 0.25cm}\includegraphics{bear.png} \end{center}
\hspace
has minus 0.25cm
,
each can shrink a little if the three figures are too wide. But each
space won&textrsquo;t shrink more than 0.25\hfill
\hfill
\noindent Name:\hfill Quiz One
\hfill
command is equivalent to \hspace{\fill}
and
so the space can be discarded at line breaks. To avoid that instead use
\hspace*{\fill}
(\newcommand*{\vcenteredhbox}[1]{\begin{tabular}{&arobase;{}c&arobase;{}}#1\end{tabular}} ... \begin{figure} \hspace*{\fill}% \vcenteredhbox{\includegraphics{graph0.png}}% \hfill\vcenteredhbox{\includegraphics{graph1.png}}% \hspace*{\fill}% \caption{Comparison of two graphs} \label{fig:twographs} \end{figure}
\hspace*
&textrsquo;s where the space could otherwise be dropped.
\hss
\hss
\makebox
command to get the
effects of \hss
(\hss
makes the Z stick out to the right,
overwriting the Y. In the second line the Z sticks out to the left,
overwriting the X.
X\hbox to 0pt{Z\hss}Y X\hbox to 0pt{\hss Z}Y
\hss
you get something like Overfull \hbox
(6.11111pt too wide) detected at line 20.
\spacefactor
\spacefactor=integer
\spacefactor
command
(from Plain &tex;) allows you to, for instance, have the space
after a period stretch more than the space after a word-ending letter.
A man's best friend is his
dog.
After it, &tex; puts in a fixed extra space, and also allows the
glue to stretch 3 times as much and shrink 1/3 as much, as the glue
after friend
, which does not end in a period.
\spacefactor
in paragraph mode or LR mode
(\the\spacefactor
or \showthe\spacefactor
.
\spacefactor
: if you get errors
like You can't use `\spacefactor' in vertical mode, or You
can't use `\spacefactor' in math mode., or Improper \spacefactor
then you have probably tried to redefine an internal command.
\&arobase;
capital-letter\&arobase;.
The songs \textit{Red Guitar}, etc.\ are by Loudon Wainwright~III\&arobase;.
\&arobase;
before it. The first period ends the abbreviation
etc. but not the sentence. The backslash-space, \
,
produces a mid-sentence space.
\&arobase;
before the period. This holds even if
there is an intervening right parenthesis or bracket, or right single or
double quote, because the spacing effect of that period carries through
those characters. For example, this
Use the \textit{Instructional Practices Guide}, (a book by the MAA)\&arobase;.
\&arobase;
command is only for a text mode. If you use it outside of
a text mode then you get You can't use `\spacefactor' in vertical
mode (\
), or a tie, (~
), or \&arobase;
.
Examples are Nat.\ Acad.\ Science
, and Mr.~Bean
, and
(manure, etc.\&arobase;) for sale
(note in the last one that the
\&arobase;
comes before the closing parenthesis).
\frenchspacing
& \nonfrenchspacing
\frenchspacing \nonfrenchspacing
\frenchspacing
(the command is from plain &tex;) switches to the tradition that all
spaces are treated equally.
\normalsfcodes
\normalsfcodes
\
\
\begin{tabular}{rl} One blank:& makes some space \\ Three blanks:& in a row \\ Three spaces:&\ \ \ in a row \\ \end{tabular}
\hspace
;
see \TeX
in \TeX\ (or \LaTeX)
. (But using curly braces
has the advantage of still working whether the next character is a blank
or any other non-letter, as in \TeX{} (or \LaTeX{})
in which
{}
can be added after \LaTeX
as well as after
\TeX
.) The other common use is that it marks a period as ending
an abbreviation instead of ending a sentence, as in Prof.\ Smith
or Jones et al.\ (1993)
(\
\
\
.
one word
~
before~after
~
, produces a space between before and
after at which the line will not be broken. By default the white
space has length 3.33333Thanks to Prof.~Lerman.
\mbox
(Chapter~12
, or Theorem~\ref{th:Wilsons}
, or
Figure~\ref{fig:KGraph}
.
(b)~Show that $f(x)$ is
(1)~continuous, and (2)~bounded
.
siunitx
siunitx
$745.7.8$~watts
(the
siunitx
package has a special facility for this) or
144~eggs
. This includes between a month and day number in a date:
October~12
or 12~Oct
. In general, in any expressions where
numbers and abbreviations or symbols are separated by a space:
AD~565
, or 2:50~pm
, or Boeing~747
, or
268~Plains Road
, or \$$1.4$~billion
. Other common
choices here are a thin space (equals~$n$
, or
less than~$\epsilon$
, or given~$X$
, or modulo~$p^e$
for all large~$n$
(but compare is~$15$
with is $15$~times
the height
). Between mathematical symbols in apposition with nouns:
dimension~$d$
or function~$f(x)$
(but compare with
length $l$~or more
). When a symbol is a tightly bound object of a
preposition: of~$x$
, or from $0$ to~$1$
, or in
common with~$m$
.
$1$,~$2$, or~$3$
or $1$,~$2$,
\ldots,~$n$
.
Donald~E. Knuth
, or Luis~I. Trabb~Pardo
, or
Charles~XII
&textmdash;but you must give &tex; places to break the line
so you might do Charles Louis Xavier~Joseph de~la
Vall\'ee~Poussin
.
\thinspace
& \negthinspace
\thinspace \negthinspace
\,
and \!
(\,
as a synonym for \thinspace
in text mode.
\thinspace
is as the space between nested
quotes:
Killick replied, ``I heard the Captain say, `Ahoy there.'\thinspace''
\thinspace
between an ellipsis and a sentence ending period (other style guides,
think the three dots and/or four dots are plenty). Another
style-specific use is between initials, as in D.\thinspace E.\
Knuth
.
amsmath
amsmath
amsmath
package, or as
of the 2020-10-01 &latex; release, they can be used in text mode as
well as math mode, including \!
for \negthinspace
; but
otherwise, they are available only in math mode.
\/
before-character\/after-character
\/
, &latex;
takes the correction from the font metric file, scales it by any
scaling that has been applied to the font, and then inserts that much
horizontal space.
\/
, the before-character
italic f would hit the after-character roman H
\newcommand{\companylogo}{{\it f}\/H}
\emph
and \textit
and
\textsl
to change fonts, &latex; automatically inserts the
italic correction when needed (\em
and \itshape
and
\slshape
do not automatically insert italic corrections.
pdf\/\TeX
. However, most
upright characters have a zero italic correction. Some font creators
do not include italic correction values even for italic fonts.
\fontdimen1
), to determine whether
to possibly insert an italic correction, rather than tying the action to
particular font commands.
\hrulefill
& \dotfill
\hrulefill \dotfill
Name:~\makebox[2in]{\hrulefill}
\noindent John Aubrey, RN \dotfill{} Melbury Lodge
\null
at the
start or end.
\renewcommand{\hrulefill}{% \leavevmode\leaders\hrule height 1pt\hfill\kern0pt }
\renewcommand{\dotfill}{% \leavevmode\cleaders\hbox to 1.00em{\hss .\hss }\hfill\kern0pt }
\begin{minipage}{4cm} \centering \hrulefill\\ Signed \end{minipage}
\bigskip
& \medskip
& \smallskip
\bigskip \medskip \smallskip
Mr Saumarez would have something rude to say to him, no doubt: he was at home again, and it was delightful. \bigskip ``A hundred and fifty-seven miles and one third, in twenty-four hours,'' said Peter.
\vspace{\bigskipamount}
, ordinarily about one line
space, with stretch and shrink. The default for the book
and
article
classes is 12pt plus 4pt minus 4pt
.
\vspace{\medskipamount}
, ordinarily about half of a
line space, with stretch and shrink. The default for the book
and article
classes is 6pt plus 2pt minus 2pt
.
\vspace{\smallskipamount}
, ordinarily about a
quarter of a line space, with stretch and shrink. The default for the
book
and article
classes is 3pt plus 1pt minus 1pt
.
\vspace
, if you use it in mid-paragraph
then it will insert its vertical space between the line in which you use
it and the next line, not necessarily at the place that you use it. So
these are best between paragraphs.
\bigbreak
, \medbreak
, and \smallbreak
are similar but also suggest to &latex; that this is a good place to
put a page break (\bigbreak
& \medbreak
& \smallbreak
\bigbreak \medbreak \smallbreak
\addvspace
). In addition, they terminate a paragraph where
they are used: this example
abc\bigbreak def ghi jkl mno pqr
\strut
\strut
0.7\baselineskip
and depth at least 0.3\baselineskip
. Essentially, &latex;
inserts into the line a rectangle having zero width,
\rule[-0.3\baselineskip]{0pt}{\baselineskip}
(\baselineskip
changes with the current font or fontsize.
\strut
keeps the box inside the frame from
having zero height.
\setlength{\fboxsep}{0pt}\framebox[2in]{\strut}
\strut
at the end of its first
item&textrsquo;s second line.
\setlength{\fboxsep}{0pt} \noindent\begin{minipage}[t]{0.2\linewidth} \begin{enumerate} \item \parbox[t]{15pt}{test \\ test} \item test \item test \end{enumerate} \end{minipage}% \begin{minipage}[t]{0.2\linewidth} \begin{enumerate} \item \parbox[t]{15pt}{test \\ test\strut} \item test \item test \end{enumerate} \end{minipage}% \begin{minipage}[t]{0.2\linewidth} \begin{enumerate} \item \fbox{\parbox[t]{15pt}{test \\ test}} \item \fbox{test} \item \fbox{test} \end{enumerate} \end{minipage}% \begin{minipage}[t]{0.2\linewidth} \begin{enumerate} \item \fbox{\parbox[t]{15pt}{test \\ test\strut}} \item \fbox{test} \item \fbox{test} \end{enumerate} \end{minipage}%
\fbox
to show what&textrsquo;s happening. The
first item \parbox
of the third list goes only to the bottom of
its second test, which happens not have any characters that
descend below the baseline. The fourth list adds the strut that gives
the needed extra below-baseline space.
TikZ
TikZ
Asymptote
Asymptote
\strut
command is often useful in graphics, such as in
TikZ
or Asymptote
. For instance, you may have a command
such as \graphnode{node-name}
that fits a circle around
node-name. However, unless you are careful the node-name&textrsquo;s
x and y will produce different-diameter circles because
the characters are different sizes. A careful \graphnode
might
insert a \strut
, then node-name, and then draw the circle.
\rule
is useful in
many circumstances. In this table, the zero-width rule keeps the top of
the first integral from hitting the \hline
. Similarly, the
second rule keeps the second integral from hitting the first.
\begin{tabular}{rl} \textsc{Integral} &\textsc{Value} \\ \hline $\int_0^x t\, dt$ &$x^2/2$ \rule{0em}{2.5ex} \\ $\int_0^x t^2\, dt$ &$x^3/3$ \rule{0em}{2.5ex} \end{tabular}
\\[2.5ex]
will put more room between the header line and the
\hline
rule, and the integral would still hit the rule.)
\vspace
\vspace{length} \vspace*{length}
plus
or minus
component (And I slept. \vspace{1ex plus 0.5ex} The new day dawned cold.
*
-form inserts vertical space that is non-discardable. More
precisely, &latex; discards vertical space at a page break and the
*
-form causes the space to stay. This example leaves space
between the two questions.
Question: Find the integral of \( 5x^4+5 \). \vspace*{2cm plus 0.5cm} Question: Find the derivative of \( x^5+5x+9 \).
\vspace
in the middle of a paragraph (i.e., in
horizontal mode) then the space is inserted after the line containing
the \vspace
command; it does not start a new paragraph at the
\vspace
command.
\begin{document} 1) Who put the bomp in the bomp bah bomp bah bomp? \vspace{1in plus 1fill} 2) Who put the ram in the rama lama ding dong? \vspace{1in plus 1fill} \end{document}
\vfill
\vfill
\vspace{\fill}
, except that
\vfill
ends the current paragraph whereas \vspace{\fill}
adds the infinite vertical space below its line, irrespective of the
paragraph structure. In both cases that space will disappear at a page
boundary; to circumvent this see the starred option
in \begin{document} Lost Dog! \vfill Lost Dog! % perfectly in the middle \vfill Lost Dog! \end{document}
\addvspace
\addvspace{vert-length}
\addvspace
&textrsquo;s in a sequence then together they only add the
space needed to make the natural length equal to the maximum of the
vert-length&textrsquo;s in that sequence. This command is fragile
(picture
draws a scale over which
to rules are placed. In a standard &latex; article the length
\baselineskip
is 12\baselineskip
and the
10\addvspace
.
\documentclass{article} \usepackage{color} \begin{document} \setlength{\unitlength}{2pt}% \noindent\begin{picture}(0,0)% \multiput(0,0)(0,-1){25}{{\color{blue}\line(1,0){1}}} \multiput(0,0)(0,-5){6}{{\color{red}\line(1,0){2}}} \end{picture}% \rule{0.25\linewidth}{0.1pt}% \par\addvspace{10pt}% \addvspace{20pt}% \par\noindent\rule{0.25\linewidth}{0.1pt}% \end{document}
\addvspace
. It does not make the gap
20\baselineskip
and 20\addvspace
in a sense does the opposite of
its name&textmdash;it makes sure that multiple vertical spaces do not
accumulate, but instead that only the largest one is used.
theorem
environment begins and ends with \addvspace
so
that two consecutive theorem
&textrsquo;s are separated by one vertical
space, not two.
\addvspace
means that you were not in vertical mode when you hit
this command. One way to change that is to precede \addvspace
with a \par
command (adjustbox
adjustbox
adjustbox
.
\mbox
& \makebox
\mbox{text} \makebox{text} \makebox[width]{text} \makebox[width][position]{text}
\mbox
command is robust, while \makebox
is fragile
(text
is not broken into lines, you can use \mbox
to prevent hyphenation. In this example, &latex; will not hyphenate
the tank name, T-34.
The soviet tank \mbox{T-34} is a symbol of victory against nazism.
\mbox
and \makebox
, are
roughly equivalent. They create a box just wide enough to contain the
text. (They are like plain &tex;&textrsquo;s \hbox
.)
\makebox[\linewidth]{Chapter Exam}
\depth
, \height
, \width
,
\totalheight
(this is the box&textrsquo;s height plus its depth). For
example, to make a box with the text stretched to double the natural
size you can say this.
\makebox[2\width]{Get a stretcher}
\makebox
is to make zero-width text boxes. This
puts the value of the quiz questions to the left of those questions.
\newcommand{\pts}[1]{\makebox[0em][r]{#1 points\hspace*{1em}}} \pts{10}What is the air-speed velocity of an unladen swallow? \pts{90}An African or European swallow?
TikZ
TikZ
Asymptote
Asymptote
\makebox
similarly when making graphics, such as in TikZ
or Asymptote
, where you put the edge of the text at a known
location, regardless of the length of that text.
\makebox
that is used within the
picture
environment, where the length is given in terms of
\unitlength
(\\
nor \par
will give you a new line; for instance
\makebox{abc def \\ ghi}
outputs abc defghi while
\makebox{abc def \par ghi}
outputs abc def ghi, both on
a single line. To get multiple lines see \fbox
& \framebox
\fbox{text} \framebox{text} \framebox[width]{text} \framebox[width][position]{text}
\mbox
and \makebox
except
for the frame (\fbox
command is
robust, the \framebox
command is fragile (\fbox{Warning! No work shown, no credit given.}
\fbox{...}
and
\framebox{...}
, are roughly the same. As to the third and
fourth invocations, the optional arguments allow you to specify the box
width as width and the position of the text inside that box as
position. \setlength{\fboxsep}{0pt}\framebox[0.25in]{\strut}}
\strut
ensures a total height of \baselineskip
(\setlength{\fboxrule}{0.8pt}
(\setlength{\fboxsep}{0pt}
({\setlength{\fboxsep}{0pt}% \framebox{% \includegraphics[width=0.5\textwidth]{prudence.jpg}}}
\setlength
local.
\mbox
and \makebox
, &latex; will not break lines
in text. But this example has &latex; break lines to make a
paragraph, and then frame the result.
\framebox{% \begin{minipage}{0.6\linewidth} My dear, here we must run as fast as we can, just to stay in place. And if you wish to go anywhere you must run twice as fast as that. \end{minipage}}
picture
environment has a version of the \framebox
command where the units depend on picture
&textrsquo;s \unitlength
(\parbox
\parbox{width}{contents} \parbox[position]{width}{contents} \parbox[position][height]{width}{contents} \parbox[position][height][inner-pos]{width}{contents}
\begin{picture}(0,0) ... \put(1,2){\parbox{1.75in}{\raggedright Because the graph is a line on this semilog paper, the relationship is exponential.}} \end{picture}
minipage
environment
(\parbox
(except for contents) are the same
as those for minipage
. For convenience a summary of the options
is here but see c
or m
to make the vertical center of the
parbox lines up with the center of the adjacent text line (this is the
default), or t
to match the top line of the parbox with
the baseline of the surrounding material, or b
to match the
bottom line.
parbox
. Its default is the value of
position. Its possible values are: t
to put the
content at the top of the box, c
to put it in the vertical
center, b
to put it at the bottom of the box, and s
to
stretch it out vertically (for this, the text must contain vertically
stretchable space).
\raisebox
\raisebox{distance}{text} \raisebox{distance}[height]{text} \raisebox{distance}[height][depth]{text}
\newcommand*\restricted[1]{\raisebox{-.5ex}{$|$}_{#1}} $f\restricted{A}$
\depth
, \height
,
\width
, \totalheight
(this is the box&textrsquo;s height plus its
depth).
\usepackage{graphicx,calc} % in preamble ... \begin{center} \raisebox{1ex-\height}{% \includegraphics[width=0.4\linewidth]{lion.png}} \qquad \raisebox{1ex-\height}{% \includegraphics[width=0.4\linewidth]{meta.png}} \end{center}
\height
is the height of \sbox
& \savebox
\sbox{box-cmd}{text} \savebox{box-cmd}{text} \savebox{box-cmd}[width]{text} \savebox{box-cmd}[width][pos]{text}
\makebox
(\
. You must
have previously allocated the box register box-cmd with \newsavebox
(\sbox
command is robust while
\savebox
is fragile (\newsavebox{\fullname} \sbox{\fullname}{John Jacob Jingleheimer Schmidt} ... \usebox{\fullname}! His name is my name, too! Whenever we go out, the people always shout! There goes \usebox{\fullname}! Ya da da da da da da.
\newcommand
macro variable is efficiency, that &latex; need not
repeatedly retypeset the contents. See the example below.
\sbox{box-cmd}{text}
and
\savebox{box-cmd}{text}
, are roughly equivalent.
As to the third and fourth, the optional arguments allow you to specify
the box width as width, and the position of the text inside that
box as position. \sbox
and \savebox
commands the text is
typeset in LR mode so it does not have line breaks (\sbox{\newreg}{test \\ test}
and
\usebox{\newreg}
then you get testtest, while if you
enter \sbox{\newreg}{test \par test}
and
\usebox{\newreg}
then you get test test, but no error or
warning. To fix this use a \parbox
or minipage
as here.
\newsavebox{\areg} \savebox{\areg}{% \begin{minipage}{\linewidth} \begin{enumerate} \item First item \item Second item \end{enumerate} \end{minipage}} ... \usebox{\areg}
\usepackage{graphicx} % all this in the preamble \newsavebox{\sealreg} \savebox{\sealreg}{% \setlength{\unitlength}{1in}% \begin{picture}(0,0)% \put(1.5,-2.5){% \begin{tabular}{c} \includegraphics[height=2in]{companylogo.png} \\ Office of the President \end{tabular}} \end{picture}% } \markright{\usebox{\sealreg}} \pagestyle{headings}
picture
environment is good for fine-tuning the placement.
\noreg
has not already been defined then you get something like
Undefined control sequence. <argument> \noreg.
lrbox
\begin{lrbox}{box-cmd} text \end{lrbox}
\sbox
and \savebox
commands, and is equivalent to them. box-cmd
. The variable name
box-cmd must begin with a backslash, \
. You must allocate
this box register in advance with \newsavebox
(tabular
.
\newsavebox{\jhreg} \begin{lrbox}{\jhreg} \begin{tabular}{c} \includegraphics[height=1in]{jh.png} \\ Jim Hef{}feron \end{tabular} \end{lrbox} ... \usebox{\jhreg}
\usebox
\usebox{box-cmd}
\sbox
or \savebox
, or the lrbox
environment. For more information and examples, \
.) This command is robust (\usepackage{color}
in your document preamble to use the
commands described here.
color
package options\usepackage[comma-separated option list]{color}
\definecolor{name}{model}{specification}
\definecolor{silver}{rgb}{0.75,0.75,0.74}
Hi ho,
\textcolor{silver}{Silver}!
.
\definecolor{logocolor}{RGB}{145,92,131} % RGB needs pdflatex \newcommand{\logo}{\textcolor{logocolor}{Bob's Big Bagels}}
\textcolor{name}{...} \textcolor[color model]{color specification}{...}
\color{name} \color[color model]{specification}
\textcolor{magenta}{My name is Ozymandias, king of kings:} Look on my works, ye Mighty, and despair!
\definecolor
in exactly the same
way that we just used the builtin color magenta.
\definecolor{MidlifeCrisisRed}{rgb}{1.0,0.11,0.0} I'm thinking about getting a \textcolor{MidlifeCrisisRed}{sports car}.
\textcolor
and \color
differ in that the first is
a command form, enclosing the text to be colored as an argument. Often
this form is more convenient, or at least more explicit. The second
form is a declaration, as in The moon is made of {\color{green}
green} cheese
, so it is in effect until the end of the current group
or environment. This is sometimes useful when writing macros or as
below where it colors everything inside the center
environment,
including the vertical and horizontal lines.
\begin{center} \color{blue} \begin{tabular}{l|r} UL &UR \\ \hline LL &LR \end{tabular} \end{center}
\definecolor{highlightcolor}{RGB}{225,15,0}
\begin{equation} \int_a^b \textcolor{highlightcolor}{f'(x)}\,dx=f(b)-f(a) \end{equation}
Colors of \textcolor[rgb]{0.33,0.14,0.47}{Purple} and {\color[rgb]{0.72,0.60,0.37}Gold} for the team.
rgb
takes three
numbers, gray
takes only one.
The selection was \textcolor[gray]{0.5}{grayed out}.
\textcolor{green}{kind of \textcolor{blue}{blue}}
\colorbox{name}{...} \colorbox[model name]{box background color}{...}
\fcolorbox{frame color}{box background color}{...} \fcolorbox[model name]{frame color}{box background color}{...}
\fcolorbox
command puts a frame around the box. For instance this
Name:~\colorbox{cyan}{\makebox[5cm][l]{\strut}}
\strut
(so the depth is
-.3\baselineskip
and the height is \baselineskip
). This
puts white text on a blue background.
\colorbox{blue}{\textcolor{white}{Welcome to the machine.}}
\fcolorbox
commands use the same parameters as \fbox
(\fboxrule
and \fboxsep
, to
set the thickness of the rule and the boundary between the box interior
and the surrounding rule. &latex;&textrsquo;s defaults are 0.4pt
and
3pt
, respectively.
{\setlength{\fboxrule}{0.8pt} \fcolorbox{black}{red}{Under no circumstances turn this knob.}}
\pagecolor{name} \pagecolor[color model]{color specification} \nopagecolor
\pagecolor{white}
, although that will make a white background
rather than the default transparent background.)
... \pagecolor{cyan} ... \nopagecolor
\include{graphicx} % goes in the preamble ... \includegraphics[width=0.5\linewidth]{plot.pdf}
\usepackage{graphicx}
or
\usepackage{graphics}
. Most of the time, graphicx
is the
better choice.
picture
environment
(graphics
package options\usepackage[comma-separated option list]{graphics}
\usepackage[comma-separated option list]{graphicx}
graphicx
package has a format for optional arguments to the
\includegraphics
command that is convenient (it is the key-value
format), so it is the better choice for new documents. When you load
the graphics
or graphicx
package with \usepackage
there are two kinds of available options.
graphics
package configuration\graphicspath
\graphicspath{list of directories inside curly braces}
\includegraphics{lion.png}
instead of having to give its path.
\usepackage{graphicx} % or graphics; put in preamble ... \graphicspath{ {pix/} {../pix/} }
\graphicspath
declaration is optional. If you don&textrsquo;t include
it then &latex;&textrsquo;s default is to search all of the places that it
usually looks for a file (it uses &latex;&textrsquo;s \input&arobase;path
). In
particular, in this case one of the places it looks is the current
directory.
{pix}
. Do this even if there is only one directory.
Each directory name must end in a forward slash, {"my docs/"}
. Getting one of these rules wrong
will cause &latex; to report Error: File `filename' not
found
.
\graphicspath{ {pix/} {../pix/} } ... \usepackage{lion.png}
\graphicspath
command does not recursively search subdirectories:
if you issue \graphicspath{{a/}}
and the graphic is in
\graphicspath{{/home/jim/logos/}}
or
\graphicspath{{C:/Users/Albert/Pictures/}}
. However, using
these means that the document is not portable. (You could preserve
portability by adjusting your &tex; system settings configuration file
parameter TEXINPUTS
; see the documentation of your system.)
\graphicspath
anywhere in the document. You can use
it more than once. Show its value with
\makeatletter\typeout{\Ginput&arobase;path}\makeatother
.
\include{chapters/chap1}
. If in
\graphicspath{{plots/}}
then
&latex; will not search for graphics in \DeclareGraphicsExtensions
\DeclareGraphicsExtensions{comma-separated list of file extensions}
\includegraphics{functionplot}
.
\DeclareGraphicsExtensions{.png,PNG,.pdf,.PDF} ... \includegraphics{lion} % will findlion.png beforelion.pdf
\DeclareGraphicsExtensions
in
your document; the printer driver has a sensible default. For example,
the most recent .pdf,.png,.jpg,.mps,.jpeg,.jbig2,.jb2,.PDF,.PNG,.JPG,.JPEG,.JBIG2,.JB2
grfext
grfext
grfext
package.
\makeatletter\typeout{\Gin&arobase;extensions}\makeatother
.
\DeclareGraphicsRule
\DeclareGraphicsRule{extension}{type}{size-file extension}{command}
\DeclareGraphicsRule{.mps}{mps}{.mps}{}
\DeclareGraphicsRule{*}{mps}{*}{}
graphics
and
graphicx
packages.
\includegraphics
graphics
package:
\includegraphics{filename} \includegraphics[urx,ury]{filename} \includegraphics[llx,lly][urx,ury]{filename} \includegraphics*{filename} \includegraphics*[urx,ury]{filename} \includegraphics*[llx,lly][urx,ury]{filename}
graphicx
package:
\includegraphics{filename} \includegraphics[key-value list]{filename} \includegraphics*{filename} \includegraphics*[key-value list]{filename}
\includegraphics*
will
clip the graphic to the size specified, while for the unstarred form any
part of the graphic that is outside the box of the specified size will
over-print the surrounding area.
\usepackage{graphicx} % in preamble ... \begin{center} \includegraphics{plot.pdf} \end{center}
\includegraphics{graphics/plot.pdf}
. To specify a list
of locations to search for the file, \includegraphics{"sister picture.jpg"}
.
\includegraphics{filename}
command decides on the
type of graphic by splitting filename on the first dot. You can
instead use filename with no dot, as in
\includegraphics{turing}
, and then &latex; tries a sequence of
extensions such as .png
and .pdf
until it finds a file
with that extension (\includegraphics{{plot.2018.03.12.a}.pdf}
. Or, if you use
the graphicx
package then you can use the options type
and
ext
; see below. This and other filename issues are also handled
with the package figure
environment so &latex; can
move it to the next page if fitting it on the current page is awkward
(\begin{figure} \centering \includegraphics[width=3cm]{lungxray.jpg} \caption{The evidence is overwhelming: don't smoke.} \label{fig:xray} \end{figure}
\usepackage{caption} % in preamble ... \begin{center} \includegraphics{pix/nix.png} \captionof{figure}{The spirit of the night} \label{pix:nix} % optional \end{center}
\newcommand*{\vcenteredhbox}[1]{\begin{tabular}{&arobase;{}c&arobase;{}}#1\end{tabular}} ... \begin{center} \vcenteredhbox{\includegraphics[width=0.4\textwidth]{plot}} \hspace{1em} \vcenteredhbox{\begin{minipage}{0.4\textwidth} \begin{displaymath} f(x)=x\cdot \sin (1/x) \end{displaymath} \end{minipage}} \end{center}
graphics
package then the only options involve the
size of the graphic (but see [urx,ury]
and it gives the coordinates of the top
right corner of the image, as a pair of &tex; dimensions (bp
. In
this case, the lower left corner of the image is assumed to be at (0,0).
If two optional arguments are present then the leading one is
[llx,lly]
, specifying the coordinates of the image&textrsquo;s
lower left. Thus, \includegraphics[1in,0.618in]{...}
calls for
the graphic to be placed so it is 1 inch wide and 0.618 inches
tall and so its origin is at (0,0).
graphicx
package gives you many more options. Specify them
in a key-value form, as here.
\begin{center} \includegraphics[width=1in,angle=90]{lion} \hspace{2em} \includegraphics[angle=90,width=1in]{lion} \end{center}
%%BoundingBox
that appears in the file. It has four values,
giving the lower coordinate, lower coordinate, upper
coordinate, and upper coordinate. The units are
PostScript points, equivalent to &tex;&textrsquo;s big points, 1/72 inch.
For example, if an %%BoundingBox 10
20 40 80
then its natural size is 30/72 inch wide by
60/72 inch tall.
\includegraphics[type=png,ext=.xxx,read=.xxx]{lion}
will read the file \rotatebox
graphics
package:
\rotatebox{angle}{material}
graphicx
package:
\rotatebox{angle}{material} \rotatebox[key-value list]{angle}{material}
\begin{tabular}{ll} \rotatebox{45}{Character} &\rotatebox{45}{NATO phonetic} \\ A &AL-FAH \\ B &BRAH-VOH \end{tabular}
\rotatebox[origin=c]{45}{\includegraphics[width=1in]{lion}}
graphics
package then the rotation is about the
reference point of the box. If you use the graphicx
package
then these are the options that can go in the key-value list,
but note that you can get the same effect without needing this
package, except for the x
and y
options
(\scalebox
\scalebox{horizontal factor}{material} \scalebox{horizontal factor}[vertical factor]{material} \reflectbox{material}
\scalebox{0.5}{DRINK ME} and \scalebox{2.0}{Eat Me}
\scalebox{0.5}{\includegraphics{lion}}
graphicx
package then you can accomplish the same
thing with optional arguments to \includegraphics
(\reflectbox
command abbreviates
\scalebox{-1}[1]{material}
. Thus, Able was
I\reflectbox{Able was I}
will show the phrase Able was I
immediately followed by its mirror reflection against a vertical axis.
\resizebox
\resizebox{horizontal length}{vertical length}{material} \resizebox*{horizontal length}{vertical length}{material}
3cm
, transform material to make it
that size. If either horizontal length or vertical length
is an exclamation point !
then the other argument is used
to determine a scale factor for both directions.
\resizebox{0.5in}{!}{\includegraphics{lion}}
\resizebox
takes vertical length to be
the box&textrsquo;s height while the starred form \resizebox*
takes it to
be height+depth. For instance, make the text have a height+depth of a
quarter-inch with \resizebox*{!}{0.25in}{\parbox{3.5in}{This
box has both height and depth.}}
.
\depth
, \height
, \totalheight
, and
\width
to refer to the original size of the box. Thus, make the
text two inches wide but keep the original height with
\resizebox{2in}{\height}{Two inches}
.
%
is for comments. They are
called reserved characters or special characters. They are
all discussed elsewhere in this manual.
# $ % & { } _ ~ ^ \
\
in front of the character. Thus,
typing \$1.23
will produce $1.23
in your output.
\~{}
(omitting the curly braces would result in the next
character receiving a tilde accent). Similarly, to get a text body
font circumflex use \^{}
. To get a backslash in the font of
the text body, enter \textbackslash{}
.
\verb!!
as below (the double backslash \\
is only
there to split the lines in the output).
\begin{center} \# \$ \% \& \{ \} \_ \~{} \^{} \textbackslash \\ \verb!# $ % & { } _ ~ ^ \! \end{center}
\uppercase{text} \lowercase{text} \MakeUppercase{text} \MakeLowercase{text}
\uppercase
and \lowercase
are set up by default to work
only with the 26 letters a&textndash;z and A&textndash;Z. The &latex; commands
\MakeUppercase
and \MakeLowercase
commands also change
characters accessed by commands such as \ae
or \aa
. The
commands \MakeUppercase
and \MakeLowercase
are robust
but they have moving arguments (\MakeUppercase{Let $y=f(x)$
} produces LET Y=F(X). Another
example is that the name of an environment will be changed, so that
\MakeUppercase{\begin{tabular} ... \end{tabular}}
will
produce an error because the first half is changed to
\begin{TABULAR}
.
\Schoolname
produces
COLLEGE OF MATHEMATICS.
\newcommand{\schoolname}{College of Mathematics} \newcommand{\Schoolname}{\expandafter\MakeUppercase\expandafter{\schoolname}}
textcase
textcase
textcase
package brings some of the missing feature of the
standard &latex; commands \MakeUppercase
and
\MakeLowerCase
.
mfirstuc
mfirstuc
mfirstuc
.
expl3
expl3
expl3
package as of 2020. The article &textldquo;Case changing: From
&tex; primitives to the Unicode algorithm&textrdquo;, (Joseph Wright,
TUGboat 41:1,
\symbol
command. For example, the visible space character
used in the \verb*
command has the code decimal 32 in the
standard Computer Modern typewriter font, so it can be typed as
\symbol{32}
.
'
prefix, or hexadecimal (base 16) with a "
prefix, so the
visible space at 32 decimal could also be written as
\symbol{'40}
or \symbol{"20}
.
textcomp
package for some (technically, those in the
TS1
font encoding).
\ldots
and \dots
also work in math mode.
f\textcompwordmark i
produces fi without a ligature. This
is most useful in non-English languages. The
\textcapitalcompwordmark
form has the cap height of the font
while the \textascendercompwordmark
form has the ascender height.
\$
)\$
)---
)---
)The playoffs---if you're lucky
enough to make the playoffs---are more like a sprint.
&textrsquo; Conventions
for spacing around em-dashes vary widely.
--
)--
)see pages 12--14
&textrsquo;.
eurosym
eurosym
eurosym
eurosym
eurosym
package; also, most fonts nowadays come with their own
Euro symbol (Unicode U+20AC).
!`
)!`
)\textfiguredash
above;
the pdf&tex; approximation is an em-dash.
\textfiguredash
above; the pdf&tex; approximation is a regular ASCII hyphen (with
breaks disallowed after).
?`
)?`
)``
)``
)''
)''
)`
)`
)'
)'
)babel
babel
polyglossia
polyglossia
babel
package, which
supports pdf&latex;, Xe&latex; and Lua&latex;. The
polyglossia
package provides similar support with the latter
two engines.
\capital...
commands shown here produce alternative forms for
use with capital letters. These are not available with OT1.
\i
produces a dotless i,
\j
produces a dotless j.
These are often used in place of their dotted counterparts when they are
accented.
\accent
\accent number character
\accent18 e \accent20 e \accent21 e \accent22 e \accent23 e
\accent
use may differ between fonts. In &latex; it is
desirable to have glyphs for accented characters rather than building
them using \accent
. Using glyphs that already contain the
accented characters (as in T1 encoding) allows correct hyphenation
whereas \accent
disables hyphenation (specifically with OT1 font
encoding where accented glyphs are absent).
\spacefactor
to 1000 (\accent
provides for a single accent mark and a single letter
combination. There are also cases where accents must appear between
letters that \accent does not support. Still other cases exist where
the letters I and J have dots above their lowercase counterparts that
conflict with dotted accent marks. The use of \accent
in these
cases will not work as it cannot analyze upper/lower case.
inputenc
package\usepackage[encoding-name]{inputenc}
\"a
is used. This would make source files for anything
but English hard to read; even for English, often a more extensive
encoding is more convenient.
inputenc
package is how &latex; knows what encoding is
used. For instance, the following command explicitly says that the
input file is UTF-8 (note the lack of a dash).
\usepackage[utf8]{inputenc}
inputenc
only with the pdf&tex; engine
(inputenc
,
such as latin1
, then you will get the error inputenc is
not designed for xetex or luatex
.
inputenc
package error such as Invalid UTF-8 byte "96
means that some of the material in the input file does not follow the
encoding scheme. Often these errors come from copying material from a
document that uses a different encoding than the input file; this one
is a left single quote from a web page using latin1
inside a
&latex; input file that uses UTF-8. The simplest solution is to
replace the non-UTF-8 character with its UTF-8 equivalent, or use a
&latex; equivalent command or character.
\inputencoding{encoding-name}
. The most common values
for encoding-name are: ascii
, latin1
,
latin2
, latin3
, latin4
, latin5
,
latin9
, latin10
, and utf8
.
\rule
\rule{width}{thickness} \rule[raise]{width}{thickness}
\newcommand{\qedsymbol}{\rule{0.4em}{2ex}}
amsthm
amsthm
amsthm
package includes this command, with a somewhat
different-looking symbol.
\noindent\rule{\textwidth}{0.4pt}
\today
\today
babel
babel
polyglossia
polyglossia
babel
or polyglossia
, or
classes such as \today
. For example,
the following will output 4 juillet 1976:
\year=1976 \month=7 \day=4 \documentclass{minimal} \usepackage[french]{babel} \begin{document} \today \end{document}
\today
uses the counters \day
, \month
, and
\year
(datetime
datetime
datetime
package
which can produce a wide variety of date formats, including ISO standards.
\documentclass{book} \includeonly{ % comment out lines below to omit compiling pref, chap1, chap2, append, bib } \begin{document} \frontmatter \include{pref} \mainmatter \include{chap1} \include{chap2} \appendix \include{append} \backmatter \include{bib} \end{document}
\includeonly{...}
except for chap1
, and compile again,
then &latex; will only process the material in the first chapter.
Thus, your output will appear more quickly and be shorter to print.
However, the advantage of the \includeonly
command is that
&latex; will retain the page numbers and all of the cross reference
information from the other parts of the document so these will appear in
your output correctly.
\includeonly
.
\endinput
\endinput
\include{filename}
, inside \endinput
will not be included. This command is
optional; if \endinput
then &latex;
will read all of the file.
\input{chap1}
and this is \chapter{One} This material will appear in the document. \endinput This will not appear.
\endinput
halfway
through the included file and see if the error disappears. Now, knowing
which half contains the error, moving \endinput
to halfway
through that area further narrows down the location. This process
rapidly finds the offending line.
\endinput
, &latex; continues to read to the end of
the line, so something can follow this command and be read nonetheless.
This allows you, for instance, to close an \if...
with a
\fi
.
\include
& \includeonly
\includeonly{ % in document preamble ... filename, ... } ... \include{filename} % in document body
\include
command does three things: it executes
\clearpage
(\clearpage
. This command can only
appear in the document body.
\includeonly
command controls which files will be read by
&latex; under subsequent \include
commands. Its list of
filenames is comma-separated. It must appear in the preamble or even
earlier, e.g., the command line; it can&textrsquo;t appear in the document body.
\documentclass{book} \includeonly{ preamble, articles, amendments } \begin{document} \include{preamble} \include{articles} \include{amendments} \end{document}
\chapter{Preamble} We the People of the United States, in Order to form a more perfect Union, ...
\includeonly
&textrsquo;s lines with preamble
and amendments
and run &latex; again then the resulting document shows only the
material from \includeonly
then
&latex; will include all the files you call for with \include
commands.
\include
command makes a new page. To avoid that, see
\include
and \includeonly
. That example also uses \input
for some
material that will not necessarily start on a new page.
\documentclass{book} \includeonly{ chapters/chap1, } \begin{document} \include{chapters/chap1} \end{document}
\documentclass{book} \includeonly{ "amo\space amas\space amat" } \begin{document} \include{"amo\space amas\space amat"} \end{document}
\documentclass{book} \includeonly{ {"amo amas amat"} } \begin{document} \include{{"amo amas amat"}} \end{document}
\include
, not allowed\include
inside a file that is being included or
you get LaTeX Error: \include cannot be nested. The
\include
command cannot appear in the document preamble; you will
get LaTeX Error: Missing \begin{document}.
\include
does not exist, for instance if you
\include{athiesm}
but you meant \include{atheism}
,
then &latex; does not give you an error but will warn you No file
athiesm.tex. (It will also create \include
the root file in itself then you first get
LaTeX Error: Can be used only in preamble. Later runs get
TeX capacity exceeded, sorry [text input levels=15]. To fix
this, you must remove the inclusion \include{root}
but
also delete the file \input
\input{filename}
\input{macros}
\input{"amo\space amas\space amat"}
\input{{"amo amas amat"}}
\tableofcontents \listoffigures \listoftables
\chapter
, etc.
\tableofcontents
.
&latex; will produce a table of contents on the book&textrsquo;s first page.
\documentclass{book} % \setcounter{tocdepth}{1} \begin{document} \tableofcontents\newpage ... \chapter{...} ... \section{...} ... \subsection{...} ... \end{document}
\section
command has level 1. tocdepth
\tableofcontents
is in \newpage
command after the \tableofcontents
command, as
above.
\documentclass{article} \begin{document} \tableofcontents\newpage \section{First section} \subsection{First subsection} ...
\contentsline {section}{\numberline {1}First section}{2} \contentsline {subsection}{\numberline {1.1}First subsection}{2}
\contentsline
(section
or
subsection
, is the sectioning unit. The second argument has two
components. The hook \numberline
determines how the sectioning
number, 1
or 1.1
, appears in the table of contents
(\contentsline
, First section or First subsection,
is the sectioning title text. Finally, the third argument, 2, is
the page number on which this sectioning unit starts.
\l&arobase;section-unit
commands such as
\l&arobase;section{text}{pagenumber}
and
\l&arobase;subsection{text}{pagenumber}
. These commands
often use the \&arobase;dottedtocline
command
(\listoffigures
and \listoftables
produce a
list of figures and a list of tables. Their information is stored in
files with extension \tableofcontents
but the latter is more common, so we use it
for most examples.
\addcontentsline{toc}{section}{text}
.
(\addtocontents
, as with the command
\addtocontents{lof}{\protect\vspace{2ex}}
, which adds
vertical space to the list of figures (\&arobase;tocrmarg
and the page number is flush right in that space,
inside a box of width \&arobase;pnumwidth
. By default
\&arobase;tocrmarg
is 2.55em
and \&arobase;pnumwidth
is
1.55em
. Change these as with
\renewcommand{\&arobase;tocrmarg}{3.5em}
.
tocloft
tocloft
tocbibbind
tocbibbind
tocloft
is convenient for
adjusting some aspects of the default such as spacing. And,
tocbibbind
will automatically add the bibliography, index,
etc. to the table of contents.
\tableofcontents
, etc.
\renewcommand{\contentsname}{Table of Contents} \renewcommand{\listfigurename}{Plots} \renewcommand{\listtablename}{Specifications}
babel
babel
polyglossia
polyglossia
babel
or polyglossia
will change these headers depending on the chosen base language.
\&arobase;dottedtocline
\&arobase;dottedtocline{section-level-num}{indent}{numwidth}{text}{pagenumber}
\&arobase;dottedtocline
commands.
\l&arobase;section
, \l&arobase;subsection
,
etc., to format the content lines. For example, the \newcommand*\l&arobase;section{\&arobase;dottedtocline{1}{1.5em}{2.3em}} \newcommand*\l&arobase;subsection{\&arobase;dottedtocline{2}{3.8em}{3.2em}} \newcommand*\l&arobase;subsubsection{\&arobase;dottedtocline{3}{7.0em}{4.1em}}
\&arobase;dottedcline
appears to have been given only
three arguments. But tracing the internal code shows that it picks up
the final text and pagenumber arguments in the synopsis
from a call to \contentsline
(\&arobase;dottedtocline
commands insert leaders, that
is, evenly-spaced dots. The dot-to-dot space is given by the command
\&arobase;dotsep
. By default it is 4.5 (it is in math units, aka.&noeos;
mu
, which are 1/18
em. Change it using
\renewcommand
, as in \renewcommand{\&arobase;dotsep}{3.5}
.
\addcontentsline
\addcontentsline{ext}{unit}{text}
\addcontentsline{toc}{section}{\protect\textbf{Appendices}}
\addcontentsline
command writes information to the file
\contentsline{unit}{text}{num}
, where
num
is the current value of counter unit
(\chapter
,
etc. (\caption
inside a float
environment (\chapter*
. But that
command leaves out table of contents information, which can be entered
manually, as here.
\chapter*{Preface} \addcontentsline{toc}{chapter}{\protect\numberline{}Preface}
\contentsline {chapter}{\numberline {}Preface}{3}
; note
that the page number 3 is automatically generated by the system,
not entered manually.
\addcontentsline
are required.
\protect
any fragile commands
(\addcontentsline
command has an interaction with
\include
(\addcontentsline{...}{...}{...}\include{...}
then lines
in the table of contents can come out in the wrong order. The solution
is to move \addcontentsline
into the file being included.
\addcontentsline{toc}{setcion}{\protect\textbf{Appendices}}
\addtocontents
\addtocontents{ext}{text}
\tableofcontents\newpage \addtocontents{toc}{\protect\vspace*{3ex}}
\tableofcontents \addtocontents{toc}{~\hfill\textbf{Page}\par} \chapter{...}
\addtocontents{toc}{% \protect\vspace{2ex} \textbf{Chapters by N. Other Author}\par}
\addtocontents
and \addcontentsline
is that the latter is strictly for lines, such as with a line giving the
page number for the start of a new subset of the chapters. As the above
examples show, \addtocontents
is for material such as spacing.
\addtocontents
command has two arguments. Both are
required.
\chapter
use the
\addcontentsline
command to store information. This command
creates lines in the \contentsline
command (\addtocontents
puts material directly in that file.
\addtocontents
command has an interaction with
\include
(\addtocontents{...}{...}\include{...}
then lines in the
table of contents can come out in the wrong order. The solution is to
move \addtocontents
into the file being included.
\contentsline
\contentsline{unit}{text}{pagenumber}
\contentsline
commands.
\chapter
, \section
, etc. for the table of
contents, or by the \caption
command inside of a \figure
or \table
environment (\tableofcontents
, the command \chapter{Chapter One}
produces something like this in the file \contentsline {chapter}{\numberline {1}Chapter One}{3}
\listoffigures
then a figure
environment involving \caption{Test}
will produce
something like this in \contentsline {figure}{\numberline {1.1}{\ignorespaces Test}}{6}
\addcontentsline{filetype}{unit}{text}
,
where filetype is toc
, lof
, or lot
(tocloft
tocloft
\contentline
material is typeset, see
the tocloft
package.
hyperref
hyperref
hyperref
package changes the definition of
\contentsline
(and \addcontentsline
) to add more
arguments, to make hyperlinks. This is the source of the error
Argument of \contentsline has an extra }
when one adds/remove
the use of package hyperref
and a compilation was already run.
Fix this error by deleting the \nofiles
\nofiles
\nofiles
command this example will not produce a
\documentclass{book} \nofiles \begin{document} \tableofcontents\newpage \chapter{...} ...
\nofiles
command after you have run the file and gotten
a \numberline
\numberline{number}
\contentsline
command to typeset the section number
(1.1
to be
typeset flush left.
\contentsline {subsection}{\numberline {1.1}Motivation}{2}
\&arobase;tempdima
. That length is set by the commands
\l&arobase;section
, \l&arobase;subsection
, etc. Put section numbers
inside a natural-width box with
\renewcommand{\numberline}[1]{#1~}
before
\tableofcontents
.
\protect
(\protect
in this command,
\addcontentsline{toc}{section}{\protect\numberline{}Summary}
\numberline
into the \contentsline
command in the \contentsline
{section}{\numberline {}Summary}{6}
(the page number 6
is automatically added by &latex;; \documentclass{article} \usepackage{makeidx} % Provide indexing commands \makeindex % \usepackage{showidx} % Show marginal notes of index entries ... \begin{document} ... Wilson's Theorem\index{Wilson's Theorem} says that a number $n>1$ is prime if and only if the factorial of $n-1$ is congruent to $-1$ modulo~$n$.\index{congruence!and Wilson's Theorem} ... \printindex \end{document}
\index
command
(\index
writes its
information, such as Wilson's Theorem and the page number, to an
auxiliary file whose name ends in \printindex
brings this
manipulated information into the output (\printindex
command is in the source file.
\index{congruence!and Wilson's Theorem}
produces a main entry of congruence with a subentry of and
Wilson's Theorem. For more, \makeindex
and \printindex
commands are independent.
Leaving out the \makeindex
will stop &latex; from saving the
index entries to the auxiliary file. Leaving out the \printindex
will cause &latex; to not show the index in the document output.
showidx
showidx
multind
multind
showidx
package causes each index entries to be shown in the margin on the
page where the \index
appears. This can help in preparing the index.
The multind
package, among others, supports multiple indexes.
See also the &tex; FAQ entry on this topic,
theindex
theindex
\begin{theindex} \item acorn squash, 1 \subitem maple baked, 2 \indexspace \item bacon, 3 \subitem maple baked, 4 \end{theindex}
\item
,
subentries use \subitem
, and the lowest level uses
\subsubitem
. Blank lines between entries have no effect. The
example above includes \indexspace
to produce vertical space in
the output that some index styles use before the first entry starting
with a new letter.
\index
\index{index-entry-string}
pdflatex test
, then
process the index entries with makeindex test
, and then compile
again with pdflatex test
.
% file test.tex ... W~Ackermann (1896--1962).\index{Ackermann} ... Ackermann function\index{Ackermann!function} ... rate of growth\index{Ackermann!function!growth rate}
\index{Ackermann!function!growth rate!comparison}
then
\index
with the same
index-entry-string then you will get a single index entry with two
page numbers (unless they happen to fall on the same page). Thus,
adding as for Ackermann.\index{Ackermann}
later in the same
document as above will give an index entry like Ackermann, 22,
151. Also, you can enter the index entries in any order, so for
instance \index{Ackermann!function}
could come before
\index{Ackermann}
.
W~Ackermann (1896--1962).\index{Ackermann} ... D~Hilbert (1862--1943)\index{Ackermann!Hilbert|(} ... disapproved of his marriage.\index{Ackermann!Hilbert|)}
\index{Jones!program}
and \index{Jones!results}
, then
the output is the item Jones with no comma or page number,
followed by two subitems, like program, 50 and results,
51.
babel
babel
polyglossia
polyglossia
\index{Ackermann!function|see{P\'eter's
function}}
. You can instead get see also with seealso
.
(The text see is defined by \seename
, and see also
by \alsoname
. You can redefine these either by using an
internationalization package such as babel
or polyglossia
,
or directly as with \renewcommand{\alsoname}{Also see}
.)
\index{group|textit}
(note the missing backslash on the
\textit
command) and the system will apply that command to the
page number, here giving something like \textit{7}
. You can
define your own one-input commands, such as
\newcommand{\definedpage}[1]{{\color{blue}#1}}
and then
\index{Ackermann!function|definedpage}
will give a blue page
number (\newcommand\indexownpage[1]{#1, \thepage} ... Epimenides.\index{self-reference|indexownpage}
\index{Ackermann!function|(definedpage} ... \index{Ackermann!function|)}
$\alpha$-ring
will cause it to be alphabetized according to
the dollar sign. You can instead enter it using an at-sign, as
\index{alpha-ring&arobase;$\alpha$-ring}
. If you specify an entry
with an at-sign separating two strings, pos&arobase;text
,
then pos gives the alphabetical position of the entry while
text produces the text of the entry. Another example is that
\index{Saint Michael's College&arobase;SMC}
produces an index entry
SMC alphabetized into a different location than its spelling
would naturally give it.
!
, or &arobase;
, or |
, or "
character in
an index entry, escape it by preceding it with a double quote, "
.
(The double quote gets deleted before alphabetization.)
index
index
makeidx
. One is index
, which allows for
multiple indices and contains a command
\index*{index-entry-string}
that prints the
index-entry-string as well as indexing it.
\index
command writes the indexing information to the file
\indexentry{index-entry-string}{page-num}
,
where page-num is the value of the \thepage
counter. On
occasion, when the \printindex
command is confused, you have to
delete this file to start with a fresh slate.
\index
command then you get a
message like this.
Runaway argument? {Ackermann!function ! Paragraph ended before \&arobase;wrindex was complete.
makeindex filename makeindex -s style-file filename makeindex options filename0 ...
\printindex
(% book.isty % $ makeindex -s book.isty -p odd book.idx % creates the index as book.ind, starting on an odd page. preamble "\\pagestyle{empty} \\small \\begin{theindex} \\thispagestyle{empty}" postamble "\n \\end{theindex}"
"
, and the maximum length of a
string is 144 characters. The \n
is for a newline and \t
is for a tab. Backslashes are escaped with another backslash,
\\
. If a line begins with a percent sign, %
, then it is a
comment.
"\\begin{theindex}\n"
.
"\n\n\\end{theindex}\n"
.
"\n\n
\\indexspace\n"
(\indexspace
is a command inserting a rubber
length, by default 10pt plus5pt minus3pt
).
group_skip
nothing
will be inserted before the group. If it is positive then at a new
letter the lethead_prefix
and lethead_suffix
will be
inserted, with that letter in uppercase between them. If it is negative
then what will be inserted is the letter in lowercase. The default
is 0.
""
""
.
"\n \\item
"
.
"\n \\subitem "
.
"\n \\subsubitem "
.
"\n \\subitem "
.
\index{aaa|see{bbb}}
). Default: "\n \\subitem "
.
"\n \\subsubitem "
.
"\n
\\subsubitem "
.
", "
.
", "
.
", "
.
", "
.
"--"
.
72
.
"\t\t"
.
indent_space
is two tabs and each tab is eight spaces so the
default here is 16
.
r
, and numeric
or arabic n
, and lowercase alphabetic a
, and uppercase
roman R
, and uppercase alphabetic A
. Default:
"rnaRA"
.
xindex
,
written in Lua (\printindex
makeidx
makeidx
\usepackage{makeidx}\makeindex
in the document preamble and
compile the document, then run the system command \printindex
.
\usepackage{glossaries} \makeglossaries ... \newglossaryentry{label}{settings} ... \gls{label}. ... \printglossaries
pdflatex filename
), then run the command line command
makeglossaries filename
, and then compile the document again.
\documentclass{...} \usepackage{glossaries} \makeglossaries \newglossaryentry{tm}{% name={Turing machine}, description={A model of a machine that computes. The model is simple but can compute anything any existing device can compute. It is the standard model used in Computer Science.}, } \begin{document} Everything begins with the definition of a \gls{tm}. ... \printglossaries \end{document}
\makeglossary
opens the file that will contain the
entry information, \printglossaries
command where you want the glossaries to appear
in your document.
\newglossaryentry
and \gls
, there are similar
commands for a list of acronyms. See the package documentations on
CTAN.
\newglossaryentry
\newglossaryentry{label} { name={name}, description={description}, other options, ... }
\longnewglossaryentry{label} { name={name}, other options ..., } {description}
key=value
.
\newglossaryentry{R} { name={\ensuremath{\mathbb{R}}}, description={the real numbers}, }
\glspl
or \Glspl
(\gls
\gls{label} \glspl{label} \Gls{label} \Glspl{label}
\newglossaryentry
(\newglossaryentry{N}{% name={the natural numbers}, description={The numbers $0$, $1$, $2$, $\ldots$\&arobase;}, symbol={\ensuremath{\mathbb{N}}}, } ... Consider \gls{N}.
\glspl{label}
produces the plural
of name (by default it tries adding an s). The third form
capitalizes the first letter of name, as does the fourth form,
which also takes the plural.
\documentclass{letter} \address{senders address} % return address \signature{sender name} \begin{document} \begin{letter}{recipient address} \opening{salutation} letter body \closing{closing text} \end{letter} ... \end{document}
letter
environment, whose argument
recipient address often contains multiple lines separated with a
double backslash, (\\
). For example, you might have:
\begin{letter}{Ninon de l'Enclos \\ l'h\^otel Sagonne} ... \end{letter}
letter
environment resets the page number to 1,
and the footnote number to 1 also.
\\
). &latex; will put the sender name
under the closing, after a vertical space for the traditional
hand-written signature.
letter
environment body begins with a required
\opening
command such as \opening{Dear Madam or Sir:}
.
The letter body text is ordinary &latex; so it can contain
everything from enumerated lists to displayed math, except that commands
such as \chapter
that make no sense in a letter are turned off.
Each letter
environment body typically ends with a
\closing
command such as \closing{Yours,}
.
\closing
. You can say who
is receiving a copy of the letter with a command like \cc{the
Boss \\ the Boss's Boss}
. There&textrsquo;s a similar \encl
command for
a list of enclosures. And, you can add a postscript with \ps
.
\longindentation
. By default this is
0.5\textwidth
. To make them flush left, put
\setlength{\longindentation}{0em}
in your preamble.
\renewcommand{\today}{1958-Oct-12}
. If put in your preamble
then it will apply to all the letters.
letter
environment. The three lines
marked as optional are typically omitted.
\documentclass{letter} \address{Sender's street \\ Sender's town} \signature{Sender's name \\ Sender's title} % optional: \location{Mailbox 13} % optional: \telephone{(102) 555-0101} \begin{document} \begin{letter}{Recipient's name \\ Recipient's address} \opening{Sir:} % optional: \thispagestyle{firstpage} I am not interested in entering a business arrangement with you. \closing{Your most humble, etc.,} \end{letter} \end{document}
letter
class.
\address
\address{senders address}
\\
.
letter
environment.
\address
declaration then it
is formatted as a personal letter.
\address{Stephen Maturin \\ The Grapes of the Savoy}
\cc
\cc{name0 \\ ... }
\closing
. Put the names on different lines by separating them
with a double backslash, \\
, as in:
\cc{President \\ Vice President}
\closing
\closing{text}
\closing{Regards,}
\encl
\encl{first enclosed object \\ ... }
\closing
.
Separate multiple lines with a double backslash, \\
.
\encl{License \\ Passport}
\location
\location{text}
firstpage
.
\makelabels
\makelabels % in preamble
letter
environments. If
you just put \makelabels
in the preamble then at the end of the
document you will get a sheet with labels for all the recipients, one
for each letter environment, that you can copy to a sheet of peel-off
address labels.
\startlabels
,
\mlabel
, and \returnaddress
(and perhaps \name
) in
the preamble. The command \startlabels
sets the width, height,
number of columns, etc., of the page onto which the labels are printed.
The command \mlabel{return address}{recipient
address}
produces the two labels (or one, if you choose to ignore the
return address) for each letter environment. The first argument,
return address, is the value returned by the macro
\returnaddress
. The second argument, recipient address, is
the value passed in the argument to the letter
environment. By
default \mlabel
ignores the first argument, the return
address, causing the default behavior described in the prior paragraph.
\documentclass{letter} \renewcommand*{\returnaddress}{Fred McGuilicuddy \\ Oshkosh, Mineola 12305} \newcommand*\originalMlabel{} \let\originalMlabel\mlabel \def\mlabel#1#2{\originalMlabel{}{#1}\originalMlabel{}{#2}} \makelabels ... \begin{document} \begin{letter}{A Einstein \\ 112 Mercer Street \\ Princeton, New Jersey, USA 08540} ... \end{letter} \begin{letter}{K G\"odel \\ 145 Linden Lane \\ Princeton, New Jersey, USA 08540} ... \end{letter} \end{document}
envlab
envlab
envlab
makes formatting the labels easier, with
standard sizes already provided. The preamble lines
\usepackage[personalenvelope]{envlab}
and \makelabels
are all that you need to print envelopes.
\name
\name{name}
\opening
\opening{salutation}
\begin{letter}{...}
. The argument
salutation is mandatory. For instance:
\opening{Dear John:}
\ps
\ps{text}
\closing
.
\ps{P.S. After you have read this letter, burn it. Or eat it.}
\signature
\signature{first line \\ ... }
\\
. For example:
\signature{J Fred Muggs \\ White House}
\closing
text
down to the \signature
text is 6\medskipamount
, which is
six times \medskipamount
(where \medskipamount
is equal to
a \parskip
, which in turn is defined by default here to
0.7letter
environment and before the \closing
.
\signature{\vspace{-6\medskipamount}\includegraphics{sig.png}\\ My name}
\usepackage{graphicx}
in the preamble
(\telephone
\telephone{number}
firstpage
pagestyle is selected. If so, it appears on the lower right of the
page.
\openin
& \openout
\openin number=filename
\openout number=filename
\openin3
; in
Lua&latex;, number can be between 0 and 127.
\newread\presidentsfile \openin\presidentsfile=presidents \typeout{presidentsfile is \the\presidentsfile} \read\presidentsfile to\presidentline \typeout{\presidentline}
\newread
command allocates input stream numbers from 0
to 15 (there is also a \newwrite
). The
\presidentsfile
is more memorable but under the hood it is still
a number; the first \typeout
gives something like
presidentsfile is 1. In addition, \newread
keeps track of
the allocation so that if you use too many then you get an error like
! No room for a new \read. The second \typeout
gives the
first line of the file, something like 1 Washington, George.
\immediate\openin number=filename
or
\immediate\openout number=filename
.
\closein number
and
\closeout number
.
\newwrite\presidentsfile \openout\presidentsfile=presidents \write\presidentsfile{1 Washington, George} \closeout\presidentsfile
\openin
, if &tex; cannot find the file then it does not give
an error. It just considers that the stream is not open (test for this
with \ifeof
; one recourse is the command
\InputIfFileExists
, \read
\read number tomacro
\read5 to\data
.
\email
, and then closes the file.
\newread\recipientfile \openin\recipientfile=email \read\recipientfile to\email \typeout{Email address: \email} \closein\recipientfile
\read
will take input from the terminal (or exit if interaction is not
allowed, e.g., \nonstopmode
; \typein
(\input
(\include
(datatool
datatool
datatool
.
\typein
\typein{prompt-msg} \typein[cmd]{prompt-msg}
As long as I live I shall never forget \typein{Enter student name:}
Enter student name: \&arobase;typein=Aphra Behn
\typein{prompt-msg}
, causes
the input you typed to be processed as if it had been included in the
input file in place of the \typein
command.
cmd
argument must be a command name, that is, it must begin with a
backslash, \. This command name is then defined or redefined to be
the input that you typed. For example, this
\typein[\student]{Enter student name:} \typeout{Recommendation for \student .}
Enter student name: \student=John Dee Recommendation for John Dee.
\typeout
\typeout{msg}
msg
on the terminal and in the log
file.
\newcommand{\student}{John Dee} \typeout{Recommendation for \student .}
\student
, commands that are defined with \newcommand
or
\renewcommand
(among others) are replaced by their definitions
before being printed.
msg
. Use the
command \space
to get a single space, independent of surrounding
spaces. Use ^^J
to get a newline. Get a percent character with
\csname &arobase;percentchar\endcsname
.
\newlength{\jhlength} \setlength{\jhlength}{5pt} \typeout{The length is \the\jhlength.}
\write
\write number{string}
\openout
. For instance, \write6
writes to text
stream number 6.
\newwrite\myfile \immediate\openout\myfile=\jobname.jh % \jobname is root file basename ... \immediate\write\myfile{Hello world!} ... \immediate\closeout\myfile
\newwrite
allocates a stream number, giving it a symbolic
name to make life easier, so that stream
\newwrite\myfile\the\myfile
produces something like stream 3.
Then \openout
associates the stream number with the given file
name. &tex; ultimately executed \write3
which puts the string
in the file.
test \write-1{Hello World!}
puts Hello World!
followed by a newline in the log file. (This is what the \wlog
command does; \write100{Hello World!}
puts the same in the log file but also puts Hello World!
followed by a newline in the terminal output. (But 16, 17, and 18 are
special as number; see below.)
\write\&arobase;auxout{string}
to write to the current
\write\&arobase;mainaux{string}
to write to the main
\write
to
save the current page number, but when &tex; comes across a
\write
it typically does not know what the page number is,
since it has not yet done the page breaking. So, you use \write
in one of three contexts:
\immediate\write\&arobase;auxout{string} %1 \write\&arobase;auxout{string} %2 \protected&arobase;write\&arobase;auxout{}{string} %3
\write
\edef
) so to prevent expansion you must use \noexpand
,
toks
, etc., except that you should use #
instead of
##
).
\write
\shipout
. At
\shipout
, string is fully expanded.
\protected&arobase;write
, is like the second except that
you can use \protect
to avoid expansion. The extra first
argument allows you to locally insert extra definitions to make more
macros protected or to have some other special definition for the
write.
\write
, string here
contains a control sequence \triplex
which we&textrsquo;ve defined to be
the text XYZ:
\newwrite\jhfile \openout\jhfile=test.jh \newcommand{\triplex}{XYZ} \write\jhfile{test \triplex test}
\write
streams 16, 17, 18\write
&textrsquo;s behavior when number is outside the range from 0
to 15 described above, in Plain &tex; \write16
and
\write17
were sometimes used to write to the log file and the
terminal; however, in &latex;, the natural way to do that is with
\typeout
(\write18
command is
even more special; modern &tex; systems use it for giving commands to
the operating system (\write
^^J
, in \write
\write
outputs a single line. You can include a
newline with ^^J
. Thus, this produces two lines in the log
file:
\wlog{Parallel lines have a lot in common.^^JBut they never meet.}
answers
answers
answers
.
\write
and security\write
\write
and security\newwrite\jhfile \openout\jhfile=../test.jh
Not writing to ../test.jh (openout_any = p). ! I can't write on file `../test.jh'
\include{../filename}
because &latex; will try to open
\message
\message{string}
\typeout
(\protect
on any fragile commands in
string (\typeout
always inserts a
newline at the end of string while \message
does not, so
the latter can be useful.
before\message{One Two}\message{Three}\message{Four^^JI} \message{declare a thumb war.}After
One Two Three Four I declare a thumb war.
^^J
produces a newline. Also, in the output document,
between before and After will be a single space (from
the end of line following I}).
\message
allows you more control over formatting, a
gotcha is that &latex; may mess up that formatting because it inserts
line breaks depending on what it has already written. Contrast this
document body, where the Two has moved, to the one given above.
before\message{One}\message{Two Three}\message{Four^^JI} \message{declare a thumb war.}After
\wlog
\wlog{string}
\wlog{Did you hear about the mathematician who hates negatives?} \wlog{He'll stop at nothing to avoid them.}
^^J
to insert a newline.
\wlog{Helvetica and Times Roman walk into a bar.} \wlog{The barman says,^^JWe don't serve your type.}
\write18
\write18{shell_command}
Asymptote
Asymptote
\usepackage{graphicx} % in preamble ... \newcommand{\fignum}{1} \immediate\write18{cd pix && asy figure\fignum} \includegraphics{pix\figure\fignum.pdf}
asy
program) on \write
, here &latex;
expands macros in shell_command so that \fignum
is
replaced by 1.
\immediate\write18{bibtex8 \jobname}
as the first line of the
file. Note that \jobname
expands to the basename of the root
file unless the --jobname
option is passed on the command line,
in which case this is the option argument.
texosquery
below):
\immediate\write18{ls *.pdf > tmp.dat} \input{tmp.dat}
\write
is to wait until a page is
being shipped out before expanding the macros or writing to the stream
(\immediate\write18{shell_command}
.
latex --enable-write18 filename
(--shell-escape
option is
a synonym, in &tex; Live.)
enable-write18
option. By default this list of allowed
commands is short and features only commands that are under the
control of the distribution maintainers (\write18
\write18
\write18
SHELL
environment variable, is ignored.
texosquery
texosquery
texosquery
package, which provides a convenient and secure
interface for this, unlike the above examples using the raw
\write18
: shellesc
shellesc
shellesc
on top of the primitive
\write18
command. Its primary purpose is to provide a command
\ShellEscape
which works identically on all &tex; engines;
Lua&tex; intentionally did not retain \write18
as a way to
invoke a shell command, so some engine-specific code is needed. The
shellesc
package also provides a command
\DelayedShellEscape
, executed at \output
time, for the
same reason.
pdflatex options argument
lualatex
, or
(for DVI output) latex
or dvilualatex
, among others
(pdflatex thesis
dvilualatex
, then you will get
DVI. The description here assumes pdf&latex;.
latex-engine options argument
hyperref
hyperref
hyperref
package for hyperlinks) can produce two kinds of
output, one to be read on physical paper and one to be read online.
\ifdefined\paperversion % in preamble \newcommand{\urlcolor}{black} \else \newcommand{\urlcolor}{blue} \fi \usepackage[colorlinks=true,urlcolor=\urlcolor]{hyperref} ... \href{https://www.ctan.org}{CTAN} % in body ...
pdflatex book
will give the CTAN link in blue. But
compiling it with
pdflatex "\def\paperversion{}\input book.tex"
pdflatex -jobname=students "\def\student{}\input{main}" pdflatex -jobname=teachers "\def\teachers{}\input{main}"
jobname
option is there because otherwise both files would be
called \documentclass{book} \begin{document} ... \include{chap1} \include{chap2} ... \end{document}
pdflatex "\includeonly{chap1}\input{mybook}"
\jobname
pdflatex thesis
creates
thesis.pdf
and also thesis.log
and thesis.aux
.
Here the job name is thesis
.
latex-engine
options argument
, where latex-engine is
thesis
, then &tex; considers it to be the name of the file
to input as the main document. This file is referred to as the root
file (\input
command,
and the jobname is the argument to \input
.
-jobname
option, as in pdflatex
-jobname=myname
(-jobname
option was specified, and the compilation stops before
any input file is met, then the log file will be named
texput
jobnametexput
jobname\input
occurs as a result of being called by either
\documentclass
or \RequirePackage
. So this will produce
a file named pdflatex "\documentclass{minimal}\begin{document}Hello!\end{document}"
pdflatex "\documentclass{article}\usepackage{lipsum}\input{thesis}"
\usepackage
calls
\input
.
\jobname
expands to the jobname.
(When you run &latex; on a file whose name contains spaces, the string
returned by \jobname
contains matching start and end quotes.)
In the expansion of that macro, all characters are of
catcode 12 (other) except that spaces are category 10,
including letters that are normally catcode 11.
xstring
xstring
\IfBeginWith
from the If a democracy is just a regime where citizens vote then all banana republics \IfBeginWith*{\jobname}{my-doc}% {\footnote{Including Respublica Bananensis Francorum.}}{} are democracies.
\jobname
inside of a document does not
change the name of the output file or the log file.
?
. For instance,
running &latex; on this file
\newcommand{\NP}{\ensuremath{\textbf{NP}}} The \PN{} problem is a million dollar one.
! Undefined control sequence. l.5 The \PN {} problem is a million dollar one. ?
\end{document}
or misspelled it. In this case
&latex; gives you a * prompt. You can get back to the command
line by typing \stop and RETURN; this command does its
best to exit &latex; immediately, whatever state it may be in.
pdflatex test
you might type pdflatex tste
.
! I can't find file `tste'. <*> tste (Press Enter to retry, or Control-D to exit) Please type another input file name:
beamer
templatebeamer
template and classbeamer
beamer
beamer
beamer
class creates presentation slides. It has a vast
array of features, but here is a basic template:
article
templatearticle
book
templatebook
book
templatebook
\frontmatter
, \mainmatter
, and
\backmatter
to control the typography of the three main areas
of a book (\include
and \includeonly
(\includeonly
. That will speed up compilation without losing
any information such as cross-references. (Material that does not
need to come on a new page is brought in with \input
instead of
\include
. You don&textrsquo;t get the cross-reference benefit with
\input
.)