由于某种原因,我无法\cellcolor
再渲染彩色单元格。下面是 MWE。它在 TL 2018 中有效,但我无法让它在 TL 2019 中工作。
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{tabu}
\usepackage{multirow}
\colorlet{lightgrey}{lightgray}
\begin{document}
\begin{figure}[!ht]
\renewcommand\arraystretch{1.4}
\scriptsize
\centering
\begin{tabu} to 0.9\textwidth {X[,c,]X[,c,]X[,c,]X[,c,]X[,c,]X[,c,]X[,c,]X[,c,]}
7 & 6 & 5 & 4 & 3 & 2 & 1 & 0 \\
\hline
\multicolumn{1}{|c}{\cellcolor{lightgrey} JTD} & \multicolumn{1}{|c}{ISC2} & \multicolumn{1}{|c}{\cellcolor{lightgrey} $-$} & \multicolumn{1}{|c}{\cellcolor{lightgrey} JTRF} & \multicolumn{1}{|c}{\cellcolor{lightgrey} WDRF} & \multicolumn{1}{|c}{\cellcolor{lightgrey} BORF} & \multicolumn{1}{|c}{\cellcolor{lightgrey} EXTRF} & \multicolumn{1}{|c|}{\cellcolor{lightgrey} PORF} \\ \hline
R/W & R/W & R & R/W & R/W & R/W & R/W & R/W \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
\end{tabu}
\caption{Position of the ISC2 bit in the MCUCSR register.}
\label{fig:intmcucsr}
\end{figure}
\end{document}
答案1
tabu
已损坏,请改用tabularx
:
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{tabularx}
\usepackage{multirow}
\colorlet{lightgrey}{lightgray}
\usepackage{array}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\begin{document}
\begin{figure}[!ht]
\renewcommand\arraystretch{1.4}
\scriptsize
\centering
\begin{tabularx}{0.9\textwidth}{YYYYYYYY}
7 & 6 & 5 & 4 & 3 & 2 & 1 & 0 \\
\hline
\multicolumn{1}{|c}{\cellcolor{lightgrey} JTD} & \multicolumn{1}{|c}{ISC2} & \multicolumn{1}{|c}{\cellcolor{lightgrey} $-$} & \multicolumn{1}{|c}{\cellcolor{lightgrey} JTRF} & \multicolumn{1}{|c}{\cellcolor{lightgrey} WDRF} & \multicolumn{1}{|c}{\cellcolor{lightgrey} BORF} & \multicolumn{1}{|c}{\cellcolor{lightgrey} EXTRF} & \multicolumn{1}{|c|}{\cellcolor{lightgrey} PORF} \\ \hline
R/W & R/W & R & R/W & R/W & R/W & R/W & R/W \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
\end{tabularx}
\caption{Position of the ISC2 bit in the MCUCSR register.}
\label{fig:intmcucsr}
\end{figure}
\end{document}
答案2
{NiceTabular}
以下是使用创建该表的一种方法nicematrix
。
使用\Block
带有键的命令fill
将填充整个行,但是,在具有特殊颜色的单元格中nocolor
,将不使用背景(没有背景:它不是行灰色背景上方的白色背景)。
\documentclass{article}
\usepackage{xcolor}
\usepackage{nicematrix}
\begin{document}
\begin{figure}[!ht]
\renewcommand\arraystretch{1.4}
\scriptsize
\centering
\begin{NiceTabularX}{0.9\textwidth}{*{8}{X[c]}}[color-inside]
7 & 6 & 5 & 4 & 3 & 2 & 1 & 0 \\
\Block[hvlines,fill=lightgray]{1-*}{}
JTD & \cellcolor{nocolor} ISC2 & $-$ & JTRF & WDRF & BORF & EXTRF & PORF \\
R/W & R/W & R & R/W & R/W & R/W & R/W & R/W \\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
\end{NiceTabularX}
\caption{Position of the ISC2 bit in the MCUCSR register.}
\label{fig:intmcucsr}
\end{figure}
\end{document}
您需要进行多次编译(因为nicematrix
在后台使用了 PGF/TikZ 节点)。
您将在所有 PDF 查看器中获得良好的输出,无论缩放到何种程度:垂直规则似乎不会消失。