在 Latex 中生成具有不同颜色单元格的表格

Anu*_*S B 4 latex

我正在攻读图论数学博士学位。在我的论文中,我必须在 Latex 中为表格的特定单元格行(图形的边缘)着色。这能做到吗?我只找到了一种为整行着色的方法。

ser*_*gej 5

您可以用颜色使用特定的电池\cellcolorxcolor包:

\documentclass{standalone}

\usepackage[table]{xcolor}

\begin{document}

\begin{tabular}{r|c|l}
    A & B & C \\\hline
    1 & 2 & 3 \\\hline
    x & y & \cellcolor{red!25}z
\end{tabular}

\end{document}
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

  • 太好了,我都不知道这个!另外,还可以组合: `\cellcolor{red!25}\color{blue}{z}` (3认同)

Mat*_*gro 1

第一个建议是手动为每个单元格中的文本着色(如果您的表格不是太大):

\documentclass[english]{report}
\usepackage{color}
\usepackage{booktabs}

\definecolor{light-blue}{rgb}{0.6,0.6,1}

\begin{document}

\begin{table}
\begin{tabular}{lr}
\toprule
\color{red}{Some text} & \color{light-blue}{and some other}\\
\color{cyan}{inside} & \color{green}{a table}\\
\bottomrule
\end{tabular}
\end{table}

\end{document}
Run Code Online (Sandbox Code Playgroud)

产生下表。

输出的屏幕截图

默认颜色为black、、、、、、、,此处包含更多详细信息。whiteredgreenbluecyanmagentayellow

此外,为了给单元格的背景着色,我建议使用名为 的包ytableau