Debian Codegraph @

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

raw
1 % \iffalse meta-comment
2 %<=*COPYRIGHT>
3 %% Copyright (C) 2011-2012 by Martin Scharrer <[email protected]>
4 %% ----------------------------------------------------------------------
5 %% This work may be distributed and/or modified under the
6 %% conditions of the LaTeX Project Public License, either version 1.3
7 %% of this license or (at your option) any later version.
8 %% The latest version of this license is in
9 %% http://www.latex-project.org/lppl.txt
10 %% and version 1.3 or later is part of all distributions of LaTeX
11 %% version 2005/12/01 or later.
12 %%
13 %% This work has the LPPL maintenance status `maintained'.
14 %%
15 %% The Current Maintainer of this work is Martin Scharrer.
16 %%
17 %% This work consists of the files tikzpagenodes.dtx and tikzpagenodes.ins
18 %% and the derived filebase tikzpagenodes.sty.
19 %%
20 %<=/COPYRIGHT>
21 % \fi
22 %
23 % \iffalse
24 %<*driver>
25 \ProvidesFile{tikzpagenodes.dtx}[%
26 %<=*DATE>
27 2012/09/16
28 %<=/DATE>
29 %<=*VERSION>
30 v1.1
31 %<=/VERSION>
32 DTX file for tikzpagenodes package]
33 \documentclass{ydoc}
34 \GetFileInfo{tikzpagenodes.dtx}
35 \usepackage{tikzpagenodes}[\filedate]
36 \EnableCrossrefs
37 \CodelineIndex
38 \RecordChanges
39 \begin{document}
40 \DocInput{tikzpagenodes.dtx}
41 \PrintChanges
42 \PrintIndex
43 \end{document}
44 %</driver>
45 % \fi
46 %
47 % \CheckSum{308}
48 %
49 % \CharacterTable
50 % {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
51 % 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
52 % Digits \0\1\2\3\4\5\6\7\8\9
53 % Exclamation \! Double quote \" Hash (number) \#
54 % Dollar \$ Percent \% Ampersand \&
55 % Acute accent \' Left paren \( Right paren \)
56 % Asterisk \* Plus \+ Comma \,
57 % Minus \- Point \. Solidus \/
58 % Colon \: Semicolon \; Less than \<
59 % Equals \= Greater than \> Question mark \?
60 % Commercial at \@ Left bracket \[ Backslash \\
61 % Right bracket \] Circumflex \^ Underscore \_
62 % Grave accent \` Left brace \{ Vertical bar \|
63 % Right brace \} Tilde \~}
64 %
65 %
66 % \changes{v1.0}{2011/09/15}{First version.}
67 % \changes{v1.1}{2012/09/16}{Corrected positions of 'marginpar area' nodes.}
68 %
69 % \DoNotIndex{\newcommand,\newenvironment}
70 %
71 % \providecommand*{\url}{\texttt}
72 % \GetFileInfo{tikzpagenodes.dtx}
73 % \title{The \textsf{tikzpagenodes} package}
74 % \author{Martin Scharrer\\ \url{[email protected]}}
75 % \repository{https://bitbucket.org/martin_scharrer/tikzpagenodes}
76 %
77 % \maketitle
78 % \section{Introduction}
79 % The drawing bundle PGF/TikZ provides a special rectangle node \texttt{current page} which allows users to access all edges and the center of the current page.
80 % This is useful if material should be drawn or placed on absolute positions of the page.
81 % For this to work the \texttt{tikzpicture} need to use the \texttt{remember picture} option to remember its position relative to the page origin.
82 %
83 % Often material should also be drawn or placed relative to other areas of the page, e.g.\ the text area.
84 % Such a node can be defined manually as shown in the post \href{http://permalink.gmane.org/gmane.comp.tex.pgf.user/2078}{More special nodes} on the \texttt{pgf-users} list.
85 % This package was written to simplify this by providing real special nodes which are defined in the same way as \texttt{current page}.
86 % One difficulty is that in \texttt{twoside} mode odd and even pages have different margins. For this the author's other package \texttt{ifoddpage} is used.
87 %
88 % \section{Usage}
89 % The provided nodes can be used in all \env{tikzpicture}s which use the \texttt{remember picture} option. In the majority of the cases the option \texttt{overlay} should also be used
90 % to avoid that the picture reserves any space at the position its code is placed.
91 %
92 % The following special nodes are provided. They are rectangle in shape, possess all anchors of this shape:
93 %
94 % \par\medskip\par\noindent
95 % \begin{minipage}{\textwidth}
96 % \begin{tabular}{>{\ttfamily}ll}
97 % \toprule
98 % \normalfont Node & Description \\
99 % \midrule
100 % current page text area & Text area\footnote{Up to the baseline of the text area, i.e.\ the depth of the last line is not included} \small(\Macro\textwidth\relax$\times$\Macro\textheight) \\
101 % current page marginpar area & Marginpar area \small(\Macro\marginparwidth\relax$\times$\Macro\textheight) \\
102 % current page header area & Header area \small(\Macro\textwidth\relax$\times$\Macro\headerheight) \\
103 % current page footer area & Footer area \small(\Macro\textwidth\relax$\times$\Macro\headerheight
104 % \footnote{Officially there is no footer height. Its baseline has a distance of \Macro\footerskip from the baseline of the text area.
105 % Because using this value would make the upper edge equal to the lower edge of the text area node, the \Macro\headerheight is used as a decent replacement.}) \\
106 % \bottomrule
107 % \end{tabular}
108 % \end{minipage}
109 %
110 %
111 % \clearpage
112 % \section{Examples}
113 %
114 % \begin{examplecode}
115 % \tikz[remember picture,overlay] {%
116 % \draw [blue,line width=2mm]
117 % (current page.south west)
118 % rectangle
119 % (current page.north east)
120 % ;
121 % \draw [green]
122 % (current page text area.south west)
123 % rectangle
124 % (current page text area.north east)
125 % ;
126 % \draw [yellow]
127 % (current page marginpar area.south west)
128 % rectangle
129 % (current page marginpar area.north east)
130 % ;
131 % \draw [red]
132 % (current page header area.south west)
133 % rectangle
134 % (current page header area.north east)
135 % ;
136 % \draw [orange]
137 % (current page footer area.south west)
138 % rectangle
139 % (current page footer area.north east)
140 % ;
141 % }%
142 % \end{examplecode}
143 %
144 %
145 % \StopEventually{}
146 %
147 % \clearpage
148 % \section{Implementation}
149 %
150 % \iffalse
151 %<*tikzpagenodes.sty>
152 % \fi
153 % \begin{macrocode}
154 %<!COPYRIGHT>
155 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
156 \ProvidesPackage{tikzpagenodes}[%
157 %<!DATE>
158 %<!VERSION>
159 %<*DRIVER>
160 2099/01/01 develop
161 %</DRIVER>
162 Special PGF/TikZ nodes for areas of the page]
163 % \end{macrocode}
164 %
165 %
166 % \begin{macrocode}
167 \RequirePackage{tikz}
168 \RequirePackage{ifoddpage}
169 % \end{macrocode}
170 %
171 % \subsection{Different margins for odd and even pages in \texttt{twoside} mode}
172 %
173 % Update the page conditional for every picture which uses \texttt{remember picture}.
174 % \begin{macrocode}
175 \tikzset{every picture/.append style={execute at begin picture={%
176 \ifpgfrememberpicturepositiononpage
177 \checkoddpage
178 \fi
179 }}}
180 % \end{macrocode}
181 %
182 % \begin{macro}{\currentsidemargin}
183 % Expands to the current left side margin, i.e. \Macro\oddsidemargin for odd pages in |twoside| mode and all pages in |oneside| mode
184 % or \Macro\evensidemargin for even pages in |twoside| mode.
185 % \begin{macrocode}
186 \def\currentsidemargin{\ifoddpageoroneside\oddsidemargin\else\evensidemargin\fi}%
187 % \end{macrocode}
188 % \end{macro}
189 %
190 %
191 % \subsection{Often used lengths}
192 %
193 % \begin{macro}{\current@textarea@left}
194 % Complete left margin including 1in constant and offset. This value is used multiple times and therefore stored in macro.
195 % \begin{macrocode}
196 \def\current@textarea@left{(1in+\hoffset+\currentsidemargin)}
197 % \end{macrocode}
198 % \end{macro}
199 %
200 %
201 % \begin{macro}{\current@textarea@top}
202 % Complete top margin including 1in constant, offset and header. This value is used multiple times and therefore stored in macro.
203 % \begin{macrocode}
204 \def\current@textarea@top{(1in+\voffset+\topmargin+\headheight+\headsep)}
205 % \end{macrocode}
206 % \end{macro}
207 %
208 % \subsection{Node Definition Macro}
209 % Most required macros can be |\let| to the |current page| node.
210 % \begin{macrocode}
211 \def\@newtikzpagenode#1{%
212 \expandafter\let\csname pgf@sh@ns@#1\expandafter\endcsname\csname pgf@sh@ns@current page\endcsname
213 \expandafter\let\csname pgf@sh@nt@#1\expandafter\endcsname\csname pgf@sh@nt@current page\endcsname
214 \expandafter\let\csname pgf@sh@pi@#1\expandafter\endcsname\csname pgf@sh@pi@current page\endcsname
215 \expandafter\def\csname pgf@sh@np@#1\endcsname
216 }
217 % \end{macrocode}
218 %
219 % \subsection{Current Page Text Area Node}
220 % \begin{macrocode}
221 \@newtikzpagenode{current page text area}{%
222 \def\southwest{\pgfpoint{\current@textarea@left}{\paperheight-\current@textarea@top-\textheight}}%
223 \def\northeast{\pgfpoint{\current@textarea@left+\textwidth}{\paperheight-\current@textarea@top}}%
224 }
225 % \end{macrocode}
226 %
227 %
228 % \subsection{Current Page Marginpar Area Node}
229 % \begin{macrocode}
230 \@newtikzpagenode{current page marginpar area}{%
231 \def\southwest{\pgfpoint
232 {\current@textarea@left\ifoddpageoroneside+\textwidth+\marginparsep\else-\marginparsep-\marginparwidth\fi}%
233 {\paperheight-\current@textarea@top-\textheight}%
234 }%
235 \def\northeast{\pgfpoint
236 {\current@textarea@left\ifoddpageoroneside+\textwidth+\marginparsep+\marginparwidth\else-\marginparsep\fi}%
237 {\paperheight-\current@textarea@top}%
238 }%
239 }
240 % \end{macrocode}
241 %
242 %
243 % \subsection{Current Page Header Area Node}
244 % \begin{macrocode}
245 \@newtikzpagenode{current page header area}{%
246 \def\southwest{\pgfpoint{\current@textarea@left}{\paperheight-\current@textarea@top+\headsep}}%
247 \def\northeast{\pgfpoint{\current@textarea@left+\textwidth}{\paperheight-\current@textarea@top+\headsep+\headheight}}%
248 }
249 % \end{macrocode}
250 %
251 %
252 % \subsection{Current Page Footer Area Node}
253 % \begin{macrocode}
254 \@newtikzpagenode{current page footer area}{%
255 \def\southwest{\pgfpoint{\current@textarea@left}{\paperheight-\current@textarea@top-\textheight-\footskip}}%
256 \def\northeast{\pgfpoint{\current@textarea@left+\textwidth}{\paperheight-\current@textarea@top-\textheight-\footskip+\headheight}}%
257 }
258 % \end{macrocode}
259 %
260 % \subsection{Current Page Column Areas}
261 % \begin{macrocode}
262 \@newtikzpagenode{current page column 1 area}{%
263 \def\southwest{\pgfpoint{\current@textarea@left}{\paperheight-\current@textarea@top-\textheight}}%
264 \def\northeast{\pgfpoint{\current@textarea@left+\columnwidth}{\paperheight-\current@textarea@top}}%
265 }
266 % \end{macrocode}
267 %
268 % \begin{macrocode}
269 \@newtikzpagenode{current page column 2 area}{%
270 \def\southwest{\pgfpoint{\current@textarea@left+\columnwidth+\columnsep}{\paperheight-\current@textarea@top-\textheight}}%
271 \def\northeast{\pgfpoint{\current@textarea@left+2\columnwidth+\columnsep}{\paperheight-\current@textarea@top}}%
272 }
273 % \end{macrocode}
274 %
275 % \begin{macrocode}
276 \@newtikzpagenode{current page column 3 area}{%
277 \def\southwest{\pgfpoint{\current@textarea@left+2\columnwidth+2\columnsep}{\paperheight-\current@textarea@top-\textheight}}%
278 \def\northeast{\pgfpoint{\current@textarea@left+3\columnwidth+2\columnsep}{\paperheight-\current@textarea@top}}%
279 }
280 % \end{macrocode}
281 %
282 % \begin{macrocode}
283 \@newtikzpagenode{current page column 4 area}{%
284 \def\southwest{\pgfpoint{\current@textarea@left+3\columnwidth+3\columnsep}{\paperheight-\current@textarea@top-\textheight}}%
285 \def\northeast{\pgfpoint{\current@textarea@left+4\columnwidth+3\columnsep}{\paperheight-\current@textarea@top}}%
286 }
287 % \end{macrocode}
288 %
289 % \begin{macrocode}
290 \@newtikzpagenode{current page column 5 area}{%
291 \def\southwest{\pgfpoint{\current@textarea@left+4\columnwidth+4\columnsep}{\paperheight-\current@textarea@top-\textheight}}%
292 \def\northeast{\pgfpoint{\current@textarea@left+5\columnwidth+4\columnsep}{\paperheight-\current@textarea@top}}%
293 }
294 % \end{macrocode}
295 %
296 % \begin{macrocode}
297 \@newtikzpagenode{current page column 6 area}{%
298 \def\southwest{\pgfpoint{\current@textarea@left+5\columnwidth+5\columnsep}{\paperheight-\current@textarea@top-\textheight}}%
299 \def\northeast{\pgfpoint{\current@textarea@left+6\columnwidth+5\columnsep}{\paperheight-\current@textarea@top}}%
300 }
301 % \end{macrocode}
302 %
303 % \begin{macrocode}
304 \@newtikzpagenode{current page column 7 area}{%
305 \def\southwest{\pgfpoint{\current@textarea@left+6\columnwidth+6\columnsep}{\paperheight-\current@textarea@top-\textheight}}%
306 \def\northeast{\pgfpoint{\current@textarea@left+7\columnwidth+6\columnsep}{\paperheight-\current@textarea@top}}%
307 }
308 % \end{macrocode}
309 %
310 % \begin{macrocode}
311 \@newtikzpagenode{current page column 8 area}{%
312 \def\southwest{\pgfpoint{\current@textarea@left+7\columnwidth+7\columnsep}{\paperheight-\current@textarea@top-\textheight}}%
313 \def\northeast{\pgfpoint{\current@textarea@left+8\columnwidth+7\columnsep}{\paperheight-\current@textarea@top}}%
314 }
315 % \end{macrocode}
316 %
317 % \begin{macrocode}
318 \@newtikzpagenode{current page column 9 area}{%
319 \def\southwest{\pgfpoint{\current@textarea@left+8\columnwidth+8\columnsep}{\paperheight-\current@textarea@top-\textheight}}%
320 \def\northeast{\pgfpoint{\current@textarea@left+9\columnwidth+8\columnsep}{\paperheight-\current@textarea@top}}%
321 }
322 % \end{macrocode}
323 %
324 % \begin{macrocode}
325 \@newtikzpagenode{current page column 10 area}{%
326 \def\southwest{\pgfpoint{\current@textarea@left+9\columnwidth+9\columnsep}{\paperheight-\current@textarea@top-\textheight}}%
327 \def\northeast{\pgfpoint{\current@textarea@left+10\columnwidth+9\columnsep}{\paperheight-\current@textarea@top}}%
328 }
329 % \end{macrocode}
330 %
331 % \iffalse
332 %</tikzpagenodes.sty>
333 % \fi
334 %
335 % \Finale
336 % \endinput