LaTeX备忘——表格颜色与表格线风格设置示例

    本文介绍如何设置表格的行、列与单元格颜色,以及如何设置表格线的粗细与颜色。设置方法直接看代码就明白了,不再赘述。


操作系统:Ubuntu 18.04
编辑工具:TeXstudio 2.12.6
编译方式:LuaLaTeX


% CSDN 诸法无我(陆巍的博客)
\documentclass{article}%
%
\usepackage{ctex}% 中文支持
\usepackage{geometry}% 用于页面设置
\usepackage[english]{babel}% 载入美式英语断字模板
\usepackage[dvipsnames, svgnames, x11names]{xcolor}% 颜色支持
\usepackage{colortbl}% 表格颜色支持

% 设置为A4纸,并设置边距
\geometry
{
  a4paper,%
  left = 3.17cm,%
  right = 3.17cm,%
  top = 2.54cm,%
  bottom = 2.54cm%
}%

\setlength{\parindent}{0em}% 缩进为0
%
\setmainfont{Ubuntu Mono}% 设置全局英文字体

% ------------------ 开始 -------------------
%
\begin{document}
  \Large 表格颜色与表格线设置示例\\\normalsize
  
  \begin{tabular}{p{3cm}!{\color{white}\vrule width 3pt}p{12cm}}
    \rowcolor{black}\textcolor{white}{\textbf{Goal}} & \textcolor{white}{\textbf{Explanation}}\\
    \noalign{{\color{white}\hrule height 5pt}}
    \rowcolor{LightGray}Reusability & Frameworks and adaptations readily reusable\\
    \noalign{{\color{white}\hrule height 3pt}}
    \rowcolor{WhiteSmoke}Modularity & Decoupled and easy to reassemble\\
    \noalign{{\color{white}\hrule height 3pt}}
    \rowcolor{LightGray}Testability & Components easily isolated for testing\\
    \noalign{{\color{white}\hrule height 3pt}}
    \rowcolor{WhiteSmoke}Adaptability & Should be adaptable to new contexts and  bridge to inherited\\
    \noalign{{\color{white}\hrule height 3pt}}
    \rowcolor{LightGray}Portability & Should be portable to new architectures and platforms\\
    \noalign{{\color{white}\hrule height 3pt}}
    \rowcolor{WhiteSmoke}Usability & Should be easily understood and used by customers\\
    \noalign{{\color{white}\hrule height 3pt}}
    \rowcolor{LightGray}Configurability & \textcolor{red}{Facilities in the architecture should be scalable and configurable}\\
    \noalign{{\color{white}\hrule height 3pt}}
    \rowcolor{WhiteSmoke}Performance &\cellcolor{green} Architecture should perform well in resource constrained contexts. Should be very compact.
  \end{tabular}
\end{document}

效果如下:
LaTeX备忘——表格颜色与表格线风格设置示例_第1张图片
注意事项:

  1. 这里需要colortbl宏包支持表格颜色设置;
  2. 使用非基础颜色名称需要载入相关颜色库,即\usepackage[dvipsnames, svgnames, x11names]{xcolor}

你可能感兴趣的:(LaTeX)