Problem using arrayrulecolor and compiling with make4ht

colortblmake4httex4ht

The following example crashes when compiling with make4ht The problem relies on the usage of \arrayrulecolor.

\documentclass{article}
\usepackage{booktabs,colortbl}
\begin{document}
\begin{table}
\caption{Example.}
\label{tbl01}
\begin{tabular}{lll}
\toprule 
A & B & C \\
\arrayrulecolor[gray]{.7}
\midrule
D & E & F \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

When compiling, the following error is met:

[ERROR]   htlatex: Compilation errors in the htlatex run
[ERROR]   htlatex: Filename Line    Message
[ERROR]   htlatex: ?    11   Misplaced \noalign.
[ERROR]   htlatex: ?    12   Missing } inserted.
[ERROR]   htlatex: ?    12   Missing \endgroup inserted.

And in the log file we have:

! Misplaced \noalign.
\n:midrule: ->\o:noalign:
                          {\ifnum 0=`}\fi \let \cur:rule \a:midrule \gobble:...
l.11 \midrule

Is it possible to fix or avoid this error, still using \arrayrulecolor to change the color of rules in tables?

Best Answer

I think you may have an older version of TeX4ht, I don't get any compilation error. I don't get colored rules either, but this is easy to fix. TeX4ht saves the current rule color, but the old configuration for Booktabs didn't use this information. I've just updated TeX4ht sources to use it, so it will work out of the box soon, if you update your TeX distribution.

You can use it right not with this configuration file:

\Preamble{xhtml}


\makeatletter
\catcode`\:=11
\def\hline:color{000}
\Configure{toprule}
   {\@thisrulewidth=\csname a:rule-mag\endcsname\@thisrulewidth
%
    \Css{tr\#TBL-\TableNo-\ifnum \HRow=0
          1- {border-top:\expandafter\x:Em \the\@thisrulewidth em
 solid \#\hline:color;}
     \else
          \HRow- {border-bottom:\expandafter\x:Em \the\@thisrulewidth em
 solid \#\hline:color;}
     \fi
   }}
\Configure{bottomrule}
   {\@thisrulewidth=\csname a:rule-mag\endcsname\@thisrulewidth
%
    \Css{tr\#TBL-\TableNo-\HRow-
            {border-bottom:\expandafter\x:Em \the\@thisrulewidth em
 solid  \#\hline:color}}}
\Configure{midrule}
   {\@thisrulewidth=\csname a:rule-mag\endcsname\@thisrulewidth
%
    \Css{tr\#TBL-\TableNo-\HRow-
            {border-bottom:\expandafter\x:Em \the\@thisrulewidth em
 solid \#\hline:color}}}
\Configure{cmidrule}
   {\@thisrulewidth=\csname a:rule-mag\endcsname\@thisrulewidth
%
    \Css{td\#TBL-\TableNo-\HRow-\HCol{border-bottom:\expandafter\x:Em \the\@thisrulewidth em
 solid \#\hline:color}}%
    \HCode{<span class="cmidrule"><!-- enable post-processing of cmidrule--></span>}}

\catcode`\:=12
\makeatother
\begin{document}
\EndPreamble

This configuration declares CSS code that is inserted for Booktabs rules. The rule color is saved in \hline:color. It is in the hexadecimal form suitable for CSS declarations.

This is the result:

enter image description here

Related Question