Hi Julius, It is very dangerous to use section-commands, such as \section , \subsection, \paragraph etc. within the expansion of macros redefined using \renewcommand .
The reason that the behaviour with \newcommand and \renewcommand is different is that every instance a command defined via \newcommand is replaced very early in the processing, *before* the document is broken into segments. On the other hand, when \renewcommand is used, the macro is not replaced early but instead "wrapped" to cause it to be replaced in sequence with environments and other "context-sensitive" macros. The difference is that if a command has been \renew'd once, then it may well be renew'd more than once; so it cannot be assumed to have a constant replacement throughout the whole document. (Note that the expansion model for LaTeX2HTML differs from that for TeX engines generally.) How does this affect sectioning commands ? Well, the document gets broken-up into pieces corresponding to the recognisable sections. Then each of these sections is processed (more or less independently) to make the individual HTML pages. For this to work with your \ksectionalt command, you need the replacements to have been made *before* the document is split into pieces -- this precludes the use of \renewcommand, as explained above. The correct coding for what you are trying to achieve is: \usepackage{html} % always load this with LaTeX2HTML documents %begin{latexonly} \newcommand{\ksectionalt}[4]{\section[#4]{#3}\chlabel{#1}\index{#2|textbf}} %end{latexonly} \begin{htmlonly} \newcommand{\ksectionalt}[4]{\section{#3}} \end{htmlonly} On Thu, 9 Oct 2003, Julius Smith wrote: > Oops - my "work around" does not really work around the problem. The > second newcommand is simply ignored. -- jos > > At 12:58 AM 10/9/2003 -0700, Julius Smith wrote: > >Here's an odd one: > > > >I have a macro I normally use for section headings defined as follows: > > > >\newcommand{\ksectionalt}[4]{\section[#4]{#3}\chlabel{#1}\index{#2|textbf}} > > > >In a particular document, I tried to override this with a simpler version > >as follows: > > > >... > >\renewcommand{\ksectionalt}[4]{\section{#3}} No -- don't do this! Your document only uses one expansion for \ksectionalt so just set it once --- using "conditional" environments to get different expansions with different processing engines. > >\begin{document} > >... > > > >It works for LaTeX, but not for l2h. While I see a message that Correct. To guarantee well-formed (and usually valid) HTML, the way macro definitions are handled by laTeX2HTML has significant differences from what (La)TeX does. > >ksectionalt has been redefined, it is not found at the end during section > >linking. I see the following in the WARNINGS file: > > > >Doing section links ...... > >... > >*** wrap_cmd_ksectionalt not defined, cannot wrap \ksectionalt This at least tells you that something isn't right. Wrapping would not work anyway, since after "splitting" you would get part of the wrapper in one segment, with the rest of it in the next segment. > > > > > >Changing "renewcommand" to "newcommand" in an htmlonly block works around Yes; for the reasons described above. > >the problem. ("providecommand" acts like renewcommand.) \providecommand should do nothing if \newcommand has occurred already. > > > >Julius Hope this helps, Ross Moore > > _____________________________ > Julius O. Smith III <[EMAIL PROTECTED]> > Assoc. Prof. of Music and (by courtesy) Electrical Engineering > CCRMA, Stanford University > http://www-ccrma.stanford.edu/~jos/ > > _______________________________________________ > latex2html mailing list > [EMAIL PROTECTED] > http://tug.org/mailman/listinfo/latex2html > _______________________________________________ latex2html mailing list [EMAIL PROTECTED] http://tug.org/mailman/listinfo/latex2html