From 1b5a2b603c2cf0f0bb4876a2769438f6f31a8fff Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Wed, 23 Apr 2008 23:13:33 +0000
Subject: remaining knuth 2008 updates

git-svn-id: svn://tug.org/texlive/trunk@7621 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/tex/plain/base/gkpmac.tex | 43 +++++++++++++++++++++++++----
 1 file changed, 37 insertions(+), 6 deletions(-)

(limited to 'Master/texmf-dist/tex/plain/base/gkpmac.tex')

diff --git a/Master/texmf-dist/tex/plain/base/gkpmac.tex b/Master/texmf-dist/tex/plain/base/gkpmac.tex
index cdcd7b9c087..1ae0f1a7a68 100644
--- a/Master/texmf-dist/tex/plain/base/gkpmac.tex
+++ b/Master/texmf-dist/tex/plain/base/gkpmac.tex
@@ -10,6 +10,7 @@
 \font\textbf=cmbx10			% bold
 \font\textcsc=cccsc10		% caps and small caps
 \font\oldsty=ccmi10		% equation numbers
+\font\twelvett=cmtt12
 
 % Fonts for regular math
 % I'm setting \fontdimen2 to zero because AMS forgot to do it;
@@ -405,15 +406,37 @@
     \iftitle\hfil\copyrite\else\runhead\uppercase\expandafter{\chaptitle}\hfil\fi}}
 \def\rightheadline{\hbox to35pc{\iftitle\copyrite\fi\hfil
     \vbox to 10pt{}% strut to position the baseline
-    \runhead\uppercase\expandafter{\topmark}%
+    \iftitle\else\runhead\uppercase\expandafter{\topmark}\fi
     \rlap{\hfil\iftitle\rightcorner\else\foliofont\folio\fi\kern-2pc}}}
-\def\leftcorner{\vrule\vbox to\folioht{\hrule width9pt\vfil}}
-\def\rightcorner{\vbox to\folioht{\hrule width9pt\vfil}\vrule}
+\def\leftcorner{\iffinal\else\vrule\vbox to\folioht{\hrule width9pt\vfil}\fi}
+\def\rightcorner{\iffinal\else\vbox to\folioht{\hrule width9pt\vfil}\vrule\fi}
 \def\copyrite{\ifpreprint{\textfont2=\sevensy\sevenrm\copyright\ 1988
    Addison-Wesley Publishing Company; all rights reserved}\fi}
 
+\newdimen\htrimsize \htrimsize=7.5in
+\newdimen\vtrimsize \vtrimsize=9.1875in
+\newdimen\outermargin \outermargin=23mm
+\newdimen\topmargin \topmargin=10mm % plus height of the headline box
+\newbox\htrim \newbox\vtrim \newbox\trimmarks
+\setbox\htrim=\hbox to\htrimsize{\kern-.65in
+  \vrule height .2pt depth .2pt width .4in\hfil\vrule width.4in\kern-.65in}
+  \wd\htrim=0pt
+\setbox\vtrim=\vbox to\vtrimsize{\kern-.65in
+  \moveleft.2pt\hbox{\vrule height .4in}\vfil
+  \moveleft.2pt\hbox{\vrule height .4in}\kern-.65in}
+  \wd\vtrim=0pt
+\setbox\trimmarks=\hbox to0pt{\raise\vtrimsize\copy\htrim \copy\htrim
+     \copy\vtrim \kern\htrimsize \copy\vtrim\hss}
+  \ht\trimmarks=0pt \dp\trimmarks=0pt
+
+\newif\iffinal % are we making the final copy? (pages.tex says "999")
 \def\onepageout#1{\escapechar=-1 % for writing \tabrefs
-    \shipout\vbox to\totheight{ % here we define one page of output
+    \shipout % here we define one page of output
+      \iffinal % add the trim marks
+      \hbox to\htrimsize{\copy\trimmarks
+         \ifodd\pageno\hss\else \hskip\outermargin\fi
+         \vbox to\vtrimsize{\kern\topmargin\fi
+      \vbox to\totheight{
     \offinterlineskip % butt the boxes together
     \vbox to 2pc{ % this part goes on top of the regular pages
       \ifodd\pageno \rightheadline\else\leftheadline\fi
@@ -424,6 +447,9 @@
 	\ifodd\pageno \hbox to35pc{\hfil\foliofont\folio}
 	\else\hbox{\foliofont\folio}\fi\fi
     \ifpreprint\ifinxmode\makeinxfooter\fi\fi
+    \iffinal % finish the trimmed page
+      }\vfill}\ifodd\pageno\hskip\outermargin\else\hss\fi
+      \rlap{\smash{\lower30pt\hbox to.35in{\hss\twelvett\number\pageno}}}\fi
     }
   \advancepageno}
 
@@ -851,8 +877,13 @@
  {\endlinechar=-1\read\pages to\next
   \ifx\next\empty % in this case we should have eof now
   \else\global\nxtpg=\next\fi}\fi}
-\ifeof\pages\else\message{OK, I'll ship only the requested pages!}
- \getnxtpg\fi
+\ifeof\pages\finalfalse\else\finaltrue
+ \getnxtpg
+\ifnum\nxtpg=999
+ \message{OK, I'm making final copy with trim marks!}
+ \hoffset=-.5in
+ \getnxtpg % this should ensure eof on the \pages file
+\else\message{OK, I'll ship only the requested pages!}\fi\fi
 \def\shipout{\ifeof\pages\let\next=\Shipout
  \else\ifnum\pageno=\nxtpg\getnxtpg\let\next=\Shipout
   \else\let\next=\Tosspage\fi\fi \next}
-- 
cgit v1.2.3

