I've been producing PDFs and HTML from Latex sources, using tex4ht for the HTML (I'm on Debian/Lenny; so whatever versions are default on that). I'm using the listings package to include source code.

I'm very happy with the "look" of the PDF, but the HTML looks a bit dreary without the code colouring or "blocked" listing headers.

Is there some way of getting the HTML to include more of the listings styling ? (I'm not wedded to tex4ht if there are alternatives which do the job better).


You can get the effects you want by adding this to the HTML's stylesheet (Yay Firebug!):

div.lstinputlisting table.caption {
    background: #c0c0c0;
    color: white;
    font-family: sans-serif;
    padding-right: 100%;
div.lstinputlisting .pcrro7t- {
    color: red;

The tex4ht page says you can achieve this by putting this into a config file:

  \Css{ // everything from above } 

From there I'll cross my fingers and hope you know or can figure out how to call the right tex4ht command and use that config file. tex4ht syntax is a little weird but see the linked page for examples.

  • Thanks, that does the job nicely; new versions uploaded. The '%' needed escaping in the .cfg file, and the '#' seemed to be causing trouble too but I used CSS colour names instead. – timday Dec 17 '10 at 0:19
  • @timday: that looks very nice! – Matthew Leingang Dec 17 '10 at 1:50

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.