![[table]{xcolor} 和陣列 v2.4k 衝突](https://rvso.com/image/391590/%5Btable%5D%7Bxcolor%7D%20%E5%92%8C%E9%99%A3%E5%88%97%20v2.4k%20%E8%A1%9D%E7%AA%81%20.png)
我正在嘗試創建一個表:
- 不同單元格的格式不同
- 註腳
- 小型頁面
- 彩色行
對於彩色行,我嘗試xcolor
與該[table]
選項一起使用。
但是,這會引發列規格錯誤>{\bfseries}
。我在 Windows 10 x64 上使用 MiKTeX 2.9.6972 和該array
套件的版本 2.4k,如中所述這裡和 XeLaTeX 進行編譯(儘管 PDFLaTeX 似乎會產生相同的錯誤)。如果我關閉xcolor
程式包,則此方法有效,但該\rowcolor
命令不再可用。
我的問題有兩個:
[table]{xcolor}
和可以{array}
一起使用嗎?- 如果沒有,是否有其他方法可以為表格的一行著色?
微量元素:
\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.