使用 mylatexformat 时不显示背景图像

使用 mylatexformat 时不显示背景图像

为了优化数千个 PDF 文档的生成,我正在努力研究将包含主要包的 mylatexformat。

为了构建我们的工作,我将所有公共包放在一个需要预编译的文件中,并将所有与客户端相关的定义放在另一个文件中(在第二步中,我还将尝试为每个客户端预编译一些包和定义)。

但生成的 PDF 输出不包含信头背景。PDF 还显示页码,而我已定义不应显示页码。当我不使用 mylatexformat 时,此 Hello World ! 示例可正常运行。

penarch-通用-预编译.tex

\def\encodingdefault{OT1}\normalfont
\everyjob\expandafter{\the\everyjob\def\encodingdefault{TU}\normalfont}


\documentclass{article}


\usepackage{parskip}            % vertical space between paragraphs
\usepackage{xcolor}             % foreground (text, rules, etc.) and background colour management
\usepackage{soul}               % hyphenatable letterspacing, underlining, overstriking, highlighting
\usepackage{geometry}           % customize page layout
\usepackage{enumitem}           % enumerate, itemize and description lists
\usepackage{hyperref}           % hypertext links
\usepackage{qrcode}             % generate QR codes
\usepackage{fancyhdr}           % headers and footers
\usepackage{graphicx}           % support for graphics
\usepackage{tabularx}           % tables with adjustable width columns
\usepackage{scalerel}           % vertically scaling and stretching objects
\usepackage{amssymb}            % symbols found in the AMS symbol font msam and msbm
\usepackage{multicol}           % define a multicols environment which typesets text in multiple columns
\usepackage{pst-barcode}        % printing of barcodes, including qr codes
\usepackage{scrextend}          % required to left indent address block
\usepackage{marvosym}           % includes euro symbol
\usepackage{colortbl}           % background color for row, columns or individual cells in a table
\usepackage[absolute]{textpos}  % absolute positioning of text on the page
\usepackage{tikz}               % package for creating graphics
\usepackage{setspace}           % set spacing between lines
\usepackage{wallpaper}          % use pdf as background image (letterhead)

\title{Sections and Chapters}
\hypersetup{colorlinks=true,linkcolor=blue}     % define the layout of hyperlinks
\newcommand{\hlc}[2][yellow]{
    {\sethlcolor{#1} \hl{#2}}
}                                               % define a new command to highlight in another color
\newcommand{\dole}[1]{%
    \begin{tikzpicture}[remember picture,overlay]
        \node[anchor=east,xshift=0mm,yshift=-1.2mm]{#1};
    \end{tikzpicture}
}                                               % make a font to is aligned 1.2mm beneath the normal line

\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}     % define a new column type for a fixed-width centered-aligned column - middle vertical alignment
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}m{#1}}    % define a new column type for a fixed-width right-aligned column - middle vertical alignment
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}m{#1}}   % define a new column type for a fixed-width left-aligned column - middle vertical alignment
\newcolumntype{F}[1]{>{\raggedright\arraybackslash}p{#1}}   % define a new column type for a fixed-width left-aligned column - top vertical alignment

\setlength{\TPHorizModule}{10mm}                % 1 generic horizontal unit is equivalent to 10mm for a textblock
\setlength{\TPVertModule}{10mm}                 % 1 generic vertical unit is equivalent to 10mm for a textblock
\textblockorigin{0mm}{0mm}                      % top left corner set as origin for a textblock

\endofdump

penarch-客户端.tex

\usepackage{fontspec}                       % support for OpenType fonts

\geometry{
    a4paper,
    left=30mm,
    right=25mm,
    headheight=115pt,
    top=4.5cm,
    headsep=0cm,
    bottom=3.5cm,
    footskip=95pt
}

\pagenumbering{gobble}                          % sets page numbering off

\linespread{0.8}                                % change the line spacing for entire document
\setmainfont[Path=./fonts/,
    BoldItalicFont=CALIBRIZ.TTF,
    BoldFont      =CALIBRIB.TTF,
    ItalicFont    =CALIBRII.TTF]{CALIBRI.TTF}   % set main font to Calibri

\ULCornerWallPaper{1}{letterhead.pdf}

你好世界.tex

%&penarch-common-precompiled
\input{penarch-client}
\input{penarch-hyphenation-dutch}

\begin{document}


Hello World !


\end{document}

我的 shell 脚本

xelatex -ini -jobname="penarch-common-precompiled" "&xelatex" mylatexformat.ltx penarch-common-precompiled.tex
xelatex hello-world.tex

答案1

您必须添加\endofdump。如果没有它,mylatexformat 将忽略序言中的所有内容,直到 \begin{document}:

\endofdump
\input{penarch-client}
\input{penarch-hyphenation-dutch}

\begin{document}


Hello World !


\end{document}

相关内容