[l2h] problems with renewenvironment

Ross Moore ross@ics.mq.edu.au
Sat, 19 Jan 2002 10:13:19 +1100 (EST)


> Hi there,
> 
> I have interesting problems when redefining environments. latex2html
> won't convert the following small document:
> 
> --- 8< ---
> 
> \documentclass{article}
> \usepackage{graphicx}
> 
> \newcommand{\cmda}[1]{bla #1}
> \newcommand{\cmdb}[1]{\emph{#1}}
> \newenvironment{enva}{\renewcommand{\cmda}{\cmdb}}{}
> 
> \begin{document}
> 
> \begin{enva}
> asdf \cmdb{asdf}
> \end{enva}
> 
> asfdf
> \includegraphics[]{test.eps}
> asdf
> 
> \end{document}

Yes. LaTeX2HTML's expansion model is different to that of TeX,
so the environment definition:

 \newenvironment{enva}{\renewcommand{\cmda}{\cmdb}}{}

does not work.

There are actually 2 problems.

The first is semantics only;
you should use a syntax of:

\newenvironment{enva}{\renewcommand{\cmda}[1]{\cmdb{##1}}}{}

else you'll run into difficulties because the intended
argument for \cmda  will become separated from the command-name.
In fact it may be even worse than that, since the processing
of the \cmdb in the expansion will try to pick up an argument
too soon.

Also, the \cmda  will have been substituted *before* the
\newenvironment is processed. This leads to...

> --- 8< ---
> 
> It stops at the image conversion and mumbles about a missing '}':
> 
> --- 8< ---
> 
> ...
> 
> \Gin@req@height=\dimen103
> \Gin@req@width=\dimen104
> ))
> Runaway argument?
> {\renewcommand {\bla }{\emph {}{} \par \usepackage [dvips]{color} \par \ETC.

 ... see how the \renewcommand is of \bla  and not of \cmda

This is the cause of your document failing at this point.
In fact, there will be other errors sooner, but these are not
such as to stop the processing.


> ! File ended while scanning use of \@newenv.
> <inserted text> 
>                 \par 
> <*> ./images.tex
>                 
> I suspect you have forgotten a `}', causing me
> to read past where you wanted me to stop.
> ...

The change in syntax suggested above cures this problem.
However, the redefinition of \cmda  never happens. 


> 
> I'm running LaTeX2HTML Version 99.2beta8 (1.43) on SuSE Linux 7.3.

The kind of automatic redefinition that you are trying to use
is not compatible with the way LaTeX2HTML works at present
(nor at any time in the past).

Sorry about that.
It's a tricky programming problem that needs to be addressed further.



> 
> Any ideas why this is happening?
> 
> Thanks for your help,


Hope this helps,

	Ross Moore

>   Gregor
> 
> 
> _______________________________________________
> latex2html mailing list
> latex2html@tug.org
> http://tug.org/mailman/listinfo/latex2html