2

The hyperref package seems to have conflict with titlesec package when compiled with make4ht. The following document is compiled with make4ht. The compiled html file doesn't contain table of contents.

\documentclass{article}
\usepackage{titlesec}
\titleformat{\section}[runin]{\normalfont\bfseries}{\thesection.}{3pt}{}
\usepackage{hyperref}
\begin{document}
\tableofcontents
\section{First}
\section{Second}
\section{Third}
\end{document}

How could this be dealt with? Note that there is no problem when titlesec package and the command titleformat is removed.

1 Answer 1

3

This issue is not related to hyperref, it is really the \titleformat what causes the issue, namely the runin option. It seems to redefine the \section in a way where tex4ht isn't able to insert the HTML tags for headers and they are not saved to the TOC. Also the third section is missing from the document completely.

I've found that the hang format works with tex4ht, so there is an easy fix: just redefine the runin (and display, which has the same issue as runin) format to hang:

\Preamble{xhmtl}
\begin{document}
\titlelabel{\thetitle.}
\makeatletter
\let\ttlh@runin\ttlh@hang
\let\ttlh@display\ttlh@hang
\makeatother
\EndPreamble

I've added the \titlelabel{\thetitle.} line to get the dots after section number, because it seems that this feature isn't supported by tex4ht configuration for \titleformat-

It seems to work now:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .