我们所用的宏包为colortbl,这个宏包可以设置表格中数据、文本、行、列、单元格前景和背景以及边框的颜色,从而得到彩色表格。同时需要 array 和 color 两个宏包的支持。 宏包提供了一组着色命令,经常用到是列着色命令,其格式为:

\columncolor[色系]{色名}[左伸出][右伸出]。

常用色系有三原色 rgb 灰度 gray  和四色cmyk三种;被预定义的色名有68个,详见 color 宏包介绍中所附的色标;左右伸出的长度单位可用 pt。

colortbl 的主要命令

命令

作用

\columncolor

让整个字段着色

\rowcolor

整个横列着色

\arrayrulecolor{颜色}

指定线条的颜色

\doublerulesepcolor{颜色}

指定双线内间隔的颜色

在这里,\columncolor 和 \rowcolor 的参数是一样的,他们的共同语法是:

\columncolor[颜色模型]{颜色}[左伸出长度][右伸出长度]

我们现在就来看个实例,这里头有些例子,包括:灰阶横条、部份字段着色、整个表格在着色背景及单一个表格内方框着色:

示例代码如下:

\documentclass[16px]{article}

\usepackage{textcomp,booktabs}

\usepackage[usenames,dvipsnames]{color}

\usepackage{colortbl}

\definecolor{mygray}{gray}{.9}

\definecolor{mypink}{rgb}{.99,.91,.95}

\definecolor{mycyan}{cmyk}{.3,0,0,0}

\parindent=0

\parskip=3ex

\begin{document}

\centering

\section*{SPECIFIC HEATS (20 \textcelsius\ AND 1 ATM)}

\begin{tabular}{>{\sf }lll}    %

\toprule

& \multicolumn{2}{c}{\bf Specific Heats} \\

\cmidrule{2-3}

& $c$ (J/kg$\cdot$K) & $C$ (J/mol$\cdot$K) \\

\midrule

Aluminum     & 900  & 24.3 \\

\rowcolor{mygray}

Copper       & 385  & 24.4 \\

Gold         & 130  & 25.6 \\

\rowcolor{mygray}

Steel/Iron   & 450  & 25.0 \\

Lead         & 130  & 26.8 \\

\rowcolor{mygray}

Mercury      & 140  & 28.0 \\

Water        & 4190 & 75.4 \\

\rowcolor{mygray}

Ice ($-$10 \textcelsius) & 2100 & 38 \\

\bottomrule

\end{tabular}

\vspace{8ex} %

\section*{SPECIFIC HEATS (20 \textcelsius\ AND 1 ATM)}

\begin{tabular}{>{\columncolor{mypink}\sf }lll@{}}

\toprule

\rowcolor{white}

& \multicolumn{2}{c}{\bf Specific Heats} \\

\cmidrule{2-3}

\rowcolor{white}

& $c$ (J/kg$\cdot$K) & $C$ (J/mol$\cdot$K) \\

\midrule

Aluminum     & 900  & 24.3 \\

Copper       & 385  & 24.4 \\

Gold         & 130  & 25.6 \\

Steel/Iron   & 450  & 25.0 \\

Lead         & 130  & 26.8 \\

Mercury      & 140  & 28.0 \\

Water        & 4190 & 75.4 \\

Ice ($-$10 \textcelsius) & 2100 & 38 \\

\bottomrule

\end{tabular}

\section*{SPECIFIC HEATS (20 \textcelsius\ AND 1 ATM)}

\fboxsep=16px

\colorbox{mypink}{

\begin{tabular}{@{}>{\sf }lll@{}}

\toprule

& \multicolumn{2}{c}{\bf Specific Heats} \\

\cmidrule{2-3}

& $c$ (J/kg$\cdot$K) & $C$ (J/mol$\cdot$K) \\

\midrule

Aluminum     & 900  & 24.3 \\

Copper       & 385  & 24.4 \\

Gold         & 130  & 25.6 \\

Steel/Iron   & 450  & 25.0 \\

Lead         & 130  & 26.8 \\

Mercury      & 140  & 28.0 \\

Water        & 4190 & 75.4 \\

Ice ($-$10 \textcelsius) & 2100 & 38 \\

\bottomrule

\end{tabular}}

\vspace{8ex} %

\section*{SPECIFIC HEATS (20 \textcelsius\ AND 1 ATM)}

\begin{tabular}{@{}>{\sf }lll@{}}

\toprule

& \multicolumn{2}{c}{\bf Specific Heats} \\

\cmidrule{2-3}

& $c$ (J/kg$\cdot$K) & $C$ (J/mol$\cdot$K) \\

\midrule

Aluminum     & 900  & 24.3 \\

Copper       & 385  & 24.4 \\

Gold         & 130  & 25.6 \\

Steel/Iron   & 450  & 25.0 \\

Lead         & 130  & 26.8 \\

Mercury      & 140  & 28.0 \\

Water        & \multicolumn{1}{>{\columncolor{mycyan}}l}{4190} & 75.4 \\

Ice ($-$10 \textcelsius) & 2100 & 38 \\

\bottomrule

\end{tabular}

\setlength{\extrarowheight}{2mm}

\begin{tabular}{|l|c|c|c|c|c|c|c|}

\hline

Sydney & OG4G &Thu Oct 10 &Mon Oct 21 or 28 &11 or 18 days &999\\

\rowcolor[gray]{0.5}

& &Thu Oct 17 &Mon Oct 21 or 28 & 4 or 11 days &999\\

&OG7A &Sun Oct 13 &Mon Oct 21 or 28 & 8 or 15 days &999\\

\rowcolor[gray]{0.5}

& &Sun Oct 20 &Mon Oct 28 & 8 days &999\\

\hline

\end{tabular}

\setlength{\extrarowheight}{2mm}

\setlength{\tabcolsep}{2mm}

\begin{tabular}{|l|%

>{\columncolor{yellow}}c|c|>{\columncolor{yellow}}c|c|%

>{\columncolor{red}\bfseries}c

\hline

\multicolumn{3}{>{\columncolor{red}}l}{\color{white}\textsf{LONDON}}

&\multicolumn{3}{>{\columncolor{red}}r}{\color{white}\textsf{Price}}

\\[1px]

\hline

Sydney & OG4G &Thu Oct 10 &Mon Oct 21 or 28 &11 or 18 days &999\\

& &Thu Oct 17 &Mon Oct 21 or 28 & 4 or 11 days &999\\

& OG7A &Sun Oct 13 &Mon Oct 21 or 28 & 8 or 15 days &999\\

& &Sun Oct 20 &Mon Oct 28 & 8 days &999\\

\hline

\end{tabular}

\setlength{\arrayrulewidth}{3px}

\arrayrulecolor{green}

\begin{tabular}{|l|c|r|}

\arrayrulecolor{black}\hline

United Kingdom & London & Thames\\

\arrayrulecolor{blue}\hline

France & Paris & Seine \\

\arrayrulecolor{black}\cline{1-1}

\arrayrulecolor{red}\cline{2-3}

Russia & Moscow & Moskva \\ \hline

\end{tabular}

\end{document}

matlab tabular,LaTeX表格tabular背景色添加技巧相关推荐

  1. Latex论文表格画法及相关技巧

    Latex论文表格画法 1 基本表格画法 2 合并表格画法 3 灵活实现表格 最近画了很多计算机会议和论文的表格,因此特意在这里做一个记录,以满足未来画基本表格的需要,节省时间. 1 基本表格画法 \ ...

  2. latex 表格绘制

    文章目录 表格放在页面中间 表格中,列格式对齐 一列需要使用多行 多行合并,对应列不变 三线图 设置表格的大小 命令解说 在线画图 表格放在页面中间 格式 \begin{table*}\centeri ...

  3. 基于tabular包的Latex表格尺寸设置方法(列宽和行高)

    基于tabular包的Latex表格尺寸设置方法(列宽和行高) tabel语法的小技巧 设置表格的说明文字时,有的场合要求说明文字在表格下方,有的要求说明文字在表格上方,该怎么调整呢? 只需要把\ca ...

  4. 【写博客常用】latex表格详细教程(table, tabular, multirow, multicolumn)latex表格内如何自动换行

    [写博客常用]latex表格详细教程(table, tabular, multirow, multicolumn)&latex表格内如何自动换行 看本文先看,本文是基于此篇做表格方法上加了换行 ...

  5. 使用 SQL Server 2012 Analysis Services Tabular Mode 表格建模 图文教程

    原文 http://www.cnblogs.com/biwork/archive/2013/05/22/3093896.html BI Work 使用 SQL Server 2012 Analysis ...

  6. Latex: 使 tabular 居中

    参考: How to center the table in Latex Latex: 使 tabular 居中 解决方法1: { \centering \begin{tabular} ... \en ...

  7. excel表格不够怎么添加_Excel表格技巧—表格不够怎么添加

    有时,当我们需要在原先制作的Excel表格里增加数据时,发现原先的表格已经不能满足数据的输入,这时该怎么办呢?今天我们就来教大家,表格不够怎么添加的小技巧. 首先,选中需要添加行数的单元格,如下图所示 ...

  8. html表格自动序号,word实用技巧:表格中自动添加序号

    大家在工作中,不免要用word做表格,但是序号一列,往往要用手一个一个的嵌入序列号,又麻烦,又浪费时间,还容易出错.那么下面就由学习啦小编给大家分享下word表格中自动添加序号的技巧,希望能帮助到您. ...

  9. 【LaTeX技巧】 | LaTeX数学公式环境中添加删除线

    LaTeX数学公式环境中添加删除线 LaTeX数学公式环境中添加删除线 LaTeX数学公式环境中添加删除线 作者:刘兴禄,清华大学,博士在读 cancel包 下面是一个例子. \documentcla ...

  10. latex 表格及标题居中

    1.截课本原图,代码复制到latex后的生成的图. 此图表格未居中,代码为: \begin{tabular}{11111}\end{tabular} 2.居中正确方法:前后分别加一个\begin{ce ...

最新文章

  1. MJExtension简介
  2. 漫说代理模式---给宝宝成长护航
  3. 信息学奥赛一本通(1065:奇数求和)
  4. 人工智能指用计算机,人工智能测试题..doc
  5. matlab矩阵(一)--如何控制矩阵中小数点的位数
  6. PLC-Recorder通过Modbus TCP/Modbus RTU转换器实现RS-485总线设备采集的方法
  7. CSS实现折角效果:
  8. windows10如何查看电池损耗
  9. reddit_Reddit如何设计和编码其详尽的愚人节体验,/ r / place
  10. python学习004-----python中%s的各种用法
  11. 【AI每日播报】棋圣聂卫平告负 Master取得第54场胜利
  12. Anaconda 安装与 使用
  13. 14个以春天为主题的网页设计
  14. 电脑开机后进不了桌面怎么办
  15. 五险一金是包括什么?
  16. CSS3眨眼效果(animation动画循环间的“暂停”、“延时”执行)
  17. 工人物语5战役攻略_《工人物语5》全攻略(下篇)
  18. NanoPi NEO3上手日记第三天——安装3G/4G网卡(OpenWrt系统均适用)
  19. Sec-Fetch-*请求头
  20. java如何模拟抢单_基于jsp的抢单兼职-JavaEE实现抢单兼职 - java项目源码

热门文章

  1. Knoll Light Factory 3.2 for Mac 完整汉化版 灯光工厂 for Mac中文版 支持PSCC2019
  2. PS插件:灯光工厂安装教程
  3. 慢性病管理系统/案列/APP/小程序/网站
  4. nginx源码编译安装及使用
  5. 『网站设计』配色宝典
  6. 码率多少算是正常的1080p_MP3的频率、比特率、码率与音质的关系(网络整理)...
  7. 在c语言中形参的作用域,【单选题】下列标识符中,属于块作用域的是( ) A. 函数形参 B. 语句标号 C. 函数外...
  8. cesium--3d-tiles译文[官方]
  9. redis的hscan替换hgetall的疑问,redis返回列表获取数据示例
  10. 98 服务器系统,流金岁月:重温Windows 98视窗操作系统