3

When compiling the following example with htlatex:

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{colortbl}
\usepackage{amsmath}

\begin{document}
\[\begin{array}{|l|c|} \hline 1 & 2\\ \end{array}\]
\end{document}

with the following configuration file:

\Preamble{xhtml,mathml,-css,NoFonts,fn-in}
\Configure{VERSION}{}
\Configure{DOCTYPE}{\HCode{<!DOCTYPE html>\Hnewline}}
\Configure{HTML}{\HCode{<html>\Hnewline}}{\HCode{\Hnewline</html>}}
\begin{document}
\EndPreamble

it generates a html document containing the following MathML code for the array:

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block" >
  <mrow>
    <mtable  align="axis" style="border-right:solid 1px black;border-left:solid 1px black;" equalrows="false" columnlines="solid" equalcolumns="false" class="array">
      <tr class="hline">
        <td><hr /></td>
        <td><hr /></td>
      </tr>
      <mtr>
        <mtd class="array"  columnalign="left">
          <mn>1</mn>
          ...

The above MathML code is invalid because tr is not allowed in MathML. When commenting out \usepackage{colortbl} the following good output is generated:

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block" >
  <mrow>
    <mtable  align="axis" style="border-right:solid 1px black;border-left:solid 1px black;" equalrows="false" columnlines="solid" equalcolumns="false" class="array">
      <mtr class="hline">
        <mtd> <mo> ̲ </mo> </mtd>
        <mtd> <mo> ̲ </mo> </mtd>
      </mtr>
      <mtr>
        <mtd class="array"  columnalign="left">
          <mn>1</mn>
          ...

Is there something I can put in the configuration file which stops colortbl breaking arrays which are not using colortbl?

Furthermore in my latex file there are colored array, for example:

\[\begin{array}{|l|c|} \hline \cellcolor[gray]{.8} 1 & 2\\ \end{array}\]

Is there a way to make them generate valid html with the above configuration (xhtml,mathml,-css)?

2

It seems that this issue is caused by configuration for array package, it redefines the configuration for horizontal line in table, but it doesn't take into account MathML. I will fix this issue in the tex4ht sources, so it should show in TeXLive soon. In the meantime, you can try the following configuration file:

%\Preamble{xhtml,mathml,-css,NoFonts,fn-in}
\Preamble{xhtml,mathml,NoFonts,fn-in}
\Configure{VERSION}{}
\Configure{DOCTYPE}{\HCode{<!DOCTYPE html>\Hnewline}}
\Configure{HTML}{\HCode{<html>\Hnewline}}{\HCode{\Hnewline</html>}}
\catcode`\:=11
   \Configure{putHBorder}{
  \bgroup \ifmathml
\Configure{HBorder}
   {<\:MM tr\Hnewline
       \ifmathml \expandafter\mml:class\else class\fi="hline">}
   {\ifmathml<\a:mathml mtd><mo> \string&\#x0332; </mo></\a:mathml mtd>
\else
            <td><hr\xml:empty></td>\fi}
   {</\:MM tr>}
   {<\:MM tr\Hnewline
       \ifmathml \expandafter\mml:class\else class\fi ="cline">}
   {<\:MM td></\:MM td>}
   {\ifmathml<\a:mathml mtd><mo> \string&\#x0332; </mo></\a:mathml mtd>
\else
            <td><hr\xml:empty></td>\fi}
   {</\:MM tr>}
   {<\:MM tr\Hnewline
         \ifmathml \expandafter\mml:class\else  class\fi="vspace"
         style="font-size:\HBorderspace">}
   {<\:MM td\Hnewline>\ifmathml\else\string&\#x00A0;\fi
      </\:MM td>}
   {</\:MM tr>}
   \fi\HCode{\HBorder}\egroup}
\catcode`\:=12
\begin{document}
\EndPreamble

I've added configuration for addHBorder, which is used for hline handling. It configures HBorder configuration when it is used in the MathML mode. This configuration was copy-pasted from tex4ht sources. Note that it can't work properly without CSS, which is disabled in your configuration file. I've enabled it in order to show expected results.

For this sample file:

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{colortbl}
\usepackage{array}
\usepackage{amsmath}

\usepackage[table]{xcolor}

\definecolor{maroon}{cmyk}{0,0.87,0.68,0.32}

\begin{document}
\[\begin{array}{|l|c|} \hline 1 & 2\\ \end{array}\]


\[
\begin{array}{|l|cr}
  left1 & center1 & right1\\
  \hline
  d & e & f
\end{array} 
\]

\begin{tabular}{l|l}
  l & l\\
  \hline
  l & l\\
\end{tabular}

\noindent\begin{tabular}{|l|c|}
  \rowcolor{maroon}
  one & two \\
  \rowcolor{maroon!50}
  three & four \\
  \rowcolor{maroon!10}
  five & six
\end{tabular}

\end{document}

This is the result:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.