使用 tex4ht 裝飾章節名稱時超出 TeX 容量並出現解析錯誤

使用 tex4ht 裝飾章節名稱時超出 TeX 容量並出現解析錯誤

我的 2014 年第一期 htlatex 問題也是第一天:)

我添加了這一行

\chapter*{\centering \begin{normalsize}my chapter title\end{normalsize}}

它與 pdflatex 配合良好,但 htlatex 給出

 ! TeX capacity exceeded, sorry [input stack size=5000].

當我刪除 時\centering,hlatex 給了這個錯誤

(./foo2.aux) [1] [2] [1] [2] [3] [1] [2]
! Argument of \im:g has an extra }.
<inserted text> 
                \par 
l.12 ...begin{normalsize}Abstract\end{normalsize}}

所以,我不太確定問題是什麼。我基本上想以書籍風格製作一個類似摘要的頁面,並發現了上面的內容解決方案在這裡它與 pdflatex 配合得非常好,但由於某種原因,htlatex 在解析條目內的這些命令時遇到問題\chapter。它似乎不喜歡\chapter{....}參數中的 Latex 命令。可能需要保護他們?脆弱問題?但是 pdflatex 可以很好地處理它們嗎?

有沒有解決方法,這樣我就可以用 htllatex 在頁面中間新增一個標題?

微量元素:

\documentclass[12pt]{book}%
\usepackage{lipsum}
\begin{document}
\frontmatter

\title{htlatex issue 010114}
\author{me}
\maketitle 

\chapter*{\centering \begin{normalsize}my chapter title\end{normalsize}} %crash
%\chapter*{\begin{normalsize}Abstract\end{normalsize}} %parse error
%\chapter*{Abstract}  %only this work
\noindent 
\lipsum[75]
\clearpage

\tableofcontents

\mainmatter

\chapter{one}
  \section{one}
    \lipsum[75]

\end{document}

編譯命令:

>htlatex foo2.tex 
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013)
 restricted \write18 enabled.

.....
(/usr/local/texlive/2013/texmf-dist/tex/generic/tex4ht/html4-math.4ht))
(/usr/local/texlive/2013/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2013/texmf-dist/tex/generic/tex4ht/html4-math.4ht))
(./foo2.aux) [1] [2] [1] [2] [3] [1] [2]
! TeX capacity exceeded, sorry [input stack size=5000].
\centering ->\let \\
                    \@centercr \rightskip \@flushglue \leftskip \@flushglue ...
l.10 ...rmalsize}my chapter title\end{normalsize}}
                                                   %crash
Output written on foo2.dvi (7 pages, 13108 bytes).
Transcript written on foo2.log.

日誌檔案中的一些文字顯示了問題所在:

LaTeX Font Info:    ... okay on input line 3.
--- file foo2.css ---
 [1

] [2

] [1] [2

] [3]
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <14.4> on input line 8.
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <7> on input line 8.
 [1] [2]
! TeX capacity exceeded, sorry [input stack size=5000].
\centering ->\let \\
                    \@centercr \rightskip \@flushglue \leftskip \@flushglue ...
l.10 ...rmalsize}my chapter title\end{normalsize}}
                                                   %crash
If you really absolutely need more capacity,

在 Linux mint 上使用 TexLive 2013。

要使標題居中,這適用於 htlatex:

\begin{center}
  \chapter*{Abstract}  %only this work
\end{center}

所以我可以使用上述解決方案做我想做的事。但將這個問題留在這裡,因為它顯示了一個問題。

答案1

正如我在另一個問題,您不能將任何內容作為切片命令的參數,因為它將被處理以便使TOC.所以雖然它可以在普通的 LaTeX 中工作,但它不能在 tex4ht 中工作。因此,從概念的角度來看,您的解決方法比您最初的嘗試要好得多。我認為與其濫用\chapter命令,不如使用其他方法來解決您的問題,即abstract列印。新環境怎麼樣,這也將解決將noindentclearpage放入文件正文的需要?

\documentclass[12pt]{book}%
\usepackage{lipsum}
\def\abstracttitle{Abstract}
\newenvironment{abstract}{\begin{center}\abstracttitle\end{center}\par\noindent}{\clearpage}
\begin{document}
\frontmatter

\title{htlatex issue 010114}
\author{me}
\maketitle 

\begin{abstract}
\lipsum[75]
\end{abstract}

\tableofcontents

\mainmatter

\chapter{one}
  \section{one}
    \lipsum[75]

\end{document}

我定義了新環境,abstract標題文字保存在巨集中\abstracttitle,因此可以在需要時重新定義。此解決方案開箱即用tex4ht

在此輸入影像描述

相關內容