0% found this document useful (0 votes)
61 views

This Will Look At: Latex Supplement

This document provides an overview of LaTeX document structure and features for typesetting documents. It discusses the typical structure of LaTeX documents including headers, sections, and use of begin/end commands. It also covers common elements like fonts, math typesetting, tables, figures, and more. The goal is to introduce readers to the basic functionality of LaTeX for technical document preparation and typesetting.

Uploaded by

Esat Imeraj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

This Will Look At: Latex Supplement

This document provides an overview of LaTeX document structure and features for typesetting documents. It discusses the typical structure of LaTeX documents including headers, sections, and use of begin/end commands. It also covers common elements like fonts, math typesetting, tables, figures, and more. The goal is to introduce readers to the basic functionality of LaTeX for technical document preparation and typesetting.

Uploaded by

Esat Imeraj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Latex Supplement

This will look at

1. Structure and printing of Latex Documents

2. What you dont do with Latex

3. Common styles

4. Fonts

5. Maths typesetting

6. Tables

7. Figures

A latex document has typical structrure shown here:

% comments start with %


\documentclass{article}
\usepackage[dvips]{graphicx} % include a package to
\title{Information, Money and Value}
\author{Allin Cottrell \& Paul Cockshott }
% All the above is the heading of the document nothing
\begin{document}
%Printing starts here
\maketitle
\section{Section title}
\subsection{My first subsection}
This is a sample of text for Latex.
\section{The next section}
Text for section two ...
\end{document}

Every document must have a class - this defines the generic


formating rules used in the document.
For instance an article is defined as being broken into
sections and subsections.
A book is defined as being broken up into Parts, Chapters,
Sections and Subsections.
Other styles that may be of use to you are

amsart, an article set in the style demanded by the

American Mathematical Society. This tends to look neater


than the default article style.

report Similar to a book


slides Used in preparing presentations like this - no
sections, chapters etc.

The heading must start with a \documentclass, and include a title and author.
The title and author are not printed yet.
You then include the body of the document bracketed by

\begin{document} ... \end{document} blocks.


To produce the title you must include a \maketitle command.

Processing
Two commands are useful when processing Latex documents

1. >latex filename
This runs latex on a file called filename.tex and puts
the output in a file called filename.dvi.

2. >pdflatex filename
This runs latex on a file called filename.tex and puts
the output in a PDF file called filename.pdf.

Dvi files can be viewed using xdvi under Linux, or Yap under
Windows. These packages also allow you to print the files.
Pdf files can be viewed and printed using Adobe Acrobat.

What you dont do


1. Attempt to define the detailed page and paragraph layout of the document. For that you need a desk-top publishing program. Instead you describe the logical layout
of the document and leave it to TeX to do the detailed
layout.
2. You should not attempt to insert page breaks, leave this
to TeX.
3. You should not attempt to say exactly where you want
a figure to appear, only roughly where you want it to go.
4. You should not attempt to control the fonts of section
and chapter headings. The document classes do this
for you.
If you dont like the most common document classes,
there are many other ones with different style rules.
Document classes ensure that your whole text has the
same look and feel.

Common paragraph styles


Standard paragraphs are separated by a blank line in your
source. When typeset, this will translate into an indented
first line of the paragraph.
If you want more sophisticated styles you can try the enumerate,

quote, verbatim styles.

enumerate
An example

\begin{enumerate}
\item The first paragraph.
\item The successor paragraph.
\item And here is the ultimate one.
\end{enumerate}
This producees:

1. The first paragraph.

2. The successor paragraph.

3. And here is the ultimate one.

Quotations

In his 1948 article Shannon notes:


\begin{quote}
Quantities of the form
$H=-\sum_{i=1}n p_i \log p_i$ play a central
role in information theory as
measures of information, choice and
uncertainty. The form of $H$ will be
recognized as that of entropy
as defined in certain formulations
of statistical mechanics... (Shannon 1948)
\end{quote}
In his 1948 article Shannon notes:
Quantities of the form H = ni=1 pi log pi play a
central role in information theory as measures of
information, choice and uncertainty. The form of
H will be recognized as that of entropy as defined
in certain formulations of statistical mechanics...
(Shannon 1948)

Program fragments

It is often necessary to cite


program source in a document.
When this is done we want to
avoid it being typeset in paragraphs
like this:
main(int argc, char **argv)
{
if(argc<3){ printf("Not enough arguments");}
sort(argv[1]);
merge(argv[2]);
}
It is often necessary to cite program source in a document.
When this is done we want to avoid it being typeset in paragraphs like this: main(int argc, char **argv) if(argc3) printf(Not
enough arguments); sort(argv[1]); merge(argv[2]);

Instead

It is often necessary to cite


program source in a document.
When this is done we want to
avoid it being typeset in paragraphs
like this:
\begin{verbatim}
main(int argc, char **argv)
{
if(argc<3){ printf("Not enough arguments");}
sort(argv[1]);
merge(argv[2]);
}
\end{verbatim}

Which produces
It is often necessary to cite program source in a document.
When this is done we want to avoid it being typeset in paragraphs like this:

main(int argc, char **argv)


{
if(argc<3){ printf("Not enough arguments");}
sort(argv[1]);
merge(argv[2]);
}

Fonts

1. Font Families.

2. Default font size

3. Faces.

4. Size.

Font families By default Latex uses fonts produced by MetaFont, the companion font design package. The standard
fonts are the Computer Modern family of MetaFont faces.
These include Roman, Typewriter, SansSerif, Italic, and Slanted
faces.
You can override this and use Postscript fonts by putting the
line \usepackage{pslatex} into your document prelude
before \begin{document}.
Then it will use more familiar fonts like Times, Helvetica etc.
You should also modify your documentclass line to:

\documentclass[times]{article}

Font size By default Latex uses 10pt print.


If you want to change the default size of print in the whole
document then you override it on the document class line:

\documentclass[times,11pt]{article}
or

\documentclass[times,12pt]{article}
All of the headings etc are increased in size proportionately
to the increase in size for normal paragraph text.

Changing face in a document You can override the default


face of a document by inserting the directives \bf, \sf,

\rm, \tt, \em which stand for boldface, sanserifface, roman, teletypeface, and emphasised face. The following shows
the effects.

Bold{\bf ABCD, abcd},


San Serif {\sf ABCD, abcd}
Roman {\rm ABCD, abcd},
Teletype {\tt ABCD, abcd},
Emphasis {\em ABCD, abcd}
BoldABCD, abcd,
San Serif ABCD, abcd,
Roman ABCD, abcd,
Teletype ABCD, abcd,
Emphasis ABCD, abcd

Warning
You should as far as possible try to avoid using these commands, or use them very sparingly. It is reasonable to use
them in the following ways:

Use bold face to identify certain maths variables - arrays or matrices.

Use teletype face when citing program variables or reserved words in document texts.

Use emphasis for the names of publications in citations.

You should avoid using them to make your document more


pretty. You are likely to make it just look odd.

Math
One of the strengths of Latex is its mathematical typesetting. It is particularly good at giving well balanced and well
spaced maths formulae. Maths formulae can be of 3 types,
inline, display or equation. Inline formulae are simply bracketed with dollar signs.

Let $\alpha=1$ and $\beta=2$ in the metric


$d=|\alpha \Delta_{x} +\beta \Delta_{y}|$.
Produces :
Let = 1 and = 2 in the metric d = |x + y|.
Note how Greek letters are produced, capital letters at the
start of the name of the letter produce Greek capitals. The
underbar produces subscripts.

Display formulae are enclosed in double dollars:

The result is that


$$x\rightarrow [a,b]=
[\frac{1}{\sqrt{2}},\frac{1}{\sqrt{2}}]$$
and
$$y\rightarrow [-a,b]=
[\frac{-1}{\sqrt{2}},\frac{1}{\sqrt{2}}]$$
The result is that

1 1
x [a, b] = [ , ]
2 2
and

1 1
y [a, b] = [ , ]
2 2

Numbered equations can be produced using the equation


environment.

\begin{equation}
\label{Landauer1}
e= \ln (2)kt b
\end{equation}

e = ln(2)ktb

(1)

You can then refer to the equation using the label thus:

As equation \ref{Landauer1} shows,


all computers must dispose of heat.
As equation 1 shows, all computers must dispose of heat.

Matrices
We can express this as a matrix calculation TP = Q with

1
T = 12

2
1

Is produced using the array environment.

We can express this as a matrix calculation


$\mathbf{T}P= Q$ with
\begin{equation}\label{eq:mvtrans}
\mathbf{T}=\left[
\begin{array}{cc}
\frac{1}{\sqrt{2}} & \frac{-1}{\sqrt{2}}\\
\frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}}
\end{array}
\right]
\end{equation}

(2)

Consider this again

\begin{array}{cc}
\frac{1}{\sqrt{2}} & \frac{-1}{\sqrt{2}}\\
\frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}}
\end{array}
The {cc} that comes after {array} tells Latex that we have
2 columns and that the formulae are to be centered in the
columns. Each row of the matrix is then separated by \\
and each element on a row is separated by &.

Tables are similar to arrays.


Agent
State
Alande
Tunde
Femi

Coin
2
0
0
7

Casava
0
6
2
0

Kola
0
6
5
0

\begin{tabular}{|l|ccc|}\hline
Agent &Coin& Casava&Kola \\\hline
State &2&0&0\\
Alande&0&6&6\\
Tunde&0&2&5\\
Femi&7&0&0\\\hline
\end{tabular}
The {|l|ccc|} indicates we have 4 columns, the first left
aligned the others centered. Vertical lines can be placed
between columns.
Horizontal lines are generated by \hline.

Figures
These can be inserted using encapsulated postscript files (
ending in .eps ). The packages Xfig and tgif provide Linux
drafting environments for producing .eps diagrams.
It is also possible to convert photos to .eps using the Gimp.

\begin{figure}
\includegraphics[scale=0.75]{manhattan.eps}
\caption{How to get from the corner
of Greene and Broome
to the corner of West Houston and
Broadway in the Manhattan street layout.}
\label{fig:manhattan}
\end{figure}

West Houston St

Prince St

Broadway

Mercer St

Greene St

Spring St

Broome St

Figure 1. How to get from the corner of Greene and


Broome to the corner of West Houston and Broadway in
the Manhattan street layout.

You might also like