On 28/12/10 9:58 PM, Kevin Erath wrote:
> Hello Radhakrishnan,
> 
> thank you for the fast response! Your quick fix works with simple

Welcome.

> \color commands. I found out, that alternatively the command
> \textcolor also works.

OK.

> 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;
    margin-bottom: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
-- 
Radhakrishnan

Celibacy is not hereditary.

Attachment: kevin.pdf
Description: Adobe PDF document

Attachment: kevin.tex
Description: TeX document

1 Test!

Hello black, red and blue.

  for i:=maxint to 0 
    do begin 
     { do nothing } 
  end; 
  Write(Case insensitive ); 
  WritE(Pascal keywords.);
 
/* start css.sty */
.cmtt-10{font-family: monospace;}
.cmbx-10{ font-weight: bold;}
p.noindent { text-indent: 0em }
td p.noindent { text-indent: 0em; margin-top:0em; }
p.nopar { text-indent: 0em; }
p.indent{ text-indent: 1.5em }
@media print {div.crosslinks {visibility:hidden;}}
a img { border-top: 0; border-left: 0; border-right: 0; }
center { margin-top:1em; margin-bottom:1em; }
td center { margin-top:0em; margin-bottom:0em; }
.Canvas { position:relative; }
img.math{vertical-align:middle;}
li p.indent { text-indent: 0em }
li p:first-child{ margin-top:0em; }
li p:last-child, li div:last-child { margin-bottom:0.5em; }
li p~ul:last-child, li p~ol:last-child{ margin-bottom:0.5em; }
.enumerate1 {list-style-type:decimal;}
.enumerate2 {list-style-type:lower-alpha;}
.enumerate3 {list-style-type:lower-roman;}
.enumerate4 {list-style-type:upper-alpha;}
div.newtheorem { margin-bottom: 2em; margin-top: 2em;}
.obeylines-h,.obeylines-v {white-space: nowrap; }
div.obeylines-v p { margin-top:0; margin-bottom:0; }
.overline{ text-decoration:overline; }
.overline img{ border-top: 1px solid black; }
td.displaylines {text-align:center; white-space:nowrap;}
.centerline {text-align:center;}
.rightline {text-align:right;}
div.verbatim {font-family: monospace; white-space: nowrap; text-align:left; clear:both; }
.fbox {padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; }
div.fbox {display:table}
div.center div.fbox {text-align:center; clear:both; padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; }
div.minipage{width:100%;}
div.center, div.center div.center {text-align: center; margin-left:1em; margin-right:1em;}
div.center div {text-align: left;}
div.flushright, div.flushright div.flushright {text-align: right;}
div.flushright div {text-align: left;}
div.flushleft {text-align: left;}
.underline{ text-decoration:underline; }
.underline img{ border-bottom: 1px solid black; margin-bottom:1pt; }
.framebox-c, .framebox-l, .framebox-r { padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; }
.framebox-c {text-align:center;}
.framebox-l {text-align:left;}
.framebox-r {text-align:right;}
span.thank-mark{ vertical-align: super }
span.footnote-mark sup.textsuperscript, span.footnote-mark a sup.textsuperscript{ font-size:80%; }
div.tabular, div.center div.tabular {text-align: center; margin-top:0.5em; margin-bottom:0.5em; }
table.tabular td p{margin-top:0em;}
table.tabular {margin-left: auto; margin-right: auto;}
td p:first-child{ margin-top:0em; }
td p:last-child{ margin-bottom:0em; }
div.td00{ margin-left:0pt; margin-right:0pt; }
div.td01{ margin-left:0pt; margin-right:5pt; }
div.td10{ margin-left:5pt; margin-right:0pt; }
div.td11{ margin-left:5pt; margin-right:5pt; }
table[rules] {border-left:solid black 0.4pt; border-right:solid black 0.4pt; }
td.td00{ padding-left:0pt; padding-right:0pt; }
td.td01{ padding-left:0pt; padding-right:5pt; }
td.td10{ padding-left:5pt; padding-right:0pt; }
td.td11{ padding-left:5pt; padding-right:5pt; }
table[rules] {border-left:solid black 0.4pt; border-right:solid black 0.4pt; }
.hline hr, .cline hr{ height : 1px; margin:0px; }
.tabbing-right {text-align:right;}
span.TEX {letter-spacing: -0.125em; }
span.TEX span.E{ position:relative;top:0.5ex;left:-0.0417em;}
a span.TEX span.E {text-decoration: none; }
span.LATEX span.A{ position:relative; top:-0.5ex; left:-0.4em; font-size:85%;}
span.LATEX span.TEX{ position:relative; left: -0.4em; }
div.float, div.figure {margin-left: auto; margin-right: auto;}
div.float img {text-align:center;}
div.figure img {text-align:center;}
.marginpar {width:20%; float:right; text-align:left; margin-left:auto; margin-top:0.5em; font-size:85%; text-decoration:underline;}
.marginpar p{margin-top:0.4em; margin-bottom:0.4em;}
table.equation {width:100%;}
.equation td{text-align:center; }
td.equation { margin-top:1em; margin-bottom:1em; } 
td.equation-label { width:5%; text-align:center; }
td.eqnarray4 { width:5%; white-space: normal; }
td.eqnarray2 { width:5%; }
table.eqnarray-star, table.eqnarray {width:100%;}
div.eqnarray{text-align:center;}
div.array {text-align:center;}
div.pmatrix {text-align:center;}
table.pmatrix {width:100%;}
span.pmatrix img{vertical-align:middle;}
div.pmatrix {text-align:center;}
table.pmatrix {width:100%;}
span.bar-css {text-decoration:overline;}
img.cdots{vertical-align:middle;}
.partToc a, .partToc, .likepartToc a, .likepartToc {line-height: 200%; font-weight:bold; font-size:110%;}
.index-item, .index-subitem, .index-subsubitem {display:block}
div.caption {text-indent:-2em; margin-left:3em; margin-right:1em; text-align:left;}
div.caption span.id{font-weight: bold; white-space: nowrap; }
h1.partHead{text-align: center}
p.bibitem { text-indent: -2em; margin-left: 2em; margin-top:0.6em; margin-bottom:0.6em; }
p.bibitem-p { text-indent: 0em; margin-left: 2em; margin-top:0.6em; margin-bottom:0.6em; }
.paragraphHead, .likeparagraphHead { margin-top:2em; font-weight: bold;}
.subparagraphHead, .likesubparagraphHead { font-weight: bold;}
.quote {margin-bottom:0.25em; margin-top:0.25em; margin-left:1em; margin-right:1em; text-align:justify;}
.verse{white-space:nowrap; margin-left:2em}
div.maketitle {text-align:center;}
h2.titleHead{text-align:center;}
div.maketitle{ margin-bottom: 2em; }
div.author, div.date {text-align:center;}
div.thanks{text-align:left; margin-left:10%; font-size:85%; font-style:italic; }
div.author{white-space: nowrap;}
.quotation {margin-bottom:0.25em; margin-top:0.25em; margin-left:1em; }
.abstract p {margin-left:5%; margin-right:5%;}
div.abstract {width:100%;}
.lstlisting .label{margin-right:0.5em; }
div.lstlisting{font-family: monospace; white-space: nowrap; margin-top:0.5em; margin-bottom:0.5em; }
div.lstinputlisting{ font-family: monospace; white-space: nowrap; }
.lstinputlisting .label{margin-right:0.5em;}
div.lstlisting{font-family: monospace; white-space: nowrap; margin-top:0.5em; margin-bottom:0.5em; color: green ; background-color: black;}
/* end css.sty */

%
% kevin.cfg
%
% Custom configuration file for running Kevin's documents.
% The invocation shall be:
%
% htlatex <file> kevin.cfg
%
%

\makeatletter
\catcode`\:=11

\Preamble{xhtml,info}

\begin{document}

\EndPreamble

 \let\savecolor\color
 \newconfigure{color}[2]{\de...@color{#1}\def\b@color{#2}}
 \def\@@tmp#1...@color#1\b@color\savecolor{#1}\aftergroup\endspan}
 \let\color\@@tmp
 \def\endspan{\Tg</span>}
 \Configure{color}{\HCode{<span style="color:}}{\HCode{">}}

\ConfigureEnv{lstlisting}
   {\let\color\savecolor
    \ifvmode \IgnorePar\fi \EndP
    \gHAdvance\listingN by 1
    \HCode{<!--l. \the\inputlineno-->}%
    \gdef\start:LstLn{\HCode{<div class="lstlisting" id="listing-\listingN">}%
      \gdef\start:lstln{\leavevmode\special{t...@+\string&{35}x00A0{59}}x%
    \HCode{<br />}}}
    \bgroup
       \Configure{listings}
         {{\everypar{}\leavevmode}}
         {{\everypar{}\leavevmode}}
         {\start:LstLn \HCode{<span class="label">}}
         {\HCode{</span>}}%
   }
   {\egroup
    \ifvmode \IgnorePar\fi \EndP \HCode{</div>}\par}
   {}{}


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

\catcode`\:=12
\makeatother

\endinput

%
% End of file 'kevin.cfg'
% 

Reply via email to