1

This issue is only for tex4ht.

How to increase the space a little more between entries in main TOC when using tex4ht? There is a solution for this when generating PDF but it does not work for tex4ht.

Here is MWE

\documentclass[11pt]{book}
\usepackage{setspace}%tried this
\usepackage{tocloft}%tried this
\setlength{\cftbeforesecskip}{6pt}%tried this

\begin{document}
\ifdefined\HCode 
\doublespacing
\Configure{tableofcontents*}{chapter,section,subsection}    
\singlespacing
\fi 

\chapter{A}
\section{A-B}
stuff 
\subsection{A-B-C1}
stuff 
\subsection{A-B-C2}
stuff 
\subsection{A-B-C3}
stuff 
\subsection{A-B-C4}
stuff 
\subsection{A-B-C4}
end
\end{document}

Compiled using make4ht -ulm default -a debug foo.tex "mathjax,2,htm" gives

enter image description here

The raw HTML generated is

<!DOCTYPE html> 
<html lang='en-US' xml:lang='en-US'> 
<head><title></title> 
<meta charset='utf-8' /> 
<meta content='TeX4ht (https://tug.org/tex4ht/)' name='generator' /> 
<meta content='width=device-width,initial-scale=1' name='viewport' /> 
<link href='foo.css' rel='stylesheet' type='text/css' /> 
<meta content='foo.tex' name='src' /> 
<script>window.MathJax = { tex: { tags: "ams", }, }; </script> 
 <script async='async' id='MathJax-script' src='https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js' type='text/javascript'></script>  
</head><body>

<!-- l. 15 --><p class='indent'>

</p>   
<div class='tableofcontents'>
<span class='chapterToc'>1 <a href='foch1.htm#a' id='QQ2-2-1'>A</a></span>
<br />    <span class='sectionToc'>1.1 <a href='foch1.htm#ab' id='QQ2-2-2'>A-B</a></span>
<br />     <span class='subsectionToc'>1.1.1 <a href='foch1.htm#abc' id='QQ2-2-3'>A-B-C1</a></span>
<br />     <span class='subsectionToc'>1.1.2 <a href='foch1.htm#abc1' id='QQ2-2-4'>A-B-C2</a></span>
<br />     <span class='subsectionToc'>1.1.3 <a href='foch1.htm#abc2' id='QQ2-2-5'>A-B-C3</a></span>
<br />     <span class='subsectionToc'>1.1.4 <a href='foch1.htm#abc3' id='QQ2-2-6'>A-B-C4</a></span>
<br />     <span class='subsectionToc'>1.1.5 <a href='foch1.htm#abc4' id='QQ2-2-7'>A-B-C4</a></span>
</div> 
</body> 
</html>

Does this need special CSS to modify div class='tableofcontents?

TL 2021

1 Answer 1

1

Of course you can change spacing using CSS:

\Preamble{xhtml}
\Css{.tableofcontents span{display:inline-block;margin-top:0.3rem;}}
% prevent vertical spacing before first TOC entry
\Css{.tableofcontents span:first-child{margin-top:0}} 
\begin{document}
\EndPreamble

This configuration file changes the display property of <span> elements that are inside table of contents to inline-block. This then enables us to set the margin-top. We set it to zero in the first TOC element to prevent spurious white space.

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 .