-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathstructure.tex
128 lines (113 loc) · 4.3 KB
/
structure.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
\chapter{Document Structure}
\label{structure}
Every \LaTeX{} document is different,
but all share a few common elements.
\section{Preambles and packages}
In the last chapter, you built your first document with:
\begin{leftfigure}
\begin{lstlisting}
\documentclass{article}
\begin{document}
Hello, World!
\end{document}
\end{lstlisting}
\end{leftfigure}
The space between \verb|\documentclass| and the start of the
\texttt{document} environment is called the \introduce{preamble}.
Here we handle whatever setup we need, including importing packages.
These add new commands, or modify the document in interesting ways.
The ones in your \LaTeX{} distribution come from the Comprehensive \TeX{}
Archive Network---or \acronym{ctan}---at \https{ctan.org}.\punckern\footnote{%
Curious readers might wonder what \TeX{} is, and how it differs from \LaTeX.
The short answer is that \TeX{} is the original program, and \LaTeX{}
is a set of common commands that were later built on top of it.
A longer answer is at the end of this guide under Appendix~\ref{history}.
We won't discuss how to use plain \TeX{} here. That is for another book---The
\TeX book.}
You will also find package manuals there,
so make it your first stop when learning how to use one.
To import a package, add a \verb|\usepackage| command
with its name as the argument.
As a simple example, let's write a document with the \texttt{metalogo}
package, which adds \verb|\LuaLaTeX| and \verb|\XeLaTeX|:
\begin{leftfigure}
\begin{lstlisting}
\documentclass{article}
\usepackage{metalogo}
\begin{document}
\XeLaTeX{} and \LuaLaTeX{} are neat.
\end{document}
\end{lstlisting}
\end{leftfigure}
\begin{samepage}
should get you a \textsc{pdf} that reads
\begin{leftfigure}
\lm \XeLaTeX{} and \LuaLaTeX{} are neat.
\end{leftfigure}
\end{samepage}
\verb|\usepackage| accepts optional arguments
and passes them to whatever code you are importing.
The \texttt{geometry} package, for instance,
takes your desired paper size and margins.
For \acronym{us}~\textsc{l}etter paper with one-inch margins,
type:
\begin{leftfigure}
\begin{lstlisting}
\usepackage[
letterpaper,
left=1in, right=1in, top=1in, bottom=1in
]{geometry}
\end{lstlisting}
\end{leftfigure}
Arguments can be spaced however you like,
so long as there are no empty lines between them.
\section{Hierarchy}
Authors often split their writing into sections to help readers navigate it.
\LaTeX{} offers seven different commands to break up your documents:
\verb|\part|, \verb|\chapter|, \verb|\section|, \verb|\subsection|,
\verb|\subsubsection|, \verb|\paragraph|, and \verb|\subparagraph|.
Issue the command where you want an area to start,
providing its name as the argument.
For example,
\begin{leftfigure}
\begin{lstlisting}
\documentclass{book}
\begin{document}
\chapter{The Start}
This is a very short chapter in a very short book.
\chapter{The End}
Is the book over yet?
\section{No!}
There's some more we must do before we go.
\section{Yes!}
Goodbye!
\end{document}
\end{lstlisting}
\end{leftfigure}
Some levels are only available in certain document classes---chapters,
for example, only appear in books.
And don't go too crazy with these commands.
Most works just need a few levels to organize them.
These bits of structure are automatically numbered.
The title of this chapter was produced with \verb|\chapter{Document Structure}|,
and \LaTeX{} figured out that it was chapter~\ref{structure}.
\exercises{}
As promised, this book won't try to be a comprehensive reference,
but it \emph{will} point you to places where you can learn more.
We'll wrap up most chapters with some related topics that you can
explore yourself.
Consider learning how to:
\begin{itemize}
\item Automatically start your document with its title, your name,
and the date using \verb|\maketitle|.
\item Build a table of contents
with \verb|\tableofcontents|.
\item Control section numbering with \verb|\setcounter{secnumdepth}|
or starred commands like \verb|\subsection*{foo}|.
\item Create cross-references with \verb|\label| and \verb|\ref|.
\item Use KOMA~Script, a set of packages that let you customize nearly every
aspect of your document, from heading fonts to footnotes.
\item Include images with the \texttt{graphicx} package.
\item Add hyperlinks with the \texttt{hyperref} package.
\item Split large documents into multiple source files using \verb|\input|.
\end{itemize}