我正在编写一本电子书,我想在每一章的末尾列出该章的图表/表格列表(就像 minilot 和 minilof 一样,但不幸的是 minitoc 不适用于 tex4ht)。到目前为止,目录的 config.cfg 如下所示:
\let\origincludegraphics\includegraphics
\Preamble{xhtml,pic-tabular}
\TocAt{chapter,section,subsection}
\Configure{tableofcontents*}{chapter,section}
\Configure{NavSection}{%
\booltrue{tocnoempty}
\HCode{<li>}}{\HCode{<ol>\Hnewline}}{}{\Tg</ol>\Tg</li>}
\Css{nav\#toc ol{list-style: none;}}
\begin{document}
\CssFile[custom.css]
/* css.sty */
\EndCssFile
\Configure{CoverMimeType}{image/jpg}
\DeclareGraphicsExtensions{.eps,.png,.jpg,.gif,}
\EndPreamble
梅威瑟:
\documentclass{book}
\usepackage{mwe}
\usepackage[ngerman]{babel}
\usepackage{hyperref}
\hypersetup{%
linktocpage=true,
breaklinks=true,
colorlinks=true,
citecolor=black,
linkcolor=black,
urlcolor=black,
pdfpagemode=UseThumbs,
pdftitle={thetitle},
pdfauthor={theAuthor},
pdfsubject={thetitle},
pdfkeywords={thekeywords},
}
\makeatletter
\g@addto@macro\UrlBreaks{\do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i%
\do\j\do\k\do\l\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t\do\u\do\v\do\w%
\do\x\do\y\do\z\do\&\do\1\do\2\do\3\do\4\do\5\do\6\do\7\do\8\do\9\do\0}
\def\do@url@hyp{\do\-}
\makeatother
\addto\extrasngerman{
\def\subsectionautorefname{Kap.}
\def\figureautorefname{Abb.}
\def\tableautorefname{Tab.}
\def\chapterautorefname{Kap.}
\def\sectionautorefname{Kap.}
\def\subsectionautorefname{Kap.}
}
\usepackage[nohints]{minitoc}
\mtcselectlanguage{german}
\mtcsettitle{minitoc}{}
\mtcsettitle{minilof}{}
\mtcsettitle{minilot}{}
\mtcsetfeature{minitoc}{open}{\vspace{1cm}}
\nomtcrule
\nomlfrule
\nomltrule
\tightmtctrue
\begin{document}
\dominitoc
\dominilof
\dominilot
\doparttoc
\fakelistoffigures
\fakelistoftables
\ifdefined\HCode\else
\tableofcontents
\fi
\chapter{chapter 1}
\minitoc
\section{Table}
\begin{table}[ht!]
\centering
\caption{a table}
\label{a table}
\begin{tabular}{ll}
test & test
\end{tabular}
\end{table}
\begin{table}[ht!]
\centering
\caption{a table2}
\label{a table}
\begin{tabular}{ll}
test & test
\end{tabular}
\end{table}
\begin{table}[ht!]
\centering
\caption{a table3}
\label{a table}
\begin{tabular}{ll}
test & test
\end{tabular}
\end{table}
\begin{figure}
\caption{Sample figure}
\end{figure}
\begin{figure}
\caption{Sample figure2}
\end{figure}
\begin{figure}
\caption{Sample figure3}
\end{figure}
\section{LOT}
\minilot
\section{LOF}
\minilof
\end{document}
有没有办法实现我上面描述的内容?
答案1
该软件包的问题minitoc
在于它重新定义了很多内部 LaTeX 命令,这会干扰tex4ht
,而 也会重新定义这些命令。特别是,似乎表格和图形信息没有保存。幸运的是,如果在正常的 LaTeX 运行中保存了这些信息,它就可以正常工作。因此,tex4ebook
当表格或图形发生变化时,请先使用正常的 LaTeX 编译文档。
还有一个问题。\minilot
和\minilof
命令tabular
在内部使用环境,这会导致问题,因为您使用了pic-tabular
指示tex4ht
将表格转换为图像的选项。 要解决这个问题,我们需要提供这些命令的替代版本,这些版本不使用tabular
。 它们也不使用最初使用的间距和分页命令,因为这些命令在 HTML 代码中没有任何意义。 通常,最好只是向由 重新定义的命令添加一些代码tex4ht
,但在这种情况下,我们需要大量修改它们,因为原始定义会带来太多麻烦。
将此代码保存为minitoc.4ht
:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% minitoc.4ht 2009-05-21-09:32 %
% Copyright (C) 1997--2009 Eitan M. Gurari %
% %
% This work may be distributed and/or modified under the %
% conditions of the LaTeX Project Public License, either %
% version 1.3c of this license or (at your option) any %
% later version. The latest version of this license is %
% in %
% http://www.latex-project.org/lppl.txt %
% and version 1.3c or later is part of all distributions %
% of LaTeX version 2005/12/01 or later. %
% %
% This work has the LPPL maintenance status "maintained".%
% %
% This Current Maintainer of this work %
% is Eitan M. Gurari. %
% %
% If you modify this program your changing its signature %
% with a directive of the following form will be %
% appreciated. %
% \message{signature} %
% %
% [email protected] %
% http://www.cse.ohio-state.edu/~gurari %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\immediate\write-1{version 2009-05-21-09:32}
\NewConfigure{minitoc}{4}
\NewConfigure{parttoc}{4}
\NewConfigure{secttoc}{4}
\NewConfigure{minilof}{4}
\NewConfigure{partlof}{4}
\NewConfigure{sectlof}{4}
\NewConfigure{minilot}{4}
\NewConfigure{partlot}{4}
\NewConfigure{sectlot}{4}
\let\minitoc:\minitoc@
\def\minitoc@[#1]{%
\a:minitoc@
\minitoc:[#1]
\b:minitoc@
}
\NewConfigure{minitoc@}{2}
\def\minilot@[#1]{%
\global\@minilot@used@true
\if@mtc@longext@%
\def\@tocfile{mlt\The@mtc}%
\else
\def\@tocfile{T\The@mtc}%
\fi
\mtc@CkFile{\jobname.\@tocfile}
\if@mtc@FE
\mtcPackageInfo[I0006]{minitoc}%
{\jobname.\@tocfile\space is empty}
\@mtc@empty@minilot@true
\else
\beforeminilot
\begingroup
\makeatletter
\@ifundefined{mlt@pgno}%
{\let\@dottedtocline\@undottedtocline}{}
\@fileswfalse\mtc@hook@beforeinputfile
\mlt@setform
\global\openminilot\inminilottrue
\@input{\jobname.\@tocfile}%
\global\inminilotfalse\closeminilot
\global\@nobreakfalse\endgroup
\par\afterminilot\fi}%
\NewConfigure{minilot@}{2}
\let\minilot:\minilot@
\def\minilot@[#1]{%
\a:minilot@
\minilot:[#1]
\b:minilot@
}
\def\minilof@[#1]{%
\global\@minilof@used@true
\if@mtc@longext@%
\def\@tocfile{mlf\The@mtc}%
\else
\def\@tocfile{F\The@mtc}%
\fi
\mtc@CkFile{\jobname.\@tocfile}
\if@mtc@FE
\mtcPackageInfo[I0006]{minitoc}%
{\jobname.\@tocfile\space is empty}
\@mtc@empty@minilof@true
\else
\beforeminilof
\begingroup
\makeatletter
\@ifundefined{mlf@pgno}%
{\let\@dottedtocline\@undottedtocline}{}
\@fileswfalse\mtc@hook@beforeinputfile
\mlf@setform
\global\openminilof\inminiloftrue
\@input{\jobname.\@tocfile}%
\global\inminiloffalse\closeminilof
\leavevmode\mtc@strut
\global\@nobreakfalse\endgroup
\par\afterminilof\fi}%
\Hinput{minitoc}
\endinput
TeX 文件不需要所有条件代码,只需禁用\tableofcontents
,它由以下方式处理tex4ebook
:
\documentclass{book}
\usepackage{mwe}
\usepackage[nohints]{minitoc}
\mtcselectlanguage{german}
\mtcsettitle{minitoc}{}
\mtcsettitle{minilof}{}
\mtcsettitle{minilot}{}
\mtcsetfeature{minitoc}{open}{\vspace{1cm}}
\nomtcrule
\nomlfrule
\nomltrule
\tightmtctrue
\begin{document}
\dominitoc
\dominilof
\dominilot
\doparttoc
\fakelistoffigures
\fakelistoftables
\ifdefined\HCode\else
\tableofcontents
\fi
\chapter{chapter 1}
\minitoc
\section{Table}
\begin{table}[ht!]
\centering
\caption{a table}
\label{a table}
\begin{tabular}{ll}
test & test
\end{tabular}
\end{table}
\begin{figure}
\caption{Sample figure}
\end{figure}
\section{LOT}
\minilot
\section{LOF}
\minilof
\end{document}
可以\minitoc
在文件中禁用.cfg
,只需将其重新定义为\relax
:
\let\minitoc\relax
结果如下: