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

Indian TEX Users Group: On-Line Tutorial On L TEX

The document is an online tutorial on tables in LaTeX provided by the Indian TEX Users Group. It discusses the longtable environment for tables that span multiple pages. Longtables function similarly to tabular environments but allow automatic page breaks. The tutorial provides an example longtable and explains features like optional arguments and commands for footnotes and page breaks within longtable rows. It is authored by professors and engineers affiliated with the Indian TEX Users Group.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views

Indian TEX Users Group: On-Line Tutorial On L TEX

The document is an online tutorial on tables in LaTeX provided by the Indian TEX Users Group. It discusses the longtable environment for tables that span multiple pages. Longtables function similarly to tabular environments but allow automatic page breaks. The tutorial provides an example longtable and explains features like optional arguments and commands for footnotes and page breaks within longtable rows. It is authored by professors and engineers affiliated with the Indian TEX Users Group.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Indian TEX Users Group

URL: http://www.river-valley.com/tug
Longtable
Another example

7
Exercise

Title Page

JJ II
On-line Tutorial on LAT EX J I
The Tutorial Team
Indian TEX Users Group, SJP Buildings, Cotton Hills
Page 1 of 10
Trivandrum 695014, INDIA
2000

Prof. (Dr.) K. S. S. Nambooripad, Director, Center for Mathematical Sciences, Trivandrum, (Editor); Dr. E. Krishnan,
Reader in Mathematics, University College, Trivandrum; Mohit Agarwal, Department of Aerospace Engineering, Go Back
Indian Institute of Science, Bangalore; T. Rishi, Focal Image (India) Pvt. Ltd., Trivandrum; L. A. Ajith, Focal Image
(India) Pvt. Ltd., Trivandrum; A. M. Shan, Focal Image (India) Pvt. Ltd., Trivandrum; C. V. Radhakrishnan, River
Valley Technologies, Software Technology Park, Trivandrum constitute the Tutorial team

This document is generated from LATEX sources compiled with pdfLATEX v. 14e in an Full Screen
INTEL Pentium III 700 MHz system running Linux kernel version 2.2.14-12. The
packages used are hyperref.sty and pdfscreen.sty

2000,
c Indian TEX Users Group. This document may be distributed under the terms of the Close
LATEX Project Public License, as described in lppl.txt in the base LATEX distribution, either
version 1.0 or, at your option, any later version
Quit
7 Tables Continued

Longtable
Another example
Exercise
7.1. Longtable
Title Page
The tabular and tabularx environments explained in the previous chapter provide a con-
venient way of making tables. These environments, however, fail if a table exceeds one page.
One easy trick that might do the job would be to break the tables manually but the longtable JJ II
package enables automatic page breaks by the TEX compiler.

J I
7.1.1. Constructing longtables

Page 2 of 10
The longtable environment shares most of the features with the tabular environment. We
begin with the following example that uses most of the features of the longtable environment.
Go Back
Table 7.1: A long table

This part appears at the top of the table


Full Screen
FIRST1 SECOND * THIRD
This table is only slightly different from the one in the * 1
This goes at the bottom. * 0.00 Close

1 You can also have a footnote in the table head by using \footnotemark and \footnotetext. Quit
Table 7.1: (continued)

This part appears at the top of every other page


First Second * Third
guide to the longtable package. * 2
Columns 1 & 2 here have fixed widths. * 3
Longtable
2.5in 1in *
Another example
longtable columns are specified in the * 5
Exercise
same way as in the tabular environment. * 6
|p{2.5in}||p{1in}@{*}c| in this case. * 7
Each line ends with a \\ command. * 8
Title Page
The \\ command has an optional * 9
argument, just as in the * 10
tabular environment. * 11
JJ II
See the effect of \\[10pt] below: * 12

The \tabularnewline command is an al- * 13


J I
ternative to \\ for use in the scope of
\raggedleft and similar commands that re-
define \\.
Page 3 of 10
Notice \tabularnewline[10pt] below: * 14

Some lines can be really long: This column This is also a “p”* This is not.
Go Back
is a “p” column so that this row of the table column.
can take up several lines. But TEX will never
break a page within such a row.
Full Screen
\\* has the same effect as \\ but it * 16
disallows a page break after the row. * 17
command in * 18 Close
setlongtables is an obsolete
This goes at the bottom. * 0.00
Quit
Table 7.1: (continued)

This part appears at the top of every other page


First Second * Third
v4.09 of longtable and does nothing. * 19
Center aligned text  * 20 Longtable
These lines will appear * 1.00 Another example
in place of the usual foot * 2.00
Exercise
at the end of the table. * 3.00

Title Page
7.1.2. Optional arguments

The optional arguments to \begin{longtable} are: JJ II

c The table is set center aligned. J I


l The table is set flush left.
r The table is set flush right.
Page 4 of 10
If no arguments are specified, the position of the table is set according to the values of
\LTleft and \LTright.
Go Back

7.1.3. Commands and parameters


Full Screen
This section contains a brief description of the commands and other parameters that may be
used in the longtable environment.
Close

LTchunksize This corresponds to the number of rows that TEX has to keep in memory at
one time. By default this value is set to 20, but it can be set by the user; for
Quit
instance, by \setcounter{LTchunksize}{10} or \LTchunksize=10 to
a value of 10. Changing the default does not affect page breaking. However,
TEX will run faster with a large LTchunksize, and, on the other hand, will
require more memory. The minimum value of LTchunksize can be set equal
to 1; however, it must be at least as large as the number of rows in each of the
head or foot sections (if the table head and foot need to be set).
Longtable
\LTleft The defaults in the longtable package are such that the tables are set flush
Another example
left, but are indented by the usual paragraph indentation. \LTleft con-
trols the amount of glue to the left of the table. By default this is set to Exercise

\parindent, but can be changed according to the requirements; for instance,


by \setlength \LTleft{0pt}.
Title Page
\LTright This parameter determines the glue to the right of the table. The default for
this is \fill.
\LTpre Denotes the glue before the table. The default is set to \bigskipamount. JJ II
\LTpost Denotes the glue after the table. The default is again \bigskipamount.
\LTcapwidth This controls the width of the parbox containing the caption. The default
J I
width is set to 4in, but changed be changed, for instance, to a value of 2in
by using \setlength\LTcapwidth{2in}.
\endhead At the start of the table, one may specify the lines that are to appear at the top Page 5 of 10
of every page. This command is used in place of the last \\.
\endfirsthead If the head on the first page needs to be different than on the others, then one
may specify the lines to appear in a normal way followed by \endfirsthead Go Back
(in place of the last \\).
\endfoot Specifies rows to appear at the bottom of every page.
Full Screen
\endfirstfoot Specifies rows to appear at the bottom of the last page. The commands \endfirsthead
and \endlastfoot are useful when one wants to specify something that
should logically appear in the table at the end of the firsthead, of at the Close
beginning of the lastfoot.
\\ This is similar to the tabular environment and specifies the end of the row.
Quit
\\[hdimi] This is also similar as in the tabular environment and marks the end of the
row, and then adds vertical space (as shown in Table (7.1)).
\\* It is the same as \\, but disallows a page break after the row.
\tabularnewlineIt is an alternative to \\ for use in the scope of \raggedright and similar
commands that redefine \\. It can also be used with an optional argument,
\tabularnewline[hdimi], so as to specify the end of the row, and then add
Longtable
a vertical space.
Another example
\kill If a line is \killed, by using \kill rather than \\ at the end of the line, it is Exercise
used in calculating column widths, but removed from the final table.
\pagebreak Forces a page break.
\pagebreak[hvali] Title Page
A ‘hint’ between 0 and 4 of the desirability of a page break. A high value
indicates more desirability.
\nopagebreak Prohibits a page break. JJ II
\nopagebreak[hvali]
A ‘hint’ between 0 and 4 of the undesirability of a page break. J I
\newpage Forces a page break.
\caption{hcaptioni}
Caption ‘Table ?: hcaptioni’, and a ‘hcaptioni’ entry in the list of tables. Page 6 of 10

\caption[hloti]{hcaptioni}
Caption ‘Table ?: hcaptioni’, and a ‘hloti’ entry in the list of tables.
Go Back
\caption[]{hcaptioni}
Caption ‘Table ?: hcaptioni’, but no entry in the list of tables.
\caption*{hcaptioni} Full Screen
Caption ‘hcaptioni’, but no entry in the list of tables.
\footnote Used for having footnotes, but it cannot be used in the table head and foot.
Close
\footnotemark Footnotemark, can be used only in the table head and foot.
\footnotetext Footnote text: for use in the table body after a \footnotemark has been set
(should appear on the page on which the footnote is desired). Quit
\setlongtables setlongtables is an obsolete command in v4.09 of longtable and does
nothing.
\multicolumn The \multicolumn command works in the same way as in the tabular
environment. Please refer to Chapter 6 for details about this.

Longtable
Another example
7.2. Another example
Exercise

We will show another simple example using the longtable environment.


Title Page
Table 7.2: A simple example

Another long table example JJ II


First two columns Third column
p-type
J I
p column another one 1
Lots of line like this 2
Lots of line like this 2 Page 7 of 10
Lots of line like this 2
Lots of line like this 2
Lots of line like this 2 Go Back
Lots of line like this 2
Lots of line like this 2
Lots of line like this 2 Full Screen
Lots of line like this 2
Lots of line like this 2
Lots of line like this 2 Close
Lots of line like this 2
Continued . . .
Quit
Table 7.2: (continued)

Another long table example (continued)


First two columns Third column
Lots of line like this 2
Lots of line like this 2
Longtable
Lots of line like this 2
Another example
Lots of line like this 2
Exercise
Lots of line like this 2
Lots of line like this 2
Lots of line like this 2
Title Page
Lots of line like this 2
Lots of line like this 2
The End JJ II

J I

Page 8 of 10

Go Back

Full Screen

Close

Quit
7.2.1. Verbatim highlights from Table (7.2):

\begin{longtable}{|p{0.9in}|p{2in}|c|}
xxxxx & xxxxx & xxxxxxxxxxxxx \kill
\caption{A simple example\label{simple}}\\ \hline\hline
\multicolumn{3}{|c|}{\bf Another long table example}\\ \hline\hline Longtable

\multicolumn{2}{|c|}{First two columns} & {Third column}\\ \hline Another example

\multicolumn{2}{|c|}{p-type} & \\ \hline\hline Exercise


\endfirsthead
\caption[]{(continued)}\\ \hline\hline
\multicolumn{3}{|c|}{\bf Another long table example (continued)}\\ Title Page
\hline\hline
\multicolumn{2}{|c|}{First two columns} & {Third column}\\
\hline JJ II
\endhead
\hline
\multicolumn{3}{|c|}{\bf Continued $\ldots$}\\ J I
\hline
\endfoot
Page 9 of 10
\hline
\multicolumn{3}{|c|}{\bf The End}\\
\hline
Go Back
\endlastfoot
p column & another one & 1 \\
\hline
Full Screen
Lots of line like & this & 2 \\
...
\end{longtable} Close

Quit
7.3. Exercise

Try making Table (7.1); it seems to be quite strange, but it contains most of the features one
would need in order to get thoroughly acquainted with the longtable environment. It should
be quite easy if one actually reads the table itself. Look at the spaces carefully.
Longtable
Another example
Exercise

Title Page

JJ II

J I

Page 10 of 10

Go Back

Full Screen

Close

Quit

You might also like