Debian Codegraph @

texmf-dist/source/latex/bophook/bophook.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright 2000-2001
4 % Karsten Tinnefeld <[email protected]>
5 %
6 % -----------------------------------------
7 % This file is part of the bophook package,
8 % a contribution to the LaTeX2e system.
9 % -----------------------------------------
10 %
11 % It may be distributed and/or modified under the conditions of the
12 % LaTeX Project Public License, either version 1.2 of this licence, or
13 % (at your option) any later version. The latest version of this license
14 % is in http://www.latex-project.org/lppl.txt and version 1.2 is part
15 % of all distributions of LaTeX version 1999/12/01 or later.
16 %
17 % This program consists of bophook.dtx and bophook.ins.
18 %
19 \NeedsTeXFormat{LaTeX2e}
20 %<*dtx>
21 \ProvidesFile{bophook.dtx}
22 %</dtx>
23 %<!driver>\ProvidesPackage{bophook}
24 %<driver>\ProvidesFile{bophook.drv}
25 % \fi
26 % \ProvidesFile{bophook.dtx}
27 [2001/03/29 v0.02 beginning-of-page hook, K. Tinnefeld]
28 % \iffalse
29 %<*driver>
30 \documentclass{ltxdoc}
31 \usepackage{multicol}
32 \GetFileInfo{bophook.dtx}
33 \newcommand*{\docdate}{2001/03/29}
34 \EnableCrossrefs
35 %\DisableCrossrefs% when index is ready
36 \CodelineIndex
37 \RecordChanges
38 \def\example{Re-run \LaTeX\ on the documentation after installing
39 {\MacroFont bophook.sty} in order to see an example of this.}
40 \IfFileExists{bophook.sty}{%
41 \RequirePackage{bophook}
42 \AtBeginPage{%
43 \setlength{\unitlength}{1cm}
44 \put(3, -5){\makebox(0,0)[tl]{\framebox{image}}}}
45 \def\example{This page has a box created according to these
46 parameters.}}{}
47 \begin{document}
48 \DocInput{bophook.dtx}
49 \end{document}
50 %</driver>
51 % \fi
52 %
53 % \CheckSum{99}
54 %
55 % \changes{v0.01}{2000/03/07}{Initial Revision (KT).}
56 % \changes{v0.02}{2001/03/29}{Adaptation for use with hyperref (KT).}
57 %
58 % \DoNotIndex{\@empty, \@begindvibox, \box, \CheckCommand, \dp,
59 % \else, \fi, \gdef, \global, \hb@xt@, \hss, \@ifpackageloaded,
60 % \ignorespaces, \let, \moveleft, \newcommand, \renewcommand, \relax,
61 % \setbox, \unvbox, \vbox, \vskip, \vss, \z@, \ProcessOptions}
62 %
63 % \date{printed \today}
64 % \title{\texttt{bophook}, a beginning-of-page hook\thanks{This file
65 % has version number \fileversion, last revised on \filedate,
66 % documentation dated \docdate.}}
67 % \author{Karsten Tinnefeld\\
68 % Universit\"at Dortmund\\
69 % \texttt{[email protected]}}
70 % \maketitle
71 %
72 % \section{Introduction}
73 % This program adds two \LaTeX\ hooks to set up the page layout and
74 % output material in the background of every page. In order to use
75 % the package with |hyperref|, you have to load |hyperref| first.
76 %
77 % \DescribeMacro{\AtBeginPage} Using the |\AtBeginPage| hook, you can
78 % add material in the background of a page. Think of it as a
79 % construct that does: For every page, create a picture environment
80 % with its origin at the top left corner\footnote{When I mean the top
81 % left corner or the paper, I do \emph{not} mean some 25.4mm down and
82 % to the right of it.} of the paper (resp., output device). So for
83 % example, you can put an image that is three centimeters from the
84 % left border and five from the top border by
85 % saying\footnote{\example}
86 % \begin{verbatim}
87 % \AtBeginPage{%
88 % \setlength{\unitlength}{1cm}
89 % \put(3, -5){\makebox(0,0)[tl]{\includegraphics{image}}}}
90 % \end{verbatim}
91 %
92 % Of course, reusing |\AtBeginPage| during the document changes the
93 % page background of the next page that is going to start. No
94 % spurious spaces are generated whatsoever. |\AtBeginPage| eats up
95 % every white space after its closing brace to allow its use in
96 % horizontal mode. This hook uses normal \TeX\ boxes and is
97 % therefore not bound with respect to a certain output driver.
98 %
99 % \DescribeMacro{\PageLayout} In normal \LaTeX\ page makeup, there is
100 % few if any room for a user to re-define page width and length
101 % and/or margin settings. These should be set in the |\ps@...|
102 % commands, but are sometimes interfering with current pages that
103 % have not yet been shipped out. The idea is that a page style
104 % command should give these makeup commands wrapped in
105 % |\PageLayout{}|, which is guaranteed to be executed on every page
106 % where that page style is in effect.
107 %
108 % \StopEventually {}
109 %
110 % \section{Realization}
111 % We straightforwardly modify the output routine where
112 % the |\AtBeginDvi| code takes place. This could clash with any
113 % other routine that does the same thing. Caveat emptor.
114 %
115 % Start by ignoring all options.
116 %
117 % \begin{macrocode}
118 \ProcessOptions \relax
119 % \end{macrocode}
120 %
121 % \begin{macro}{\PageLayout}
122 % The |\PageLayout| command just stores its argument in a global
123 % variable, which is initialized with the empty value.
124 % \begin{macrocode}
125 \newcommand*{\PageLayout}[1]{\gdef\BH@pagelayout{#1}\ignorespaces }
126 \let \BH@pagelayout \relax
127 % \end{macrocode}
128 % \end{macro}
129 %
130 % \begin{macro}{\AtBeginPage}
131 % Likewise does |\AtBeginPage|.
132 % \begin{macrocode}
133 \newcommand*{\AtBeginPage}[1]{\gdef\BH@originpic{#1}\ignorespaces }
134 \let \BH@originpic \relax
135 % \end{macrocode}
136 % \end{macro}
137 %
138 % The |hyperref| package does a lot of modification to the \LaTeX\
139 % kernel. Prepare for the case that it is loaded. Note that it has
140 % to be loaded prior to |bophook|!
141 %
142 % We check the original definition of the internal begin-dvi hook.
143 % In case this has been modified, either by a new kernel or another
144 % style file, a warning will be issued.
145 %
146 % \begin{macrocode}
147 \@ifpackageloaded{hyperref}{%
148 \CheckCommand*\@begindvi{%
149 \unvbox \@begindvibox
150 \ifHy@pageanchor
151 \@hyperfixhead
152 \global\let \@begindvi \@hyperfixhead
153 \else
154 \global\let \@begindvi \HyPL@EveryPage
155 \fi }}{%
156 \CheckCommand*\@begindvi{%
157 \unvbox \@begindvibox
158 \global\let \@begindvi \@empty}}
159 % \end{macrocode}
160 %
161 % \begin{macro}{\@begindvi}
162 % Having verified, that it is like it should have been, we insert
163 % our own code. |\AtBeginDvi|-code is still executed on the first
164 % page before the |\AtBeginPage|-code of page~1. No provision is
165 % taken (as it was) that |\AtBeginDvi|-code might create typeset
166 % output.
167 %
168 % |hyperref| performs different actions according to a switch.
169 % This behaviour is initiated at the start of the first page. We
170 % record it for reference in |\@BH@originpic|.
171 %
172 % \begin{macrocode}
173 \let \BH@hyperpageaction \@empty
174 \@ifpackageloaded{hyperref}{%
175 \renewcommand*\@begindvi{%
176 \unvbox \@begindvibox
177 \ifHy@pageanchor
178 \@hyperfixhead
179 \BH@originprint
180 \global\let \BH@hyperpageaction \@hyperfixhead
181 \else
182 \BH@originprint
183 \global\let \BH@hyperpageaction \HyPL@EveryPage
184 \fi
185 \global\let \@begindvi \BH@originprint
186 }}{% no hyperref
187 \renewcommand*\@begindvi{%
188 \unvbox \@begindvibox
189 \BH@originprint
190 \global\let \@begindvi \BH@originprint}}
191 % \end{macrocode}
192 % \end{macro}
193 %
194 % \begin{macro}{\BH@originprint}
195 % We create a box that will be inserted at the ``page origin'' in
196 % the arcane Knuthian sense, that is, one inch down and to the
197 % right of the output medium start. It consists of the move to the
198 % real origin and the formatting of the |\AtBeginPage|-code flush
199 % top left and taking no horizontal nor vertical space. As one can
200 % easily see from the documentation of the |picture|-environment,
201 % there is no magic about a |picture|---a |\put|-command can simply
202 % be issued everywhere. It is however well sensible to
203 % \emph{interprete} the typeset material as a |picture|.
204 %
205 % \begin{macrocode}
206 \newcommand*{\BH@originprint}{%
207 \setbox\@tempboxa\vbox to\z@{%
208 \vskip-1in \moveleft1in \vbox{%
209 \hb@xt@\z@{%
210 \BH@originpic\hss}}\vss}
211 \dp\@tempboxa\z@
212 \box\@tempboxa \BH@pagelayout
213 \BH@hyperpageaction }
214 % \end{macrocode}
215 % \end{macro}
216 %
217 %\Finale
218 %
219 %% \CharacterTable
220 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
221 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
222 %% Digits \0\1\2\3\4\5\6\7\8\9
223 %% Exclamation \! Double quote \" Hash (number) \#
224 %% Dollar \$ Percent \% Ampersand \&
225 %% Acute accent \' Left paren \( Right paren \)
226 %% Asterisk \* Plus \+ Comma \,
227 %% Minus \- Point \. Solidus \/
228 %% Colon \: Semicolon \; Less than \<
229 %% Equals \= Greater than \> Question mark \?
230 %% Commercial at \@ Left bracket \[ Backslash \\
231 %% Right bracket \] Circumflex \^ Underscore \_
232 %% Grave accent \` Left brace \{ Vertical bar \|
233 %% Right brace \} Tilde \~}
234 %
235 %\endinput