我想给一列着色,但只从以 C1 开头的行开始。我有这个示例输出。我想从 C1 之前的行中删除黄色。
这是脚本:
\documentclass[10pt]{llncs}
\usepackage{array}
\usepackage{booktabs}
\usepackage{makecell, booktabs, caption}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{adjustbox}
\newcommand{\normal}[1]{\multicolumn{1}{l}{#1}}
\usepackage{sistyle} % for numbers
\SIthousandsep{,} % for numbers
\usepackage{xcolor}
\usepackage{colortbl}
\definecolor{lightYellow}{cmyk}{0,0.04,4.4,0}
\begin{document}
\title{Title}
\maketitle
\begin{abstract}
Abstract
\end{abstract}
\section{Section1}
\begin{table*}[!tp]
\centering
\caption{some table}
\label{tab:example}
\begin{adjustbox}{max width=\textwidth}
\begin{tabular}{l>{\columncolor{lightYellow}}r@{\hspace{5pt}}>{\columncolor{lightYellow}}rr@{\hspace{5pt}}r}
\toprule
\multirow{2}{*}{Criterion} &
\multicolumn{2}{c}{\multirow{2}{*}{Result}}&
\multicolumn{2}{c}{Country} \\
\cline{4-5}
& & &\multicolumn{2}{c}{AU} \\
\midrule
C1 & \num{11}&(0.11\%) & \num{22} &(0.22\%) \\
C2 & \num{33} & (0.33\%) & \num{44}&(0.44\%)\\
\midrule
C3 & \num{44}&(0.44\%) & \num{55}&(0.55\%)\\
C4 & \num{66}&(0.66\%)&\num{77}&(0.77\%)\\
\bottomrule
\end{tabular}
\end{adjustbox}
\end{table*}
\bibliographystyle{splncs04}
\bibliography{ref}
\end{document}
答案1
这是一个解决方案,在下一行中有两个\rowcolor{white}
和。请注意,已被取代,并且带有选项 [table] 的已经加载。此外,您不应使用带有表格的,因为它会导致字体大小不一致。\multirow{-2}
sistyle
siunitx
xcolor
colortbl
adjustbox
\documentclass[10pt]{llncs}
\usepackage{array}
\usepackage{makecell, booktabs}
\usepackage{multirow}
\newcommand{\normal}[1]{\multicolumn{1}{l}{#1}}
\usepackage{siunitx}
\sisetup{group-separator={,}}
\usepackage[table]{xcolor}
\definecolor{lightYellow}{cmyk}{0,0.04,4.4,0}
\begin{document}
\section{Section1}
\begin{table*}[!tp]
\centering
\caption{some table}
\label{tab:example}
\begin{tabular}{l@{\hspace{5pt}}*{2}{>{\columncolor{lightYellow}}r}@{\hspace{10pt}}rr}
\toprule
\rowcolor{white} & & &
\multicolumn{2}{c}{Country} \\
\cmidrule{4-5}
\rowcolor{white}
\multirowcell{-2}{Criterion} & \multicolumn{2}{c}{\multirowcell{-2}{Result}} &\multicolumn{2}{c}{AU} \\
\midrule
C1 & \num{11}&(0.11\%) & \num{22} &(0.22\%) \\
C2 & \num{33} & (0.33\%) & \num{44}&(0.44\%)\\
\midrule
C3 & \num{44}&(0.44[![enter image description here][1]][1]\%) & \num{55}&(0.55\%)\\
C4 & \num{66}&(0.66\%)&\num{77}&(0.77\%)\\
\bottomrule
\end{tabular}
\end{table*}%
\end{document}
答案2
该表被视为 tikzpicture。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{table}[t]
\centering
%\caption{Some table}
\label{tab:example}
\begin{tikzpicture}[xscale=3.5,yscale=1.2]
\draw
(0,1) node{Results}
+(180:1) node[right]{Criterion}
++(0:1)--+(0:.25)--+(180:.25)
+(90:.2) node{Country} +(-90:.2) node{AU};
\fill[yellow,shift={(-.5,.5)}] (0,0) rectangle +(1,-2);
\path[every node/.style={align=center}]
(0,0) node{$11\quad (0.11\%)$\\$33\quad (0.33\%)$}
(1,0) node{$22\quad (0.22\%)$\\$44\quad (0.44\%)$}
(0,-1) node{$44\quad (0.44\%)$\\$66\quad (0.66\%)$}
(1,-1) node{$55\quad (0.55\%)$\\$77\quad (0.77\%)$}
(-1,0) node[right]{C1\\C2}
(-1,-1) node[right]{C3\\C4};
\foreach \i in {-2,...,1}
\draw[shift={(90:.5)}] (-1,\i)--+(0:2.35);
\end{tikzpicture}
\end{table}%
\end{document}
答案3
使用{NiceTabular}
of nicematrix
(及其键color-inside
),您只需\rowlistcolors{lightYellow}[cols={2,3}]
在第三行的开头添加一条指令。
\documentclass[10pt]{llncs}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{sistyle}
\SIthousandsep{,}
\usepackage{xcolor}
\usepackage{nicematrix}
\definecolor{lightYellow}{cmyk}{0,0.04,4.4,0}
\begin{document}
\begin{table}[!tp]
\centering
\caption{some table}
\begin{NiceTabular}{lr@{\hspace{5pt}}rr@{\hspace{5pt}}r}[color-inside]
\toprule
\multirow{2}{*}{Criterion} &
\multicolumn{2}{c}{\multirow{2}{*}{Result}}&
\multicolumn{2}{c}{Country} \\
\cline{4-5}
& & &\multicolumn{2}{c}{AU} \\
\midrule
\rowlistcolors{lightYellow}[cols={2,3}]
C1 & \num{11}&(0.11\%) & \num{22} &(0.22\%) \\
C2 & \num{33} & (0.33\%) & \num{44}&(0.44\%)\\
\midrule
C3 & \num{44}&(0.44\%) & \num{55}&(0.55\%)\\
C4 & \num{66}&(0.66\%)&\num{77}&(0.77\%)\\
\bottomrule
\end{NiceTabular}
\end{table}
\end{document}
您需要进行多次编译(因为nicematrix
在后台使用了 PGF/TikZ 节点)。
也可以将指令放在数组的开头(所谓的\CodeBefore
提供{NiceTabular}
)。
\documentclass[10pt]{llncs}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{sistyle}
\SIthousandsep{,}
\usepackage{xcolor}
\usepackage{nicematrix}
\definecolor{lightYellow}{cmyk}{0,0.04,4.4,0}
\begin{document}
\begin{table}[!tp]
\centering
\caption{some table}
\begin{NiceTabular}{lr@{\hspace{5pt}}rr@{\hspace{5pt}}r}
\CodeBefore
\rectanglecolor{lightYellow}{3-2}{6-3}
\Body
\toprule
\multirow{2}{*}{Criterion} &
\multicolumn{2}{c}{\multirow{2}{*}{Result}}&
\multicolumn{2}{c}{Country} \\
\cline{4-5}
& & &\multicolumn{2}{c}{AU} \\
\midrule
C1 & \num{11}&(0.11\%) & \num{22} &(0.22\%) \\
C2 & \num{33} & (0.33\%) & \num{44}&(0.44\%)\\
\midrule
C3 & \num{44}&(0.44\%) & \num{55}&(0.55\%)\\
C4 & \num{66}&(0.66\%)&\num{77}&(0.77\%)\\
\bottomrule
\end{NiceTabular}
\end{table}
\end{document}
输出是否相同。