I need to convert a Latex document to several HTML files. I'm using tex4ht for this. What I need next is to add some features to the web pages. I managed to add the needed extra elements in the head section by writing a .cfg file and adding lines like the following one.

\Configure{@HEAD}{\HCode{<meta charset="utf-8" />\Hnewline}}

Now I need to add the HTML code right after <body> and before </body> to wrap the content generated by tex4ht in some divs that the extra functionality to the web pages. How can I do that? Where can I find good documentation about tex4ht usage? Thanks!


You have two options for configuring <body> element, first one is Configure{BODY}{start}{end}, the second is \Configure{@BODY} and \Configure{@/BODY}. In your case it is better to use the second option, which is similar to \Configure{@HEAD}, because you can use it several times to add stuff after and before <body>.:


\Configure{@BODY}{\ifvmode\IgnorePar\fi\EndP\HCode{<article class="main">}}


this configuration produces:

   <article class="main">
document body

regarding documentation, besides documentation linked from tex4ht website, you can also browse literate sources of tex4ht, which are huge, most important are tex4ht-info, which contains some coments on particular configurations and tex4ht-html4 with configurations used in conversion to HTML

  • Thanks! This worked for me! I'll see the links you gave here. Thanks again! – Matteo Ipri Mar 3 '16 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.