Compiled result:
page 1,   page 2,
page 3,   page 4

Sample LaTeX document (4 pages)

illustrating several formatting features

 

\documentclass[12pt]{article}

\setlength{\parskip}{1.2ex}	   % space between paragraphs
\setlength{\parindent}{2em}	   % amount of indention
\setlength{\textwidth}{175cm}	   % default = 6.5"
\setlength{\oddsidemargin}{-5mm}   % default = 0"
\setlength{\textheight}{225mm}	   % default = 9"
\setlength{\topmargin}{-12mm}	   % default = 0"

	%  ---  define your own commands!! ---
\newcommand{\iii}{\indent \indent \indent}	% triple-depth indent

\title{A Sample \LaTeX\  Document}
\author{Schl\oe ff\d{o}nffl\t{oo}\ae g\"{e}n, \L\"{a}rs}
\date{July 14, 1992}

\begin{document}
				(PAGE 1)
\maketitle

\noindent
I{\footnotesize MPORTANT} S{\footnotesize TUFF} \\
{\bf 	I{\bf \footnotesize MPORTANT} S{\bf \footnotesize TUFF}} \\
\textbf{ I{\footnotesize MPORTANT} S{\footnotesize TUFF}}

This is a document produced by the \LaTeX\ software, and generated by the
source file {\tt sample.tex}.  Compare the source text file (left-hand
sides) with the document it produces using \LaTeX\  (right-hand sides).

\section{Ordinary Text}	% Produces section heading.  Lower-level sections
			% are begun with similar \subsection and
			% \subsubsection commands; numbering is automatic!

\subsection{Spacing in the source text}
The ends  of words and sentences are marked
  by   spaces. It  doesn't matter how many
spaces
you
type; one is as good as                        100.
The       end of   a line counts as a space.

One   or more   blank lines denote the  end of  a paragraph.

Since any number of consecutive spaces are treated like a single one, the
formatting of the input file makes no difference to \TeX, but it makes a
difference to you.  When you use \LaTeX, making your input file as easy to
read as possible will be a great help as you write your document and when
you change it.  Keep typed lines {\bf short} in length, and use
\verb9 % comments9.                             % like this!

Because printing is different from typewriting, there are a number of things
that you have to do differently when preparing an input file than if you were
just typing the document directly.  Quotation marks like ``this'' have to
be handled specially.

\subsection{Special characters}
Dashes come in three sizes: an
       intra-word
dash, a medium dash for number ranges like
       1--2,
and a punctuation
       dash---like
this.

\TeX\ interprets some common characters as commands, so you must type
special commands to generate them.  These characters include the
following: \$ \& \% \# \{ and \}.

\subsection{Fonts}		(PAGE 2)
In printing, text is emphasized by using an {\em italic\/}
type style.     % The \/ command produces the tiny extra space that
                % should be added between a slanted and a following
                % unslanted letter.
\begin{em}
   A long segment of text can also be emphasized in this way.  Text within
   such a segment given additional emphasis
          with\/ {\em Roman}
   type.  Italic type loses its ability to emphasize and become simply
   distracting when used excessively.
\end{em}

Other font types are available:    \\
\indent  {\bf Bold face type,}	\\
\indent  {\tt typewriter style type,}	\\
\indent  {\sf sans-serif type,}	\\
\indent  {\sl slanted type,}	\\
\indent  {\sc all caps type.}	\\
Formulae and other mathematical expressions are given
their own ``math mode'' font.

\section{Spacing}
A sentence-ending space should be larger than the space between words
within a sentence.  You sometimes have to type special commands in
conjunction with punctuation characters to get this right, as in the
following sentence.
       Gnats, gnus, etc.\    % `\ ' makes an inter-word space.
       all begin with G\@.   % \@ marks end-of-sentence punctuation.
Generating an ellipsis
  \ldots\	% `\ ' needed because TeX ignores spaces after
		% command names like \ldots made from \ + letters.
with the right spacing around the periods requires a special  command.

It is sometimes necessary to prevent \TeX\ from breaking a line where
it might otherwise do so.  This may be at a space, as between the
``Mr.'' and ``Jones'' in
``Mr.~Jones'',  %	~ produces an unbreakable interword space.
or within a word---especially when the word is a symbol like
\mbox{\em itemnum\/} that makes little sense when hyphenated
across lines.

In math mode, \TeX\ ignores the spaces you type and formats
the formula the way it thinks is best. Some authors feel that
\TeX\ cramps formulae, and they want to add more space; however,
\TeX\ knows more about typesetting formulae than do many authors.
Adding extra space usually makes a formula prettier but
harder to read, because it visually fractures the formula into
separate units.

Though fiddling with the spacing is dangerous, you sometimes
have to do it to make a formula look just right.  One reason
is that \TeX\ may not understand the formula's logical structure,
interpreting (for example) ${\bf y\:dx}$ as the product of
three quantities rather than as $y$ times the differential $dx$,
so that it doesn't add the little extra space after the $y$.
You can define your own commands to take care of such cases,
or use these special spacing commands:	\\
\iii \verb2\,2~~~thin space~~~~~~(any mode)  \\		% "verbatim"
\iii \verb9\:9~~~medium space~~~~(math mode only) \\
\iii \verb#\;#~~~thick space~~~~~(math mode only) \\
\iii \verb2\!2~~~thin backspace~~(math mode only) \\
A most precise spacing command can be used in either math or
paragraph modes; the \verb2\kern2 command.  Use it with the
unit ``em'', which is the width of a capital M.  Example:
to print `R' over an `I' you might use the command
\verb@I\kern-0.27emR@ to produce ``I\kern-0.27emR''.

\section{Displayed Text}		(PAGE 3)
Text is displayed by indenting it from the left margin.
Quotations are commonly displayed.  There are short quotations
\begin{quote}
   This is a short a quotation.  It consists of a
   single paragraph of text.  There is no paragraph
   indentation.
\end{quote}
and longer ones.
\begin{quotation}
   This is a longer quotation.  It consists of two paragraphs
   of text.  The beginning of each paragraph is indicated
   by an extra indentation.

   This is the second paragraph of the quotation.  It is just
   as dull as the first paragraph.
\end{quotation}

Footnotes\footnote{This is an example of a footnote.} pose no problem.
Likewise, bibliographic references \cite{Lam} are handled with ease.
!`\TeX\ can g\`{e}n\'{e}rate alm\"{o}st all the accents and
spe\c{c}ial symbols used in Western \cite{Sch} l\aa nguages! Likewise,
its arsenal of mathematical sym$\beta$ols, introduced below, is formidable.

Another frequently-displayed structure is a list.
The following is an example of an {\em itemized} list.
 \begin{itemize}
   \item  This is the first item of an itemized list.  Each item
          in the list is marked with a ``tick''.  The document
          style determines what kind of tick mark is used.

   \item  This is the second item of the list.  Need there be more?
 \end{itemize}

\section{Mathematical Formulae}
\TeX\ is good at typesetting mathematical formulas like
       $ x-3y = 7 $
or
       $ y_{i+1} = x_{i}^{2n} - \sqrt{5}x_{i}^{n} + 1$.
Remember that a letter like
       \( x \)        % $ ... $  and  \( ... \)  are equivalent
is a formula when it denotes a mathematical symbol, and should
be treated as one.

Mathematical formulas may also be		%  use \[ \]
{\em displayed}.  A displayed formula		%  or  $$  $$
is one-line long; multiline formulas		%  or \begin{equation}
require special formatting instructions.	%  \begin{eqnarray}
The following formulae demonstrate
many constructions you might find useful.
Refer to equation (\ref{eq:fermat}), which is probably true,
while equations (\ref{eq:dumb}-\ref{eq:realdumb}) are silly.
Note that the \verb9equation9 and \verb9eqnarray9 environments
number the equations, but \verb9eqnarray*9 doesn't.
\[  x_{i+1} ~=~ N^{i+1}(x_{0}) ~=~ N(x_{i}) ~=~
	x_{i} - \frac{f(x_{i})}{f'(x_{i})}	\]

$$ \frac{\partial u}{\partial t} + \nabla^{4}u + \nabla^{2}u +
	\frac12    |\nabla u|^{2}~ =~ c^2   $$

				(PAGE 4)
\begin{equation}  a^{p} + b^p   \neq c^{p} ~~~\mbox{for } p>2
	~~ \mbox{(see proof in margin)}  \label{eq:fermat}
\end{equation}
$$ \lim_{n \rightarrow \infty}x_{n} \geq \pi $$
$$ \forall x \in {\cal O} ~~\exists \delta ~~~\mbox{such that}~~~
	|y-x|<\delta ~\Rightarrow ~y \in {\cal O} $$
\vspace{4mm}
$$
\Psi' = \frac{d}{d \phi} \left( \begin{array}{c}
  \phi_{2}  \\  \phi_{3}  \\  1 - \phi_{2} - \phi_{1}^{2}/2
 \end{array} \right)
 ~~~~~~~~~~~~~
 \Theta =  \left(	\begin{array}{ccc}
	0 			& 	1	&	0	\\
- \theta_{1} \psi_{1} - \psi_{2} &	0	&	\psi_3	\\
	-\phi_{1}   		&	-1	&	0
			\end{array}  \right)
$$
\vspace{4mm}
\begin{eqnarray}
	\int_0^{\infty} e^{-x^2}\,dx
	& = &	e^{-\left(\int_0^{\infty}x\,dx\right)^2} \label{eq:dumb}  \\
	& = &	e^{-\infty} ~~~~~\mbox{(bogus)} \\
	& = &	0.38-1.7i ~~~~~\mbox{(not!)} \label{eq:realdumb}
\end{eqnarray}
\vspace{4mm}
\begin{eqnarray*}			%  "*" = no line numbering
  \sum_{n=1}^k \frac1n
	& \approx &	\ln k + \gamma  \\
	& = &		(\ln 10)(\log_{10}k) + \gamma \\
	& \approx &	2.3026\log_{10}k + 0.57772
\end{eqnarray*}

\vspace{6mm}
\centerline{
\begin{tabular}{ | c | c   c   c | } \hline
        $k$ &   $x_1^k$  &   $x_2^k$  &    $x_3^k$   \\
         \hline
         0 & -0.30000000 & 0.60000000 &  0.70000000  \\
         1 &  0.47102965 & 0.04883157 & -0.53345964  \\
         2 &  0.49988691 & 0.00228830 & -0.52246185  \\
         3 &  0.49999976 & 0.00005380 & -0.52365600  \\
         4 &  0.50000000 & 0.00000307 & -0.52359743  \\
         5 &  0.50000000 & 0.00000007 & -0.52359885  \\
         6 &  0.50000000 & 0.00000000 & -0.52359877  \\
         7 &  0.50000000 & 0.00000000 & -0.52359878  \\
         \hline
\end{tabular}}

Unary operators ``plus'' and ``minus'' -- just use exponentiation:
$$	{}^{+}0.168  \mbox{ or } {}^{-}1.168	$$

$$  \Vert \diamond\star \Vert ~~~ \clubsuit\diamondsuit\heartsuit\spadesuit
 ~~~ \sharp\flat\natural ~~~ \cap\cup\pm\mp ~~~ \prod\alpha\beta\gamma
 ~~~ \oint_Cf(z)dz ~~~ \Gamma_{\sqrt7}^{v,\upsilon} ~~~ V\bigoplus W $$

				(PAGE 5)
\begin{thebibliography}{9}	% 9 = maximum expected references!

\bibitem{Lam} Lamport, Leslie.
\LaTeX : A Document Preparation System.  \\
Copyright \copyright 1986, Addison-Wesley Publ.Co.,Inc.

\bibitem{Sch} Schl\oe ff\d{o}nffl\t{oo}\ae g\"{e}n,
\L\"{a}rs.  Silly Typography.		\\
{\em Journal of Linguistic Horseplay 19D} (1977), 23-37.

\end{thebibliography}
\end{document}             % End of document.

page 1       (back to top)

page 2       (back to top)

page 3       (back to top)

page 4       (back to top)

page 5       (back to top)