[tex4ht] How to insert HTML code at any location in the generated HTML file?

Michal Hoftich michal.h21 at gmail.com
Wed Jul 10 13:14:58 CEST 2013


Correct way is to not insert any HTML code to the document, but
instead redefine ordinary LaTeX commands to insert html codes in .4ht
files.

If you really want to insert HTML code directly, you can define
command which will eat arguments in normally LaTeX run and insert
\HCode with tex4ht. Like this (untested, just an idea):

\documentclass{article}
\ifdefined\HCode
\newcommand\html[1]{%
\HCode{#1}%
}%
\else
\newcommand\html[1]{}%
\fi
\begin{document}
\html{<div class="hello>world</div>}
\end{document}

Regards,
Michal

2013/7/10 Nasser M. Abbasi <nma at 12000.org>:
> I am converting a latex document that I used to compile with
> latex2html to htlatex.
>
> With latex2html, I used to do this to insert raw HTML code
> any where:
>
> --------------------------------
> \documentclass{article}
> \usepackage{html}
> \begin{document}
> \begin{rawhtml}
>    any HTML code here
>
> \end{rawhtml}
> \end{document}
> -------------------------
>
> So I changed the above to
>
> --------------------------------
> \documentclass{article}
> \begin{document}
>
> \HCode{
>
> any HTML code here
> }
>
> \end{document}
> --------------------------------
>
> but I get an error:
>
> --------------------------
> htlatex foo.tex
> (./foo.aux)
> Runaway argument?
> {
> ! Paragraph ended before \HCode was complete.
> <to be read again>
>                    \par
> l.5
>     ?
> -----------------------------
>
> What is the correct way to insert HTML code any where in
> the document, and have it show at that location in the HTML
> file? I have very large amount of HTML code that was inserted in
> that document.
>
> Using TL 2013 on linux mint.
>
> thanks,
> --Nasser
>
>
>


More information about the tex4ht mailing list