1

I'm trying to create a table with:

  1. different formatting across cells
  2. footnotes
  3. minipages
  4. coloured rows

For the coloured rows I'm trying to use xcolor with the [table] option.

However, this throws an error with the >{\bfseries} column spec. I'm using MiKTeX 2.9.6972 on Windows 10 x64 and version 2.4k of the array package as described in here, and XeLaTeX to compile (although PDFLaTeX seems to generate the same error). This works if I switch off the xcolor package, but then the \rowcolor command is no longer available.

My question is two-fold:

  1. Is it possible to use [table]{xcolor} and {array} together?
  2. If not, is there an alternative to color a row of a table?

MWE:

\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}

The error I get is:

! 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.
Mico
  • 506,678
  • The only color I get is that grey is not defined. If I replace grey by blue, your code runs through on my machine. –  Mar 03 '19 at 07:19
  • 1
    you look like you have an old version somewhere, can you post your log file for the above, after defining grey? – David Carlisle Mar 03 '19 at 07:35
  • @DavidCarlisle log file here: link Miktex says it's completely up to date, not sure how true that is. – user3754505 Mar 03 '19 at 07:36
  • 2
    We do not like going to sites for data. I cannot read from Dropbox on my tablet, but remember: under miktex you essentially have two installations, admin and user. If you only updated admin, user may still have an old version dangling (user takes precedence). Did you update as both user and admin? – daleif Mar 03 '19 at 07:42
  • 1
    Now I got access to the log. As expected, you have old versions dangling under AppData (see the log) – daleif Mar 03 '19 at 07:43
  • 1
    standard miktex issue (it's the only thing I know about miktex:-) you only updated half of it you have an old xcolor in C:\Users\thijsv\AppData\Roaming\MiKTeX\2.9\tex/latex/xcolor\xcolor.sty – David Carlisle Mar 03 '19 at 07:44
  • 3
    See also https://tex.stackexchange.com/q/55437/35864 and https://tex.stackexchange.com/q/108447/35864. If you installed MikTeX as a multi-user system, you will have two more or less independent package trees: One managed by the user and one by the admin. Files in the user tree are given preference over the global admin files. If you update your system it is important to update in both admin and user mode to make sure that everything is up to date and that versions match. Contrary to what one might think the Admin updater is not more powerful in that it would also update the user installs. – moewe Mar 03 '19 at 07:51
  • Didn't know about the duplicate package trees in MikTex. That solves the issue indeed. Thanks! – user3754505 Mar 03 '19 at 22:04
  • @moewe Please see the comment above. – Johannes_B Mar 11 '19 at 08:14
  • @Johannes_B Sorry, I'm a bit busy at the moment. If you think an answer makes sense, feel free to copy my comment for one. Otherwise we could think of closure as duplicate of the canonical 'update your MikTeX' question or as off-topic b/c solved by an update. – moewe Mar 11 '19 at 08:32
  • 5
    I'm voting to close this question as off-topic because the issue was solved by updating the TeX distribution. – Johannes_B Mar 11 '19 at 08:38
  • @moewe I voted to close. – Johannes_B Mar 11 '19 at 08:38

0 Answers0