1

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). That ended in failure, so in trying to derive an MWE to post, I think I stumbled upon a more precise problem.

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} % BAD with lastpage (+\frontmatter)!!!!
\usepackage{amsmath,amssymb}
\usepackage{csquotes}
\usepackage[backend=biber]{biblatex}
\usepackage{tikz}
\usepackage{siunitx}

\usepackage{lastpage}

test.tex

%% This is the file `test.tex'

\input{setup/_preamble.tex}

\csname endofdump\endcsname%

\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)
...
Beginning to dump on file test.fmt
 (preloaded format=test 2015.2.18)
31400 strings of total length 611843
661162 memory locations dumped; current usage is 654&652915
28229 multiletter control sequences
\font\nullfont=nullfont
\font\OMX/cmex/m/n/10=cmex10
...
20 words of pdfTeX memory
8 indirect objects
No pages of output.

pdfTeX warning: pdflatex: dangling objects discarded, no output file produced.
Transcript written on test.log.

Then I 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)
 restricted \write18 enabled.
...
==============================================================================
JOB NAME         : "test"
CUSTOMISED FORMAT: "test"
PRELOADED FILES:
setup/_preamble.tex
    book.cls    2014/09/29 v1.4h Standard LaTeX document class
...
==============================================================================
(mylatexformat)Info: start reading document "test"
(mylatexformat)      on input line 6. (\endofdump)
==============================================================================
(/media/disk/texlive/2014/texmf-dist/tex/latex/lipsum/lipsum.sty)
...
Output written on test.pdf (1 page, 41826 bytes).
SyncTeX written on test.synctex.gz.
Transcript written on test.log.

So the MWE as-is works with the "precompiled" .fmt file.

Now, if you comment the \usepackage[english]{babel}, and uncomment the \usepackage[greek,english]{babel} line in setup/_preamble.tex: the .fmt file can be built successfully, BUT building the .pdf fails with:

$ pdflatex --file-line-error --synctex=1 "&test" test.tex
...
==============================================================================
JOB NAME         : "test"
CUSTOMISED FORMAT: "test"
PRELOADED FILES:
setup/_preamble.tex
...
==============================================================================
(mylatexformat)Info: start reading document "test"
(mylatexformat)      on input line 6. (\endofdump)
==============================================================================
(/media/disk/texlive/2014/texmf-dist/tex/latex/lipsum/lipsum.sty)
...
(/media/disk/texlive/2014/texmf-dist/tex/latex/siunitx/siunitx-abbreviati
ons.cfg)<<ot1.cmap>><<ot1tt.cmap>><<t1.cmap>> 
AED: lastpage setting LastPage
[1{/media/disk/texlive/2014/texmf-var/fonts/map/pdftex/updmap/pdftex.map}
]
./test.tex:16: Use of \\@lipsum doesn't match its definition.
\text@command #1->\def \reserved@a {
                                    #1}\ifx \reserved@a \@empty \let \check@...
l.16 \end{document}

? 

... and the failure of \lipsum is, I guess, just a symptom of some other problem.

However, the .pdf build will succeed with precompiled .fmt and [greek,]{babel} if either \usepackage{lastpage} (in _preamble.tex) is commented; OR if \frontmatter (in test.tex) is commented?

And after this, I discovered that the .pdf build will fail even without using precompiled .fmt file (i.e. just with pdflatex test.tex) - even if in my original doc, I never got an error like this, before I started messing with .fmt files ?! (Although, I should note, the error I get in my original doc is not expressed as an error with \lipsum, the error message is different)

What am I doing wrong - and how can I get this set of packages to build with a precompiled .fmt file without an error?

(PS: may be related to Possible bug in babel-greek, TexLive 2014 - as it was also a problem with a .fmt file there, but I'm not sure).

  • 1
    You probably have an old version of lipsum; as far as I know, it has been corrected to avoid using \roman. – egreg Feb 18 '15 at 21:38
2

Ok, turns out this is the exact same problem solved by the answer by @egreg in Error when using Greek babel, mparhack and \pagenumbering{roman}. Here too, [greek,]{babel} redefines \thepage to use the unexpandable \textlatin - but the problem here occurs because {lastpage} wants to write \thepage into the .aux file, through its function/macro \lastpage@putl@bel.

So one solution is to add this to the setup/_preamble.tex:

\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

... and then, seemingly, all works fine for [greek,english]{babel} - even when generating and using the precompiled .fmt file.

So, after all, this had not much to do with mylatexformat as such (so I'll have to still look for an MWE to demonstrate the problem I still have :))

Btw, I saw this by using package {trace} in test.tex like this:

\input{setup/_preamble.tex}

\csname endofdump\endcsname%

\usepackage{lipsum}
\usepackage{trace}

\begin{document}
\frontmatter
\clearpage

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

\traceon % trace only the \end{document} part
\end{document}

... and then comparing the .log files (for [greek,english]{babel} run vs. [english]{babel} one) in meld.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.