# How to put a whole part of generated HTML from htlatex in a special div?

Using TeX files, I generate two pdf deliverables and one website from the same source.

I generate my html using htxelatex and a config file like that has the following:

\Css { .tableofcontents {
float:left;
top:20px;
width:30%;
background:#eee;
font-size:1em;
}
}
\Css { .container {
float:left;
top:20px;
width:65\%;
height:1024px;
}
}


This what I just add the following to my generated HTML using scripting

<div class="container">
<--! The whole tex code except the tableofcontents -->
</div>


And now I have a gorgeous HTML with the table of contents on one half of the screen and the content on the other one.

It works I was just wondering if there is a way to add the whole body in the div automatically from the config file somehow. When I generate the html, the tableofcontents is inside the body so I can't use body object

You need to solve three problems:

1. Contents heading is outside the .tableofcontents div, so it doesn't float together

2. Add <div class="container"> after \tableofcontents

3. Add closing </div> before <body> element

First two of them are pretty easy to solve with config file like this:

\edef\hash{\string#}
\Preamble{xhtml}

\Configure{tableofcontents}
{\IgnorePar\EndP\HCode{</div><div class="container">}\ShowPar}
{\HCode{<br />}}   {}

\Css { .tableofcontents{
float:left;
top:20px;
width:30\%;
background:\hash eee;
font-size:1em;
}
}
\Css { .container {
float:left;
top:20px;
width:65\%;
height:1024px;
}
}
\begin{document}
\let\contentsname=\empty
\EndPreamble


With \let\contentsname=\empty you suppress printing the contents title, which is then printed inside .tableofcontents div. I copied \Configure{tableofcontents} from html4.4ht file and just added <h3 class="likesectionHead">Contents</h3> and <div class="container"> into right places.

Also note that I modified your css instructions, characters % and # need to be escaped.

Last task is the hardest. You can use \Configure{BODY}{body start}{body end} to insert closing </div>, but if you look at configurations of BODY in html4.4ht file, you can see that lot of things happens there and you may break something, if you just use \Configure{BODY}{\HCode{<body>}}{\HCode{</div></body>}}. I suggest to postprocess the html file with tidy command:

tidy -m -utf8 filename.html


For sample document:

\documentclass{article}
\begin{document}
\tableofcontents

\section{Intro}

Just try some random paragraph

\section{Some environments}

\subsection{verbatim}

\begin{verbatim}
echo "verbatim"
\end{verbatim}

\subsection{quotation}
\begin{quotation}
hello from quotation
\end{quotation}
\end{document}