[l2h] Re: getting \par in graphical output of listings environment

Hans Fangohr H.FANGOHR at soton.ac.uk
Fri Oct 22 18:03:28 CEST 2004


In the absence of any replies that would solve my problem I will
report an ugly hack which allows me to do what I need to do. (But it
is far from being good.)

The trick to produce an empty line which should not appear as '\par'
in latex2html's graphical output is to print something invisible in
that line, for example a white word on white background. You can
achieve this as follows:

\documentclass{article}

\usepackage{listings}
\usepackage{color}
\lstset{backgroundcolor=\color{white},frame=single,emph={EMPTY},emphstyle=\color{white},}

\begin{document}

\begin{lstlisting}
print ``Hello World!''
EMPTY
print ``Done''
\end{lstlisting}
\end{document}



Note that the DVI output of this looks ugly (black boxes) but the PS
is okay (that is because the color-package does color using post
script commands so it is not expected to work for the dvi files).

Note also that the backgroundcolor for the listings environment has to
be set: listings seems to be quite clever and changes the background
to gray if you try to print something in white.


If anyone comes along a decent fix for this problem, please let me know.

Thanks,

Hans




On Thu, 21 Oct 2004, Hans Fangohr wrote:

> Dear all,
>
> I am trying to use html2latex on this document:
>
> %--------------------------------------------------
> \documentclass{article}
>
> \usepackage{listings}
>
> \begin{document}
> \begin{lstlisting}[frame=single]
> print "Hello World"
>
> print "Done"
> \end{lstlisting}
> \end{document}
> %--------------------------------------------------
>
> The graphical output (embedded in the html page) for the lstlisting
> environment reads
>
> print "Hello World"
> \par
> print "Done"
>
>
> All is working great APART from that I get this "\par" for every empty
> line in the listings environment.
>
> I have scanned the archives but couldn't find any answer (although the
> problem was reported in a more complicated context before:
> http://www.tug.org/pipermail/latex2html/2002-October/002106.html)
>
>
> Many thanks for your help,
>
> Hans
>
>
>



More information about the latex2html mailing list