所以我有一张 A0 纸,我想在上面粘贴代表原始 A0 海报展示的多张 A4 纸。我没有 A0 打印机。我只能打印 A4 纸。如何将 A0 乳胶海报打印成多张 A4 纸,以便我可以将它们粘在一起?
没有页面重叠,没有偏移 - 我想要获得4x4==16
A4 页面(我用于pdflatex
tex 到 pdf 打印)
答案1
较长的文章
答案由三部分组成:模拟海报创作、海报拆分阶段和验证我们努力的重建测试。我们可以在所有主要的 LaTeX 引擎上运行代码,例如运行以下三行:
lualatex mal-poster-input.tex
lualatex mal-poster-output.tex
lualatex mal-poster-reconstruction.tex
步骤1:海报创作(一页 PDF 文件);注释
mal-poster-input.tex
我制作了一张 A0 海报,a0poster
包。如果我们在参数中更改portrait
为,我们将获得海报替代方案。我通过运行以下命令验证了纸张尺寸:landscape
\documentclass
pdfinfo mal-poster-input.pdf
纸张尺寸为 2379.97 x 3368.13 pts(纵向)和 3368.13 x 2379.97 pts(横向)。我尝试为任何输入 PDF 文件准备通用解决方案,因此纸张尺寸并不那么重要。这是这两张海报的代码和预览。
% run: *latex mal-poster-input.tex
% let's use portrait or landscape in the class...
% use any paper size (and change font size accordingly), in this example we use a0...
\documentclass[a0,portrait]{a0poster}
\usepackage{kantlipsum}
\parindent=2cm % indentation of the first line in the paragraph
\begin{document}
\font\malfont=cmr10 at 39pt% setting up a font
\malfont % using the font
\kant[1-10]
\end{document}
第2步:拆分输入 PDF 文件;注意
mal-poster-output.tex
到第 7 行到第 11 行。在代码中,我们可以指定要使用哪个 PDF 文件、哪一页以及我们想要多少部分,此示例使用 4x4。我们可以预期有 16 页,拆分方向与阅读英文相同 - 从上到下(外
\foreach
循环)和从左到右(内\foreach
循环)。还有一个缩放选项,对于这篇文章我使用了0.92
,如果我们将值设置为1.00
它,则意味着之后将不会缩放页面。到第 26 行和第 27 行。我们可以将默认的 A4 纸更改为不同的纸张尺寸。这可能对某些任务有用。
到第 35 行。我们可以指定一个 TikZ 样式,该样式将在本阶段的最后阶段用于页面周围。在此示例中,您可以看到蓝色矩形,生产的建议值为
draw=none
。我使用一种方法在
\documentclass
加载之前先测试输入的 PDF 文件。因此我可以自动设置纸张的旋转。它会旋转纸张(纵向与横向),以便读者始终可以读取原始 PDF 文件的部分。我使用外循环和内
\foreach
循环进行分离,关键命令是\includegraphics
改变viewport
和clip
参数graphicx
包裹。我的第一个实验是使用绝对位置
tikz
包。但是它需要运行两次 TeX。可能有一些方法,比如pdfpages
只需运行一次即可完成的软件包。我也想要这个功能。:-) 经过多年,我终于学会了这个技巧,万岁!:从实际位置跳转到左上角,然后跳转到页面的中心。我2pt
在垂直方向上迷失了一段时间,关键步骤不是使用\baselineskip
(12pt
)而是\the\fontdimen6\font
(10pt
)。这种方法的结果是,我们只需要运行一次 TeX 并借助overlay
TikZ。我们得到了 16 页,并且我们在终端中获悉了纵向 A0 海报的进度:
注意:它以点(pt)为单位列出了原始 PDF 文件中使用的页码和尺寸 - 左下角的 x 和 y 坐标以及右上角的 x 和 y 坐标。
Processing page 1: 0.0, 2535.56119, 597.22202, 3380.74825
Processing page 2: 597.22202, 2535.56119, 1194.44403, 3380.74825
Processing page 3: 1194.44403, 2535.56119, 1791.66605, 3380.74825
Processing page 4: 1791.66605, 2535.56119, 2388.88806, 3380.74825
Processing page 5: 0.0, 1690.37413, 597.22202, 2535.56119
Processing page 6: 597.22202, 1690.37413, 1194.44403, 2535.56119
Processing page 7: 1194.44403, 1690.37413, 1791.66605, 2535.56119
Processing page 8: 1791.66605, 1690.37413, 2388.88806, 2535.56119
Processing page 9: 0.0, 845.18707, 597.22202, 1690.37413
Processing page 10: 597.22202, 845.18707, 1194.44403, 1690.37413
Processing page 11: 1194.44403, 845.18707, 1791.66605, 1690.37413
Processing page 12: 1791.66605, 845.18707, 2388.88806, 1690.37413
Processing page 13: 0.0, 0.00002, 597.22202, 845.18707
Processing page 14: 597.22202, 0.00002, 1194.44403, 845.18707
Processing page 15: 1194.44403, 0.00002, 1791.66605, 845.18707
Processing page 16: 1791.66605, 0.00002, 2388.88806, 845.18707
我附上了代码和这 16 页的预览。
% run once: *latex mal-poster-output.tex
\batchmode % Rather silent mode...
% I am a butcher, I'll slice your pdf file into pieces... ;-)
% ... and we will get a series of A4 papers...
% Basic settings for user...
\def\malfile{mal-poster-input.pdf} % name of the file
\def\malpage{1} % page in pdf file to be cut
\def\xmal{4} % number of cuts (x-axis), >1
\def\ymal{4} % number of cuts (y-axis), >1
\def\malscale{0.92} % postcut scaling (1.0 = no change; 0.92 common change)
% This file will be processed...
% Sort of hacking before \documentclass...
\makeatletter\input{graphicx.sty}\makeatother
\newbox\malbox
\setbox\malbox=\hbox{\includegraphics[page=\malpage]{\malfile}}
\ifnum\wd\malbox<\ht\malbox
\def\malpaper{portrait}
\else
\def\malpaper{landscape}
\fi
\documentclass[a4paper,\malpaper]{article}
\pagestyle{empty}
% Want to change the size? Uncomment and modify the following two lines...
%\paperwidth=21mm%
%\paperheight=29.7mm%
\pdfpagewidth=\paperwidth
\pdfpageheight=\paperheight
\usepackage{tikz}
% I am setting these two parameters right now before I forget to do that.
\tikzset{inner sep=0pt, outer sep=0pt}
\usetikzlibrary{calc}
% For intermediate+ TeXists... we can set a lot of things here...
\tikzset{pagestyle/.style={draw=blue,line width=0.01\paperwidth}}% or draw=none, draw=blue; common setting is draw=none
% opacity=50, it is not needed as rectangle is drawn first
\begin{document}
% ...Setting dimensions part...
% Dimensions related to the x-axis; \paperwidth (in pt)...
\pgfmathparse{\wd\malbox/\xmal}
\let\realx=\pgfmathresult
\pgfmathparse{2*\realx}
\let\secondx=\pgfmathresult
\pgfmathparse{\wd\malbox}
\let\lastinx=\pgfmathresult
% Dimensions related to the y-axis; \paperheight (in pt)...
\pgfmathparse{\ht\malbox/\ymal}
\let\realy=\pgfmathresult
\pgfmathparse{\ht\malbox-\realy}
\let\beforelasty=\pgfmathresult
\pgfmathparse{\ht\malbox}
\let\lastiny=\pgfmathresult
% ...The main part...
% Cycle from top to bottom...
\foreach \y in {\lastiny,\beforelasty,...,\realy} {%
% Cycle from left to right side...
\foreach \x in {\realx,\secondx,...,\lastinx} {%
% The core of this TeX file...
\newpage % One cut shown on one page...
% Computation of the opposite corner...
\pgfmathparse{\x-\realx}
\let\previousx=\pgfmathresult
\pgfmathparse{\y-\realy}
\let\previousy=\pgfmathresult
% Page number is... \thepage, therefore none computation is needed... :-)
% Message to the terminal...
\scrollmode % Write me something...
\message{Processing page \thepage: \previousx, \previousy, \x, \y}%
\batchmode % And go back to the silent mode...
% Show me that part of the pdf file, give me some fancy drawing...
% First: go to the left upper corner and then jump in the center of the page...
\pgfmathparse{1in+\oddsidemargin+\parindent-0.5\paperwidth}% left-right direction
\let\movemex=\pgfmathresult
\pgfmathparse{1in+\topmargin+\headheight+\headsep+\the\fontdimen6\font-0.5\paperheight}%
% up-down direction; or \baselineskip-2pt
\let\movemey=\pgfmathresult
% For more information and experiments of yours, please see the layouts package:
% http://ctan.org/pkg/layouts
% Including a portion of the pdf file into this document...
\begin{tikzpicture}[overlay] %no need for: remember picture ;-)
\node[scale=\malscale,pagestyle] at (-\movemex pt, \movemey pt) {%
\includegraphics[page={\malpage}, viewport={\previousx pt} {\previousy pt} {\x pt} {\y pt}, clip, width=\paperwidth]{\malfile}%
};% End of \node...
\end{tikzpicture}%
}% End of \x...
}% End of \y...
\end{document}
步骤3:重建原始 PDF 文件;注释
mal-poster-reconstruction.tex
现在,我们想验证一下我们的工作。对于pdfpages
解决方案开箱即用的包。我再次使用了测试输入 PDF 文件的方法(\ifnum...\fi
语句),因此我们不必手动设置纵向或横向模式,它是自动选择的。我附上了最后一个文件和重建海报版本的预览。
% run: *latex mal-poster-reconstruction.tex
\makeatletter\input{graphicx.sty}\makeatother
\def\maloutput{mal-poster-output.pdf}
\newbox\testbox
\setbox\testbox=\hbox{\includegraphics{\maloutput}}
\ifnum\wd\testbox<\ht\testbox
\def\orient{portrait}
\else
\def\orient{landscape}
\fi
% use any paper size here, in this example we use a0...
\documentclass[a0,\orient]{a0poster}
\pdfpagewidth=\paperwidth
\pdfpageheight=\paperheight
\usepackage{pdfpages}
\begin{document}
\includepdf[pages={-},nup=4x4,frame=true]{\maloutput}
\end{document}