<< . .

. 20
( : 23)

. . >>

exactly one of the positioning symbols l, r, c, with possible @-expressions and
vertical lines ". A value of 1 may be given for num when the positioning
argument is to be changed for that column in one particular row.
In this context, a ˜column™ starts with a positioning symbol l, r, or c and
includes everything upto but excluding the next one. The ¬rst column also
includes everything before the ¬rst positioning symbol. Thus c@{}rl" contains
three columns: the ¬rst is "c@{}, the second r, and the third r".

Table style parameters

There are a number of style parameters used in generating tables which LTEXsets to stan-

dard values. These may be altered by the user, either globally within the preamble or
locally inside an environment. They should not be changed within the tabular environ-

• \tabcolsep is half the width of the spacing that is inserted between columns in the
tabular and tabular* environments.

• \arrayrulewidth is the thickness of the vertical and horizontal lines within a table.

• \doublerulesep is the separation between the lines of a double rule.

• \arraystretch can be used to change the distance between the rows of a table.
This is a multiplying factor, with a standard value of 1. A value of 1.5 means that
the inter-row spacing is increased by 50%. A new value is set by rede¬ning the
parameter with the command:


Following are the commands for changing the table style parameters that relate to



Creating tables is much easier in practice than it would seem from the above list of
formatting possibilities. This is best illustrated with an example.
The simplest table consists of rows and columns in which the text entries are either
centered or justi¬ed to one side. The column widths, the spacing between the columns,
and thus the entire width of the table are automatically calculated.

Sample Tabular
col head col head col head
Left centered right
aligned items aligned
items items items
Left items centered right aligned

See the code that generated the table above.
\multicolumn{3{|c|}{Sample Tabular}
col head & col head & col head
Left & centered & right \\\cline{1-2}
aligned & items & aligned \\\cline{2-3}
items & items & items \\\cline{1-2}
Left items & centered & right aligned

The discussion on tables doesn™t conclude with this chapter, instead more bells and
whistles are to be discussed, such as long tables (tables that span multiple pages), how to
repeat the column headings and special footlines in all multipaged tables, color tables and
also a few other embellishments, which the scienti¬c community at large might require
in their document preparation.


Here is an exercise you can try.

Plan for TEX Users Group 2001“2003

Project No. Name

Year 2001 2002 2003
Rs. US$ Rs. US$ Rs. US$
Internet costs
Journal costs
TEXLive production costs

Signature Authorization



Cross reference is the technical term for quoting yourself. This is what you do when you
say something like, “As I said earlier,. . .”. More seriously, in a written article you may
often have occasion to refer the reader to something mentioned earlier (or sometimes to
something yet to be said) in the same document. Thus you may have explained a new
term in the second section of your article and when you use this term again in the fourth
section, it is a matter of courtesy to the reader to point to the explanation. Again, in
a mathematics article, you may have to cite an earlier result in the proof of the current
Such cross referencing can be done by hand, but if you revise your document and
insert some new sections (or theorems) then changing all cross references manually is no
easy task. It is always better to automate such tedious tasks. (After all what™s a computer
for, if not to do such mundane jobs?)


The basic method of using cross references (see Section XII.1 for what we mean by cross
reference) in LTEX is quite simple. Suppose that somewhere in the second section of your

article, you want to refer to the ¬rst section. You assign a key to the ¬rst section using
the command
\section{section name}\label{key}

and at the point in the second section where the reference is to be made, you type the

Thus the reference “see Section XII.1. . . ” in the ¬rst sentence of this section was
produced by including the command \label{intro} in the command for the ¬rst section
\section{Why cross references}\label{intro}

and the command \ref{intro} at the place of reference in the second section as
. . . (see Section \ref{intro} for. . .

Okay, the example is a bit silly, since the actual reference here is not really necessary, but
you get the general idea, don™t you? Incidentally, the \label{key} for a section need not
be given immediately after the \section{section name}. It can be given anywhere within
the section.


The ¬rst time you run LTEX on a ¬le named, say, myfile.tex containing cross refer-

ences, the reference information is written in an auxiliary ¬le named myfile.aux and at
the end of the run LTEX prints a warning

LaTeX Warning: There were undefined references.

LaTeX Warning: Label(s) may have changed.
Rerun to get cross-references right.

A second run gets the references right. The same thing happens when you™ve changed
the reference information in any way, say, by adding a new section.
Though the key in \label{key} can be any sequence of letters, digits or punctuation
characters, it is convenient to use some mnemonic (such as \label{limcon} for a section
entitled “Limits and Continuity” rather than \label{sec@#*?!}. Also, when you make a
reference, it™s better to type ˜\ref{limcon} (notice the tie?) than \ref{limcon} to prevent
the possibility of the reference number falling off the edge as in “ . . . see Section XII.1 for
further details.. . . ”.
In addition to sectioning commands such as \chapter or \section, reference can
also be made to an \item entry in an enumerate environment, by attaching a \label. For
example the input
In the classical \emph{syllogism}
\item All men are mortal.\label{pre1}
\item Socrates is a man.\label{pre2}
\item So Socrates is a mortal.\label{con}
Statements (\ref{pre1}) and (\ref{pre2}) are the \emph{premises} and
statement (\ref{con}) is the conclusion.

gives the following output

In the classical syllogism
(1) All men are mortal.
(2) Socrates is a man.
(3) So Socrates is a mortal.
Statements (1) and (2) are the premises and statement (3) is the conclusion

You must be a bit careful about references to tables or ¬gures (technically, “¬‚oats”).
For them, the \label command should be given after the \caption command or in its
argument, as in the example below:
Value of $x$ & 1 & 2 & 3\\
Value of $y$ & 1 & 8 & 27\\
\caption{Observed values of $x$ and $y$}\label{tabxy}
A 137

Two possible relations betweeen $x$ and $y$ satisfying
the data in Table\ref{tabxy} are $y=xˆ3$ and

This produces the following output:

Value of x 1 2 3
Value of y 1 8 27

Table XII.1: Observed values of x and y

Two possible relations between x and y satisfying the data in Table XII.1
are y = x3 and y = 6x2 ’ 11x + 6

You can think of a \caption command within a figure or table environment as a
sort of sectioning command within the environment. Thus you can have several \caption
and \label pairs within a single figure or table environment.
You can also make forward references in exactly the same way by \ref-ing to the
key of some succeeding \label such as “see Subsection XII.2.1 for a discussion of cross
references in mathematics.”

Cross references in math

Mathematical documents abound in cross references. There are references to theorems
and equations and ¬gures and whatnot. The method of reference is exactly as before.
Thus if you™ve de¬ned \newtheorem{theorem}[subsection], then after typing

Every differentiable function is continuous

you get

Theorem. Every differentiable function is continuous

and you can type elsewhere in the document
The converse of Theorem˜\ref{diffcon} is false.

to get

The converse of Theorem is false.

References can be made to equations as in the following examples:
Changing $y$ to $-y$ in Equation˜(\ref{sumsq}) gives the following

(x + y)2 = x2 + 2xy + y2

Changing y to ’y in Equation (XII.1) gives the following

If you load the package amsmath, you can use the command \eqref instead of \ref
to make a reference to an equation. This automatically supplies the parantheses around
the equation number and provides an italic correction before the closing parenthesis, if
necessary. For example,
Equation \eqref{sumsq} gives the following ..........


Equation gives the following ..........

References can be made to individual equations in multiline displays of equations
produced by such environments as align or gather (de¬ned in the amsmath package).
The \label command can be used within such a structure for subnumbering as in the
example below:

(x + y)2 = x2 + 2xy + y2
(x ’ y)2 = x2 ’ 2xy + y2


In making a reference to a table or an equation, it is more to convenient (for the reader,
that is) to give the page number of the reference also. The command

typesets the number of the page where the command \label{key} was given. Thus for
see Table˜\ref{tabxy} in page˜\pageref{tabxy}

in this document produces

see Table in page 137

To avoid the tedium of repeated by typing
\ref{key} on page \pageref{key}

you can de¬ne the macro

\newcommand{\fullref}[1]{\ref{#1} on page˜\pageref{#1}}

and use \fullref for such references. But the trouble is that at times the referred object
and the reference to it fall on the same page (with TEX you never know this till the end)
so that you get a reference to the page number of the very page you are reading, which
looks funny. This can be avoided by using the package varioref. If you load this package
by including \usepackage{varioref} in your preamble, then you can use the command

to refer to an object you™ve marked with \label{key} elsewhere in the document. The ac-
tion of \vref varies according to the page(s) where the referred object and the references
are typeset by TEX in the ¬nal output.

(1) If the object and the reference are on the same page, \vref produces only a \ref sup-
pressing \pageref so that only the number pointing to the object is typeset, without
any reference to the page number.
(2) If the object and the reference are on different pages whose numbers differ by more
than one, \vref produces both \ref and \pageref.
(3) If the object and the reference fall on pages whose numbers differ by one (that is,
on successive pages), \vref produces \ref followed by the phrase “on the preceding
page” or “on the following page” depending on whether the object or the reference
occurs ¬rst. Moreover, in the next occurrence of \vref in a situation of the same type,
the phrases are changed to “on the next page” and the “page before” respectively.
This is the default behavior of \vref in the article documentclass. If the article class is
used with the twoside option or if the documentclass book is used, then the behavior in
Case (3) above is a bit different.

(1) If the object and the reference fall on the two sides of the same leaf, the behavior of
\vref is as in (3) above.
(2) If the object and the reference fall on pages forming a double spread (that is, a page
of even number followed by the next page), then \vref produces \ref followed by the
phrase “on the facing page”. Moreover, in the next occurence of \vref in a situation
of the same type, the phrases are changed to “on the preceding page” and “on the
next page” respectively.
The phrases used in the various cases considered above can be customized by rede¬ning
the commands used in generating them. For the article class without the twoside option,
reference to the previous page uses the command \reftextbefore and reference to the
next page uses \reftextafter. In the case of the article class with the twoside option or
the book class, the commands \reftextfaceafter and \reftextfacebefore are used in the
case of reference to a page in a double spread. The default de¬nitions of these commands
are given below. In all these, the two arguments of the command \reftextvario are
phrases alternatively used in the repeated use of the reference as mentioned above.
{on the \reftextvario{preceding page}{page before}}
{on the \reftextvario{following}{next} page}
{on the \reftextvario{facing}{preceding} page}
{on the \reftextvario{facing}{next}{page}}

You can customize the phrases generated in various situations by rede¬ning these

<< . .

. 20
( : 23)

. . >>