[tex4ht] Missing Colors when generating HTML

CV Radhakrishnan cvr at river-valley.org
Thu Dec 30 05:18:44 CET 2010

On 28/12/10 9:58 PM, Kevin Erath wrote:
> 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.

Generally, colors shall be brought into HTML page with the help of css
which is much more easier and also elegant way to do. You might prefer
to have a small *.cfg (TeX4ht configuration file that has your custom
setup for your documents, a bit like a LaTeX style file) in which you
might provide various custom css declarations that will eventually be
written out to your \jobname.css while generating html. Of course, for
simple \color or \textcolor for random text strings, the configuration
I had given in the previous mail will help.

> 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}, }

The following \Css code can solve your problem:

\Css{div.lstlisting{font-family: monospace;
    white-space: nowrap; margin-top:0.5em;
    color: green ;
    background-color: black;}}

> Maybe you have a solution for this too.

I have attached to this mail a specimen configuration, kevin.cfg which
shows you how to write one for your custom needs. Once you have a
*.cfg with custom setup, the invocation of TeX4ht shall be:

  htlatex <file> kevin

  (htlatex <your LaTeX file with/without extension> <configuration>)

Also attached are the TeX sources, pdf and html outputs. The advantage
of configuration is that your source file remains clean without any
TeX4ht specific stuff which allows seamless compilation with pdflatex
for pdf output.

If you are using GNU/Linux or similar OS, you might make use of a
Makefile with different targets for various outputs which makes the
process all the more enjoyable.

Best regards

Celibacy is not hereditary.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kevin.pdf
Type: application/pdf
Size: 19419 bytes
Desc: not available
URL: <http://tug.org/pipermail/tex4ht/attachments/20101230/7b973e56/attachment-0001.pdf>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kevin.tex
Type: application/x-tex
Size: 458 bytes
Desc: not available
URL: <http://tug.org/pipermail/tex4ht/attachments/20101230/7b973e56/attachment-0001.tex>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/tex4ht/attachments/20101230/7b973e56/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kevin.css
Type: text/css
Size: 6044 bytes
Desc: not available
URL: <http://tug.org/pipermail/tex4ht/attachments/20101230/7b973e56/attachment-0001.css>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: kevin.cfg
URL: <http://tug.org/pipermail/tex4ht/attachments/20101230/7b973e56/attachment-0001.ksh>

More information about the tex4ht mailing list