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 (\
. 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 commands 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.
\mainmatter
declaration changes the typesetting of
page numbers from roman numerals to arabic (*
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).
\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}
\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.
\text...
commands,
is used with an argument, as in \textit{text}
. This is
the preferred form. But shown after it, in parenthesis, is the
corresponding declaration form, which is sometimes useful. This form
takes no arguments, as in {\itshape text}
. The scope of
the declaration form lasts until the next type style command or the end
of the current group. In addition, each has an environment form such as
\begin{itshape}...\end{itshape}
.
\sffamily\bfseries
or \bfseries\sffamily
.
\nocorrlist
, which by default consists of a period and a 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.
textcomp
textcomp
\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 the
textcomp
package must be loaded, and 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
extra curly braces {\small We are here, we are here, we are
here!}
. You can instead use the environment form of these commands;
for instance, \begin{tiny}...\end{tiny}
.
\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 environment starts; in the preamble is a good
place.
\setlength{\columnseprule}{0.4pt}
, before the two-column
environment starts.
\textwidth
. In two-column mode by default &latex; sets the
width of each of the two columns 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 and 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
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.
figure
(table
(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 \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}
):
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 is not numbered and does not make an entry in the table of contents.
An example of using this is for an appendix in an article
. The
input \appendix\section{Appendix}
gives the output A
Appendix (\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, that before a \section
you will
have a \chapter
. Otherwise you can get a something like a
subsection numbered 3.0.1.
\setcounter{secnumdepth}{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
secnumdepth
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
titlesec
titlesec
\part
is \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
\renewcommand{\chaptername}{Lecture}
or this
(\makeatletter \renewcommand{\&arobase;chapapp}{Lecture} \makeatother
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
\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
titlesec
titlesec
\section
command, there
are a number of options. One is the \&arobase;startsection
command
(\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 section number, does not increment the
section
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
titlesec
titlesec
\subsection
command. One is the \&arobase;startsection
command
(\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
titlesec
titlesec
\&arobase;startsection
command (\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
\appendixpage
to put a separate Appendices in the document
body before the first appendix, and the command \addappheadtotoc
to do the same in the table of contents. You can reset the name
Appendix with a command like
\renewcommand{\appendixname}{Specification}
, as well as a
number of other features. See the documentation on CTAN.
\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
declaration 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
changes the behavior back to the expected
version, and resets the page number. The \backmatter
leaves the
page numbering alone but switches the chapters back to being not
numbered. \&arobase;startsection
\&arobase;startsection{name}{level}{indent}{beforeskip}{afterskip}{style}
\section
or \subsection
.
\&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
to have the form
\section*[toctitle]{title}
(here too, the
star *
is optional). \renewcommand{section}{...}
,
the \&arobase;startsection{...}
must come last in the definition. See
the examples below.
\&arobase;startsection
, for the -3.5ex
plus -1ex minus -0.2ex
, the afterskip is 2.3ex plus 0.2ex
,
and the style is \normalfont\Large\bfseries
. For
subsection, the level is 2, the indent is 0-3.25ex plus -1ex minus -0.2ex
, the
afterskip is 1.5ex plus 0.2ex
, and the style is
\normalfont\large\bfseries
. For subsubsection, the level
is 3, the indent is 0-3.25ex plus -1ex minus -0.2ex
, the afterskip is
1.5ex plus 0.2ex
, and the 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
\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}
\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
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
\usepackage{amsmath} % in preamble \begin{equation} \begin{vmatrix}{cc} % array with vert lines a &b \\ c &d \end{vmatrix}=ad-bc \end{equation}
array (package)
array (package)
dcolumn
dcolumn
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{definition} \item[lama] A priest. \item[llama] A beast. \end{definition}
\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.
\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
\[math text\]
is essentially a synonym for
\begin{displaymath}math text\end{displaymath}
but the
latter is easier to work with in the source file; for instance,
searching for a square bracket may get false positives but the word
displaymath
will likely be unique. (The construct
$$math text$$
from Plain &tex; is sometimes
mistakenly used as a synonym for displaymath
. It is not a
synonym, because the displaymath
environment checks that it isn&textrsquo;t
started in math mode and that it ends in math mode begun by the matching
environment start, because the displaymath
environment has
different vertical spacing, and because the displaymath
environment honors 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
(\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
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
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. By default it is numbered. If loftitle is present, it is
used in the list of figures instead of title (\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
: Write an external filefilecontents
filecontents
filecontents*
filecontents*
\begin{filecontents}{filename} text \end{filecontents}
\begin{filecontents*}{filename} text \end{filecontents*}
filecontents
prefixes the
content of the created file with a header; see the example below. The
starred version filecontents*
does not include the header.
\documentclass
command. It is typically used
when a source file requires a nonstandard style or class file. The
environment will write that file to the directory containing the source
and thus make the source file self-contained. Another use is to include
bib
references in the file, again to make it self-contained.
filecontents
environment so that instead of doing
nothing in that case, it will overwrite the existing file.
\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 \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.
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
; 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}
\item
command (\item
an optional argument by following it with square
brackets, as in \item[Optional label]
, then by default it 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 optional text, which may
contain multiple paragraphs.
enumerate
(itemize
environment
uses the commands \labelitemi
through \labelitemiv
to
produce the default label (this also uses 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
. (Note 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.
\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 items 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 as 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] 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.
\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|l} \multicolumn{1}{r}{Borough} &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 commands \end{picture}
\begin{picture}(width,height)(xoffset,yoffset) picture commands \end{picture}
TikZ
, PSTricks
, MetaPost
,
or Asymptote
. These are not covered in this document; see CTAN.
\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){\line(1,1){6}} \put(3,3){\makebox(0,0)[r]{sum\ }} \end{picture}
\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}
\linewidth
from
the left margin, and 0.35\linewidth
up from the bottom. 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.
picture
environment has one required argument, a pair of
numbers (width,height). Multiply these by the value
\unitlength
to get the nominal size of the output, 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 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.
\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.
\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.
\qbezier
for
that curve.
\begin{picture}(3,1.5) \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 rectangle \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}
\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
).
\graphpaper
\graphpaper(x_init,y_init)(x_dimen,y_dimen) \graphpaper[spacing](x_init,y_init)(x_dimen,y_dimen)
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
packagepict2e
pict2e
TikZ
TikZ
PSTricks
PSTricks
MetaPost
MetaPost
Asymptote
Asymptote
picture
, see the package \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 \\ ... }
\put(0,0){\vector(1,0){4}} % x axis \put(0,0){\vector(0,1){2}} % y \put(-0.25,2){\makebox[0][r]{\shortstack[r]{$y$\\ axis}}}
\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 heights. Thus, in
\shortstack{X\\o\\o\\X}
the first and last rows are taller than
the middle two. You can adjust row heights either by putting in the
usual interline spacing with \shortstack{X\\ \strut o\\o\\X}
,
or by hand, via an explicit zero-width box \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{0.75in} \= \hspace{0.40in} \= \hspace{0.40in} \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 starts a new paragraph.
tabbing
environment always starts a new paragraph, without
indentation. Moreover, as shown in the example above, there is no need
to use the starred form of the \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
,
including text, &latex; commands, etc.
parbox
of width \textwidth
.
It can contain text, commands, graphics, etc.
\caption
command is also optional. It specifies caption text
for the table. By default it is numbered. If its optional
lottitle is present then that text is used in the list of tables
instead of title (\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}
\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
\refname
or \bibname
to fit the selected
language.
\bibitem
\bibitem{cite_key}
\bibitem[label]{cite_key}
enumi
counter. The citation key
\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}
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
(\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.
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 (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 commands's first argument is \verb*!filename with extension! and ...
url
url
url
provides an option that is better than the \verb
command, since
it allows line breaks.
listings
listings
minted
minted
\verb
. One is 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 (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]
\\*
, tells &latex; not to start a new page
between the two lines, by issuing a \nobreak
.
\title{My story: \\[0.25in] a tale of woe}
\\
. 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.
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}{\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 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 insist on 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 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
\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 it extends to 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. 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
\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
\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 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}
table
environment (\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
\usepackage{bigfoot} % in preamble \DeclareNewFootnote{Default} \DeclareNewFootnote{from}[alph] % create class \footnotefrom{} ... The third theorem is a partial converse of the second.\footnotefrom{% First 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
).
{}
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, 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}}
.
\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}{Saint Michael's College} 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
changes the
default code and then changes it back. Use them 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. For commands the situation is more
complex. 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 at-sign &arobase;
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{night}
will return "starry night sky" while
\ciel*{blue}
will return "starry not blue sky".
\newcommand*{\ciel&arobase;unstarred}[1]{starry #1 sky} \newcommand*{\ciel&arobase;starred}[1]{starry not #1 sky} \newcommand*{\ciel}{\&arobase;ifstar{\ciel&arobase;starred}{\ciel&arobase;unstarred}}
``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}}
\&arobase;ifstar
. The \newcommand\mycommand{unstarred version}
followed by
\WithSuffix\newcommand\mycommand*{starred version}
. And
&latex;3 has the \NewDocumentCommand\foo{s}{\IfBooleanTF#1 {starred version}% {unstarred version}% }
\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{arg}
\
. 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
\arg
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.
\makeatletter \newcommand{\honorific}[1]{\def\&arobase;honorific{#1}} % remember title \newcommand{\fullname}[1]{\&arobase;honorific~#1} % put title before name \makeatother \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\&arobase;honorific~#1}
.
\ignorespaces
is also often used in a \newenvironment
at the end of the begin clause, that is, as part of the second
argument, 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}
.
\
. 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 &textmdash; 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 \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) such as 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
.
\enspace
, which is 0.5em
). Use of these can help make a
definition work better across font changes. For example, a definition
of the vertical space between list items given as
\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}
\
. 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 the above as
\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. <to be
read again> \relax l.19 \setlength{specparindent}{0.6\parindent}
\addtolength
\addtolength{len}{amount}
\
. 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
, 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}
\
.
\newlength{\alphabetdepth} \settodepth{\alphabetdepth}{abcdefghijklmnopqrstuvwxyz} \the\alphabetdepth
\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 must
begin with a backslash, \
.
\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}
\
.
\newlength{\alphabetwidth} \settowidth{\alphabetwidth}{abcdefghijklmnopqrstuvwxyz} \the\alphabetwidth
\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.
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?''
%
.
\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 but
it 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 \section
command (\par
command is not the same as the \paragraph
command. The latter is, like \section
or \subsection
, a
sectioning unit used by the standard &latex; documents
(\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{\parskip}{horizontal len} \setlength{\parinden}{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
. The default
value for \parskip
in &latex;&textrsquo;s standard document styles 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 (\displaystyle
declaration
forces the size and style of the formula to be that of
displaymath
. Thus \(\displaystyle \sum_{n=0}^\infty
x_n\)
will have the limits above and below the summation sign, not next
to it. Another example is that
\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
, the Arithmetic line&textrsquo;s
fraction will be scrunched. But, because of its \displaystyle
,
the Geometric line&textrsquo;s fraction will be easy to read, with
characters the same size as in the rest of the line.
amsmath
amsmath
amsfonts
amsfonts
mathtools
mathtools
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
symbols
symbols
$\pi$
in your source,
you will get the pi symbol 03C0. See the \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
.
\cdot
.
\bigcap
.
\bullet
.
\bigcirc
.
$S^\complement$
(ordinary). Not available in plain &tex;. In &latex; you need to load the $S^{\mathsf{c}}$
or $\bar{S}$
.
\bigcup
.
\vdash
.
\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
.
\vartriangleleft
(which is a relation
and so gives better spacing).
\gg
.
\neg
.
\Longleftarrow
.
\Longleftrightarrow
.
\mapsto
.
\Longrightarrow
.
\wedge
.
\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 \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 \upharpoonright
. Not available in plain &tex;. In &latex; you need to load the \varnothing
. Not available in plain &tex;. In &latex; you need to load the \lfloor
.
\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 \subseteq
.
\supset
. Not available in plain &tex;. In &latex; you need to load the \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 \vartriangleleft
(which
is a relation and so gives better spacing).
\vartriangleright
(which is a
relation and so gives better spacing).
\vartrianglelefteq
(which is a relation and so gives
better spacing).
\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 \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 \phi
03D5.
\pi
03C0.
\rho
03C1.
\sigma
03C3.
\theta
03B8.
\dashv
.
\wedge
. Similar: variable-sized
operator \bigvee
.
\vert
.
\DeclarePairedDelimiter\norm{\lVert}{\rVert}
. This gives you
three command variants for double-line vertical bars that are correctly
horizontally spaced: if in the document body you write the starred
version $\norm*{M^\perp}$
then the height of the vertical bars
will match the height of the argument, whereas with
\norm{M^\perp}
the bars do not grow with the height of the
argument but instead are the default height, and \norm[size
command]{M^\perp}
also gives bars that do not grow but are set to
the size given in the size command, e.g., \Bigg
.
\Vert
. For such that, as in the definition of a
set, use \mid
because it is a relation.
\DeclarePairedDelimiter\abs{\lvert}{\rvert}
. This gives you
three command variants for single-line vertical bars that are correctly
horizontally spaced: if in the document body you write the starred
version $\abs*{\frac{22}{7}}$
then the height of the
vertical bars will match the height of the argument, whereas with
\abs{\frac{22}{7}}
the bars do not grow with the height of
the argument but instead are the default height, and
\abs[size command]{\frac{22}{7}}
also gives bars that
do not grow but are set to the size given in the size command,
e.g., \Bigg
.
\land
. See also
logical or \vee
. Similar: variable-sized
operator \bigwedge
.
\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, while
\mathcal{+}
outputs a plus sign.
\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 \usepackage{bm} % in preamble ... we have $\bm{v} = 5\cdot\bm{u}$
\boldmath
.
\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 \hdots
.
The gears, brakes, \ldots{} are all broken
. (In a paragraph
mode or LR mode a synonym for \ldots
is \dots
.)
amsmath
amsmath
\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.
\( 5\bmod 3=2 \)
\( 5\equiv 2\pmod 3 \)
amsmath
amsmath
\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
\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
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 box but not its ink. The \vphantom
variant also produces an invisible box with the same height and depth as
subformula, but it has width zero. And \hphantom
makes a
box with the same width as subformula but with height and depth
zero.
\vphantom
in this example, the top bars of the two
square roots would be at different heights.
\( \sqrt{\vphantom{a^3}a}\cdot\sqrt{a^3} \)
\vphantom{a^3}
causes the first \sqrt
to have inside
it a box of the same height as the second \sqrt
, so &latex;
makes the bars align.
\smash
. \vphantom
.
mathtools
mathtools
\makebox
(\settodepth
(\settoheight
(\settowidth
(amsmath
amsmath
\operatorname
command from the package \leavevmode
.
:
& \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
\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
(\left
& \right
\left delimiter1 ... \right delimiter2
\begin{equation} \left(\begin{array}{c} 1 \\ 0 \\ \end{array}\right)
\left
must have a matching \right
. Leaving out the
\left(
in the above gets Extra \right. Leaving off the
\right)
gets You can't use `\eqno' in math mode.
\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}
\{
.
\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
. This 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
\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
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}}
*
-version inserts horizontal space that 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
*
-version 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
\frenchspacing \nonfrenchspacing
\frenchspacing
(the command is from Plain &tex;) switches to the tradition that all
spaces are treated equally.
\normalsfcodes
\normalsfcodes
\
\
\begin{tabular}{l} One blank: makes some space \\ Three blanks: in a row \\ Three spaces:\ \ \ in a row \\ \end{tabular}
\hspace
; see \TeX\ is nice
. (But using curly parentheses, as in
\TeX{} is best
, has the advantage of still working if the next
character is a period.) The other common use is that it marks a period
as ending an abbreviation instead of ending a sentence, as in So
says Prof.\ Smith
(\
\
\
.
~
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.
Chapter~12
, or Theorem~\ref{th:Wilsons}
, or
Figure~\ref{fig:KGraph}
. When cases are enumerated inline:
(b)~Show that $f(x)$ is (1)~continuous, and (2)~bounded
.
siunitx
siunitx
$745.7.8$~watts
(the
144~eggs
. This includes between a month and 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
.
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
(but you must give TeX places to break the line so
you may do Charles Louis Xavier~Joseph de~la Vall\'ee~Poussin
).
pages 12~--14
or it is~--- it must be
said~--- plausible
.
\thinspace
& \negthinspace
\thinspace \negthinspace
\,
and
\!
(\,
as a synonym for \thinspace
in text mode.
\negthinspace
command is used in text mode mostly for
fiddling with spaces. One common use of \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,
though, think the three dots are quite enough already). Still another
use is between initials, as in D.\thinspace E.\ Knuth
.
\/
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}
\textit
or \itshape
to
change fonts, &latex; will automatically insert any needed italic
correction (pdf\/\TeX
.
\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\kern\z&arobase;}
\renewcommand{\dotfill}{% \leavevmode\cleaders\hb&arobase;xt&arobase;1.00em{\hss .\hss }\hfill\kern\z&arobase;}
\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 on 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 and 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
third list&textrsquo;s \parbox
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
\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 the room between the header line and the \hline
, and the
integral would still hit the line.)
\vspace
\vspace{length} \vspace*{length}
plus
or minus
component (And I slept. \vspace{1ex plus 0.5ex} The new day dawned cold.
*
-version inserts vertical space that non-discardable. More
precisely, &latex; discards vertical space at a page break and the
*
-version 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. In a
standard &latex; article the length \baselineskip
is 12\baselineskip
and the 10addvspace
.
\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 (\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 table name, T-4.
See Table~\mbox{T-4}
\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 \makebox
that is used within the
picture
environment, where the length is given in terms of
\unitlength
(\makebox{abc def \\ ghi}
outputs abc defghi while \makebox{abc def \par ghi}
outputs abc def ghi, but neither go to a second 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
inserts a vertical 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 this 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 parbox
with respect to the surrounding material. The possible
values are c
or m
to make the vertical center of the
parbox
lines up with the center of the adjacent 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} \usepackage{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 bin
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
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{\newbin}{test \\ test}
and
\usebox{\newbin}
then you get testtest, while if you
enter \sbox{\newbin}{test \par test}
and
\usebox{\newbin}
then you get test test, but no error or
warning. To fix this use a \parbox
or minipage
as here.
\savebox{\abin}{% \begin{minipage}{\linewidth} \begin{enumerate} \item First item \item Second item \end{enumerate} \end{minipage}} ... \usebox{\abin}
\usepackage{graphicx} % all this in the preamble \newsavebox{\sealbin} \savebox{\sealbin}{% \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{\sealbin}} \pagestyle{headings}
picture
environment is good for fine-tuning the placement.
lrbox
\begin{lrbox}{box-cmd} text \end{lrbox}
box-cmd
. The box-cmd must begin with a
backslash. You must create this bin in advance with \newsavebox
(\sbox
and \savebox
commands, and is equivalent to them. tabular
.
\newsavebox{\jhbin} \begin{lrbox}{\jhbin} \begin{tabular}{c} \includegraphics[height=1in]{jh.png} \\ Jim Hef{}feron \end{tabular} \end{lrbox} ... \usebox{\jhbin}
\usebox
\usebox{box-cmd}
\sbox
or \savebox
, or the lrbox
environment. \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, 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 \usepackage
there are two kinds of available options.
graphics
package configuration\graphicspath
\graphicspath{list of dir names inside curly brackets}
\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 .png,.pdf,.jpg,.mps,.jpeg,.jbig2,.jb2,.PNG,.PDF,.JPG,.JPEG,.JBIG2,.JB2
\makeatletter\typeout{\Gin&arobase;extensions}\makeatother
.
\DeclareGraphicsRule
\DeclareGraphicsRule{extension}{type}{size-file extension}{command}
\DeclareGraphicsRule{.mps}{mps}{.mps}{}
\DeclareGraphicsRule{*}{mps}{*}{}
\includegraphics
\includegraphics{filename} \includegraphics[urx,ury]{filename} \includegraphics[llx,lly][urx,ury]{filename} \includegraphics*{filename} \includegraphics*[urx,ury]{filename} \includegraphics*[llx,lly][urx,ury]{filename}
\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
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 type
and
ext
; see below. This and other filename issues are also handled
with the package \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}
[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).
\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
\rotatebox{angle}{material}
\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}}
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}}
\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.
\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{1in}{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.
# $ % & { } _ ~ ^ \
\
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 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).
\begin{center} \# \$ \% \& \{ \} \_ \~{} \^{} \textbackslash \\ \verb!# $ % & { } _ ~ ^ \! \end{center}
\uppercase{text} \lowercase{text} \MakeUppercase{text} \MakeLowercase{text}
\uppercase
and \lowercase
only work for American
characters. 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
\MakeUppercase
and
\MakeLowerCase
.
mfirstuc
mfirstuc
\symbol
command. For example, the visible space character
used in the \verb*
command has the code decimal 32, so it can be
typed as \symbol{32}
.
'
prefix, or hexadecimal (base 16) with a "
prefix, so the previous
example could also be written as \symbol{'40}
or
\symbol{"20}
.
textcomp
package.
\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 are fortunate enough to make the playoffs ---
is more like a sprint.
).
--
)--
)See pages 12--14
).
eurosym
eurosym
!`
)!`
)?`
)?`
)``
)``
)''
)''
)`
)`
)'
)'
)babel
babel
polyglossia
polyglossia
babel
package and related support if you are using
pdf&latex;, or \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.
\rule
\rule{width}{thickness} \rule[raise]{width}{thickness}
\newcommand{\qedsymbol}{\rule{0.4em}{2ex}}
amsthm
amsthm
\noindent\rule{\textwidth}{0.4pt}
\today
\today
babel
babel
polyglossia
polyglossia
\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
\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. The \includeonly
command controls
which files will be read by &latex; under subsequent \include
commands. Its list of filenames is comma-separated, and it can only
appear in the preamble.
\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}
section
or subsection
is the sectioning unit. The
hook \numberline
lets you to change how the information appears
in the table of contents. Of its two arguments, 1
or 1.1
is the sectioning unit number and First section
or First
subsection
is the title. Finally, 2
is the page number on which
the sectioning units start.
\listoffigures
and \listoftables
produce a
list of figures and a list of tables. They work the same way as the
contents commands; for instance, these work with information stored in
babel
babel
polyglossia
polyglossia
\renewcommand{\contentsname}{Table of contents} \renewcommand{\listfigurename}{Plots} \renewcommand{\listtablename}{Tables}
tocloft
tocloft
tocbibbind
tocbibbind
\addcontentsline
\addcontentsline{ext}{unit}{text}
toc
for the table of contents, lof
for the list of
figures, or lot
for the list of tables.
\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
. The
most common case is the table of contents and there num is the
page number of the first page of unit.
\chapter
,
etc., and also by \caption
inside a float environment. But it is
also used by authors. For example, in a book to have the preface
unnumbered, you may use the starred \chapter*
. But that does not
put in table of contents information, so you can enter it manually, as
here.
\chapter*{Preface} \addcontentsline{toc}{chapter}{\protect\numberline{}Preface}
\contentsline
{chapter}{\numberline {}Preface}{3}
; note the page number
3.
\addcontentsline
are required.
\protect
any commands that are
fragile (\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}}
\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.
\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 \documentclass{article} \usepackage{makeidx} \makeindex ... \begin{document} ... Recall Wilson's Theorem: \index{Wilson's Theorem} a number \( n>1 \) is prime if and only if the factorial of \( n-1 \) is congruent to \( -1 \) modulo~\( n \). ... \printindex ...
\usepackage{makeidx}
and \makeindex
in the preamble
bring in the relevant commands.
\index
command
(\index
writes its
information to an auxiliary file \printindex
command (showidx
showidx
multind
multind
showidx
package causes each index entries to be shown in the
margin on the page where the entry appears. This can help in preparing
the index. The multind
package supports multiple indexes. See
also the &tex; FAQ entry on this topic,
\index
\index{index-entry-string}
pdflatex test
, then
process the index entries with makeindex test
, and then compile
again with pdflatex test
.
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 \renewcommand{\alsoname}[1]{Also see
#1}
.)
\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 |
character in an index
entry, preceding it with a double quote, "
. (The double quote
gets deleted before alphabetization.)
index
index
\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 rubber length with default value 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"
.
\printindex
\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.
\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 &textmdash; 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
. As above,
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.}
pdflatex options argument
lualatex
, or dviluatex
, or
latex
.
pdflatex thesis
dvilualatex
, then you will get DVI. The description here
assumes pdf&latex;.
<control>-D
.
pdflatex options
argument
you can specify arbitrary &latex; input by starting
argument with a backslash. This allows you to do some special
effects.
hyperref
hyperref
\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"
has the link in black. (Note the use of double quotes to prevent
interpretation of the symbols by the command line shell; your system may
do this differently.)
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 draft
pdflatex -jobname=aa "\RequirePackage[draft]{graphicx}\input{aa.tex}"
jobname
option is there because
otherwise the output file would be \RequirePackage
does an \input
of its own.)
?
. 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. ?
<return>
and fix the
typo. You could instead enter ? and <return>
to see other
options.
\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>
.
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:
<Control>
and d (holding
them down at the same time), and then retype the correct command line.
beamer
templatebeamer
template and classbeamer
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 this way.)
tugboat
templateltugboat
class