[pstricks] Table with colored boxes and rounded corners

Herbert Voss herbert49 at googlemail.com
Mon Aug 18 13:56:35 CEST 2008


Kjell Magne Fauske schrieb:
> On Aug 18, 11:25 am, Herbert Voss <herber... at googlemail.com> wrote:
> 
>> without a pagebreak it is pretty easy ...
>> needs latex->dvips->ps2pdf
>>
>> \documentclass{article}
>>
>> \usepackage[table]{pstricks}
>> \usepackage{pst-node}
>> \SpecialCoor
>>
>> \begin{document}
>>
>> \begin{tabular}{p{3cm}*{6}{c}r}
>> \rowcolor{cyan!50}
>> Team & P & W & \rnode[tr]{ur1}{D} & L & F & A & \rnode[tr]{ur2}{Pts}
>> \\\hline
>> Manchester United & 6 & 4 & 0 & 2 & 10 & 5 & 12  \\
>> Celtic            & 6 & 3 & 0 & 3 & 8  & 9 & 9   \\
>> Benfica           & 6 & 2 & 1 & 3 & 7  & 8 & 7   \\
>> FC Copenhagen & \rnode[bl]{ll1}{6} & 2 & 1 & 2 & 5 & \rnode[bl]{ll2}{8}
>> & 7 \\
>> \end{tabular}
>> \psframe*[linecolor=red,opacity=.2,framearc=0.2]%
>>    ([angle=210,nodesep=10pt]ll1)([angle=60,nodesep=10pt]ur1)
>> \psframe*[linecolor=blue,opacity=.2,framearc=0.2]%
>>    ([angle=210,nodesep=10pt]ll2)([angle=60,nodesep=10pt]ur2)
>>
>> \end{document}
>>
>> Herbert
> 
> An elegant solution Herbert! For the record, here is a similar TikZ
> version:
> 
> Note:
> - PGF 2.0 or later is required.
> - Two compilations may be necessary to get correct positioning.
> - The rectangles are placed behind the table.

with a box also very easy

\documentclass{article}
\usepackage[table]{pstricks}
\usepackage{pst-node}
\newsavebox\PstBox
\SpecialCoor

\begin{document}
\savebox\PstBox{%
\begin{tabular}{p{3cm}*{6}{c}r}
\rowcolor{cyan!50}
Team & P & W & \rnode[tr]{ur1}{D} & L & F & A & \rnode[tr]{ur2}{Pts} 
\\\hline
Manchester United & 6 & 4 & 0 & 2 & 10 & 5 & 12  \\
Celtic            & 6 & 3 & 0 & 3 & 8  & 9 & 9   \\
Benfica           & 6 & 2 & 1 & 3 & 7  & 8 & 7   \\
FC Copenhagen & \rnode[bl]{ll1}{6} & 2 & 1 & 2 & 5 & \rnode[bl]{ll2}{8} 
& 7 \\
\end{tabular}}
\makebox[0pt][l]{\usebox\PstBox}%
\psframe*[linecolor=red!50,opacity=.2,framearc=0.2]%
   ([angle=210,nodesep=10pt]ll1)([angle=60,nodesep=10pt]ur1)
\psframe*[linecolor=blue!50,opacity=.2,framearc=0.2]%
   ([angle=210,nodesep=10pt]ll2)([angle=60,nodesep=10pt]ur2)%
\makebox[0pt][l]{\usebox\PstBox}

\end{document}

Herbert




More information about the PSTricks mailing list