| 1 |
% ftp://tug.ctan.org/tex-archive/macros/latex/base/sample2e.tex |
| 2 |
% This is a sample LaTeX input file. (Version of 12 August 2004.) |
| 3 |
% |
| 4 |
% A '%' character causes TeX to ignore all remaining text on the line, |
| 5 |
% and is used for comments like this one. |
| 6 |
|
| 7 |
\documentclass{article} % Specifies the document class |
| 8 |
|
| 9 |
% The preamble begins here. |
| 10 |
\title{An Example Document} % Declares the document's title. |
| 11 |
\author{Leslie Lamport} % Declares the author's name. |
| 12 |
\date{January 21, 1994} % Deleting this command produces today's date. |
| 13 |
|
| 14 |
\newcommand{\ip}[2]{(#1, #2)} |
| 15 |
% Defines \ip{arg1}{arg2} to mean |
| 16 |
% (arg1, arg2). |
| 17 |
|
| 18 |
%\newcommand{\ip}[2]{\langle #1 | #2\rangle} |
| 19 |
% This is an alternative definition of |
| 20 |
% \ip that is commented out. |
| 21 |
|
| 22 |
\begin{document} % End of preamble and beginning of text. |
| 23 |
|
| 24 |
\maketitle % Produces the title. |
| 25 |
|
| 26 |
This is an example input file. Comparing it with |
| 27 |
the output it generates can show you how to |
| 28 |
produce a simple document of your own. |
| 29 |
|
| 30 |
\section{Ordinary Text} % Produces section heading. Lower-level |
| 31 |
% sections are begun with similar |
| 32 |
% \subsection and \subsubsection commands. |
| 33 |
|
| 34 |
The ends of words and sentences are marked |
| 35 |
by spaces. It doesn't matter how many |
| 36 |
spaces you type; one is as good as 100. The |
| 37 |
end of a line counts as a space. |
| 38 |
|
| 39 |
One or more blank lines denote the end |
| 40 |
of a paragraph. |
| 41 |
|
| 42 |
Since any number of consecutive spaces are treated |
| 43 |
like a single one, the formatting of the input |
| 44 |
file makes no difference to |
| 45 |
\LaTeX, % The \LaTeX command generates the LaTeX logo. |
| 46 |
but it makes a difference to you. When you use |
| 47 |
\LaTeX, making your input file as easy to read |
| 48 |
as possible will be a great help as you write |
| 49 |
your document and when you change it. This sample |
| 50 |
file shows how you can add comments to your own input |
| 51 |
file. |
| 52 |
|
| 53 |
Because printing is different from typewriting, |
| 54 |
there are a number of things that you have to do |
| 55 |
differently when preparing an input file than if |
| 56 |
you were just typing the document directly. |
| 57 |
Quotation marks like |
| 58 |
``this'' |
| 59 |
have to be handled specially, as do quotes within |
| 60 |
quotes: |
| 61 |
``\,`this' % \, separates the double and single quote. |
| 62 |
is what I just |
| 63 |
wrote, not `that'\,''. |
| 64 |
|
| 65 |
Dashes come in three sizes: an |
| 66 |
intra-word |
| 67 |
dash, a medium dash for number ranges like |
| 68 |
1--2, |
| 69 |
and a punctuation |
| 70 |
dash---like |
| 71 |
this. |
| 72 |
|
| 73 |
A sentence-ending space should be larger than the |
| 74 |
space between words within a sentence. You |
| 75 |
sometimes have to type special commands in |
| 76 |
conjunction with punctuation characters to get |
| 77 |
this right, as in the following sentence. |
| 78 |
Gnats, gnus, etc.\ all % `\ ' makes an inter-word space. |
| 79 |
begin with G\@. % \@ marks end-of-sentence punctuation. |
| 80 |
You should check the spaces after periods when |
| 81 |
reading your output to make sure you haven't |
| 82 |
forgotten any special cases. Generating an |
| 83 |
ellipsis |
| 84 |
\ldots\ % `\ ' is needed after `\ldots' because TeX |
| 85 |
% ignores spaces after command names like \ldots |
| 86 |
% made from \ + letters. |
| 87 |
% |
| 88 |
% Note how a `%' character causes TeX to ignore |
| 89 |
% the end of the input line, so these blank lines |
| 90 |
% do not start a new paragraph. |
| 91 |
% |
| 92 |
with the right spacing around the periods requires |
| 93 |
a special command. |
| 94 |
|
| 95 |
\LaTeX\ interprets some common characters as |
| 96 |
commands, so you must type special commands to |
| 97 |
generate them. These characters include the |
| 98 |
following: |
| 99 |
\$ \& \% \# \{ and \}. |
| 100 |
|
| 101 |
In printing, text is usually emphasized with an |
| 102 |
\emph{italic} |
| 103 |
type style. |
| 104 |
|
| 105 |
\begin{em} |
| 106 |
A long segment of text can also be emphasized |
| 107 |
in this way. Text within such a segment can be |
| 108 |
given \emph{additional} emphasis. |
| 109 |
\end{em} |
| 110 |
|
| 111 |
It is sometimes necessary to prevent \LaTeX\ from |
| 112 |
breaking a line where it might otherwise do so. |
| 113 |
This may be at a space, as between the ``Mr.''\ and |
| 114 |
``Jones'' in |
| 115 |
``Mr.~Jones'', % ~ produces an unbreakable interword space. |
| 116 |
or within a word---especially when the word is a |
| 117 |
symbol like |
| 118 |
\mbox{\emph{itemnum}} |
| 119 |
that makes little sense when hyphenated across |
| 120 |
lines. |
| 121 |
|
| 122 |
Footnotes\footnote{This is an example of a footnote.} |
| 123 |
pose no problem. |
| 124 |
|
| 125 |
\LaTeX\ is good at typesetting mathematical formulas |
| 126 |
like |
| 127 |
\( x-3y + z = 7 \) |
| 128 |
or |
| 129 |
\( a_{1} > x^{2n} + y^{2n} > x' \) |
| 130 |
or |
| 131 |
\( \ip{A}{B} = \sum_{i} a_{i} b_{i} \). |
| 132 |
The spaces you type in a formula are |
| 133 |
ignored. Remember that a letter like |
| 134 |
$x$ % $ ... $ and \( ... \) are equivalent |
| 135 |
is a formula when it denotes a mathematical |
| 136 |
symbol, and it should be typed as one. |
| 137 |
|
| 138 |
\section{Displayed Text} |
| 139 |
|
| 140 |
Text is displayed by indenting it from the left |
| 141 |
margin. Quotations are commonly displayed. There |
| 142 |
are short quotations |
| 143 |
\begin{quote} |
| 144 |
This is a short quotation. It consists of a |
| 145 |
single paragraph of text. See how it is formatted. |
| 146 |
\end{quote} |
| 147 |
and longer ones. |
| 148 |
\begin{quotation} |
| 149 |
This is a longer quotation. It consists of two |
| 150 |
paragraphs of text, neither of which are |
| 151 |
particularly interesting. |
| 152 |
|
| 153 |
This is the second paragraph of the quotation. It |
| 154 |
is just as dull as the first paragraph. |
| 155 |
\end{quotation} |
| 156 |
Another frequently-displayed structure is a list. |
| 157 |
The following is an example of an \emph{itemized} |
| 158 |
list. |
| 159 |
\begin{itemize} |
| 160 |
\item This is the first item of an itemized list. |
| 161 |
Each item in the list is marked with a ``tick''. |
| 162 |
You don't have to worry about what kind of tick |
| 163 |
mark is used. |
| 164 |
|
| 165 |
\item This is the second item of the list. It |
| 166 |
contains another list nested inside it. The inner |
| 167 |
list is an \emph{enumerated} list. |
| 168 |
\begin{enumerate} |
| 169 |
\item This is the first item of an enumerated |
| 170 |
list that is nested within the itemized list. |
| 171 |
|
| 172 |
\item This is the second item of the inner list. |
| 173 |
\LaTeX\ allows you to nest lists deeper than |
| 174 |
you really should. |
| 175 |
\end{enumerate} |
| 176 |
This is the rest of the second item of the outer |
| 177 |
list. It is no more interesting than any other |
| 178 |
part of the item. |
| 179 |
\item This is the third item of the list. |
| 180 |
\end{itemize} |
| 181 |
You can even display poetry. |
| 182 |
\begin{verse} |
| 183 |
There is an environment |
| 184 |
for verse \\ % The \\ command separates lines |
| 185 |
Whose features some poets % within a stanza. |
| 186 |
will curse. |
| 187 |
|
| 188 |
% One or more blank lines separate stanzas. |
| 189 |
|
| 190 |
For instead of making\\ |
| 191 |
Them do \emph{all} line breaking, \\ |
| 192 |
It allows them to put too many words on a line when they'd rather be |
| 193 |
forced to be terse. |
| 194 |
\end{verse} |
| 195 |
|
| 196 |
Mathematical formulas may also be displayed. A |
| 197 |
displayed formula |
| 198 |
is |
| 199 |
one-line long; multiline |
| 200 |
formulas require special formatting instructions. |
| 201 |
\[ \ip{\Gamma}{\psi'} = x'' + y^{2} + z_{i}^{n}\] |
| 202 |
Don't start a paragraph with a displayed equation, |
| 203 |
nor make one a paragraph by itself. |
| 204 |
|
| 205 |
\end{document} % End of document. |