Typography with TeX and LaTeX

## KOMA-Script 3.09 released

April 7th, 2011 by Stefan Kottwitz

On April 5th the version 3.09 of KOMA-Script has been released by Markus Kohm. It brings some new features:

• scrartcl, scrbook and scrreprt offer new commands and options for placing captions above and below figures and tables. In contrast to \caption, the new commands also work outside floating environments.
• scrdate and scrlttr2 now support Austrian resp. naustrian.
• scrlttr2 provides options for placing the date.
• scrlfile introduces several commands for executing code after the class or a certain package has been loaded.
• tocbasic supports new options atbegin=code and atend=code allowing to run code at the beginning or at the end of the (floating) environment.

This text is available in German. Dieser Text ist auch in Deutsch verfügbar.

## Automatically counting table rows

September 10th, 2009 by Stefan Kottwitz

I’v just read the blog post Automatic Table Row Numbers in LaTeX by Alexander O’Connor, while reading it came to my mind how to use a feature of the array package to automatize such tasks. The array syntax >{command} allows to include commands in row formating parameters that will be executed with each cell. Here’s a short compilable demonstration example:

\documentclass[a4paper,10pt]{article} \usepackage{array} \newcounter{rowno} \setcounter{rowno}{0} \begin{document} \begin{tabular}{>{\stepcounter{rowno}\therowno.}cl} \multicolumn{1}{r}{No.} & text \\\hline & first \\ & second \\ & third \\ & fourth \end{tabular} \end{document}

Output:

Of course it would be only useful with longer tables. But this example is also intended to show how to execute commands for certain cells in general.

Category: Figures and Tables, LaTeX General | 1 Comment »

## Fancy tables with TikZ

August 26th, 2009 by Stefan Kottwitz

Today I wanted to create a table for a presentation and I remembered a suggestion made by Kjell Magne Fauske in comp.text.tex in August 2008, to use TikZ to create tables with rounded corners. I’ve investigated this idea further to achieve a colorful table layout in a shape that’s unusual for LaTeX. Here’s the result, displaying a ranking of Linux distributions produced by DistroWatch.com:

Click on the image to see it bigger, for a complete view open the pdf presentation.

The table has been put into a TikZ node, both at the top and at the bottom of the table I’ve used rectangles with rounded corners and some shading. A third rectangle is used to overlay parts of the other two rectangles.

The complete source code:


It’s just a draft, some lengths have been adjusted to fit in order to demonstrate using TikZ with tables in a quick way.

Category: pgf/TikZ, Figures and Tables, Graphics | 20 Comments »

## 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:

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:

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

Category: News, Figures and Tables | No Comments »

## Centering wide tables or figures

September 17th, 2008 by Stefan Kottwitz

When you want to include an image or a table that’s wider than the text width, you will notice that even when \centering or the center-environment is used this wide object will not be centered in relation to the surrounding text. It will be placed at the left margin but go into the right margin. Its frequently requested that wide figures or tables should overlap at both sides in equal measure.

It can easily achieved by putting the table or picture inside a box, giving the box the width of the text, by the \makebox command. Here is a compilable example, where I’m centering a table having 1.5 times the width of the text:

\documentclass[a4paper,10pt]{article} \usepackage[english]{babel} \usepackage{blindtext} \usepackage{tabularx} \begin{document}   \blindtext \bigskip   \noindent\makebox[\textwidth]{% \begin{tabularx}{1.5\textwidth}{XX} \blindtext & \blindtext \end{tabularx}}   \bigskip \blindtext   \end{document}

I’ve used \noindent to suppress the paragraph indentation, otherwise I would get an overfull \hbox. As you may notice there’s no \centering necessary because the width of the box equals \textwidth.

This topic was discussed in the LaTeX Community Forum, on CQF.info and on mrunix.de.
.

Category: Figures and Tables, Layout | 30 Comments »