# fmt and command line commands (with e.g. mylatexformat)

I want to speed up the compilation process, so I splitted the main document in two files:

## MWE

preamble.tex

\documentclass{article}

\csname endofdump\endcsname


main.tex

\begin{document}

\ifdefined\test
:)
\else
:/
\fi

\end{document}


This works:

#!/bin/bash

pdftex -ini -jobname="preamble" "&pdflatex" mylatexformat.ltx "preamble.tex"
pdflatex -fmt preamble "main.tex"


## Problem

However, I want to pass data from command line to tex to get a happy smilie,

#!/bin/bash
pdftex -ini -jobname="preamble" "&pdflatex" mylatexformat.ltx "preamble.tex"
pdflatex -fmt preamble "\def\test{1}\input{main}"


and I stumble across an interactive mode where I don't know what to do. Using the -no-parse-first-line doesn't help either.

texput.log

This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2015/dev/Debian) (preloaded format=preamble 2014.12.16)  16 DEC 2014 14:17
entering extended mode
restricted \write18 enabled.
**\def\test{1}\input{main}

==============================================================================
JOB NAME         : "texput"
CUSTOMISED FORMAT: "preamble"
article.cls    2007/10/19 v1.4h Standard LaTeX document class
size10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)

==============================================================================
*
! Emergency stop.
<*> \def\test{1}\input{main}

End of file on the terminal!

Here is how much of TeX's memory you used:
3 strings out of 494701
113 string characters out of 6174765
48268 words of memory out of 5000000
3561 multiletter control sequences out of 15000+600000
7639 words of font info for 26 fonts, out of 8000000 for 9000
14 hyphenation exceptions out of 8191
8i,0n,22p,42b,30s stack positions out of 5000i,500n,10000p,200000b,80000s
!  ==> Fatal error occurred, no output PDF file produced!

• Did you solve the problem in the end? I get into this situation when combining preamble pre-compilation with tikz externalization... Feb 16, 2015 at 14:07
• @ingomueller.net: Unfortunately I haven't found a solution :/ An idea for a workaround: generating a config.tex file by the scripts which are used to build the document Feb 17, 2015 at 23:33

I'm no expert on this, but I guess mylatexformat doesn't scan through input files recursively, thus never encounters the literal \begin{document} in main.tex, necessary to mark the end of the format according to its documentation. At least for your MWE, it works if you issue \endofdump (the alternative to mark the end of the format, to avoid two \begin{document}) on the command line:
pdflatex -fmt preamble "\endofdump\def\test{1}\input{main}"