修复背景单元格颜色以匹配边框

修复背景单元格颜色以匹配边框

我如何修复书签边框以匹配单元格颜色或反之亦然?

\documentclass{article}
 \usepackage[normalem]{ulem}
 \usepackage[svgnames,table,xcdraw]{xcolor} 
 \usepackage{booktabs} 
 \usepackage{graphicx} 
 \usepackage{stfloats}
 \usepackage{float}
 \usepackage{tikz}
 \usepackage{enumitem}

\begin{document}

\begin{table}[]
\begin{tabular}{@{}lclcllll@{}}
    \toprule
    \multicolumn{1}{c}{\textbf{Pros}} & \textbf{I} & \multicolumn{1}{c}{\textbf{P}} & \textbf{W} & \multicolumn{1}{c}{\textbf{Cons}} & \multicolumn{1}{c}{\textbf{I}} & \multicolumn{1}{c}{\textbf{P}} & \multicolumn{1}{c}{\textbf{W}} \\ \midrule
    \rowcolor[HTML]{CBCEFB} 
    \sout{Income} & \sout{8} & \sout{10} & \sout{80} & \cellcolor[HTML]{FFCE93}\sout{It’s lower level work than I’ve been doing} & \cellcolor[HTML]{FFCE93}\sout{5} & \cellcolor[HTML]{FFCE93}\sout{8} & \cellcolor[HTML]{FFCE93}\sout{40} \\
    \rowcolor[HTML]{FFFFC7} 
    \sout{Benefits} & \sout{7} & \sout{10} & \sout{70} & \sout{involves a relocation/move} & \sout{7} & \sout{10} & \sout{70} \\
    \rowcolor[HTML]{9AFF99} 
    \sout{Actual job} & \sout{5} & \sout{10} & \sout{50} & \cellcolor[HTML]{CBCEFB}\sout{Imposes considerable time demands} & \cellcolor[HTML]{CBCEFB}\sout{8} & \cellcolor[HTML]{CBCEFB}\sout{10} & \cellcolor[HTML]{CBCEFB}\sout{80} \\
    \rowcolor[HTML]{FFFFC7} 
    \sout{Colleagues} & \sout{7} & \sout{10} & \sout{70} & \cellcolor[HTML]{9AFF99}\sout{Entails occasional trips to Columbus area} & \cellcolor[HTML]{9AFF99}\sout{5} & \cellcolor[HTML]{9AFF99}\sout{10} & \cellcolor[HTML]{9AFF99}\sout{50} \\
    Opportunities & 7 & \multicolumn{1}{c}{7} & 49 & \cellcolor[HTML]{FFFFC7}\sout{Disrupts our current life style} & \cellcolor[HTML]{FFFFC7}\sout{7} & \cellcolor[HTML]{FFFFC7}\sout{10} & \cellcolor[HTML]{FFFFC7}\sout{70} \\
    Get away from two pesky people & 4 & 10 & 40 & Might have to take guff again & 5 & 5 & 25 \\
    Makes things easier financially & 8 & 10 & 80 & I won’t fit in & 5 & 2 & 10 \\
    It would be nice to bag a job at my age & 5 & 10 & 50 & I can’t do the work & 10 & 2 & 20 \\
    Larger urban area & 7 & 10 & 70 &  &  &  &  \\
    \cellcolor[HTML]{FFCE93}\sout{Firm reputation} & \cellcolor[HTML]{FFCE93}\sout{5} & \cellcolor[HTML]{FFCE93}\sout{8} & \cellcolor[HTML]{FFCE93}\sout{40} &  &  &  &  \\ \midrule
    \multicolumn{1}{r}{\textbf{Total}} & \textbf{31} & \multicolumn{1}{c}{\textbf{47}} & \textbf{289} & \multicolumn{1}{r}{\textbf{Total}} & \textbf{20} & \textbf{9} & \textbf{55} \\ \bottomrule
\end{tabular}
\end{table}


\end{document}

在此处输入图片描述

答案1

tblr环境的替代解决方案tabularray包:您可以通过将样式与内容分离来制作非常干净的代码。

\documentclass{article}

\usepackage[margin=1cm]{geometry}
\usepackage[normalem]{ulem}
\usepackage{xcolor}

\usepackage{tabularray}
\UseTblrLibrary{booktabs} 

\begin{document}

\begin{table}[]
\begin{tblr}{
  colspec = {@{}lclcllll@{}},
  row{1} = {c,font=\bfseries},
  row{Z} = {r,font=\bfseries},
  row{2-5} = {cmd=\sout},
  cell{6}{5-8} = {cmd=\sout},
  cell{Y}{1-4} = {cmd=\sout},  
  cell{2}{1-4} = {blue9},
  cell{3}{1-8} = {yellow9},
  cell{4}{1-4} = {green9},
  cell{5}{1-4} = {yellow9},
  cell{Y}{1-4} = {brown9}, 
  cell{2}{5-8} = {brown9},
  cell{4}{5-8} = {blue9},
  cell{5}{5-8} = {green9},
  cell{6}{5-8} = {yellow9},
}
\toprule
  Pros & I & P & W & Cons & I & P & W \\
\midrule
  Income                                  &  8 & 10 & 80  & It’s lower level work than I’ve been doing &  5 &  8 & 40 \\
  Benefits                                &  7 & 10 & 70  & involves a relocation/move                 &  7 & 10 & 70 \\
  Actual job                              &  5 & 10 & 50  & Imposes considerable time demands          &  8 & 10 & 80 \\
  Colleagues                              &  7 & 10 & 70  & Entails occasional trips to Columbus area  &  5 & 10 & 50 \\
  Opportunities                           &  7 &  7 & 49  & Disrupts our current life style            &  7 & 10 & 70 \\
  Get away from two pesky people          &  4 & 10 & 40  & Might have to take guff again              &  5 &  5 & 25 \\
  Makes things easier financially         &  8 & 10 & 80  & I won’t fit in                             &  5 &  2 & 10 \\
  It would be nice to bag a job at my age &  5 & 10 & 50  & I can’t do the work                        & 10 &  2 & 20 \\
  Larger urban area                       &  7 & 10 & 70  &                                            &    &    &    \\
  Firm reputation                         &  5 &  8 & 40  &                                            &    &    &    \\
\midrule
                                    Total & 31 & 47 & 289 &                                      Total & 20 &  9 & 55 \\
\bottomrule
\end{tblr}
\end{table}

\end{document}

在此处输入图片描述

相关内容