[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
Fri Jun 10 08:11:25 CEST 2016

I am struggling with this. I need to be able to define
an environment, where when Latex file is compiled to HTML
does one thing, and when compiled to pdf does another thing.

This sounds easy enough. The problem is it is for code
listing. For pdf, I can use listing package no problem.

For HTML, I'd like to use special HTML code to make
the code more customized for HTML. The problem is
that one can't define an environment for verbatim
or listing content. So I am stuck. Here is a small
example which shows what I mean:



The above compiled ok to pdf, but ofcourse it gives
error with tex4ht

! Undefined control sequence.
<argument> <\PRE
l.19 \end{code}

I used PRE above just an example. If I can this method
to work, I wanted to use more complicate HTML code
there for the start of the environment, which uses
outside javascript library for code formatting, much
nicer than what I can get from standard listings.

Listings works ok for both html and pdf. I just wanted
to use direct HTML environment for the code listing
when compiling with tex4ht.

I could of course duplicate the code itself, and use

         my code here
         code here

But I am trying to avoid this.

If some one has any idea how to do this, that will be great.

I asked on this also at


Thank you,

More information about the tex4ht mailing list