在Latex中生成一个表格,其中包含不同颜色的单元格[关闭]

问题描述 投票:3回答:2

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

latex
2个回答
2
投票

您可以使用\cellcolor包中的xcolor为特定单元格着色:

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


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}

生成下表。

默认颜色是blackwhiteredgreenbluecyanmagentayellow,更多细节包括here

© www.soinside.com 2019 - 2024. All rights reserved.