summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/latex-veryshortguide/veryshortguide.tex
blob: 698e51ef64448de21c9f7a4f893ad54893c8e6e5 (plain)
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
%% The Very Short Guide to Typesetting with \LaTeX{}
\documentclass[a5paper]{vsg}
\addbibresource{veryshortguide.bib}
\setlength{\bibnamesep}{-\itemsep}
\begin{document}
\title{The very short guide to typesetting with~\LaTeX}
\author{Silmaril Consultants\\
  \textbf{Textual Therapy Division}\\
  \protect\url{http://latex.silmaril.ie}}
\date{\monthdate}
\maketitle
\subsection*{What's this all about? What's \LaTeX?}
\LaTeX\ is a document preparation system which uses the \TeX\
typesetting program. It enables you to produce
publication-quality documents with great accuracy and
consistency. \LaTeX\ works on any computer and produces
industry-standard PDF. It is available both in free (open-source)
and commercial implementations. \LaTeX\ can be used for any kind
of document, but it is especially suited to those with complex
structures, repetitive formatting, or notations like
mathematics\footnote{For reasons of space this guide does not
cover details of mathematics typesetting.}; or where technical
stability, dimensional accuracy, or a persistent and
non-proprietary file format are needed. Install the software from
\url{www.tug.org/texlive/} or buy a commercially-supported
version from one of the vendors (see the list on
p.\thinspace\pageref{comm}).
\subsection*{Creating and typesetting your document}
\begin{enumerate}[noitemsep]\setlength{\fboxsep}{1pt}
   \item Create your document using any suitable plain-text
     editor with \LaTeX\ controls, eg \textit{\TeX shop}
     (Mac), \textit{\TeX Maker} (Win), \textit{Kile}
     (Linux), \textit{Emacs} (all), even
     \textit{vi}\thinspace!
   \item Save the file with a name ending in \verb+.tex+
     (\emph{never} use spaces in filenames!);
   \item Use the {\small\keys{Build}} or
     {\small\keys{Compile}} toolbar button or menu item in
     your editor to typeset and display the
     document;\label{typeset}
   \item Make any changes needed in your original document
     and repeat step \ref{typeset}.
\end{enumerate}
\subsection*{Syntax (how to type \LaTeX\ commands --- these
  are the rules)}
\begin{itemize}[noitemsep]
  \item \textbf{All \LaTeX\ commands begin with a
    backslash}.\\ \example
    \verb+\tableofcontents+\endexample
  \item \textbf{If a command needs text to work with, it
    goes in curly braces}.\\ \example
    \verb+\title{Irisches Tagebuch}\author{Heinrich Böll}+\endexample
  \item \textbf{If options are used, they go in square
    brackets before the curly braces}.\\ \example
    \verb+\documentclass[a4paper,11pt]{book}+\endexample
  \item \textbf{Spaces after commands \emph{without} braces
    get suppressed}.\\ \example
    \verb+Copyright \copyright␣+\texttt{\number\year}
    \gives{Copyright ©\number\year} \nobox\\ To prevent
    this, put empty curly braces after the
    command:\\ \example
    \verb+Copyright \copyright{}␣+\texttt{\number\year}
    \gives{Copyright ©~\number\year} \yesbox
  \item \textbf{Curly braces are also used to restrict the
    scope of effects inside them}.\\ \example
    \verb+Some {\tiny little} word+ \gives{Some {\tiny
        little} word}
\end{itemize}
\begin{note}
This guide shows only a tiny fraction of \LaTeX's power. For
more information, visit the \TeX\ Users Group site
(\url{www.tug.org}). For help, see the FAQ
(\url{www.tex.ac.uk/faq}), StackExchange
(\url{tex.stackexchange.com}), or the Usenet newsgroup
\url{comp.text.tex}. For packages (plugins), use CTAN, the
Comprehensive \TeX\ Archive Network
(\url{www.ctan.org}). For further details, see
\citetitle{fi} \parencite{fi} and other online resources.
\end{note}
\begin{multicols}{2}\small\parskip4pt
\subsection*{Writing a \LaTeX\ document}
\subsubsection{Basic document structure}
Here's the skeleton of a \LaTeX\ document. These three lines are
\textsc{compulsory}: your document will not work without them:
\begin{Verbatim}[frame=single,fontsize=\small,commandchars=!<>]
!added\documentclass[11pt]{article}
!comment your Preamble goes here (extra setups, if any)
!added\begin{document}
!comment your document text goes here
!added\end{document}
\end{Verbatim}
\vspace*{-.5\baselineskip}
{\fontsize67\selectfont\sffamily New material in each example is
shown in {\ttfamily\added blue}; material from previous examples
is in black. Comments and mnemonics are in
\textcolor{DarkRed}{red}.\par}
\begin{itemize}[noitemsep]
  \item The document class name \textsc{must} be one of the
    standard \verb+book+, \verb+article+, or \verb+report+,
    or one of the many others preinstalled or downloadable
    (eg \verb+thesis+, \verb+memoir+, etc);
  \item There are body type size options \verb+10pt+ (the
    default), \verb+11pt+, and \verb+12pt+;
  \item There are paper size options including
    \verb+a4paper+ (210\thinspace mm$\times$297\thinspace
    mm) and \verb+letterpaper+ (8½$''\times$11$''$) [see
      below].
\end{itemize}

\subsubsection{Front matter}

The \textbf{Preamble} [see above] is where you speci\-fy any
\textbf{packages} (\LaTeX\ plugins like typefaces or special
formatting), and where you put any changes to standard features.

\begin{Verbatim}[frame=single,fontsize=\small,commandchars=!<>]
\documentclass[a4paper,11pt]{book}
!added\usepackage{charter,graphicx}!revert
!added\setlength{\parindent}{1em}!revert
\begin{document}
!added\title!comment{your document title!revert}
!added\author!comment{your name!revert}
!added\date!comment{date of publication!revert}
!added\maketitle
!added\begin{abstract}
!comment the paragraphs of your abstract go here
!added\end{abstract}
!added\tableofcontents
!comment the text of your document goes here
\end{document}
\end{Verbatim}

The title, author, and date \textsc{must} be followed by the
\verb+\maketitle+ command to be formatted correctly.

\subsubsection{Body matter}

\textbf{Leave a blank line between paragraphs} as you type: this
signals a new paragraph. Spacing is controlled by the
document class and packages you use. For an unindented,
line-spaced style, use the \textsf{parskip} package.

\paragraph{Sectioning:}
Sections get numbered automatically in bold type, and get included in
the Table of Contents (if you use it). Numbering can be turned off
selectively. Section heading layout can be modified with the
\textsf{sectsty}, \mbox{\textsf{titlesec}}, and other packages.

\begin{Verbatim}[frame=single,fontsize=\small,commandchars=!<>]
!comment (Preamble, titling, and abstract as above)
\tableofcontents
!added\chapter!comment{heading of a chapter!revert}
!comment text for the chapter goes here
!added...as shown in section \ref{blah}.
!added\section!comment{heading of a section!revert}
!added\label{blah} !comment make up name for the label
!comment text for the section goes here
!added\chapter!comment{heading of a new chapter!revert}
!comment text for the new chapter goes here
\end{document}
\end{Verbatim}

\paragraph{Lists:}
There are three types of list: \textbf{itemized} (bulleted), \textbf{enumerated} (numbered
or lettered), and \textbf{descriptive} (topic-and-explanation
format).

Like \textsf{document}, these are all \textbf{environments}, using
\verb+\begin{...}+ and \verb+\end{...}+.

\begingroup\fontsize{4.5}{5.5}\selectfont
\renewcommand{\labelitemi}{\textbullet}
\leftmargini=2em
\setlength{\tabcolsep}{3pt}
\begin{tabular}{@{}%
    p{.25\columnwidth}|%
    p{.32\columnwidth}|%
    p{.33\columnwidth}@{}}
\begin{verbatim}
\begin{itemize}
 \item 1lb Sugar
 \item ½pt Cream
 \item Chocolate
 \item 2oz Butter
\end{itemize}
\end{verbatim}
&
\begin{verbatim}
\begin{enumerate}
 \item Mix ingredients
 \item Boil to 112°C
 \item Stir and cool
 \item Pour into dish
\end{enumerate}
\end{verbatim}
&
\begin{verbatim}
\begin{description}
 \item[Fudge] is fun...
 \item[Broccoli] sucks...
 \item[Exercise] is good
  for you if taken daily
\end{description}
\end{verbatim}
\\\hline\scriptsize
\begin{itemize}[noitemsep]
\item 1lb Sugar
\item ½pt Cream
\item Chocolate
\item 2oz Butter
\end{itemize}
&\fontsize{6.5}{8}\selectfont
\begin{enumerate}[noitemsep]
\item Mix ingredients
\item Boil to 112°C
\item Stir and cool
\item Pour into dish
\end{enumerate}
&\tiny
\begin{description}[noitemsep]
\item[Fudge] is fun but fattening if made too often.
\item[Broccoli] sucks, period.
\item[Exercise] is good for you if taken daily and not to extremes.
\end{description}
\end{tabular}
\endgroup

You can nest lists inside each other. Use the \textsf{enumitem}
package to control list formatting.

\colorbox{LightGrey}{\color{black}\begin{minipage}{.965\columnwidth}%
\sffamily\scriptsize\bfseries\raggedright
For help, see the links on the front and back pages. There is a
summary of common commands at\\
\url{www.stdout.org/~winston/latex/latexsheet.pdf}
and a comprehensive list at
\url{www.eeng.dcu.ie/local-docs/latex-help/}~.
\end{minipage}}
\columnbreak
\paragraph{Tables and figures:}
These environments \textbf{float} (to fit
available space). They have \verb+\caption+ and \verb+\label+ commands.

\begin{Verbatim}[frame=single,fontsize=\footnotesize,commandchars=!<>]
!added\begin{figure} !comment(see below)
\caption{Swiss and Dutch Mennonite
 migrations of the 1700s and 1800s}
\label{lmig}
!added\centering !comment(centre the contents)
!added\includegraphics[width=.8\columnwidth]
!added {menno-a}\\ !comment(double backslash for linebreak)
!added\scriptsize!revert Courtesy of Paul C. Adams,
 Department of Geography and the
 Environment, University of Texas at
 Austin.
!added\cite{adams}\end{figure}
\end{Verbatim}

Graphics \textsc{must} be EPS files for standard \LaTeX, but JPG, PNG,
or PDF for pdf\LaTeX.

\begin{Verbatim}[frame=single,fontsize=\footnotesize,commandchars=!<>]
!added\begin{table}
 !added\caption{Mean growth rate and intakes
 !added of supplement, milk, and water for 4
 !added diets (after Sherington, J, undated)}
 \label{dietgrowth}
 \centering
 !added\begin{tabular}{|l|r|r|r|r|}
 !added\hline !comment(horizontal line between rows)
  !added&Growth&Supplement&Milk&Water
  !added\\\hline !comment(double backslash for new row)
 !added Supplement&rate&intake&intake&intake
  !added\\\hline
  !added&(g/day)&(g/day)&(ml/kg$^{0.75}$)&
  !added (ml/kg$^{0.75}$)\\\hline
 !added Lucerne &145&450&10.5&144\\\hline
 !added Sesbania&132&476& 9.2&128\\\hline
 !added Leucaena&128&364& 8.9&121\\\hline
 !added None    & 89&  0& 9.8&108\\\hline
 !added\end{tabular}
!added\end{table}
\end{Verbatim}

\begin{center}\sffamily
  \fontsize78\selectfont
\setlength{\tabcolsep}{2pt}
\setlength{\arrayrulewidth}{.2pt}
\begin{tabular}{@{}|>{\vrule height1em width0pt}l|r|r|r|r|@{}}
\multicolumn5l{\textbf{Table 2}: \textit{Mean growth rate and intakes
of supplement,}}\\
\multicolumn5l{\textit{milk, and water for four diets} (after
    Sherington, J, undated)}\\[6pt]\hline
\vrule height1.1em width0pt&Growth&Supplement&Milk&Water\\[-1pt]
Supplement&rate&intake&intake&intake\\[-1pt]
&(g/day)&(g/day)&(ml/kg\textsuperscript{\fontsize34\selectfont 0.75})&(ml/kg\textsuperscript{\fontsize34\selectfont 0.75})\\[3pt]\hline
Lucerne &145&450&10.5&144\\\hline
Sesbania&132&476& 9.2&128\\\hline
Leucaena&128&364& 8.9&121\\\hline
None    & 89&  0& 9.8&108\\\hline
\end{tabular}
\end{center}
Packages like \textsf{longtable} and \textsf{array} can help
with more complex table formats.

\end{multicols}

\begin{center}\sffamily
  \textbf{Figure 1}: \textit{Swiss and Dutch Mennonite migrations of the
    1700s and 1800s}\\[3pt]
  \ifafive\includegraphics[width=.8\columnwidth]{menno-a}\fi
  \iflegal\includegraphics[width=.7\columnwidth]{menno-a}\fi
  \\\scriptsize
  Courtesy of Paul C. Adams, Department of Geography
  and the Environment, University of Texas at Austin. [1]
\end{center}

\begin{multicols}{2}\small\parskip4pt
\paragraph{Typefaces:}
{\ff{lrm}\selectfont The default typeface in \LaTeX\ is Computer
  Modern, like this.}

{\footnotesize\tabcolsep4pt
\begin{tabular}{@{}l@{\hspace{6pt}}>{\ttfamily}l|l@{\hspace{6pt}}>{\ttfamily}l@{}}
\ff{ptm}Times&mathptmx&\ff{pcr}Courier&courier\\
\ff{ppl}Palatino&mathpazo&\ff{pag}\scriptsize Avant Garde&avant\\
\ff{pbk}Bookman&bookman&\ff{phv}Helvetica&helvet\\
\ff{bch}Charter&charter&\ff{pzc}Zapf Chancery&chancery\\
\ff{put}Utopia&utopia&\ff[OT1]{pnr}Pandora&pandora\\
\ff{pnc}Century&newcent&\ff[U]{yfrak}Fraktur&oldgerm\\
\end{tabular}
}

Dozens of other font packages are available in \TeX\ Live and the \LaTeX\ Font
Catalogue, including mathematics and decorative fonts. Any
Postscript Type~1 font can be configured for \LaTeX.

If you use \XeLaTeX\ and the \textsf{fontspec} package, you can also
use your computer's system fonts as well as those available
with \TeX\ Live.

\colorbox{LightGrey}{\color{black}\begin{minipage}{.965\columnwidth}%
\sffamily\scriptsize\raggedright
Commercial implementations of \TeX\ for Windows with business-level
support are available from Personal \TeX, Inc (PC\TeX); MacKichan
Software, Inc (Scientific Word); Micropress, Inc (V\TeX), and
True\TeX\ Software (True\TeX).\label{comm}
\end{minipage}}

\columnbreak
\textsf{Typefaces continued}

To change font for a word or phrase, use these commands (they can be
nested):

{\small
\begin{tabular}{l@{\enspace}>{\ttfamily\char'134 text}l<{\char'173
      Hello\char'175}@{}>{\ \gives\bgroup}l<{Hello\egroup}}
Italics&it&\itshape\\
Boldface&bf&\bfseries\\
Smallcaps&sc&\ff{cmr}\scshape\\
Sans-serif&sf&\sffamily\\
Monospace&tt&\ttfamily\\
\end{tabular}}

\begingroup\small
\example\verb+\textit{\textbf{\textsf+\ifafive\linebreak\fi
\verb+{bold+ \iflegal\linebreak\fi\verb+italic sans}}}+
\gives{\ff{cmss}\textit{\textbf{bold italic sans}}}
\par\endgroup

Sizes for titles, headings, footnotes, etc are automatic, but
there are some step-sizes:

{\scriptsize\centering
\begin{tabular}{>{\ttfamily\char'134}lrrr}
normalsize&10&11&12\\\hline\vrule height1.1em width0pt
tiny&5&6&7\\
scriptsize&6&7&8\\
footnotesize&7&8&9\\
small&9&10&11\\
large&11&12&14\\
Large&12&14&17\rlap*\\
LARGE&14&17\rlap*&20\rlap*\\
huge&17\rlap*&20\rlap*&24\rlap*\\
Huge&20\rlap*&24\rlap*&28\rlap*\\
\end{tabular}
\quad
\rotatebox[origin=c]{90}{\tiny* sizes rounded here to save space}
\par}

For other sizes, add the special command
{\added\verb+\RequirePackage{fix-cm}+}\iflegal\linebreak\fi \emph{before} the
\verb+\documentclass+ line and use
{\added\verb+\fontsize{+\texttt{\uline{pp}}\verb+}{+\texttt{\uline{bb}}\verb+}\selectfont+}
for the point-size (\textit{pp}) and baseline
(\textit{bb}).

{\sffamily\footnotesize
  Size commands are all \textbf{unscoped} commands, so enclose them \emph{and}
the applicable text in curly braces to stop them affecting the rest
of the document.\par}
For double or 1½ line-spacing (eg in theses) use the \textsf{setspace}
package.

You can use colour palettes in the RGB, CMYK, HTML, and other
colourspaces with \iflegal\\\fi the \textsf{xcolor} \ifafive\\\fi
package and the\hfil
\smash{\raisebox{0ex}{\sffamily\bfseries\Huge\iflegal\quad\else\enspace\fi
\textcolor[HTML]{2F50AD}{G}%
\textcolor[HTML]{B32F17}{o}%
\textcolor[HTML]{F3C20B}{o}%
\textcolor[HTML]{2F50AD}{g}%
\textcolor[HTML]{48C847}{l}%
\textcolor[HTML]{B32F17}{e}}}%
\\\verb+\color{+\texttt{\textit{name}}\verb+}+ command.

For verbatim text, use the \verb+\verb+ command or the
\textsf{verbatim} environment, or (better) the \textsf{listings} or
\textsf{fancyvrb} packages.

\paragraph{Footnotes:}
You do footnotes with \iflegal\\\fi \verb+\footnote(like this}+.\footnote{Like
  this.} Endnotes too.

\paragraph{Cross-references:}\label{blah} Use the command
\verb+\label{...}+ to label the target, and \verb+\ref{...}+ or
\verb+\pageref{...}+ to refer to it. Make up the labels yourself.

\begingroup\small
\example{...\ttfamily section \verb+\ref{blah}+ on
  p.\\ \verb+\pageref{blah}+.}\gives{...section \ref{blah} on
  p.\thinspace\pageref{blah}}.
\par\endgroup

\paragraph{Citation and reference:} Create your bibliographic database
in BIB\TeX\ format \parencite{bibtex} using \emph{JabRef} or
similar. Each entry \textsc{must} have a unique label (here `\verb+fi+'):
\begin{Verbatim}[frame=single,fontsize=\scriptsize,commandchars=!<>]
!added@book{fi,
!added  title = {Formatting Information},
!added  author = {Peter Flynn},
!added  publisher = {Silmaril},
!added  year = {2016}}
\end{Verbatim}
Use the
\textsf{biblatex} package to specify the style, and give
the filename of your database:
\begin{Verbatim}[frame=single,fontsize=\footnotesize,commandchars=!<>]
!added\usepackage[style=apa]{biblatex}
!added\addbibresource{myrefs.bib}
\end{Verbatim}
To cite, use \verb+\cite{...}+ (or
\verb+\textcite+ or \verb+\parencite+) with the relevant label:\\ \example{\verb+\textcite{fi}+}\gives{\textcite{fi}}.

\subsubsection{Back matter}
For an index, use the \textsf{makeidx} package and the
\verb+\makeindex+ command with the \verb+\index{...}+
and \verb+\printindex+ commands and the \textsf{makeindex} program.

\nocite{*}
{\defbibheading{shortbib}[References]{\subsection*{#1}}\renewcommand*{\bibfont}{\scriptsize}\setlength{\bibhang}{1em}\urlstyle{tt}\label{refs}\printbibliography[heading=shortbib]}

\colorbox{LightGrey}{\color{black}\begin{minipage}{.965\columnwidth}%
\sffamily\scriptsize\bfseries\raggedright
For information about \LaTeX\ training and consutancy, please contact
Silmaril at \url{latex@silmaril.ie}
\end{minipage}}%
\end{multicols}
\end{document}