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