大家使用TeX的表格样式也基本比较朴素的表格样式,在texbolg看到作者用tikz设计的表格样式非常不错,代码预定义了表格的行列所需的样式,总体样图非常不错,截图如下: fcytable 代码分别是:

\documentclass[svgnames]{beamer}
\setbeamertemplate{background canvas}[vertical shading]%
  [top=blue!1,bottom=blue!30]
\setbeamertemplate{navigation symbols}{}
\usepackage{tikz}
\usetikzlibrary{matrix}
\newcommand*\up{\textcolor{YellowGreen}{$\blacktriangle$}}
\newcommand*\down{\textcolor{Red}{$\blacktriangledown$}}
\newcommand*\const{\textcolor{darkgray}{\textbf{--}}}
\newcommand*\head[1]{\textbf{#1}}
\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}[fragile,bg=lightgray]
\begin{center}
\begin{matrixtable}{1.2cm}{2.4cm}{1.2cm}{0.6cm}{
  \head{Rank}   & \head{Distribution} & \head{Hits} & \\
  1 & Ubuntu    & 2114 & \down  \\
  2 & Fedora    & 1451 & \up    \\
  3 & Mint      & 1297 & \const \\
  4 & OpenSUSE  & 1228 & \up    \\
  5 & Debian    & 910  & \down  \\
  6 & Mandriva  & 907  & \up    \\
  7 & PCLinuxOS & 764  & \up    \\
  8 & Puppy     & 738  & \up    \\
  9 & Sabayon   & 671  & \up    \\
 10 & Arch      & 625  & \down  \\
}
\end{matrixtable}
\end{center}
\end{frame}
\end{document}
\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}
tikz的代码,看起来总是比较费劲,那么用tcolorbox如何实现呢?
\documentclass{article}
\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[usenames,dvipsnames,table]{xcolor}
\usepackage[most]{tcolorbox}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{environ}
\usepackage{times}

\renewcommand\rmdefault{phv} % Arial
\renewcommand\sfdefault{phv} % Arial

\colorlet{TablaBordeSuperior}{BurntOrange}
\colorlet{TablaBordeInferior}{Bittersweet}
\colorlet{TablaCentroSuperior}{blue!1}
\colorlet{TablaCentroInferior}{blue!20}
\colorlet{FuenteCabeceraTabla}{white}

\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}

\tcbset{rtab/.style={
freelance,
frame code={
  \path[top color=BurntOrange,bottom color=Bittersweet] 
    ([yshift=-#1*(\baselineskip+2pt)]interior.north west) --
    ([yshift=-#1*(\baselineskip+2pt)]interior.north east) {[rounded corners]--
    ([yshift=3pt]interior.north east) --
    ([yshift=3pt]interior.north west)} -- cycle;
  \path[top color=TablaCentroSuperior,bottom color=TablaCentroInferior] 
    ([yshift=-#1*(\baselineskip+2pt)]interior.north west) --
    ([yshift=-#1*(\baselineskip+2pt)]interior.north east) --
    (interior.south east) --
    (interior.south west) -- cycle;
  \path[top color=TablaBordeInferior,bottom color=TablaBordeSuperior] 
    (interior.south west) --
    (interior.south east) {[rounded corners]--
    ([yshift=-5pt]interior.south east) --
    ([yshift=-5pt]interior.south west)} -- cycle;
  },
interior code={},
 }
}

\newcommand\fuentecabecera[1]{\textcolor{FuenteCabeceraTabla}{\textbf{#1}}}

\NewEnviron{RCtable}[4][htbp]
  {%
    \begin{table}[#1]
    \begin{tcolorbox}[#2]\BODY\end{tcolorbox}%
    \caption{#3}
    \label{tab:#4}
    \end{table}
  }

\begin{document}

Como vemos en los cuadros~\ref{tab:pruebaa} y ~\ref{tab:pruebab}...
\begin{RCtable}{
  rtab=1,
  tabularx*={\arrayrulecolor{purple}}%
    {>{\bfseries}M{0.10\linewidth} M{0.33\linewidth}M{0.46\linewidth}}
}{Primer cuadro de prueba}{pruebaa}
\fuentecabecera{Hito} & \fuentecabecera{Fecha} & \fuentecabecera{Descripción} \\
\\[-1.7ex]
H1 &  Mes 0 & Comienzo del proyecto \\ 
\midrule
H2 & 2 meses y 3 semanas & Fin del estudio del arte \\ 
\midrule
H3 & 6 meses y 1 semana & Finalización de la plataforma de virtualización \\ 
\midrule
H4 & 9 meses & Finalización de lo concerniente a DTN \\ 
\midrule
H5 & 10 meses y 1 semana & Finalización de lo concerniente a CDN \\ 
\midrule
H6 & 12 meses & Fin del Proyecto Fin de Carrera (PFC) \\ 
\end{RCtable}


\begin{RCtable}{
  rtab=2,
  tabularx*={\arrayrulecolor{purple}}%
    {>{\bfseries}M{0.10\linewidth} M{0.33\linewidth}M{0.46\linewidth}}
}{Segundo cuadro de prueba}{pruebab}
\fuentecabecera{Lin1} & \fuentecabecera{Lin1} & \fuentecabecera{Lin1} \\
\fuentecabecera{Lin2} & \fuentecabecera{Lin2} & \fuentecabecera{Lin2} \\
\\[-1.7ex]
H1 &  Mes 0 & Comienzo del proyecto \\ 
\midrule
H2 & 2 meses y 3 semanas & Fin del estudio del arte \\ 
\midrule
H3 & 6 meses y 1 semana & Finalización de la plataforma de virtualización \\ 
\midrule
H6 & 12 meses & Fin del Proyecto Fin de Carrera (PFC) \\ 
\end{RCtable}

\end{document}
效果图: fcytable3 选自:http://tex.stackexchange.com/questions/128695/table-with-rounded-corners

点赞(2)

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部