42
18 ♦
Chapter 4. Within the Text
4.3 Starting New Lines and New Pages
Normally L
A
T
E
Xdecides where to start a new line and a new page, always trying to pick
the most aesthetically pleasing break points. But sometimes you want to force the start
of a new line or page. The command \\ will force a new line. For example,
This will be on one line\\ this will be on the next line
If you want extra space between two lines, do not use two \\ commands in a row.
Instead use an optional parameter (given inside square brackets) to specify the amount
of blank space. For example, the following command will leave an extra space of 10
points between the lines:
This will be on one line\\[10pt] this will be on the next line
To force a new page, the simplest command is \newpage, which starts a new page
immediately. There is also the command \clearpage, which acts like \newpage except
that it also forces any leftover figures or tables to print before starting the new page.
With the twoside documentclass option, the command \cleardoublepage produces a
blank page, if necessary, to ensure that the new page starts on a new sheet of paper.
4.4 Leaving Horizontal and Vertical Space
The commands \hspace and \vspace leave horizontal and vertical space in your text.
Both commands take a mandatory parameter—the amount of blank space you want to
leave. For example, \vspace{3in} will leave 3 inches of blank space in your text. If
vertical space is requested in the middle of a paragraph, the space will appear after the
current line has ended.
Space requested by the \hspace and \vspace commands disappears if it falls at the
beginning or end of a line or page. To create space that remains no matter where it
falls, use the variations \hspace* and \vspace*. For example, the following lines:
This text starts at the left margin\\
\hspace*{1in}This text starts a new line after a one-inch space
produces:
This text starts at the left margin
This text starts a new line after a one-inch space
4.5 Drawing Rules
To draw a line (horizontal or vertical) on the page, use the \rule command:
\rule[lift]{width}{height}
width is the horizontal dimension, height is the vertical dimension, and the optional
parameter lift is the amount raised above the baseline. For example, the line below was
drawn with the command \rule{\textwidth}{1pt}.
April 2007
42
4.6 Footnotes ♦
19
4.6 Footnotes
Footnotes are numbered automatically by L
A
T
E
X. The command \footnote{footnote
text} should be placed exactly where you want the footnote number to appear, with no
extra space between the \footnote command and the text before it. For example:
This is text with a note.\footnote{This is the note text.
Here it is at the bottom of the page.}
produces:
This is text with a note.
2
4.7 Centering
If you have only one line to center, it’s easiest to use the plain T
E
X command
\centerline; for example,
\centerline{This line will be centered}.
If you have several lines to be centered horizontally, the center environment is conve-
nient. The example below produces three lines, each horizontally centered.
\begin{center}
This is line one. \\
This is line two. \\
This is line three.
\end{center}
There is also the declaration \centering, which is always used within a group—either a
pair of braces or an environment. This is useful when you don’t want the extra vertical
space surrounding the center environment.
4.8 Quotations
The quote environment beginsa new lineand indentstextfrom both sides. It
isdelimited with \begin{quote}and \end{quote}. Any special effects (such
as changes to the type size or style) started within the quote environment
are terminated by \end{quote}.
New paragraphs are block style: that is, no indent and a blank line as sepa-
ration. This section is inside a quote environment.
There is also a very similar environment called quotation. The only difference is that
paragraphs in the quotation environment are indented with no blank line between.
2Thisisthenotetext.Hereitisatthebottomofthepage.
Academic and Research Computing, RPI
50
20 ♦
Chapter 4. Within the Text
4.9 Reproducing Text As-Is
To reproduce new lines and spaces exactly as they are in your input file, you have a
choice of several methods.
The verbatim environment prints its text in typewriter-style type and sets it off from
the rest of the document with blank lines before and after. (It does not indent.) To use
it, surround the text with the commands \begin{verbatim} and \end{verbatim}. The
only L
A
T
E
Xcommand obeyed inside this environment is \end{verbatim}. For example,
the following input
\begin{verbatim}
All
spacing is displayed in verbatim as entered.
So are special characters
! @ # & * ( ) _ } ] \ | > <
verbatim is used to display LaTeX commands in this document.
\end{verbatim}
produces:
All
spacing is displayed in verbatim as entered.
So are special characters
! @ # & * ( ) _ } ] \ | > <
verbatim is used to display LaTeX commands in this document.
Avariation on the verbatim environment, called the alltt environment, is provided
by a package. It is used in the same way as the verbatim environment and works
the same, in that spaces and lines are retained from the input file. The difference is
that L
A
T
E
X commands are recognized inside this environment. It cannot be used to
reproduce L
A
T
E
Xcommands, but it is very useful if you want to print in roman or italic
type instead of typewriter. Before you can use this environment, you must include the
command \usepackage{alltt} following the \documentclass command.
If the text is short enough to be contained on one input line and should not be set off,
you can use the \verb command. For example,
\verb+This is inside the \verb command+
produces:
This is inside the \verb command
Note that the “+” is used here to delimit the verbatim text. Any character except the
“*” can be used as the delimiter.
April 2007
71
4.10 Lists ♦
21
4.10 Lists
The three L
A
T
E
Xlist environments all use the \item command to start new items in the
list. The enumerate environment numbers items sequentially, the itemize environment
puts a bullet in front of each item, and the description environment puts a boldface
word or phrase in front of each item.
The following examples show both the output and the input used to create them.
Example of Enumerate
\begin{enumerate}
\item Sugar
\item Cream
\item Chocolate
\end{enumerate}
1. Sugar
2. Cream
3. Chocolate
Example of Itemize
\begin{itemize}
\item Mix all ingredients together.
\item Boil until the thermometer
reaches 112 $^\circ$C.
\item Stir and cool.
\end{itemize}
• Mix all ingredients together.
• Boil until the thermometer
reaches 112
◦
C.
• Stir and cool.
Example of Description
\begin{description}
\item[dog] A loving animal that
likes to sleep on the furniture.
\item[cat] Aloof creature that can
warm your feet on a winter’s night
\item[horse] Large animal, gives
great rides. Eats a lot, luckily
doesn’t sleep on the furniture.
\end{description}
dog A loving animal that likes to
sleep on the furniture.
cat Aloof creature that can warm
your feet on a winter’s night
horse Large animal, gives great rides.
Eats a lot, luckily doesn’t sleep
on the furniture.
Below is an example of nesting list environments:
Here are some useful environments:
\begin{itemize}
\item center environment
\item quote environment
\item the three list environments:
\begin{enumerate}
\item enumerate (uses numbers)
\item itemize (uses bullets)
\item description (uses words)
\end{enumerate}
\end{itemize}
Here are some useful environments:
• center environment
• quote environment
• the three list environments:
1. enumerate (uses numbers)
2. itemize (uses bullets)
3. description (uses words)
Academic and Research Computing, RPI
C# HTML5 PDF Viewer SDK deployment on IIS in .NET place where you store XDoc.PDF.HTML5 Viewer correspond site-> Edit Permissions -> Security -> Group or user names -> Edit -> Add -> Add Everyone usersgiven
creating secure pdf files; convert secure webpage to pdf
40
22 ♦
Chapter 4. Within the Text
4.11 Cross References
In longer documents, there are often cross references to sections, figures, tables, or
equations. L
A
T
E
Xprovides the following commands for cross referencing:
\label{marker}
set a marker for future reference
\ref{marker}
include the number of the section, figure, etc. of the cor-
responding \label command
\pageref{marker} include thepage numberofthe corresponding\label com-
mand
marker is an identifier that you choose—it may contain letters, numbers, or other
characters (except for L
A
T
E
X’s special list of characters). It can be helpful, but not
necessary, to start the marker name with a tag that identifies what is being marked:
for example, sec: for sections, eqn: for equations, fig: for figures, etc. (See the
example below.) The \label command should be placed immediately after a sectioning
command, within an equation environment, or inside a figure or table environment
immediately following the caption command.
\label{sec:xrefs}
For information on cross references,
see section~\ref{sec:xrefs} on
page~\pageref{sec:xrefs}.
For information on cross references, see
section4.11 on page22.
Note that L
A
T
E
Xuses the numbers from the .aux file produced by the previous run, so
it will take two runs (sometimes more) to get the cross references correct.
April 2007
48
Chapter 5. Tabular Material
There are two environments in L
A
T
E
X for formatting tabular material: the tabbing
environment, which uses \begin{tabbing}...\end{tabbing}, and the tabular envi-
ronment, which uses \begin{tabular}...\end{tabular}.
The tabbing environment works in a manner similar to a typewriter—you set the tabs
and then move from one to another. Tab stops may be reset on any line. Page breaks
within the tabbed material are allowed since each line is processed individually.
The tabular environment allows you to construct a much fancier looking table: for
example, you can specify the alignment of each column and use horizontal and vertical
lines. However, these tables cannot be broken across pages because L
A
T
E
Xreads in the
entire table at once to establish correct column widths. Often material inside a tabular
environment is placed inside the table environment, which ensures that if it can’t fit at
the current location it will be “floated” to an appropriate location. For information on
using the table environment, see Chapter8..
5.1 Tabbing
Tabbing uses the following commands:
\= Set a tab stop
\> Move right to the next tab stop
\\ Terminate a line
Tabs are usually set in the first line but may also be added in later lines. A special line
ending with the command \kill may be used to set tabs but not print the line. Below
are two examples of tabbing. Note that the last entry does not require a \\ to end the
line.
Example 1: A Very Simple Case
\begin{tabbing}
Column 1 \= Column 2 \= Column 3 \= Column4 \\
Col 1 \> Col 2 \> Col 3 \> Col 4 \\
one \> two \> three \> four
\end{tabbing}
Produces:
Column 1 Column 2 Column 3 Column 4
Col 1
Col 2
Col 3
Col 4
one
two
three
four
23
50
24 ♦
Chapter 5. Tabular Material
Example 2: A Little More Complex
\begin{tabbing}
\hspace{2in} \= \hspace{2in} \= \kill
First column \> Second column \> Third column \\
\> Second
\> Third \\
\hspace{1in} \\ % make a blank line
This Text extends past tab 1 \>\> Third column \\
\> Text spans columns two and three \\
xxxxxxxx \= xxxxxxxx \= xxxxxxxx \= \kill % set up new tab stops
Col 1 \> Col 2 \> Col 3 \> Col 4
\end{tabbing}
Produces:
First column
Second column
Third column
Second
Third
This Text extends past tab 1
Third column
Text spans columns two and three
Col 1
Col 2
Col 3
Col 4
5.2 Tabular
The tabular environment requires an additional argument that specifies the alignment
of each column (centered, left justified, etc.):
\begin{tabular}{align}
You may substitute any combination of the following symbols for the align argument:
l
Left-justified column entry
c
Centered column entry
r
Right-justified column entry
p
Paragraph column entry
|
Vertical rule column
||
Double vertical rule column
The width necessary for each column is determined automatically from the widest entry.
Inside the tabular environment, use the tab character (&) to move to the next column,
\\ to end each line (except the last one), and \hline to insert a horizontal line.
The following examples illustrate the tabular environment. Note that you can center
atable by enclosing the tabular environment inside a center environment.
April 2007
53
5.2 Tabular ♦
25
5.2.1 A Simple Ruled Table
\begin{center}
\begin{tabular}{|l|c|r|} % 3 cols (left, ctr, right); vert. lines
\hline
% draw horizontal line
Name & Oblateness & Diameter \\
\hline
Mercury & 0 & 3,100 \\
Venus & 0 & 7,700 \\
Earth & 1/297 & 7,927 \\
Mars & 1/192 & 4,200 \\
Jupiter & 1/15 & 88,700 \\
Saturn & 1/9.5 & 75,100 \\
Uranus & 1/14 & 32,100 \\
Neptune & 1/40 & 27,700 \\
Pluto & ? & 3,600\\
\hline
\end{tabular}
\end{center}
Produces:
Name
Oblateness
Diameter
Mercury
0
3,100
Venus
0
7,700
Earth
1/297
7,927
Mars
1/192
4,200
Jupiter
1/15
88,700
Saturn
1/9.5
75,100
Uranus
1/14
32,100
Neptune
1/40
27,700
Pluto
?
3,600
Academic and Research Computing, RPI
43
26 ♦
Chapter 5. Tabular Material
5.2.2 Using Paragraph Columns, Spanning Columns
The following example illustrates making paragraphs within a table and placing text
across multiple columns using the \multicolumn command. This command has the
form:
\multicolumn{n}{pos}{item}
where n is the number of columns to be spanned, pos specifies the alignment of the item,
and item is the text.
This example is inside the table environment, which ensures that the table will be
“floated” rather than broken across a page (see chapter8.on page37) and also provides
the opportunity to supply a caption. In this example, the optional parameter [hb]
specifies that the table should appear “here” or at the bottom of the page.
To center tabular material inside the table environment, you can use the declaration
\centering, which has the same effect as the center environment. (The centering
action will be confined to inside the table environment.)
\begin{table}[hb] % place table ‘‘here’’ or at bottom of page
\centering
\caption{More Things You can Do With Tabular}
\bigskip
\begin{tabular}{|l|l|p{2.5in}|}
\hline
\multicolumn{2}{|c|}{Text in columns 1 and 2}
& A paragraph 2.5 inches wide \\
\hline
Column 1 & Column 2 & This text is a paragraph. It will wrap
around to the next line if necessary. \\
Column 1 & Column 2 & The paragraph column \\
\hline
\end{tabular}
\end{table}
Table 1: More Things You can Do With Tabular
Text in columns 1 and 2
Aparagraph 2.5 inches wide
Column 1
Column 2
This text is a paragraph. It will
wrap around to the next line if nec-
essary.
Column 1
Column 2
The paragraph column
April 2007
Documents you may be interested
Documents you may be interested