1

I want to make a webpage with 2 chapters in which each chapter contains some sections and subsections inside some sections.

I use split=4 when calling tex4ht. Which means to split at section. i.e. make each section as its own separate page.

enter image description here

The above from how-to-split-an-article-at-subsubsection-level-using-tex4ht

However, for the first chapter, I do not want to do the split. i.e. I want the whole chapter to show on its own page (including all sections and any subsections).

For this, I use the trick

\ifdefined\HCode
\PauseCutAt{section}
\fi

\chapter{This is Chapter 1}
   .....

\ifdefined\HCode
\ContCutAt{section}
\fi

\chapter{This is Chapter 2}
   .....

The above works. i.e. Chapter 1 is all now on its own web page (all sections in same page), but chapter 2, has each of its sections in separate page which is what I wanted.

But here is the problem. For chapter 1, it is now missing the subsections inside section 3. They simply gone.

I have no idea why this happens. Below is MWE.

How to make it stop splitting at section level, but not drop the subsections? These subsection do show up in chapter 2.

\documentclass[12pt]{book}
\usepackage{hyperref}
    
\begin{document}      
\frontmatter
\title{the title}
\author{me}
\date{\today}
\maketitle    

\ifdefined\HCode
\Configure{tableofcontents*}{chapter}
\else
\setcounter{tocdepth}{1} % for main TOC, only show chapter and sections
\tableofcontents
\fi 

\ifdefined\HCode
\TocAt{chapter,section}
\TocAt{section,subsection}
\fi

\mainmatter  


\ifdefined\HCode
\PauseCutAt{section}
\fi

\chapter{This is Chapter 1}
\section{First section in chapter 1}
This is First section in chapter 1
\section{Second section in chapter 1}
This is Second section in chapter 1
\section{Third section in chapter 1}
This is Third section in chapter 1
\subsection{First subsection in third section in chapter 1}
This is First subsection in third section in chapter 1
\subsection{Second subsection in third section in chapter 1}
This is First subsection in third section in chapter 1

\section{Fourth section in chapter 1}
This is Fourth section in chapter 1

\ifdefined\HCode
\ContCutAt{section}
\fi

\chapter{This is  Chapter 2}
\section{First section in chapter 2}
This is First section in chapter 2
\section{Second section in chapter 2}
This is Second section in chapter 2
\section{Third section in chapter 2}
This is Third section in chapter 2
\subsection{First subsection in third section in chapter 2}
This is First subsection in third section in chapter 2
\subsection{Second subsection in third section in chapter 2}
This is First subsection in third section in chapter 2

\section{Fourth section in chapter 2}
This is Fourth section in chapter 2

\end{document}

Compiled using

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

Gives

enter image description here

Clicking on chapter 1, I see this

enter image description here

For chapter 2, which has splitting resumed, these subsections do show up OK.

I tried changing the split level at command line, but the subsections remain missing in action !

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

Is this a bug in tex4ht or a user error? I can report it as bug, but now I am not sure if I am using this feature correctly or not.

Update

I found a solution. But this makes no sense. But it does produce chapter 1 now with no missing subsection. It was to use split=2 ! But according to the list above, split=2 means split at \part. So my question now, is why this works? And why split=4 did not work?

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

Now chapter 1 looks like this

enter image description here

I guess I really still do not understand the split level by texh4t and what it actually mean. What does split level at 4 actually mean then if not what I thought it was, which is "put each section and everything in it, on one webpage" ? I think now this is a bug.

What if a user wants split level 4 but still see the subsections there?

TL 2022

>which make4ht
/usr/local/texlive/2022/bin/x86_64-linux/make4ht
>make4ht --version
make4ht version v0.3l

1 Answer 1

1

This is because you need to use \PauseCutAt and \ContCutAt for correct levels. With the option 4, you cut pages at \part, \chapter, \section, and \subsection (note that I've updated the linked answer, because it provided incorrect facts).

So you need to stop cutting not only for \section, but also for \subsection. So the correct code is:

\ifdefined\HCode
\PauseCutAt{section}
\PauseCutAt{subsection}
\fi

\chapter{This is Chapter 1}
\section{First section in chapter 1}
This is First section in chapter 1
\section{Second section in chapter 1}
This is Second section in chapter 1
\section{Third section in chapter 1}
This is Third section in chapter 1
\subsection{First subsection in third section in chapter 1}
This is First subsection in third section in chapter 1
\subsection{Second subsection in third section in chapter 1}
This is First subsection in third section in chapter 1

\section{Fourth section in chapter 1}
This is Fourth section in chapter 1

\ifdefined\HCode
\ContCutAt{section}
\ContCutAt{subsection}
\fi

This is the result:

enter image description here

2
  • Thanks. I had no idea one need to enumerate all the levels needed to stop the cut at. This is good to know. I need to update my cheat sheet with this information.
    – Nasser
    Apr 27, 2022 at 13:03
  • @Nasser I didn't know it too, it wasn't mentioned anywhere in the sources.
    – michal.h21
    Apr 27, 2022 at 13:14

You must log in to answer this question.

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