# Suppress TOC in htlatex (compiling with htlatex fails with Undefined control sequence \TocTitle)?

Consider this MWE, test2.tex:

\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{times}
\usepackage[top=3cm,bottom=3cm,left=2cm,right=2cm,showframe]{geometry}
\usepackage{pgffor}
\usepackage[firstinits=true]{biblatex}
\bibliography{biblatex-examples}

\global\let\TocTitle\relax

\begin{document}
\global\let\TocTitle\relax

\section*{\centering Article Card}
\bigskip
\noindent The paper is:
\bigskip

\fullcite{murray}
\bigskip

\noindent The authors are:
\bigskip

\noindent%
\citeauthor{murray}

\end{document}


This compiles fine with latex test2.tex and pdflatex test2.tex; however, htlatex test2.tex fails with:

[1
! Undefined control sequence.
<write> ...dcsname{1}{x1-1000}{QQ2-1-1}{\TocTitle
}}{\folio }\relax
l.31 \end{document}


The weird thing, however, is that I explicitly define \TocTitle to be \relax twice - both in the preamble, and after start of document? So how is it possible at all that \TocTitle becomes undefined ????!!! What is going on and how do I fix this?

EDIT: It turns out, I got it to compile fine into html with these changes:

...
\usepackage[top=3cm,bottom=3cm,left=2cm,right=2cm,]{geometry} %showframe
...
\global\let\TocTitle\relax
\end{document}


... that is, just add another \def of \TocTitle to \relax just before the end document.

But the problem, more generally, seems to be this: I do not have a \tableofcontents in my doc, because I don't need/want it in this doc; however, even if that is so, it seems htlatex still insists on collecting data for the TOC. So more generally, the question would be - what is the canonical way to tell htlatex not to collect nor process data for generating a table of contents?

This is because you use \section*{\centering Article Card}. All sectioning titles are saved by tex4ht and use of \centering seems to break this. \TocTitle is internal tex4ht command containing the saved title, and it is redefined at each sectioning command, so it can't help if you declare it at another place.

You shouldn't use such formatting command in \section anyway, it is better to use for example titlesec package to change section formatting:

\global\let\TocTitle\relax
\usepackage{titlesec}
\titleformat*{\section}{\bfseries\large\centering}
\begin{document}
%\global\let\TocTitle\relax
%\show\TocTitle
\section*{Article  Card}


This of course doesn't make the section centered in html, you need to add css declaration for that in the myconfig.cfg file:

\makeatletter
\Gm@showframefalse
\makeatother
\Preamble{xhtml}
\begin{document}
\EndPreamble


\Gm@showframefalse will suppress the grid around page created by geometry

Compile with

htlatex filename myconfig


the result:

regarding your question after an edit, no tex4ht always collects all section titles, even for starred sections, because you can break the html files into many smaller files for each section and you won't be able to open these files otherwise

• Many, many thanks, @michal.h21 - that is a great explanation! Especially good since you caught the centering thing, which was the next thing that puzzled me :) One subquestion, though - this with the centering via css, is this also required if I'd want to get an ODT document via mk4ht oolatex test.tex? It seems that the oolatex conversion goes via HTML, so probably the same approach holds for ODT, right? – sdaau Apr 15 '15 at 20:04
• @sdaau ODT is another problem, it doesn't go through HTML, it is created directly, and formatting styles are in special xml file. they are configurable in theory, but I don't have too much experience with that – michal.h21 Apr 15 '15 at 20:12
• Thanks again, @michal.h21 - good to know ODT doesn't go through HTML, that was a bit hard information for me to track down. Cheers! – sdaau Apr 15 '15 at 20:22