[table]{xcolor} 与 array v2.4k 冲突

[table]{xcolor} 与 array v2.4k 冲突

我正在尝试创建一个包含以下内容的表:

  1. 不同单元格的格式不同
  2. 脚注
  3. 迷你页面
  4. 彩色行

对于彩色行,我尝试使用xcolor[table]选项。

但是,这会引发列规范错误>{\bfseries}。我在 Windows 10 x64 上使用 MiKTeX 2.9.6972 和 2.4k 版本的软件包,array如中所述这里和 XeLaTeX 进行编译(尽管 PDFLaTeX 似乎会产生相同的错误)。如果我关闭包,这可以正常工作xcolor,但\rowcolor命令将不再可用。

我的问题有两个:

  1. 可以[table]{xcolor}{array}一起使用吗?
  2. 如果没有的话,有没有其他方法可以为表格的某一行添加颜色?

梅威瑟:

\documentclass{article}
\usepackage[table]{xcolor} % works if we remove the 'table' option, but then we don't have access to cellcolor/rowcolor
%\usepackage{xcolor}

\usepackage{booktabs}

% force the new array package to be loaded.
\usepackage{tabularx}

% https://texfaq.org/FAQ-wholerow
\newcolumntype{@}{>{\global\let\currentrowstyle\relax}}
\newcolumntype{^}{>{\currentrowstyle}}
\newcommand{\rowstyle}[1]{\gdef\currentrowstyle{#1}%
   #1\ignorespaces
}

\begin{document}

\begin{tabular}{>{\bfseries}@p{5.5cm}^r}
    Col A  & Col B  \\
    \midrule
    \rowstyle{\bfseries\itshape\large}This row should be large, bold, italics with shading & So this cell too. \\
    \rowcolor{blue}This bold but shaded & this just normal.\footnote{I.e., no extra mark-up} \\
    Remark & \multicolumn{1}{c}{\begin{minipage}[t]{3.5cm}\raggedright {\footnotesize Some cells are included as a minipage to accommodate extra text.}\end{minipage}} \\
    \midrule    
 \end{tabular}

 \end{document}

我收到的错误是:

! Use of \@startpbox doesn't match its definition.
<inserted text> \@startpbox {
                         >{\bfseries }@p{5.5cm}^r}
l.19 \begin{tabular}{>{\bfseries}@p{5.5cm}^r}

If you say, e.g., `\def\a1{...}', then you must always put `1' after `\a', 
since control sequence names are made up of letters only. 
The macro here has not been followed by the required stuff, so I'm ignoring
it.

! LaTeX Error: Command \bfseries invalid in math mode.

相关内容