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