%
% instructions for "compiling" (old style -- produces DVI files):
%   latex sampler (first pass, also generates .aux file for bibtex)
%   bibtex sampler (generates .bbl file with bibliography)
%   latex sampler (second pass, incorporates bibliography)
%   latex sampler (do this if you still get messages about labels
%      having changed or missing references)
% to generate postscript from DVI:
%   dvips -o sampler.ps sampler 
% to generate PDF from DVI:
%   dvips -Pcmz -Ppdf -j0 -G0 -o sampler.ps sampler
%   ps2pdf sampler.ps sampler.pdf
%
% to "compile" directly to PDF, replace "latex" with "pdflatex"
%   in instructions for compiling.
%   
\documentclass{article}

% make sure of okay hyphenation
% (this may no longer be needed, but at one time it fixed a bug)
\usepackage[english]{babel}
\selectlanguage{english}

% some useful packages
\usepackage{url}	% has \url for formatting URLs
\usepackage{html}	% has stuff that helps latex2html generate HTML
\usepackage{graphicx}	% has \includegraphics
\usepackage{moreverb}	% has \verbatiminput and others
\usepackage{fancybox}	% has \BVerbatim and others

% allow more figures on a page
\setcounter{topnumber}{10}
\setcounter{bottomnumber}{10}
\setcounter{totalnumber}{10}
\setcounter{dbltopnumber}{10}
\def\topfraction{1.0}
\def\bottomfraction{1.0}
\def\textfraction{0.0}
\def\dbltopfraction{1.0}
% for boxed code examples
%\fboxrule=2pt % change width of box rule
\fboxsep=10pt % change space between box and enclosed text

% my macros -- if you have a lot of these you will use in many
%   documents, put them in a separate file foo.tex and use \input{foo}
%   to include them
% macros to reference sections, equations, consistently
%   the "~" disallows line breaks between Section, etc., and number
\newcommand{\SectionRef}[1]{Section~\ref{#1}}
\newcommand{\EqnRef}[1]{Equation~\ref{#1}}
\newcommand{\FigRef}[1]{Figure~\ref{#1}}
\newcommand{\TableRef}[1]{Table~\ref{#1}}
% macro to start an unindented paragraph with space before
\newcommand{\SpacedPar}{\vspace*{\baselineskip}\noindent}

% title, etc.
\title{A Sampler of \LaTeX\ Features}
\author{Berna Massingill}
\date{March 30, 2004}

%-----------------------------------------------------------------------

\begin{document}

\maketitle

\tableofcontents

\section{Text and sectioning}
\label{some-section}

\subsection{A subsection}
\label{some-subsection}

\LaTeX\ formats lines into paragraphs automagically.
I'll put in more words to show how that works.
words, words, words, words, words, words, words, words, words, words, 
words, words, words, words, words, words, words, words, words, words, 
words, words, words, words, words, words, words, words, words, words, 
words, words, words, words, words, words, words, words, words, words, 

A blank line in the source starts a new paragraph, like this
one.
words, words, words, words, words, words, words, words, words, words, 
words, words, words, words, words, words, words, words, words, words, 
words, words, words, words, words, words, words, words, words, words, 
words, words, words, words, words, words, words, words, words, words, 

You \emph{emphasize text} with the \verb+\emph+ macro.
There are also macros for doing various different fonts.
Here are some of them:
\verb+\textsf+ \textsf{looks like this},
\verb+\texttt+ \texttt{looks like this},
\verb+\textbf+ \textbf{looks like this},
\verb+\textit+ \textit{looks like this},
\verb+\textsl+ \textsl{looks like this}, and
\verb+\textsc+ \textsc{looks like this}.

You can also put in text of different sizes.  Here I'll combine that
with centering.
\begin{center}
\begin{large}
Some Large Text
\end{large} \\ % start a new line
\begin{small}
Some Small Text \\ % start a new line
with an explicit line break
\end{small}
\end{center}

\subsection{Another subsection}

words, words, words, words, words, words, words, words, words, words, 
words, words, words, words, words, words, words, words, words, words, 
words, words, words, words, words, words, words, words, words, words, 
words, words, words, words, words, words, words, words, words, words, 

\section{Lists}

% the blank comment lines are to provide visual separation in the
% source but avoid starting a new "paragraph" -- of which the first
% line would be indented

Here is an itemized list.
%
\begin{itemize}
\item An item.
\item Another item.
\end{itemize}
% 
It has some text after it.

% SpacedPar is a macro I defined earlier
\SpacedPar
Here is an enumerated list.  (See the source code for why
this paragraph isn't indented.)
%
\begin{enumerate}
\item An item.
\item Another item.
\end{enumerate}
%
It has some text after it.

\SpacedPar
Here is a description list.
%
\begin{description}
\item[Something.]  An item.
\item[Another thing.]  Another item.
\end{description}
%
It has some text after it.

\section{Math}

% the mbox prevents splitting the equation across lines
Here is some math inline:  \mbox{$c = \sqrt{a^2 + b^2}$}.
And here is the same math displayed:
\[
c = \sqrt{a^2 + b^2}
\]
And here it is again with an equation number:
\begin{equation}
c = \sqrt{a^2 + b^2} \label{eqn}
\end{equation}

\section{References}
\label{refs-section}

You can label things and reference them later.
For example, in this document
% EqnRef, etc., are my macros defined earlier
I labeled \EqnRef{eqn},
\SectionRef{some-section},
\SectionRef{some-subsection},
\FigRef{diagram-fig},
and
\TableRef{table-tbl}.
You can also have footnotes.\footnote{This is a footnote.
It could go on for a while.
words, words, words, words,
words, words, words, words,
words, words, words, words,
words, words, words, words,
}

There is also support for bibliographies.
Here I'm going to shamelessly plug two of my own papers
\cite{plop-1999,sct00-paper} and also cite a book \cite{gof-book}
and a Web site \cite{MPI2}.

\section{Figures and tables}

words, words, words, words, words, words, words, words, words, words, 
words, words, words, words, words, words, words, words, words, words, 
words, words, words, words, words, words, words, words, words, words, 
words, words, words, words, words, words, words, words, words, words, 
%
\begin{figure}[htbp]
\begin{center}
% includes xor.eps when processed with latex, xor.pdf with pdflatex
\includegraphics[width=0.5\textwidth]{xor}
\end{center}
\caption{Here is a picture of an XOR circuit I drew for my
	CSCI~2321 class.  It's scaled here to half the text width.
	I drew this with \texttt{xfig}.}
\label{diagram-fig}
\end{figure}
%
words, words, words, words, words, words, words, words, words, words, 
words, words, words, words, words, words, words, words, words, words, 
words, words, words, words, words, words, words, words, words, words, 
words, words, words, words, words, words, words, words, words, words, 
%
\begin{figure}[htbp]
\begin{verbatim}
#include <iostream>
int main(void) {
    cout << "Hello, world!\n";
    return 0;
}
\end{verbatim}
\caption{Here's a figure that consists of code.  Making it a figure
	keeps it all on one page and gives it a number we can
	reference.  YMMV, as they say.}
\label{code-fig}
\end{figure}
%
\begin{figure}[htbp]
\verbatimtabinput{hello.c}
\caption{Here's another figure with the same code
	as \FigRef{code-fig}, but included from a file.}
\label{morecode-fig}
\end{figure}
%
\begin{figure}[htbp]
% change fboxrule, fboxsep above to change line width of box, etc.
% the following uses stuff from the fancybox package and is somewhat
% obscure, but seems to work.
\begin{Sbox}
\begin{BVerbatim}
#include <iostream>
int main(void) {
    cout << "Hello, world!\n";
    return 0;
}
\end{BVerbatim}
\end{Sbox} 
% regular verbatim isn't smart enough to center, but this is
\begin{center}
\fbox{\TheSbox} % use "saved box" generated by SBox environment
\end{center}
\caption{Here's the code from \FigRef{code-fig} again,
	this time boxed.  This was trickier to do than I thought
	it would be!}
\label{boxed-code-fig}
\end{figure}
%
\begin{figure}[htbp]
\begin{center}
\fbox{\BVerbatimInput{hello.c}}
\end{center}
\caption{Here's the code from \FigRef{morecode-fig} again, 
	included from a file and boxed.  
	This also was trickier to do than I thought
	it would be!}
\label{boxed-morecode-fig}
\end{figure}
%
words, words, words, words, words, words, words, words, words, words, 
words, words, words, words, words, words, words, words, words, words, 
words, words, words, words, words, words, words, words, words, words, 
words, words, words, words, words, words, words, words, words, words, 
%
\begin{table}[htbp]
\begin{center}
\begin{tabular}{|l|c|r|}
\hline
This & that & a line \\
\hline
Whatever & whichever & another line \\
\hline
\end{tabular}
\end{center}
\caption{This is a simple table.}
\label{table-tbl}
\end{table}
%
words, words, words, words, words, words, words, words, words, words, 
words, words, words, words, words, words, words, words, words, words, 
words, words, words, words, words, words, words, words, words, words, 
words, words, words, words, words, words, words, words, words, words, 

\section{Hyperlinks}

No, you can't have hyperlinks in a PostScript 
document,\footnote{But you can in a PDF document, and
	\texttt{pdflatex} will supposedly do the right thing if you
	use the \texttt{hyperref} package.}
but the package \texttt{html} defines macros that 
\texttt{latex2html} will convert to hyperlinks.
The \texttt{url} package includes a macro to typeset
URLs in a way I think is reasonable.
For example, my home page is \url{http://www.cs.trinity.edu/~bmassing}.

% replace "plain" with "alpha" to get the author/year style 
\bibliographystyle{plain}
\bibliography{mybiblio}

\end{document}
