2

I am not sure what I am doing wrong here. I need to produce this toc in book class

enter image description here

But in html it looks like this

enter image description here

The following is the MWE and the commands used to compile it. I think I added all the needed code for tex4ht, but it is not working. I must be missing some additional option?

\documentclass[12pt]{book}

\begin{document}

\frontmatter
\title{my book}
\author{me}
\date{\today}
\maketitle

\ifdefined\HCode 
\Configure{tableofcontents*}{chapter,section,subsection,subsubsection,paragraph}   
\else 
\setcounter{tocdepth}{5}
\setcounter{secnumdepth}{5}
\fi 

\tableofcontents
\mainmatter

\chapter{book name}
my book
\section{section name}
section data
\subsection{subsection name}
subsection data
\subsubsection{subsubsection name}
subsubsection data
\paragraph{paragraph name}
paragraph data

\end{document}

The command to compile it to html is

 make4ht -ulm default -a debug  foo.tex "mathjax,htm"

I tried also

 make4ht -ulm default -a debug  foo.tex "mathjax,htm,fn-in,notoc*"

No difference. I always tried without \frontmatter and it made no difference.

How to add numbering to subsubsection and to paragraph and why is paragraph entry is not aligned as the PDF toc shows?

TL 2022.

>which latex
/usr/local/texlive/2022/bin/x86_64-linux/latex
>which make4ht
/usr/local/texlive/2022/bin/x86_64-linux/make4ht

1 Answer 1

2

Try this configuration file:

\Preamble{xhtml}
\Configure{tableofcontents*}{chapter,section,subsection,subsubsection,paragraph}   
\catcode`\:=11
\makeatletter
\ConfigureMark{paragraph}{\ifnum \c:secnumdepth>\c@secnumdepth\expandafter\:gobble
    \else
       \HCode{<span class="titlemark">}\@seccntformat{paragraph}%
       \HCode{</span>}\fi}
\Configure{paragraph}{}{}
  {\par\ShowPar\IgnoreIndent\HCode{<span
      class="paragraphHead"\a:LRdir>}\begingroup\bf\TitleMark}
  {\endgroup\HCode{</span>}\IgnorePar}
\Css{.paragraphToc{margin-left:8em;}}

\NewConfigure{tableofcontents*}[1]{%
   \def\:tempa{#1}\ifx\empty\:tempa
      \ifx \au:StartSec\:UnDef \else \gdef\:StartSec{\au:StartSec}\fi
   \else
      \edef\auto:toc{#1}%
         \ifx \au:StartSec\:UnDef
            \let\au:StartSec\:StartSec
            \def\:StartSec{\:tableofcontents
               \global\let\auto:toc\:UnDef \let\:StartSec\au:StartSec \:StartSec}%
            \pend:def\tableofcontents{\gdef\:StartSec{\au:StartSec}}%
   \fi  \fi
}
\makeatother
\catcode`\:=12
\begin{document}
\EndPreamble

It declares the sectioning levels to be printed in TOC using \Configure{tableofcontents*}, and then fixes handling of paragraph numbering in the text with \Configure{paragraph}, where I've added the \TitleMark command to print the number, and \ConfigureMark{paragraph}, which configures the number itself. I also had to fix \NewConfigure{tableofcontetns*}, because it would print the TOC twice otherwise.

You can then simplify your document:

\documentclass[12pt]{book}

\begin{document}

\frontmatter
\title{my book}
\author{me}
\date{\today}
\maketitle

\setcounter{tocdepth}{5}
\setcounter{secnumdepth}{5}


\tableofcontents
\mainmatter

\chapter{book name}
my book
\section{section name}
section data
\subsection{subsection name}
subsection data
\subsubsection{subsubsection name}
subsubsection data
\paragraph{paragraph name}
paragraph data

\end{document}

And this is the result:

enter image description here

You must log in to answer this question.

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