Consider the following MWE - nearly the same as in Failure with [greek] babel and lastpage, \frontmatter?, but not exactly - where I have a large document, for which I wanted to generate "precompiled headers" (TikZ's externalization and mylatex (note, \jobname should be the same)) and thought I'd use mylatexformat for it (ultrafast pdflatex with precompiling).
The structure looks something like this:
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}
If I compile this with pdflatex test.tex, it compiles fine.
I "compile" the test.fmt file like this:
$ 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
...
... which seems to work fine.
But when I try to build the .pdf file using the precompiled .fmt file like this (I don't include the %&test comment as the first line of the test.tex file, but instead I specify it on the command line):
$ 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}
?
... for some reason, even if the precompiled .fmt file is loaded, TeX still starts reading from setup/_preamble.tex - and thus reports an error of "two \documentclass commands"?
I already know the fix - it is to remove the comment percent characters surrounding the \input in 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
...
... and then running the build with the precompiled .fmt file (pdflatex "&test" test.tex) works just fine.
My question is - why should comments in the preamble have influence at all in the parsing process of mylatexformat?
(\end occurred when \ifcsname on line 6 was incomplete)is an indication that bad things happened. – David Carlisle Feb 18 '15 at 19:38:)I thought I needed that\ifcsnamein order to handle package loading after the\endofdump, but I probably don't need it; so that part can probably be ignored, I guess... cheers! – sdaau Feb 18 '15 at 19:43