% The UCW Macro Collection (a successor of mjmac.tex)
-% Written by Martin Mares <mj@ucw.cz> in 2010 and placed into public domain
-% -------------------------------------------------------------------------
+% Written by Martin Mares <mj@ucw.cz> in 2010--2013 and placed into public domain
+% -------------------------------------------------------------------------------
%%% Prolog %%%
\ifx\pdfoutput\undefined
\else\ifnum\pdfoutput>0
\pdftrue
+ \pdfpkresolution=600 % Provide a reasonable default
\fi\fi
%%% Page size and margins %%%
\voffset=\topmargin
\advance\voffset by -1truein
\ifpdf
+ \pdfhorigin=1truein
+ \pdfvorigin=1truein
\pdfpagewidth=\pagewidth
\pdfpageheight=\pageheight
\fi
% Set all dimensions of a given box register to zero
\def\smashbox#1{\ht#1=0pt \dp#1=0pt \wd#1=0pt}
-\def\smashedhbox#1{{\setbox0=\hbox{#1}\smashbox0\box0}}
-\def\smashedvbox#1{{\setbox0=\vbox{#1}\smashbox0\box0}}
+\long\def\smashedhbox#1{{\setbox0=\hbox{#1}\smashbox0\box0}}
+\long\def\smashedvbox#1{{\setbox0=\vbox{#1}\smashbox0\box0}}
% Variants of \llap and \rlap working equally on both sides and/or vertically
\def\hlap#1{\hbox to 0pt{\hss #1\hss}}
% and underlays, which are zero-size vboxes positioned absolutely in the
% front / in the back of the normal material. Also, there are global
% versions of both which are not reset after every page.
-\def\addlay#1#2{\setbox#1=\vbox{\ifvbox#1\box#1\fi\smashedvbox{#2}}}
+\def\addlay#1#2{\setbox#1=\vbox{\ifvbox#1\box#1\fi\nointerlineskip\smashedvbox{#2}}}
\def\pageunderlay{\addlay\pageunderlays}
\def\pageoverlay{\addlay\pageoverlays}
\def\commonunderlay{\addlay\commonoverlays}
% Our variation on \plainoutput, which manages inner/outer margins and overlays
\output{\ucwoutput}
+\newdimen\pagebodydepth
\def\ucwoutput{\wigglepage\shipout\vbox{%
\makeheadline
\ifvbox\commonunderlays\copy\commonunderlays\nointerlineskip\fi
\ifvbox\pageunderlays\box\pageunderlays\nointerlineskip\fi
\pagebody
- \ifvbox\commonoverlays\vbox to 0pt{\vskip -\vsize\copy\commonoverlays}\fi
- \ifvbox\pageoverlays\vbox to 0pt{\vskip -\vsize\box\pageoverlays}\fi
+ \pagebodydepth=\prevdepth
+ \nointerlineskip
+ \ifvbox\commonoverlays\vbox to 0pt{\vskip -\vsize\copy\commonoverlays\vss}\nointerlineskip\fi
+ \ifvbox\pageoverlays\vbox to 0pt{\vskip -\vsize\box\pageoverlays\vss}\nointerlineskip\fi
+ \prevdepth=\pagebodydepth
\makefootline
}\advancepageno
\ifnum\outputpenalty>-\@MM \else\dosupereject\fi}