[tex4ht] Missing Colors when generating HTML

Kevin Erath Mindcry2000 at gmx.de
Tue Dec 28 17:28:15 CET 2010


Hello Radhakrishnan,

thank you for the fast response!
Your quick fix works with simple \color commands.
I found out, that alternatively the command \textcolor also works.

Though i still have a problem with the coloring, as i also use
the lstlisting command to show various code listings with color
highlighting. Unfortunately the listings package seems not to
work with color support too.

For example listings with the following configuration, are still
shown in black&white instead of green on black:
\lstdefinelanguage{Test}
{
  basicstyle=\ttfamily\color{green},
  backgroundcolor=\color{black},
}

Maybe you have a solution for this too.

Regards,

Kevin

-------- Original-Nachricht --------
> Datum: Tue, 28 Dec 2010 18:44:52 +0530
> Von: CV Radhakrishnan <cvr at river-valley.org>
> An: Kevin Erath <Mindcry2000 at gmx.de>
> CC: tex4ht at tug.org
> Betreff: Re: [tex4ht] Missing Colors when generating HTML

> 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.

-- 
Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!  
Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail


More information about the tex4ht mailing list