[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 07:57:39 CEST 2014


I am trying to make a newcommand to generate some
repetitive HTML code that I generate in latex using
the \ScriptEnv{html}...\begin{html}...\end{html}

I have to use pure HTML code fragments since the code
I want to generate can't be build in latex. For
illustration, I show a simple example below using
href= for now. (which ofcourse can be done in Latex using
\href{} but this is an example. The actual HTML I want
to generate uses <video> tag, but similar concept.

First, the example I am trying to compile:

--------------------------------------------
\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}
---------------------------------

When I type htlatex pass_string.tex, I get error

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

How do I pass the second argument #2 to HTML as shown
above? Why is the error coming from html4-math ? There is
no math at all in the above?

The equivalent latex code works with no problem:

--------------------------------------
\documentclass[12pt]{article}%
\usepackage{hyperref}
\newcommand{\mySection}[2]
{
\section{#1}
\href{#2/index.htm}{my link}
}%
\begin{document}
\mySection{Wave equation}{folderA}
\end{document}
----------------------------

It seems there needs a way to pass #1,#2.. to HTML
different from the direct way done above. But how?

thank you,
--Nasser


More information about the tex4ht mailing list