TeXblog

 Typography with TeX and LaTeX

New package tabularew: centering multicolumn headings

Juni 3rd, 2009 by Stefan Kottwitz

In standard tabular environments multicolumn headings will be aligned to the left when they are wider then the text below, even if they contain a “c” as format parameter. Here’s a very small demonstration example:

\documentclass[a4paper,10pt]{article}
\usepackage{eurosym}
\begin{document}
\begin{tabular}{r@{.}l}
\multicolumn{2}{c}{Price in \euro} \\
  \hline
  79 & 50 \\
   9 & 85 \\
  10 & 00
\end{tabular}
\end{document}

Output:

tabular example

The tabularew package by Diego Saba solves this problem by introducing new commands for modifying the horizontal alignment. The example above can be changed to:

\documentclass[a4paper,10pt]{article}
\usepackage{eurosym}
\usepackage{tabularew}
\begin{document}
\begin{tabularew}{>{\spew{.5}{+1}}r@{.}l}
\multicolumn{2}{c}{Price in \euro} \\
  \hline
  79 & 50 \\
   9 & 85 \\
  10 & 00
\end{tabularew}
\end{document}

Output:

tabular example

The command \spew and the tabularew environment are explained in the package documentation.

This entry was posted on Mittwoch, Juni 3rd, 2009 at 22:20 and is filed under News, Figures and Tables. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply