Latex 到 html:如何为 htlatex / TeX4ht 添加类似“\subsubsubsection”的规则?

Latex 到 html:如何为 htlatex / TeX4ht 添加类似“\subsubsubsection”的规则?

我在我的报告中添加了一些规则以便添加\subsubsubsection

在下面平均能量损失

\documentclass[a4paper,11pt,french]{report}
\usepackage[francais]{babel}




\usepackage{titlesec}
\titleclass{\subsubsubsection}{straight}[\subsection]

\newcounter{subsubsubsection}
\renewcommand\thesubsubsubsection{\thesubsubsection.\arabic{subsubsubsection}}
\renewcommand\theparagraph{\thesubsubsubsection.\arabic{paragraph}} % optional; useful if paragraphs are to be numbered

\titleformat{\subsubsubsection}
  {\normalfont\normalsize\bfseries}{\thesubsubsubsection}{1em}{}
\titlespacing*{\subsubsubsection}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{5}{\z@}%
  {3.25ex \@plus1ex \@minus.2ex}%
  {-1em}%
  {\normalfont\normalsize\bfseries}}
\renewcommand\subparagraph{\@startsection{subparagraph}{6}{\parindent}%
  {3.25ex \@plus1ex \@minus .2ex}%
  {-1em}%
  {\normalfont\normalsize\bfseries}}
\def\toclevel@subsubsubsection{4}
\def\toclevel@paragraph{5}
\def\toclevel@paragraph{6}
\def\l@subsubsubsection{\@dottedtocline{4}{10em}{5em}}
\def\l@paragraph{\@dottedtocline{5}{10em}{5em}}
\def\l@subparagraph{\@dottedtocline{6}{14em}{6em}}
\@addtoreset{subsubsubsection}{section}
\@addtoreset{subsubsubsection}{subsection}
\@addtoreset{subsubsubsection}{subsubsection}
\makeatother

\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{4}




\begin{document}


\tableofcontents

\pagebreak

\section{test}
\subsubsubsection{test11}
\subsubsubsection{test12}
\subsubsubsection{test13}

\section{test2}
\subsubsubsection{test21}
\subsubsubsection{test22}
\subsubsubsection{test23}


\end{document}

但是,在 texmaker(单独的 HTML 页面)上运行 htlatex 时,\subsubsubsection无法识别该规则。

问题1)请问我该如何修复它?

问题2)此外,有没有办法在 HTML 中包含/导出 tikz 图片?

答案1

我不确定使用是否\subsubsubsection是个好主意,但无论如何。将\subsubsubsection定义移至其自己的包中,subsubsub.sty

\usepackage{titlesec}
\titleclass{\subsubsubsection}{straight}[\subsection]

\newcounter{subsubsubsection}
\renewcommand\thesubsubsubsection{\thesubsubsection.\arabic{subsubsubsection}}
\renewcommand\theparagraph{\thesubsubsubsection.\arabic{paragraph}} % optional; useful if paragraphs are to be numbered

\titleformat{\subsubsubsection}
  {\normalfont\normalsize\bfseries}{\thesubsubsubsection}{1em}{}
\titlespacing*{\subsubsubsection}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{5}{\z@}%
  {3.25ex \@plus1ex \@minus.2ex}%
  {-1em}%
  {\normalfont\normalsize\bfseries}}
\renewcommand\subparagraph{\@startsection{subparagraph}{6}{\parindent}%
  {3.25ex \@plus1ex \@minus .2ex}%
  {-1em}%
  {\normalfont\normalsize\bfseries}}
\def\toclevel@subsubsubsection{4}
\def\toclevel@paragraph{5}
\def\toclevel@paragraph{6}
\def\l@subsubsubsection{\@dottedtocline{4}{10em}{5em}}
\def\l@paragraph{\@dottedtocline{5}{10em}{5em}}
\def\l@subparagraph{\@dottedtocline{6}{14em}{6em}}
\@addtoreset{subsubsubsection}{section}
\@addtoreset{subsubsubsection}{subsection}
\@addtoreset{subsubsubsection}{subsubsection}
\makeatother

\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}

现在tex4ht为这个包定义配置文件subsubsub.4ht

\NewSection\subsubsubsection{\thesubsubsubsection}
\Configure{subsubsubsection}
    {}{}
    {\ifvmode \IgnorePar\fi \EndP\addtocounter{subsubsubsection}{1}\HCode{<h4>}\thesubsubsubsection\quad}
    {\HCode{</h4>}}

这声明\subsubsubsection为分段命令,并subsubsubsection创建新的配置钩子。\Configure{subsubsubsection}您可以使用它来配置此分段的外观。

现在您需要将subsubsub包包含到您的文档中:

\documentclass[a4paper,11pt,french]{report}
\usepackage[francais]{babel}
\usepackage{subsubsub}

\begin{document}


\tableofcontents

\pagebreak

\section{test}
\subsubsubsection{test11}
\subsubsubsection{test12}
\subsubsubsection{test13}

\section{test2}
\subsubsubsection{test21}
\subsubsubsection{test22}
\subsubsubsection{test23}


\end{document}

编译后

 htlatex filename xhtml

这是结果

在此处输入图片描述

生成的html:

<?xml version="1.0" encoding="iso-8859-1" ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<!--http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd-->  
<html xml:lang="fr" xmlns="http://www.w3.org/1999/xhtml"  
> 
<head><title></title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
<meta name="generator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)" /> 
<meta name="originator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)" /> 
<!-- xhtml,html --> 
<meta name="src" content="oursay.tex" /> 
<meta name="date" content="2014-02-25 13:44:00" /> 
<link rel="stylesheet" type="text/css" href="oursay.css" /> 
</head><body 
>

   <h2 class="likechapterHead"><a 
 id="x1-1000"></a>Table des matières</h2> <div class="tableofcontents">
   &#x00A0;<span class="sectionToc" >0.1 <a 
href="#x1-20001" id="QQ2-1-2">test</a></span>
<br />   &#x00A0;<span class="sectionToc" >0.2 <a 
href="#x1-60002" id="QQ2-1-6">test2</a></span>
   </div>

<a 
 id="x1-1001r1"></a>
<h3 class="sectionHead"><span class="titlemark">0.1   </span> <a 
 id="x1-20001"></a>test</h3>
   <h4>0.1.0.0.1   <a 
 id="x1-30000.1.0.0.1"></a>test11</h4>
   <h4>0.1.0.0.2   <a 
 id="x1-40000.1.0.0.2"></a>test12</h4>
   <h4>0.1.0.0.3   <a 
 id="x1-50000.1.0.0.3"></a>test13</h4>
<a 
 id="x1-5001r2"></a>
<h3 class="sectionHead"><span class="titlemark">0.2   </span> <a 
 id="x1-60002"></a>test2</h3>
   <h4>0.2.0.0.1   <a 
 id="x1-70000.2.0.0.1"></a>test21</h4>
   <h4>0.2.0.0.2   <a 
 id="x1-80000.2.0.0.2"></a>test22</h4>
   <h4>0.2.0.0.3   <a 
 id="x1-90000.2.0.0.3"></a>test23</h4>

</body></html>

目前,\subsubsubsection没有出现在目录中,我需要调查原因。

相关内容