次の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まだ-から読み取りを開始し、「2 つのコマンド」setup/_preamble.tex
というエラーを報告しますか?\documentclass
\input
修正方法は既にわかっています。それは、を囲むコメント パーセント文字を削除することです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
。