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.
For further information and download visit
This text is available in German. Dieser Text ist auch in Deutsch verfügbar.
Category: Koma-Script, News, Figures and Tables, LaTeX General |
2 Comments »
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 »
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:
\documentclass{beamer}
\usetheme{default}
\usepackage{amsmath}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{colortbl}
\usepackage{tikz}
\usetikzlibrary{calc}
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
\setbeamertemplate{background canvas}[vertical shading]%
[top=blue!1,bottom=blue!30]
\setbeamertemplate{navigation symbols}{}
\newcommand*\up{\textcolor{green}{%
\ensuremath{\blacktriangle}}}
\newcommand*\down{\textcolor{red}{%
\ensuremath{\blacktriangledown}}}
\newcommand*\const{\textcolor{darkgray}%
{\textbf{--}}}
\begin{document}
\begin{frame}[bg=lightgray]
\textbf{\Large Linux distribution ranking,
26th August 2009}
\begin{center}
\begin{tikzpicture}
\node (tbl) {
\begin{tabularx}{.6\textwidth}{cXrcc}
\arrayrulecolor{purple}
\textbf{Rank} & \textbf{Distribution} &
\textbf{Hits} & \\
1 & Ubuntu\rule{0pt}{2.5ex} & 2114 & \down \\
\midrule
2 & Fedora & 1451 & \up \\
\midrule
3 & Mint & 1297 & \const \\
\midrule
4 & OpenSUSE & 1228 & \up \\
\midrule
5 & Debian & 910 & \down \\
\midrule
6 & Mandriva & 907 & \up \\
\midrule
7 & PCLinuxOS & 764 & \up \\
\midrule
8 & Puppy & 738 & \up \\
\midrule
9 & Sabayon & 671 & \up \\
\midrule
10 & Arch & 625 & \down \\[0.5ex]
\end{tabularx}};
\begin{pgfonlayer}{background}
\draw[rounded corners,top color=red,bottom color=black,
draw=white] ($(tbl.north west)+(0.14,0)$)
rectangle ($(tbl.north east)-(0.13,0.9)$);
\draw[rounded corners,top color=white,bottom color=black,
middle color=red,draw=blue!20] ($(tbl.south west)
+(0.12,0.5)$) rectangle ($(tbl.south east)-(0.12,0)$);
\draw[top color=blue!1,bottom color=blue!20,draw=white]
($(tbl.north east)-(0.13,0.6)$)
rectangle ($(tbl.south west)+(0.13,0.2)$);
\end{pgfonlayer}
\end{tikzpicture}
\end{center}
\small
Data by DistroWatch.com, spanning over the last 6 months,
hits per day.
\end{frame}
\end{document}
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 »
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 »
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 »