1

It seems to be a problem still not solved (related to question 311689 and 73508). The usage of colortbl package with tex4ht causes the error: Misplaced \noalign.

Here is a short example to reproduce the error:

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{colortbl}
\begin{document}
\begin{tabular}{ll}
\arrayrulecolor[gray]{.7}
\hline
test & 1 \\
test & 2 \\
\arrayrulecolor{black}
\hline
\end{tabular}
\end{document}

In the .log file I got:

! Misplaced \noalign.
\a:hline ->\ifx \ar:cnt \:UnDef \else \o:noalign: 
                                                  {\append:def \hline:s {\a:...
l.7 \hline
    

I've also tried to define a .cfg file to make the command \arrayrulecolor do nothing:

\Preamble{xhtml}
\renewcommand\arrayrulecolor[2][1]{\ignorespaces}
\begin{document}
\EndPreamble

Unfortunately it also did not work.

1 Answer 1

2

Try this .cfg file:

\Preamble{xhtml}
\makeatletter
\catcode`\:=11
% default hline color is black
\def\hline:color{fff}
% redefine default table configuration and put the color rule 
\def\a:HBorder{<tr class="hline" style="border-top:1px solid \#\hline:color">}
% get the rule color and convert it to a CSS definition stored in \hline:color
\newcommand\tmp:arrayrulecolor[2][named]{\noalign{\convertcolorspec{#1}{#2}{HTML}\:tmp\global\let\hline:color\:tmp}}
% use \HLet to support picture tables
\HLet\arrayrulecolor\tmp:arrayrulecolor
% don't display <hr> elements in this \hline
\Css{tr.hline td hr{display:none}}
\catcode`\:=12
\makeatother
\begin{document}
\EndPreamble

The issue you had with your redefinition is that it needs to use the \noalign command. In this config file, we use it to covert the color definition to CSS format and save it in \hline:color macro. It can be then used to insert the color definition in the HTML file.

We don't redefine \arrayrulecolor directly, but using temporary macro and \HLet command. This method will keep the original macro and call it inside \Picture command. This is necessary for the pic-tabular option, which turns tables into pictures.

The \a:HBorder macro inserts code for hline rows. We use the saved color to insert CSS code that colors border.

Your gray \hline then looks like this:

<tr class='hline' style='border-top:1px solid #B2B2B2'>

And it is rendered in this way:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .