[tex4ht] Missing Colors when generating HTML

CV Radhakrishnan cvr at river-valley.org
Tue Dec 28 14:14:52 CET 2010


On 26/12/10 8:25 PM, Kevin Erath wrote:
> Hello,
> 
> i'm currently trying to create a HTML-Dokument from a Latex file. 
> Everything works fine, except that the generated HTML-File does not
> contain any colors. Take a look at the following test-file:
> 
> \documentclass{article}
> \usepackage{color}
> 
> \begin{document}
> \section{Test!}
> Hello {\bf black}, {\color{red}red} and {\color{blue}blue}.
> \end{document}
> 
> When i compile the file using "htlatex test" or alternatively using
> the command-sequence:

[...]

Here is a quick and dirty solution, don't know how far it is useful to
you. Anyway color.4ht needs a lot of rework, till then:

<-------- Begin kevin.tex ---------->

\documentclass{article}
\usepackage{color}

\begin{document}

\section{Test!}
\makeatletter
 \let\savecolor\color
 \NewConfigure{color}[2]{\def\a at color{#1}\def\b at color{#2}}
 \def\@@tmp#1{\a at color#1\b at color\savecolor{#1}\aftergroup\endspan}
 \let\color\@@tmp
 \def\endspan{\Tg</span>}
 \Configure{color}{\HCode{<span style="color:}}{\HCode{;">}}
\makeatother


 Hello {\bf black}, {\color{red}red} and {\color{blue}blue}.

\end{document}

<-------- End kevin.tex ---------->

Here is the output:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
  <title></title>
  <meta http-equiv="Content-Type" content=
  "text/html; charset=us-ascii">
  <meta name="generator" content=
  "TeX4ht (http://www.tug.org/tex4ht/)">
  <meta name="originator" content=
  "TeX4ht (http://www.tug.org/tex4ht/)">
  <!-- html -->
  <meta name="src" content="kevin.tex">
  <meta name="date" content="2010-12-28 18:34:00">
  <link rel="stylesheet" type="text/css" href="kevin.css">
</head>

<body>
  <h3 class="sectionHead"><span class="titlemark">1</span> <a id=
  "x1-10001" name="x1-10001"></a>Test!</h3><!--l. 16-->

  <p class="noindent">Hello <span class="cmbx-10">black</span>,
  <span style="color:red;">red</span> and <span style=
  "color:blue;">blue</span>.</p>
</body>
</html>

Best regards
-- 
Radhakrishnan

It takes longer to lose 'x' number of pounds than
to gain 'x' number of pounds.


More information about the tex4ht mailing list