Tikz定制精美的表格


作为beamer的御用语言pgf/Tikz,可以制作让你惊异的作品,我们来看看下面的表格式如何制作的。

LaTeX技巧433:Tikz定制精美的表格

演示代码:
\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{--}}}
\newenvironment{matrixtable}[4]{%
   \begin{tikzpicture}[matrix of nodes/.style={
       execute at begin cell=\node\bgroup\strut,
       execute at end cell=\egroup;}]
   \matrix (m) [matrix of nodes,top color=blue!20,
       bottom color=blue!80,draw=white,
       nodes={draw,top color=blue!10,bottom color=blue!35,
       draw,inner sep=2pt,minimum height=3.1ex},
       column sep=1ex,row sep=0.6ex,inner sep=2ex,
       rounded corners,column 1/.style={minimum width=#1},
       column 2/.style={minimum width=#2},
       column 3/.style={minimum width=#3},
       column 4/.style={minimum width=#4}]}%
{;\end{tikzpicture}}

\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}

代码选自:http://texblog.net/latex-archive/graphics/tikz-table/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值