[tex4ht] How to use \newcommand to pass argument #n to tex4ht via direct HTML environment?

Nasser M. Abbasi nma at 12000.org
Wed Aug 13 09:44:35 CEST 2014


I found something about this problem, which is a clue to
what might be the problem.

First, I had missing \fi in my last post (I seem to have copied
a copy I was changing at the time). But this has nothing
to do with why it was not working. Adding the \fi to the last
example did nothing, same error.

What I found is that the following

    \ScriptEnv{html}..\begin{html}..\end{html}

can't be used at all Inside a \newcommand !

Here is a very simple example, that does not even use #2,
and it fails, by simply adding raw HTML.

--------------------------------------
\documentclass[12pt]{article}%
\usepackage{hyperref}

\ifdefined\HCode
\newcommand{\mySection}[1]
{
\section{#1}%

\ScriptEnv{html}
     {\NoFonts\hfill\break}
     {\EndNoFonts}
    
    \begin{html}
       test
    \end{html}
}
\fi

\begin{document}
\mySection{some text}
\end{document}
-------------------------------------

(/usr/local/texlive/2014/texmf-dist/tex/generic/tex4ht/html4-math.4ht))
(./pass_string.aux))
Runaway argument?
  test \end {html} ^^M\end{document}^^M
! File ended while scanning use of \:temp.
<inserted text>
                 \par
<*> ...tother\HCode .a.b.c.\input  pass_string.tex

If this is the case, any other suggestion how to
insert raw HTML inside a \newcommand? Is it possible?  Again, I need
to generate some repetitive raw HTML code that changes by one
string each time, and the idea is to pass this as parameter
to \newcommand and make it do all the work.

thanks,
--Nasser

On 8/13/2014 12:57 AM, Nasser M. Abbasi wrote:
> \documentclass[12pt]{article}%
> \usepackage{hyperref}
> \newcommand{\mySection}[2]
> {
> \section{#1}
> \ifdefined\HCode
> \ScriptEnv{html}
>      {\NoFonts\hfill\break}
>      {\EndNoFonts}
>
>     \begin{html}
>        <a href="#2/index.htm"> mylink </a>  %-->problem here
>     \end{html}
> }
> \begin{document}
> \mySection{Wave equation}{folderA}
> \end{document}



More information about the tex4ht mailing list