![如何重新定义表格规则的颜色而不干扰其单元格的内容?](https://linux22.com/image/233692/%E5%A6%82%E4%BD%95%E9%87%8D%E6%96%B0%E5%AE%9A%E4%B9%89%E8%A1%A8%E6%A0%BC%E8%A7%84%E5%88%99%E7%9A%84%E9%A2%9C%E8%89%B2%E8%80%8C%E4%B8%8D%E5%B9%B2%E6%89%B0%E5%85%B6%E5%8D%95%E5%85%83%E6%A0%BC%E7%9A%84%E5%86%85%E5%AE%B9%EF%BC%9F.png)
我尝试将表格的规则颜色改为红色。不幸的是,表格单元格中的内容也受到了干扰,如下图所示。边距框架规则也变成了红色,这不是它应该的样子。
我不知道应该重新定义哪些参数来改变表规则的颜色。
\documentclass[dvips,dvipsnames,rgb]{book}
\usepackage[a4paper,hmargin=10mm,vmargin=40mm,showframe]{geometry}
\usepackage{longtable}
\usepackage{array}
\usepackage{calc}
\usepackage{lscape}
\setlength{\tabcolsep}{2mm}
\setlength{\arrayrulewidth}{2mm}
\newcounter{No}
\renewcommand{\theNo}{\arabic{No}}
\newenvironment{MyTable}[4]%
{%
\newcolumntype{O}[1]%
{%
>{%
\begin{minipage}%
{%
##1\linewidth-2\tabcolsep-1.5\arrayrulewidth%
}%
\vspace{\tabcolsep}%
}%
c%
<{%
\vspace{\tabcolsep}%
\end{minipage}%
}%
}%
\newcolumntype{I}[1]%
{%
>{%
\begin{minipage}%
{%
##1\linewidth-2\tabcolsep-\arrayrulewidth%
}%
\vspace{\tabcolsep}%
}%
c%
<{%
\vspace{\tabcolsep}%
\end{minipage}%
}%
}%
\setcounter{No}{0}%comment out this if you want to continuous numbering for all tables.
\begin{longtable}%
{%
|>{\stepcounter{No}\centering\scriptsize\theNo}O{#1}<{}%
|>{\centering}I{#2}<{\input{\jobname.tmp}}%
|>{\centering\lstinputlisting{\jobname.tmp}}I{#3}<{}%
|>{\scriptsize}O{#4}<{}%
|%
}%
\hline\ignorespaces%
}%
{%
\end{longtable}%
}
\newcommand{\Comment}[1]{&&\tabularnewline\hline}
\usepackage{listings}
\lstset{%
language={PSTricks},
breaklines=true,
basicstyle=\ttfamily\scriptsize,%
keywordstyle=\color{blue},
backgroundcolor=\color{yellow!30}%
}
\usepackage{fancyvrb}
\def\MyRow{%
\VerbatimEnvironment%
\begin{VerbatimOut}{\jobname.tmp}%
}
\def\endMyRow{%
\end{VerbatimOut}%
}
\usepackage{pstricks,pst-node}
\newpsstyle{gridstyle}{%
gridwidth=0.4pt,%default: 0.8pt
gridcolor=Red!20,%default: black
griddots=0,%default: 0
%
gridlabels=3pt,%default: 10pt
gridlabelcolor=Blue,%default: black
%
subgriddiv=5,%default: 5
subgridwidth=0.2pt,%default: 0.4pt
subgridcolor=Green!20,%default: gray
subgriddots=0%default: 0
}
\usepackage{lipsum}
\begin{document}
{\color{Red}%
%\clearpage
%\pagestyle{empty}
%Landscape starts here.
%\begin{landscape}
\begin{MyTable}{0.05}{0.3}{0.3}{0.35}%
%=============
\begin{MyRow}
\pspicture*[showgrid](3,3)
\pnode(1,1){A}
\pnode(3,3){B}
\ncline{A}{B}
\endpspicture
\end{MyRow}
\Comment{\lipsum[1]}
%=============
\begin{MyRow}
\begin{pspicture}[showgrid](3,3)
\psframe*[linecolor=red!30](3,2)
\end{pspicture}
\end{MyRow}
\Comment{\lipsum[2]}
%=============
\begin{MyRow}
\pspicture[showgrid](3,3)
\psframe*[linecolor=green!30](3,2)
\endpspicture
\end{MyRow}
\Comment{\lipsum[3]}
%=============
\begin{MyRow}
\pspicture[showgrid](3,3)
\psframe*[linecolor=yellow!30](3,2)
\endpspicture
\end{MyRow}
\Comment{\lipsum[4]}
%=============
\begin{MyRow}
\pspicture[showgrid](3,3)
\psframe*[linecolor=Maroon!30](3,2)
\endpspicture
\end{MyRow}
\Comment{\lipsum[5]}
%=============
\end{MyTable}
%\end{landscape}
%Landscape stops here.
%\pagestyle{plain}
}%
\end{document}
编辑1:
单元格 (1,2) 和单元格 (1,3) 共享的垂直规则行为异常。它不应该是黑色的。:-)
答案1
\documentclass{article}
\usepackage[table]{xcolor}
\begin{document}
\bgroup
\arrayrulecolor{blue!70}
\begin{tabular}{|*6{c|}}\hline
a & b & c & d & e & f\\\hline
a & b & c & d & e & f\\\hline
\end{tabular}
\egroup
\end{document}