It looks like tex4ht headings start at <h2> for the title. The following tex:


\title{Testing headings}
\author{Alex Watson}



\section{Top level section}

\subsection{Next level section}


processed with make4ht -uf html5 ht-headings.tex produces the following HTML:

<!DOCTYPE html> 
<html lang='en-US' xml:lang='en-US'> 
<head><title>Testing headings</title> 
<meta charset='utf-8' /> 
<meta name='generator' content='TeX4ht (http://www.tug.org/tex4ht/)' /> 
<meta name='viewport' content='width=device-width,initial-scale=1' /> 
<link rel='stylesheet' type='text/css' href='ht-headings.css' /> 
<meta name='src' content='ht-headings.tex' /> 
   <div class='maketitle'>

<h2 class='titleHead'>Testing headings</h2>
<div class='author'><span class='cmr-12'>Alex Watson</span></div><br />
<div class='date'><span class='cmr-12'>September 19, 2020</span></div>
   <h3 class='sectionHead'><span class='titlemark'>1   </span> <a id='x1-10001'></a>Top level section</h3>
<!-- l. 13 --><p class='noindent'>
   <h4 class='subsectionHead'><span class='titlemark'>1.1   </span> <a id='x1-20001.1'></a>Next level section</h4>

The headings start with h2 for the title, then h3 for section, etc.

I would have expected the title to be h1.

Maybe more significantly, if using class book and some \chapter macros, the title is still h2 but then the chapters are also h2!

Is there an easy way to move the heading levels 'up one', to use h1 for title, h2 for the next level of sectioning, etc? (And is this a reasonable thing to want?)

A solution that works with different classes (and maybe even when splitting into multiple html files!) would be ideal, but I realise that might be asking a bit much.

1 Answer 1


I know that it is not too logical structure, but I am afraid that changing it would break existing documents. Anyway, you can try this configuration file:


% configure all sections to use our sectioning configuration
   {\ifvmode \IgnorePar\fi \EndP\IgnorePar
    \HCode{<#2 class="#1Head"\a:LRdir>}\TitleMark\space\HtmlParOff}
   {\HCode{</#2>}\HtmlParOn\ShowPar \IgnoreIndent \par}
   {\ifvmode \IgnorePar\fi
    \EndP\IgnorePar\HCode{<#2 class="like#1Head"\a:LRdir>}\HtmlParOff}
   {\HCode{</#2>}\HtmlParOn \IgnoreIndent \ShowPar \par}



It defines a new command, \:setlevel, that takes two parameters, sectioning level and HTML element that should be used for that level.

enter image description here

   <h1 class='chapterHead'><span class='titlemark'>Chapter 1</span> <a id='x1-10001'></a>my chapter</h1>
   <h2 class='sectionHead'><span class='titlemark'>1.1   </span> <a id='x1-20001.1'></a>Top level section</h2>
<!-- l. 15 --><p class='noindent'>
   <h3 class='subsectionHead'><span class='titlemark'>1.1.1   </span> <a id='x1-30001.1.1'></a>Next level section</h3>
  • Works like a charm. Thank you so much! Sep 23, 2020 at 17:52
  • @michal with this config, I get stray empty heading elements inside the html title tag. Is that a known issue? Jan 13, 2021 at 10:24
  • @PeterKrautzberger no, that sounds strange. do you have a MWE?
    – michal.h21
    Jan 13, 2021 at 10:42
  • Thanks, @michal.h21. I'll try to find time for a MWE. Jan 13, 2021 at 10:45

You must log in to answer this question.

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