
Parece que os títulos tex4ht começam no <h2>
título. O seguinte texto:
\documentclass{article}
\title{Testing headings}
\author{Alex Watson}
\date{\today}
\begin{document}
\maketitle
\section{Top level section}
\subsection{Next level section}
\end{document}
processado com make4ht -uf html5 ht-headings.tex
produz o seguinte 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' />
</head><body>
<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>
</div>
<h3 class='sectionHead'><span class='titlemark'>1 </span> <a id='x1-10001'></a>Top level section</h3>
<!-- l. 13 --><p class='noindent'>
</p>
<h4 class='subsectionHead'><span class='titlemark'>1.1 </span> <a id='x1-20001.1'></a>Next level section</h4>
</body>
</html>
Os títulos começam com h2
o título, depois h3
com a seção, etc.
Eu esperava que o título fosse h1
.
Talvez mais significativamente, se estiver usando classes book
e algumas \chapter
macros, o título ainda é h2
, mas os capítulos também são h2
!
Existe uma maneira fácil de mover os níveis de título 'um para cima', para usar h1
como título, h2
para o próximo nível de seccionamento, etc.? (E isso é algo razoável de se querer?)
Uma solução que funcione com classes diferentes (e talvez até mesmo quando dividida em vários arquivos html!) Seria ideal, mas percebo que isso pode ser pedir demais.
Responder1
Sei que não se trata de uma estrutura muito lógica, mas receio que a sua alteração violaria os documentos existentes. De qualquer forma, você pode tentar este arquivo de configuração:
\Preamble{xhtml}
\begin{document}
\catcode`\:=11
% configure all sections to use our sectioning configuration
\newcommand\:setlevel[2]{%
\Configure{#1}{}{}
{\ifvmode \IgnorePar\fi \EndP\IgnorePar
\HCode{<#2 class="#1Head"\a:LRdir>}\TitleMark\space\HtmlParOff}
{\HCode{</#2>}\HtmlParOn\ShowPar \IgnoreIndent \par}
\Configure{like#1}{}{}
{\ifvmode \IgnorePar\fi
\EndP\IgnorePar\HCode{<#2 class="like#1Head"\a:LRdir>}\HtmlParOff}
{\HCode{</#2>}\HtmlParOn \IgnoreIndent \ShowPar \par}
}
\ifdefined\chapter
\:setlevel{chapter}{h1}
\:setlevel{section}{h2}
\:setlevel{subsection}{h3}
\:setlevel{subsubsection}{h4}
\else
\:setlevel{section}{h1}
\:setlevel{subsection}{h2}
\:setlevel{subsubsection}{h3}
\fi
\catcode`\:=12
\EndPreamble
Ele define um novo comando, \:setlevel
, que leva dois parâmetros, nível de seccionamento e elemento HTML que deve ser usado para esse nível.
<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'>
</p>
<h3 class='subsectionHead'><span class='titlemark'>1.1.1 </span> <a id='x1-30001.1.1'></a>Next level section</h3>