Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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:

\Preamble{html} 
\begin{document} 
  \Css{ // everything from above } 
\EndPreamble  

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.

share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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