[tex4ht] is it possible to define a Latex environment, where one can issue direct HTML code in it for tex4ht only?

Nasser M. Abbasi nma at 12000.org
Tue Jun 14 10:33:07 CEST 2016

On 6/10/2016 3:53 AM, Michal Hoftich wrote:
> ""Nasser,
> this is of course typical example of case when you should put your
> macros to .sty file and redefinitions for tex4ht into .4ht file.

Thanks to the pointer above by Michal, I made some progress
with the above method. Now using tex4ht, it generates code
which uses javascript library for code syntax formatting,
which I think looks better than using listings package
to HTML as I was doing before, since the support was limited
there in HTML.

Here is a page for example which uses this new method:


All of the above is done from same Latex source code, which
produces pdf and HTML, the code syntax formatting uses a
small javascript file called syntax highlighter 3.0.8.

The nice thing, is that I can change the javascript library
for formatting, as there are others to try, without changing
the Latex code itself in the main file, since the API is now
hidden inside the .4ht file. One now just make small change
on .4ht file and recompile the Latex file.

The only issue is that \ScriptEnv does not accept arguments,
which means for each different language, new environment is
needed, and for each font size, new environment is needed,
since one can't pass these are parameters, as one could
with standard Latex environments. I posted a question
on this here


But at least, this method is working so far and I am
still learning more how to use it.


More information about the tex4ht mailing list