Hi Hans,

On 25/10/2004, at 8:45 PM, Hans Fangohr wrote:

Hi Ross,

many thanks for your detailed answer.

So you could do:

 1.  place the following coding in the preamble:

%begin{latexonly}
\lstnewenvironment{myverbatim}{}{}
%end{latexonly}

2.  change all of your usages of:
\begin{lstlisting}  to  \begin{myverbatim}
\end{lstlisting}  to  \end{myverbatim}


One problem with this solution is that an optional
argument to the listing environment is not recognised
as such by LaTeX2HTML. There's no simple way to overcome
this without some edits to the coding of the 'texexpand'
and 'latex2html' Perl scripts.

That is not too bad as there is a command to set the listings environment separately (\lstset{}) [and kind of globally].

OK; but don't forget to surround it with special comments:

%begin{latexonly}
 \lstset{.....}
%end{latexonly}

This tells LaTeX2HTML to ignore the contents completely,
but otherwise LaTeX just ignores the comments, as usual.



However, maybe you want the HTML to be an image of the
environment that LaTeX would produce, as at present
where the {lstlisting} environment is treated as being
*unknown*.

In that case, best would be to write a short Perl
subroutine, named  do_env_lstlisting  as follows.


sub do_env_lstlisting { local ($_) = @_; my $env_id = ++$global{'max_id'}; $_ =~ s/\\par/\n\n/g; &process_undefined_environment('lstlisting', $env_id, $_); }


This could be placed in an initialization file,
Done that.

Unfortunately, there is an error message and I am not very good at
Perl. Can you see what is going on:

[EMAIL PROTECTED] sesa2006 $ latex2html partestorg.tex
Note: Loading /home/fangohr/.latex2html-init
/home/fangohr/.latex2html-init did not return a true value at /usr/lib/latex2html/latex2html.pl line 162.
Compilation failed in require at /usr/bin/latex2html line 39.


where this is the content of /home/fangohr/.latex2html-init:

sub do_env_lstlisting {
        local ($_) = @_;
        my $env_id = ++$global{'max_id'};
        $_ =~ s/\\par/\n\n/g;
        &process_undefined_environment('lstlisting', $env_id, $_);
}

Just end the file with a line:

 1;


That's all you need, since 1 returns 1 (= true) as the last statement evaluated.


Hmm. That \n\n  replacement may not work under DOS/Windows,
where the line-ending character is different.
No probs, want to run this on Linux.


Ouch; that's a pretty nasty kind of hack --- clever, mind you!
--- and it only works for an image as output.
Correct on all accounts: ugly and works for image only.

:-)


Cheers,

Hans


Hope this helps,

        Ross



_______________________________________________ latex2html mailing list [EMAIL PROTECTED] http://tug.org/mailman/listinfo/latex2html

------------------------------------------------------------------------
Ross Moore                                         [EMAIL PROTECTED]
Mathematics Department                             office: E7A-419
Macquarie University                               tel: +61 +2 9850 8955
Sydney, Australia                                  fax: +61 +2 9850 8114
------------------------------------------------------------------------

_______________________________________________
latex2html mailing list
[EMAIL PROTECTED]
http://tug.org/mailman/listinfo/latex2html

Reply via email to