# Table with rounded corners?

This table I can create with this code:

\begin{tabular}{|l|l|}
\hline
\multicolumn{2}{|c|}{Team sheet} \\
\hline
GK & Paul Robinson \\
DC & Michael Duberry \\
DC & Dominic Matteo \\
RB & Didier Domi \\
MC & David Batty \\
MC & Eirik Bakke \\
MC & Jody Morris \\
FW & Jamie McMaster \\
ST & Alan Smith \\
ST & Mark Viduka \\
\hline
\end{tabular}


But is there a possibility to use rounded corners? I'm talking about the 4 main corners and not the corners of each cell.

-

You can use a TikZ node with inner sep=0pt that holds the table, and then draw a rectangle around it.

Update: You can enclose this TikZ/tabular construct in a table environment to add a table caption and label to it.

\documentclass{article}
\usepackage{tikz}
\usepackage[bf]{caption}

\begin{document}

\begin{table}
\caption{A table with rounded corners}
\centering
\begin{tikzpicture}
\node (table) [inner sep=0pt] {
\begin{tabular}{l|l}
\multicolumn{2}{c}{Team sheet} \\
\hline
GK & Paul Robinson \\
DC & Michael Duberry \\
DC & Dominic Matteo \\
RB & Didier Domi \\
MC & David Batty \\
MC & Eirik Bakke \\
MC & Jody Morris \\
FW & Jamie McMaster \\
ST & Alan Smith \\
ST & Mark Viduka \\
\end{tabular}
};
\draw [rounded corners=.5em] (table.north west) rectangle (table.south east);
\end{tikzpicture}
\label{tab1}
\end{table}

Table~\ref{tab1} can be referenced like any other.
\end{document}


-
Oh wow, what a staccato of TikZ solutions here. Interesting to see the variation in the details of the approaches, though. –  Jake Feb 4 '11 at 10:12
But yours is the simplest. So +1 for that. –  Thorsten Donig Feb 4 '11 at 10:18
@Jake Thanks that works, but were can i put the label and caption? –  RoflcoptrException Feb 7 '11 at 21:41
@Roflcoptr: You just enclose the whole stuff in a table environment, like you would with a normal table. I've edited my answer accordingly. –  Jake Feb 7 '11 at 22:00
Jake thanks a lot! –  RoflcoptrException Feb 7 '11 at 22:02

You could do this by putting the table into a tikZ node and framing that node with a rectangle that has rounded corners. See code below for some inspiration.

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}
\node (tbl) {%
\begin{tabular}{l|l}
\multicolumn{2}{c}{Team sheet} \\ \hline
GK & Paul Robinson \\
DC & Michael Duberry \\
DC & Dominic Matteo \\
RB & Didier Domi \\
MC & David Batty \\
MC & Eirik Bakke \\
MC & Jody Morris \\
FW & Jamie McMaster \\
ST & Alan Smith \\
ST & Mark Viduka \\
\end{tabular}
};
\draw[rounded corners] ($(tbl.north west)+(0.14,-0.14)$) rectangle ($(tbl.south east)+(-0.14,0.14)$);
\end{tikzpicture}
\end{document}


-

you can do it with tikz fit library

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fit}
\begin{document}

\begin{tikzpicture}
\node[inner sep=0pt] (tab){%
\begin{tabular}{l|l}
\multicolumn{2}{c}{Team sheet} \\
\hline
GK & Paul Robinson \\
DC & Michael Duberry \\
DC & Dominic Matteo \\
RB & Didier Domi \\
MC & David Batty \\
MC & Eirik Bakke \\
MC & Jody Morris \\
FW & Jamie McMaster \\
ST & Alan Smith \\
ST & Mark Viduka \\
\end{tabular}
};
\node[draw=red, inner sep=0pt, rounded corners=3pt, line width=2pt,
fit=(tab.north west) (tab.north east) (tab.south east) (tab.south west)] {};
\end{tikzpicture}

\end{document}


-
about 30sec too late :) and a slightly different approach –  Martin H Feb 4 '11 at 10:06
Hmm. I always forget this inner sep option. –  Thorsten Donig Feb 4 '11 at 10:19
AFAIK you can just say fit=(tab) here. TikZ then automatically takes the (tab.north west) (tab.north east) (tab.south east) (tab.south west) coordinates. –  Martin Scharrer Feb 4 '11 at 10:23