latexpdflatexoverleaf

Row and column colors in tabular environment with `\usepackage[table]{xcolor}` error with jss.cls?


I would like to include a table with row and column colors in a submission to the Journal of Statistical Software. The following is a reprex that uses the jss.cls class file:

\documentclass[article]{jss}

\usepackage[table]{xcolor}
\newcolumntype{s}{>{\columncolor{gray!30}} r}

\author{Author \\ University }
\title{A paper}

\Abstract{Abstract words}
\Keywords{keywords}

\begin{document}

\begin{tabular}{|rs|rs|}
      \hline
      \small 0              & 0 & \small 4 & 0 \\
      \rowcolor{green!30} 0 &   & 1        &   \\\hline
      \small 1              & 1 & \small 5 & 1 \\
      \rowcolor{green!30} 0 &   & 1        &   \\\hline
\end{tabular}

\end{document}

The needed style file is in https://www.jstatsoft.org/public/journals/1/jss-style.zip.

The code produces the table correctly in OverLeaf but generates several errors. With pdflatex from the command line (macOS TexLive distribution), it errors with:

Package hyperref Warning: Option `hyperindex' has already been used,
(hyperref)                setting the option has no effect on input line 446.

) (/usr/local/texlive/2022/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def)
 (./test.aux)
(/usr/local/texlive/2022/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/local/texlive/2022/texmf-dist/tex/latex/epstopdf-pkg/epstopdf-base.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))

Package hyperref Warning: Token not allowed in a PDF string (Unicode):
(hyperref)                removing `\\' on input line 12.

(/usr/local/texlive/2022/texmf-dist/tex/latex/psnfss/t1pzc.fd)
! Undefined control sequence.
\hyper@linkurl ...tionraw >>}\relax \Hy@colorlink 
                                                  \@urlcolor #1\Hy@xspace@en...
l.12 \begin{document}
                     
? 

The code also works fine if plain article is used instead of jss.cls.

Is it because jss.cls is older than current hyperref or color or xcolor packages? I am not finding relevant help on stackoverflow or elsewhere.


Solution

  • You can work around the problem by switching back to an old version of the kernel:

    \RequirePackage[2020/01/01]{latexrelease}
    \RequirePackage[table]{xcolor}
    \documentclass[article]{jss}
    
    \newcolumntype{s}{>{\columncolor{gray!30}} r}
    
    \author{Author \\ University }
    \title{A paper}
    
    \Abstract{Abstract words}
    \Keywords{keywords}
    
    \begin{document}
    
    test
    
    \begin{tabular}{|rs|rs|}
          \hline
          \small 0              & 0 & \small 4 & 0 \\
          \rowcolor{green!30} 0 &   & 1        &   \\\hline
          \small 1              & 1 & \small 5 & 1 \\
          \rowcolor{green!30} 0 &   & 1        &   \\\hline
    \end{tabular}
    
    \end{document}