fmt 和命令列命令(例如 mylatexformat)

fmt 和命令列命令(例如 mylatexformat)

我想加快編譯過程,所以我將主文檔分成兩個文件:

微量元素

序.tex

\documentclass{article}

\csname endofdump\endcsname

主文件

\begin{document}

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

\end{document}

這有效:

#!/bin/bash

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

問題

但是,我想將資料從命令列傳遞到 tex 以獲得快樂的笑臉,

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

我偶然發現了一種互動模式,我不知道該怎麼做。使用-不解析第一行也沒有幫助。

文字輸出日誌

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"
PRELOADED FILES:
 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!

答案1

我不是這方面的專家,但我想mylatexformat不會遞歸地掃描輸入文件,因此永遠不會遇到\begin{document}中的文字main.tex,需要根據其標記格式的結尾文件。至少對於您的 MWE,如果您在命令列上發出\endofdump(標記格式結尾的替代方法,以避免兩個),它可以工作:\begin{document}

pdflatex -fmt preamble "\endofdump\def\test{1}\input{main}"

相關內容