
<h2>
제목에 대해 tex4ht 제목이 시작되는 것 같습니다 . 다음 텍스트:
\documentclass{article}
\title{Testing headings}
\author{Alex Watson}
\date{\today}
\begin{document}
\maketitle
\section{Top level section}
\subsection{Next level section}
\end{document}
처리하면 make4ht -uf html5 ht-headings.tex
다음 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>
제목은 h2
제목으로 시작한 다음 h3
섹션 등으로 시작됩니다.
제목이 될 것으로 예상했습니다 h1
.
아마도 더 중요한 것은 클래스 book
와 일부 \chapter
매크로를 사용하는 경우 제목은 그대로이지만 h2
장도 h2
!
h1
제목 수준을 '위로' 이동하여 제목, h2
다음 수준의 섹션 등에 사용하는 쉬운 방법이 있습니까 ? (이것이 과연 합리적인 일인가?)
다양한 클래스에서 작동하는 솔루션(아마도 여러 HTML 파일로 분할하는 경우에도!)이 이상적이겠지만, 약간의 요구가 있을 수 있다는 것을 깨달았습니다.
답변1
너무 논리적인 구조는 아니지만 변경하면 기존 문서가 손상될까 두렵습니다. 어쨌든 다음 구성 파일을 사용해 볼 수 있습니다.
\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
\:setlevel
이는 섹션화 수준과 해당 수준에 사용해야 하는 HTML 요소라는 두 개의 매개변수를 사용하는 새 명령을 정의합니다 .
<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>