序言中的註解導致使用 mylatexformat 使用「預編譯」格式檔案建置時出現錯誤?

序言中的註解導致使用 mylatexformat 使用「預編譯」格式檔案建置時出現錯誤?

考慮以下 MWE - 幾乎與[希臘文] babel 和lastpage 失敗,\frontmatter?,但不完全是 - 我有一個大文檔,我想為其生成“預編譯頭”(TikZ的外化和mylatex(注意,\jobname 應該是相同的))並認為我會用mylatexformat它(帶預編譯的超快 pdflatex)。

結構看起來像這樣:

setup/_preamble.tex

\documentclass[10pt]{book}

\usepackage{cmap}% (causes pdflatex: dangling objects discarded, no output file produced. with -ini/mylatexformat)
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
% \usepackage[english]{babel} % ok
\usepackage[greek,english]{babel} % ok w/ hack below
\usepackage{amsmath,amssymb}
\usepackage{csquotes}
\usepackage[backend=biber]{biblatex}
\usepackage{tikz}
\usepackage{siunitx}

\usepackage{lastpage}
\makeatletter
\let\oldlastpage@putl@bel\lastpage@putl@bel
\renewcommand*\lastpage@putl@bel{%
  \bgroup
  \let\textlatin\@firstofone % make \textlatin a no-op
  \oldlastpage@putl@bel%
  \egroup
}
\makeatother

test.tex

%% This is the file `test.tex'
%
\input{setup/_preamble.tex}%
%
% \csname endofdump\endcsname% may \def to \relax; https://tex.stackexchange.com/questions/57398
\ifcsname endofdump\endcsname%
  % it is called with precompiled header; stop here:
  \typeout{HEEEREEEE: endofdump defined!}%
  \endofdump% shouldn't be here?
  \typeout{HEEEREEEE: POST endofdump defined!}%
\else%
\fi%

\usepackage{lipsum}

\begin{document}
\frontmatter
\clearpage

\section{Something}
\lipsum[1-5]

\end{document}

如果我用 編譯它pdflatex test.tex,它編譯得很好。

test.fmt我像這樣「編譯」檔:

$ pdflatex -ini -jobname="test" "&pdflatex" mylatexformat.ltx "test.tex"
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014) (INITEX)
...
HEEEREEEE: endofdump defined!
<<ot1.cmap>><<oml.cmap>><<oms.cmap>><<omx.cmap>> ...
(\end occurred when \ifcsname on line 6 was incomplete)
Beginning to dump on file test.fmt
 (preloaded format=test 2015.2.18)
...
20 words of pdfTeX memory
...

....這似乎工作正常。

但是,當我嘗試.pdf使用.fmt這樣的預編譯文件來建立文件時(我不將%&test註釋包含在文件的第一行test.tex,而是在命令行上指定它):

$ pdflatex --file-line-error --synctex=1 "&test" test.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014) (preloaded format=pdflatex)
...
==============================================================================
JOB NAME         : "test"
CUSTOMISED FORMAT: "test"
PRELOADED FILES:
setup/_preamble.tex
...
  t1cmtt.fd    2014/09/29 v2.5h Standard LaTeX font definitions
  t1cmss.fd    2014/09/29 v2.5h Standard LaTeX font definitions

==============================================================================
(mylatexformat)Info: start reading document "test"
(mylatexformat)      on input line 13. (\endofdump)
==============================================================================
(./setup/_preamble.tex

./setup/_preamble.tex:1: LaTeX Error: Two \documentclass or \documentstyle commands.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.1 \documentclass[10pt]{
                         book}
?

.... 因為某些原因,甚至如果預編譯.fmt檔被加載,TeX仍然從 - 開始讀取,從而報告“兩個命令”setup/_preamble.tex的錯誤?\documentclass

我已經知道修復方法 - 它是刪除\inputin周圍的註釋百分比字元test.tex

%% This is the file `test.tex'

\input{setup/_preamble.tex}

% \csname endofdump\endcsname% may \def to \relax; https://tex.stackexchange.com/questions/57398
...

....然後使用預編譯.fmt檔(pdflatex "&test" test.tex)運行建置就可以了。

我的問題是 - 為什麼序言中的註解會對 的解析過程產生影響mylatexformat

相關內容