Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Xtab breaks a long table spanning multiple pages too soon -- see my screenshot:

Xtab breaking table too soon

The output seems rather unsightly to me. Can I make it take more of the available space?

Alternatively, is there a package for long tables which produces an output in one pass, and uses available paper space more efficently?

A little background

I need a package to do a one-pass compilation of a table which could span multiple pages, for automated report generation. supertabular should be capable of producing a table spanning multiple pages in one pass and, as I understand it, xtab is an improvement over it. longtable package requires multiple passes (the manual mentions 4 passes) to get it right, which might make report generation too slow.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

xtabular overestimates the height of each row by 1pt; when the rows contain tall p cells, this is almost negligible; however, when the table has "small" rows, this becomes evident.

A supertabular based "solution" is the following strictsupertabular environment

\makeatletter 
\def\mod@estimate@lineht{% 
  \ST@lineht=\arraystretch \baslineskp 
  %\global\advance\ST@lineht by 1\p@ 
  \ST@stretchht\ST@lineht\advance\ST@stretchht-\baslineskp 
  \ifdim\ST@stretchht<\z@\ST@stretchht\z@\fi 
  \ST@trace\tw@{Average line height: \the\ST@lineht}% 
  \ST@trace\tw@{Stretched line height: \the\ST@stretchht}% 
} 
\newenvironment{strictsupertabular} 
  {\let\estimate@lineht\mod@estimate@lineht\supertabular} 
  {\endsupertabular} 
\makeatother

that needs lines that are never taller than a normal line of text.

Another defect shared by supertabular and xtab is that the column width is not the same across pages (this doesn't happen with longtable).

share|improve this answer

Another solution would be to use the \xentrystretch{<decimal-fraction>} command and set it to a negative number.

From the xtab manual:

The command \xentrystretch{<decimal-fraction>} can be used before a table to modify the amount of vertical space apparently consumed by each entry in the subsequent table(s). The default is \xentrystretch{0.1} which specifies a 10% overestimate in the vertical space.

Here is an example:

\documentclass{article}

% The geomery package is used to set the paper size and the margins
\usepackage[a4paper,hmargin={2cm,2cm},vmargin={3cm,3cm}]{geometry}

% The xtab package enables long tables to be automatically broken at page
% boundaries.
\usepackage{xtab}
% prevent tables from being broken too early
\xentrystretch{-0.1}

% increase spacing between table's rows
\renewcommand{\arraystretch}{1.2}

\begin{document}

\section*{List of species}

% specify table's header
\tablehead{%
  \hline%
   \textbf{\#} & \textbf{Latin name} & \textbf{Comment} \\%
}

% specify table's tail
\tabletail{%
  % NOTE: it is necessary to manually end a table with a \hline
  \hline%
}

\begin{xtabular}{|p{0.02\textwidth}|p{0.5\textwidth}|p{0.4\textwidth}|}
  \hline
  1 & \emph{Anemone ranunculoides} L. & \\
  \hline
  2 & \emph{Stellaria nemorum} L. (s. str.)  [\emph{S. nemorum} L. subsp. \emph{nemorum}] & \\
  \hline
  3 & \emph{Stellaria media} (L.) Vill. (s. str.) & \\
  \hline
  4 & \emph{Silene latifolia} Poiret & \\
  \hline
  5 & \emph{Saponaria officinalis} L. & \\
  \hline
  6 & \emph{Polygonum lepathifolium} L. & \\
  \hline
  7 & \emph{Filipendula vulgaris} Moench  [\emph{F. Hexapetala} Gilib.] & \\
  \hline
  8 & \emph{Agrimonia eupatoria} L. & \\
  \hline
  9 & \emph{Geum urbanum} L. & \\
  \hline
  10 & \emph{Potentilla reptans} L. & \\
  \hline
  11 & \emph{Potentilla sterilis} (L.) Garcke & \\
  \hline
  12 & \emph{Rubus caesius} L. & \\
  \hline
  13 & \emph{Ononis spinosa} L. & \\
  \hline
  14 & \emph{Melilotus officinalis} (L.) Lam. & \\
  \hline
  15 & \emph{Medicago sativa} L. & \\
  \hline
  16 & \emph{Trifolium campestre} Schreb. & \\
  \hline
  17 & \emph{Trifolium dubium} Sibth. [\emph{T. Filiforme} L. subsp. \emph{dubium} (Sibth.) Gams] & \\
  \hline
  18 & \emph{Lotus corniculatus} L. & \\
  \hline
  19 & \emph{Anthyllis vulneraria} L. & \\
  \hline
  20 & \emph{Vicia cracca} L. & \\
  \hline
  21 & \emph{Vicia sepium} L. & \\
  \hline
  22 & \emph{Lathyrus sylvestris} L. & \\
  \hline
  23 & \emph{Oenothera biennis} L. & \\
  \hline
  24 & \emph{Oxalis fontana} Bunge & \\
  \hline
  25 & \emph{Impatiens parviflora} DC. & \\
  \hline
  26 & \emph{Impatiens glandulifera} Royle  [\emph{I. roylei} Walp.] & \\
  \hline
  27 & \emph{Euphorbia peplus} L. & \\
  \hline
  28 & \emph{Astrantia major} L. & \\
  \hline
  29 & \emph{Angelica sylvestris} L. & \\
  \hline
  30 & \emph{Pastinaca sativa} L. & \\
  \hline
  31 & \emph{Heracleum sphondylium} L. subsp. \emph{sphondylium}   [\emph{H. sphondylium} L., \emph{H. sphondylium} L. subsp. \emph{Australe} (Hartm.) Neuman] & \\
  \hline
  32 & \emph{Daucus carota} L. & \\
  \hline
  33 & \emph{Hypericum maculatum} L. & \\
  \hline
  34 & \emph{Hypericum perforatum} L. & \\
  \hline
  35 & \emph{Viola tricolor} L. & \\
  \hline
  36 & \emph{Arabidopsis thaliana} (L.) Heynh. & \\
  \hline
  37 & \emph{Barbarea vulgaris} L. & \\
  \hline
  38 & \emph{Sinapis arvensis} L. & \\
  \hline
  39 & \emph{Anagallis arvensis} L. & \\
  \hline
  40 & \emph{Lysimachia vulgaris} L. & \\
  \hline
  41 & \emph{Valeriana officinalis} L.  [\emph{V. o.} L. var. \emph{latifolia} Vahl] & \\
  \hline
  42 & \emph{Knautia longifolia} (Waldst. \& Kit.) Koch & \\
  \hline
  43 & \emph{Knautia arvensis} (L.) Coulter & \\
  \hline
  44 & \emph{Galium mollugo} L. & \\
  \hline
  45 & \emph{Solanum nigrum} L. & \\
  \hline
  46 & \emph{Convolvulus arvensis} L. & \\
  \hline
  47 & \emph{Echium vulgare} L. & \\
  \hline
  48 & \emph{Symphytum officinale} L. & \\
  \hline
  49 & \emph{Verbascum nigrum} L. & \\
  \hline
  50 & \emph{Cymbalaria muralis} Gaertner, Meyer \& Scherbius [\emph{L. Cymbalaria} (L.) Miller] & \\
  \hline
  51 & \emph{Melamphyrum pratense} L.  [\emph{M. Vulgare} Hill] & \\
  \hline
  52 & \emph{Verbena officinalis} L. & \\
  \hline
  53 & \emph{Ajuga genevensis} L. & \\
  \hline
  54 & \emph{Galeopsis speciosa} Mill. & \\
  \hline
  55 & \emph{Salvia pratensis} L. & \\
  \hline
  56 & \emph{Solidago gigantea} Aiton  [\emph{S. gigantea} Aiton subsp. \emph{serotina} (O. Kuntze) Mc Neill] & \\
  \hline
  57 & \emph{Aster amellus} L. & \\
  \hline
  58 & \emph{Conyza canedensis} (L.) Cronq.  [\emph{Erigeron canedensis} (L.) Cronq.] & \\
  \hline
  59 & \emph{Achillea millefolium} L. & \\
  \hline
  60 & \emph{Chamomilla recutita} (L.) Rauschert  [\emph{Matricaria recurita} L., \emph{M. Chamomilla} L. p.p.] & \\
  \hline
  61 & \emph{Matricaria perforata} Mrat [\emph{M. inodora} L., nom. Illeg.,\emph{Tripleurospermum inodorum} Schultz Bip.] & \\
  \hline
  62 & \emph{Tanacetum vulgare} L.  [\emph{Chrysethemum vulgare} (L.) Bernh., non (Lam.) Gaterau] & \\
  \hline
  63 & \emph{Senecio vulgaris} L. & \\
  \hline
  64 & \emph{Cirsium vulgare} (Savi) Tenore  [\emph{C. Lanceolatum} (L.) Scop., non Hill] & \\
  \hline
  65 & \emph{Cirsium arvense} (L.) Scop. & \\
  \hline
  66 & \emph{Centaurea jacea} L. & \\
  \hline
  67 & \emph{Hypochoeris radicata} L. & \\
  \hline
  68 & \emph{Picris hieracioides} L. & \\
  \hline
  69 & \emph{Sonchus arvensis} L. & \\
  \hline
  70 & \emph{Lolium perenne} L. & \\
  \hline
  71 & \emph{Cynosurus cristatus} L. & \\
  \hline
  72 & \emph{Poa trivialis} L. & \\
  \hline
  73 & \emph{Phragmites australis} (Cav.) Trin. ex Steud.  [\emph{P. Communis} Trin.] & \\
  \hline
  74 & \emph{Setaria pumila} (Poir.) Roem. \& Schult.  [\emph{S. lutescens} (Weig.) F. T. Hubb., \emph{S. Glauca} auct., non (L.) PB.] & \\
  \hline
  75 & \emph{Echinochloa crus-galli} (L.) PB.  [\emph{Panicum} c.-g. L.] & \\
  \hline
\end{xtabular}

\end{document}

The output is:

  • With the line \xentrystretch{-0.1} commented out: enter image description here

  • With the line \xentrystretch{-0.1} as in the above example: enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.