![¿Los comentarios en el preámbulo causan errores en la compilación con un archivo de formato "precompilado" usando mylatexformat?](https://rvso.com/image/305880/%C2%BFLos%20comentarios%20en%20el%20pre%C3%A1mbulo%20causan%20errores%20en%20la%20compilaci%C3%B3n%20con%20un%20archivo%20de%20formato%20%22precompilado%22%20usando%20mylatexformat%3F.png)
Considere el siguiente MWE - casi el mismo que en¿Fracaso con babel [griego] y lastpage, \frontmatter?, pero no exactamente, donde tengo un documento grande para el cual quería generar "encabezados precompilados" (Exteriorización de TikZ y mylatex(nota, \jobname debería ser el mismo)) y pensé en usarlo mylatexformat
(pdflatex ultrarrápido con precompilación).
La estructura se parece a esto:
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}
Si compilo esto con pdflatex test.tex
, se compila bien.
"Compilo" el test.fmt
archivo así:
$ 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
...
... que parece funcionar bien.
Pero cuando intento compilar el .pdf
archivo usando el archivo precompilado .fmt
de esta manera (no incluyo el %&test
comentario como la primera línea del test.tex
archivo, sino que lo especifico en la línea de comando):
$ 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}
?
... por alguna razón,inclusosi el .fmt
archivo precompilado está cargado, TeXaún¿Empieza a leer setup/_preamble.tex
y, por lo tanto, informa un error de "dos \documentclass
comandos"?
Ya conozco la solución: eliminar los caracteres de porcentaje de comentarios que rodean el \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
...
... y luego ejecutar la compilación con el .fmt
archivo precompilado ( pdflatex "&test" test.tex
) funciona bien.
Mi pregunta es: ¿por qué los comentarios en el preámbulo deberían tener alguna influencia en el proceso de análisis de mylatexformat
?