序言中的注释是否导致使用 mylatexformat 构建“预编译”格式文件时出现错误?

序言中的注释是否导致使用 mylatexformat 构建“预编译”格式文件时出现错误?

考虑以下 MWE - 几乎与[greek] 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

相关内容