1

texlive 2014 on Linux mint 17.

This MWE does not generate a table of contents in the HTML file generated by htlatex

\documentclass{article}
\usepackage{tocloft}  %if this line is commented, then toc will show up
\begin{document}
\tableofcontents
  \section{sec1}
  some text 1
  \section{sec2}
  some text 2
\end{document}

if tocloft is not used, then toc will show up in html.

command to compile is

htlatex foo.tex

Then view the file foo.html in same folder to see the missing toc.

This came up when I was trying to change the font size of the toc and used this package, which works ok with pdflatex, then noticed the toc is missing in the HTML file.

1

Both tex4ht and tocloft redefine table of contents mechanism, so they clash each other. Because you can't use tocloft settings with tex4ht anyway, it is best to to disable tocloft. From fast look at tocloft source code, it seems that we can use \if@cftnctoc conditional for this purpose, when set to true, no redefinitions take place. Fortunately, all redefinitions are done in \AtBeginDocument commands, which seems is time when .4ht files are loaded. So, we can introduce tocloft.4ht file, with really simple contents:

\@cftnctoctrue
\endinput

Value of \if@cftnctoc is set to true. This file is loaded before tocloft redefinition commands check for value of \if@cftnctoc, so no redefinitions take place.

enter image description here

  • Thanks Michal. Ok, Will enter this a low priority bug in tex4ht database so it does not get lost. Thanks. – Nasser Jul 11 '14 at 9:39

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.