Debian Codegraph @

texmf-dist/source/latex/tikz-page/tikz-page.dtx

raw
1 % \iffalse meta-comment % -*- latex -*-
2 %
3 %<*ignore>
4 \begingroup
5 \catcode123=1 %
6 \catcode125=2 %
7 \def\x{LaTeX2e}%
8 \expandafter\endgroup
9 \ifcase 0\ifx\install y1\fi\expandafter
10 \ifx\csname processbatchFile\endcsname\relax\else1\fi
11 \ifx\fmtname\x\else 1\fi\relax
12 \else\csname fi\endcsname
13 %</ignore>
14 %<*install>
15 \input docstrip.tex
16 \keepsilent
17
18 \usedir{tex/latex/tikz-page}
19
20 \let\MetaPrefix\relax
21 \preamble
22 This is a generated file.
23
24 Copyright © 2016 by Sébastien Gross <seb•ɑƬ•chezwam•ɖɵʈ•org>
25
26 This program is free software. It comes without any warranty, to the extent
27 permitted by applicable law. You can redistribute it and/or modify it under
28 the terms of the Do What The Fuck You Want To Public License, Version 2, as
29 published by Sam Hocevar. See http://sam.zoy.org/wtfpl/COPYING for more
30 details.
31
32 This file may be distributed and/or modified under the conditions of
33 the LaTeX Project Public License, either version 1.3c of this license
34 or (at your option) any later version. The latest version of this
35 license is in:
36
37 http://www.latex-project.org/lppl.txt
38
39 and version 1.3c or later is part of all distributions of LaTeX
40 version 2006/05/20 or later.
41
42 \endpreamble%
43 \let\MetaPrefix\DoubleperCent
44
45
46 \generate{\file{tikz-page.sty}{\from{tikz-page.dtx}{tikz-page}}}
47
48 \obeyspaces
49 \Msg{*************************************************************}
50 \Msg{* *}
51 \Msg{* To finish the installation you have to move the following *}
52 \Msg{* file into a directory searched by TeX: *}
53 \Msg{* *}
54 \Msg{* tikz-page.sty *}
55 \Msg{* *}
56 \Msg{* To produce the documentation run the file mypackage.dtx *}
57 \Msg{* through LaTeX. *}
58 \Msg{* *}
59 \Msg{* Happy TeXing! *}
60 \Msg{* *}
61 \Msg{*************************************************************}
62 \endbatchfile
63 %</install>
64 %<*ignore>
65 \fi
66 %</ignore>
67 %<*driver>
68 \ProvidesFile{tikz-page.drv}
69 \documentclass{ltxdoc}
70 \EnableCrossrefs
71 \CodelineIndex
72 \RecordChanges
73 \usepackage[english]{babel}
74 \usepackage[T1]{fontenc}
75 \usepackage[utf8]{inputenc}
76 \usepackage{tcolorbox}
77 \tcbuselibrary{listings,documentation}
78 \tcbuselibrary{documentation,listings,minted}
79 \tcbuselibrary{breakable}
80 \tcbuselibrary{skins,raster}
81 \tcbset{listing engine=minted}
82 \usepackage{url}
83 \usepackage{minted}
84 \usepackage{calc}
85 \usepackage{makeidx}
86 \usepackage[textpos]{tikz-page}
87 \renewcommand{\headrulewidth}{0pt}
88 \makeindex
89 \definecolor{halfgray}{gray}{0.55}
90 \newcommand\anglei{-45}
91 \newcommand\angleii{45}
92 \newcommand\angleiii{225}
93 \newcommand\angleiv{135}
94 \newcommand{\pagedecoration}{
95 \tpflip{
96 \coordinate (aux1) at ([yshift=-15pt]page.northeast);
97 \coordinate (aux2) at ([yshift=-410pt]page.northeast);
98 \coordinate (aux3) at ([xshift=-4.5cm]page.northeast);
99 \coordinate (aux4) at ([yshift=-150pt]page.northeast);
100 }{
101 \coordinate (aux1) at ([yshift=-15pt]page.northwest);
102 \coordinate (aux2) at ([yshift=-410pt]page.northwest);
103 \coordinate (aux3) at ([xshift=4.5cm]page.northwest);
104 \coordinate (aux4) at ([yshift=-150pt]page.northwest);
105 \renewcommand\anglei{-135}
106 \renewcommand\angleii{135}
107 \renewcommand\angleiii{-45}
108 \renewcommand\angleiv{45}
109 }
110 \begin{scope}[halfgray!40,line width=12pt,rounded corners=12pt]
111 \draw (aux1) -- coordinate (a) ++(\angleiii:5) -- ++(\anglei:5.1) coordinate (b);
112 \draw[shorten <= -10pt] (aux3) -- (a) -- (aux1);
113 \draw[opacity=0.6,halfgray,shorten <= -10pt] (b) -- ++(\angleiii:2.2) -- ++(\anglei:2.2);
114 \end{scope}
115 \draw[halfgray,line width=8pt,rounded corners=8pt,shorten <= -10pt]
116 (aux4) -- ++(\angleiii:0.8) -- ++(\anglei:0.8);
117 \begin{scope}[halfgray!70,line width=6pt,rounded corners=8pt]
118 \draw[shorten <= -10pt] (aux2) -- ++(\angleiii:3) coordinate[pos=0.45] (c) -- ++(\anglei:3.1);
119 \draw (aux2) -- (c) -- ++(\angleiv:2.5) -- ++(\angleii:2.5) -- ++(\anglei:2.5) coordinate[pos=0.3] (d);
120 \draw (d) -- +(\angleii:1);
121 \end{scope}
122 }
123
124 \newcommand{\tikzpagelayout}{
125 \pagedecoration
126 \node [,outer sep=0,inner sep=0,anchor=base] at (page.footer center) {\thepage};
127 \node [,outer sep=0,inner sep=0,anchor=base, rotate=90, color=black!10] at (page.left south) {\footnotesize{tikz-page \pkgfileversion}};
128 }
129 \fancypagestyle{plain}{
130 \fancyhf{}
131 \chead{\tikzpage}
132 }
133 \fancypagestyle{titlepage}{
134 \fancyhf{}
135 \chead{\tikzpage}
136 }
137 \pagestyle{plain}
138 \begin{document}
139 \DocInput{tikz-page.dtx}
140 \printindex
141
142 \end{document}
143 %</driver>
144 %<*README>
145
146 %</README>
147
148 % \fi
149
150 % \iffalse
151 %% DeclareTCBListing{macrocode} leave a blank line after code.
152 % \fi
153
154 % \expandafter \let \csname macrocode\endcsname \relax \expandafter \let \csname endmacrocode\endcsname \relax
155 % \expandafter \let \csname macrocode*\endcsname \relax \expandafter \let \csname endmacrocode*\endcsname \relax
156 % \newminted[macrocode]{latex}{breaklines,breakafter=()/+-\\,baselinestretch=0.5,fontsize=\footnotesize,linenos,numbersep=3mm,firstnumber=last}
157 %
158 % \BeforeBeginEnvironment{macrocode}{%
159 % \begin{tcolorbox}[boxrule=0.1pt,colframe=red!75!black,left=8mm,width=\linewidth,breakable=true,colback=white,enhanced]}
160 % \AfterEndEnvironment{macrocode}{\end{tcolorbox}}%
161
162
163 % \newminted[example]{latex}{breaklines,breakafter=()/+-\\,baselinestretch=0.5,fontsize=\footnotesize}
164 % \BeforeBeginEnvironment{example}{%
165 % \begin{tcolorbox}[boxrule=0.1pt,colframe=red!75!black,left=8mm,width=\linewidth,breakable=true,colback=white,enhanced]}
166 % \AfterEndEnvironment{example}{\end{tcolorbox}}%
167
168 % \tcbset{
169 % tpexample/.style = {%
170 % enhanced jigsaw,
171 % lower separated=false,
172 % leftlower=0pt,
173 % rightlower=0pt,
174 % boxrule=0.1pt,
175 % breakable=true,
176 % colframe=red!75!black,
177 % colback=white,
178 % listing engine=minted,
179 % minted options={breaklines,breakafter=()/+-\\,baselinestretch=0.5,fontsize=\footnotesize},
180 % listing and comment,
181 % pdf comment,
182 % compilable listing,
183 % run pdflatex}
184 % }
185
186
187 % \iffalse
188 %<*tikz-page>
189 % \fi
190 \def\pkgfileversion{1.0}
191 \def\pkgfiledate{2016/08/22}
192 % \iffalse
193 %</tikz-page>
194 % \fi
195
196 % \title{the \textsc{tikz-page} package }
197 % \author {Sébastien Gross <seb chezwam org>}
198 % \date{This file describes version \pkgfileversion\ (\pkgfiledate)}
199 % \maketitle
200 % \tableofcontents
201
202
203 % \section{Introduction}
204
205 % There are many ways to embelish a page with \LaTeX. One of the most
206 % easiest way is to use |fancyhdr| which allows to redefine both headers and
207 % footer. The |geometry| package is also useful to setup correct margins. If
208 % you need to put some background materials this might become painful,
209 % especially if you need your background to reach the page borders.
210
211 % There are some trick that help you in this task. |tikz-page| helps you in
212 % this way by the use of semeral mechanisms. Either you can use plain |tikz|
213 % picture on the background of your page, or use the \meta{textpos} option
214 % which enables absolute |textpos| positionning. Each method has its
215 % benefits and nuisances. With |tikz| you have to compile your document
216 % twice (which can be painful while you are designing your page layout) and
217 % with |textpos| you can get some incompatibility issues (please refer to
218 % |textpos| documentation).
219
220 % |tikz-page| is trying to give you best of both world by creating a new
221 % page object in a |tikzpicture| with many anchors. So you can easily place
222 % your page material at its correct position.
223
224
225 % \section{Usage}
226
227 % Basically you only need to add \mintinline{latex}{\usepackage{tikz-page}}
228 % at the begining of your document. Then you have to declare a
229 % \docAuxCommand{tikzpagelayout} command which is executed inside the
230 % background |tikzpicture|. Thus you can access the |page| shape and all its
231 % anchors. For example the following simple example add the page number to
232 % the footer center:
233
234 % \iffalse
235 %<*example>
236 % \fi
237 % \begin{example}
238 \newcommand{tikzpagelayout}{%
239 \node [outer sep=0,inner sep=0,anchor=base] at (page.footer center) {\thepage};
240 }
241 % \end{example}
242 % \iffalse
243 %</example>
244 % \fi
245
246
247 % If you want to simulate the default |fancyhdr| behaviour you can define the
248 % \docAuxCommand{tikzpagelayout} as following:
249
250
251 % \iffalse
252 %<*example>
253 % \fi
254 % \begin{example}
255 \newcommand{tikzpagelayout}{%
256 \node [outer sep=0,inner sep=0, anchor=mid east] at (page.header east) {\tpflip{\sl\leftmark}{\sl\rightmark}};
257 \node [outer sep=0,inner sep=0, anchor=mid west] at (page.header west) {\tpflip{\sl\rightmark}{\sl\leftmark}};
258 \node [,outer sep=0,inner sep=0,anchor=base] at (page.footer center) {\thepage};
259 % \end{example}
260 % \iffalse
261 %</example>
262 % \fi
263
264 % A minimum working example:
265 % \iffalse
266 %<*example>
267 % \fi
268 %\begin{tcblisting}{tpexample}
269 \documentclass{article}
270 \usepackage{tikz-page}
271 \usepackage{lipsum}
272 \newcommand{\tikzpagelayout}{
273 \tpshowframes
274 \tikzpageputanchors
275 }
276 \pagestyle{plain}
277 \begin{document}
278 \lipsum
279 \end{document}
280 % \end{tcblisting}
281 % \iffalse
282 %</example>
283 % \fi
284
285
286 % A more complex example\cite{Graphical Decoration}:
287 % \iffalse
288 %<*example>
289 % \fi
290 %\begin{tcblisting}{tpexample}
291 \documentclass{article}
292 \usepackage{tikz-page}
293 \usepackage{lipsum}
294 \definecolor{halfgray}{gray}{0.55}
295 \newcommand\anglei{-45}
296 \newcommand\angleii{45}
297 \newcommand\angleiii{225}
298 \newcommand\angleiv{135}
299 \newcommand{\tikzpagelayout}{
300 \tpflip{
301 \coordinate (aux1) at ([yshift=-15pt]page.northeast);
302 \coordinate (aux2) at ([yshift=-410pt]page.northeast);
303 \coordinate (aux3) at ([xshift=-4.5cm]page.northeast);
304 \coordinate (aux4) at ([yshift=-150pt]page.northeast);
305 }{
306 \coordinate (aux1) at ([yshift=-15pt]page.northwest);
307 \coordinate (aux2) at ([yshift=-410pt]page.northwest);
308 \coordinate (aux3) at ([xshift=4.5cm]page.northwest);
309 \coordinate (aux4) at ([yshift=-150pt]page.northwest);
310 \renewcommand\anglei{-135}
311 \renewcommand\angleii{135}
312 \renewcommand\angleiii{-45}
313 \renewcommand\angleiv{45}
314 }
315 \begin{scope}[halfgray!40,line width=12pt,rounded corners=12pt]
316 \draw (aux1) -- coordinate (a) ++(\angleiii:5) -- ++(\anglei:5.1) coordinate (b);
317 \draw[shorten <= -10pt] (aux3) -- (a) -- (aux1);
318 \draw[opacity=0.6,halfgray,shorten <= -10pt] (b) -- ++(\angleiii:2.2) -- ++(\anglei:2.2);
319 \end{scope}
320 \draw[halfgray,line width=8pt,rounded corners=8pt,shorten <= -10pt]
321 (aux4) -- ++(\angleiii:0.8) -- ++(\anglei:0.8);
322 \begin{scope}[halfgray!70,line width=6pt,rounded corners=8pt]
323 \draw[shorten <= -10pt] (aux2) -- ++(\angleiii:3) coordinate[pos=0.45] (c) -- ++(\anglei:3.1);
324 \draw (aux2) -- (c) -- ++(\angleiv:2.5) -- ++(\angleii:2.5) -- ++(\anglei:2.5) coordinate[pos=0.3] (d);
325 \draw (d) -- +(\angleii:1);
326 \end{scope}
327 }
328 \pagestyle{plain}
329 \begin{document}
330 \lipsum
331 \end{document}
332 % \end{tcblisting}
333 % \iffalse
334 %</example>
335 % \fi
336
337
338
339 % \iffalse
340 %<*tikz-page>
341 % \fi
342
343 % \iffalse
344 %% Reset the FancyVerbLine counter to have the correct lines number in front
345 %% of implementation.
346 % \fi
347 % \setcounter{FancyVerbLine}{0}
348
349 % \section{Implementation}
350
351 % \begin{macrocode}
352 \NeedsTeXFormat{LaTeX2e}
353 \ProvidesPackage{tikz-page}[\pkgfiledate\space (v\pkgfileversion)]
354 % \end{macrocode}
355
356 % The \meta{textpos} option can be used if you want to use |textpos|
357 % \meta{overlay} option instead of |current page| to position the page
358 % layout. Beware that |textpos| with \meta{overlay} option maybe incompatible
359 % with some other packages. On the other hand |tikz| |current page| requires
360 % at least 2 compilation to work correctly. Thus you might want to use
361 % \meta{textpos} at conception time and remove this option for your final
362 % build or if you have incompatibility issues.
363
364 % \begin{macrocode}
365 \newif\if@tp@use@textpos\@tp@use@textposfalse
366 \DeclareOption{textpos}{\@tp@use@textpostrue}
367 \ProcessOptions
368
369 \if@tp@use@textpos
370 \RequirePackage[absolute]{textpos}
371 \fi
372 % \end{macrocode}
373
374 % \begin{macrocode}
375 \RequirePackage{fancyhdr}
376 \RequirePackage{tikz}
377 \usetikzlibrary{plotmarks,calc,shapes,positioning,decorations.text}
378 \RequirePackage{graphicx}
379 \RequirePackage{calc}
380 % \end{macrocode}
381
382
383 \makeatletter
384
385 % All margin sizes are defined in\docLength{@tp@left@margin},
386 % \docLength{@tp@right@margin}, \docLength{@tp@top@margin},
387 % \docLength{@tp@bottom@margin} their values are computed by the
388 % \refCom{tp@compute@margins}.
389
390 % \begin{macrocode}
391 \newlength{\@tp@left@margin}
392 \newlength{\@tp@right@margin}
393 \newlength{\@tp@top@margin}
394 \newlength{\@tp@bottom@margin}
395 % \end{macrocode}
396
397
398 % \begin{docCommand}{@tp@create@length}{\marg{block name}\marg{length name}}
399
400 % Generate a \cs{tp@\meta{block name}@\meta{length name}} length. This
401 % command is intended to be only used to create block length defined below.
402
403 % \begin{macrocode}
404 \newcommand\@tp@create@length[2]{%
405 \expandafter\newskip\csname tp@#1@#2\endcsname%
406 }%
407 % \end{macrocode}
408 % \end{docCommand}
409 %
410
411 % For each standard blocks in the page (|page|, |body|, |marginpar|,
412 % |header|, |footer|) and additionnal blocks (|top|, |right|, |bottom|,
413 % |left|), 6 lenths are computed in order to define their anchors. Each
414 % length is defined using the \refCom{@tp@create@length} macro.
415
416 % \begin{macrocode}
417 \foreach\@@tp@element in {page,body,marginpar,header,footer,top,right,bottom,left}{%
418 \foreach\@@tp@len in {xmin,xmax,xmid,ymin,ymax,ymid}{%
419 \@tp@create@length{\@@tp@element}{\@@tp@len}%
420 }}%
421 % \end{macrocode}
422
423 % \begin{docCommand}{tcflip}{\marg{odd page code}\marg{even page code}}
424 % Execute \meta{odd page even code} on odd pages and \meta{even page code}
425 % on even ones.
426 % \end{docCommand}
427 % \begin{macrocode}
428 \newcommand{\tpflip}[2]{\ifodd\thepage#1\else#2\fi}
429 % \end{macrocode}
430
431 % \begin{docCommand}{tp@compute@margins}{}
432 %
433 % This is where the magic happens. This command sets all \cs{tp@\meta{block
434 % name}@\meta{length name}} lengths.
435 %
436 % \end{docCommand}
437
438 % \begin{macrocode}
439 \def\tp@compute@margins{%
440 \setlength{\tp@page@xmin}{0pt}%
441 \setlength{\tp@page@ymin}{0pt}%
442 \setlength{\tp@page@xmax}{\paperwidth}%
443 \setlength{\tp@page@ymax}{\paperheight}%
444 \setlength{\tp@page@xmid}{\dimexpr(\tp@page@xmin+\tp@page@xmax)/2\relax}%
445 \setlength{\tp@page@ymid}{\dimexpr(\tp@page@ymin+\tp@page@ymax)/2\relax}%
446 %
447 \setlength\@tp@left@margin{\dimexpr(1in+\hoffset+\tpflip{\oddsidemargin}{\evensidemargin})\relax}%
448 \setlength\@tp@right@margin{\dimexpr(\paperwidth-\@tp@left@margin-\textwidth)\relax}%
449 \setlength\@tp@top@margin{\dimexpr(1in+\voffset+\topmargin+\headheight+\headsep)\relax}%
450 \setlength\@tp@bottom@margin{\dimexpr(\paperheight-(\textheight+\@tp@top@margin))\relax}%
451 %% Body computation
452 \setlength\tp@body@xmin{\dimexpr\tp@page@xmin+\@tp@left@margin\relax}%
453 \setlength\tp@body@xmax{\dimexpr\tp@page@xmax-\@tp@right@margin\relax}%
454 \setlength\tp@body@xmid{\dimexpr((\tp@body@xmax+\tp@body@xmin)/2)\relax}%
455 \setlength\tp@body@ymax{\dimexpr(\tp@page@ymax-\@tp@top@margin)\relax}%
456 \setlength\tp@body@ymin{\dimexpr\tp@body@ymin+\@tp@bottom@margin\relax}%
457 \setlength\tp@body@ymid{\dimexpr(\tp@body@ymin+(\tp@body@ymax-\tp@body@ymin)/2)\relax}%
458 %
459 %% Margin computation
460 %
461 \tpflip{%
462 \setlength\tp@marginpar@xmin{\dimexpr\tp@body@xmax+\marginparsep\relax}
463 \setlength\tp@marginpar@xmax{\dimexpr\tp@marginpar@xmin+\marginparwidth\relax}%
464 }{%
465 \setlength\tp@marginpar@xmax{\dimexpr\tp@body@xmin-\marginparsep\relax}%
466 \setlength\tp@marginpar@xmin{\dimexpr\tp@marginpar@xmax-\marginparwidth\relax}%
467 }%
468 \setlength\tp@marginpar@xmid{\dimexpr((\tp@marginpar@xmax+\tp@marginpar@xmin)/2)\relax}%
469 \setlength\tp@marginpar@ymax{\tp@body@ymax}%
470 \setlength\tp@marginpar@ymin{\tp@body@ymin}%
471 \setlength\tp@marginpar@ymid{\tp@body@ymid}%
472 %
473 %% header
474 %
475 \setlength\tp@header@xmax{\tp@body@xmax}%
476 \setlength\tp@header@xmin{\tp@body@xmin}%
477 \setlength\tp@header@xmid{\tp@body@xmid}%
478 \setlength\tp@header@ymin{\dimexpr\tp@body@ymax+\headsep\relax}%
479 \setlength\tp@header@ymax{\dimexpr\tp@header@ymin+\headheight\relax}%
480 \setlength\tp@header@ymid{\dimexpr((\tp@header@ymax+\tp@header@ymin)/2)\relax}%
481 %
482 %% footer
483 %
484 \setlength\tp@footer@xmax{\tp@body@xmax}%
485 \setlength\tp@footer@xmin{\tp@body@xmin}%
486 \setlength\tp@footer@xmid{\tp@body@xmid}%
487 \setlength\tp@footer@ymin{\dimexpr\tp@body@ymin-\footskip\relax}%
488 \setlength\tp@footer@ymax{\tp@footer@ymin}%
489 \setlength\tp@footer@ymid{\dimexpr((\tp@footer@ymax+\tp@footer@ymin)/2)\relax}%
490 %%
491 %% blocks%
492 %%
493 \setlength\tp@top@xmin{\tp@page@xmin}%
494 \setlength\tp@top@xmax{\tp@page@xmax}%
495 \setlength\tp@top@xmid{\dimexpr((\tp@top@xmax+\tp@top@xmin)/2)\relax}%
496 \setlength\tp@top@ymin{\tp@body@ymax}%
497 \setlength\tp@top@ymax{\tp@page@ymax}%
498 \setlength\tp@top@ymid{\dimexpr((\tp@top@ymax+\tp@top@ymin)/2)\relax}%
499 %%
500 \setlength\tp@bottom@xmin{\tp@page@xmin}%
501 \setlength\tp@bottom@xmax{\tp@page@xmax}%
502 \setlength\tp@bottom@xmid{\dimexpr((\tp@bottom@xmax+\tp@bottom@xmin)/2)\relax}%
503 \setlength\tp@bottom@ymin{\tp@page@ymin}%
504 \setlength\tp@bottom@ymax{\tp@body@ymin}%
505 \setlength\tp@bottom@ymid{\dimexpr((\tp@bottom@ymax+\tp@bottom@ymin)/2)\relax}%
506 %%
507 \setlength\tp@left@xmin{\tp@page@xmin}%
508 \setlength\tp@left@xmax{\tp@body@xmin}%
509 \setlength\tp@left@xmid{\dimexpr((\tp@left@xmax+\tp@left@xmin)/2)\relax}%
510 \setlength\tp@left@ymin{\tp@body@ymin}%
511 \setlength\tp@left@ymax{\tp@body@ymax}%
512 \setlength\tp@left@ymid{\dimexpr((\tp@left@ymax+\tp@left@ymin)/2)\relax}%
513 %%
514 \setlength\tp@right@xmin{\tp@body@xmax}%
515 \setlength\tp@right@xmax{\tp@page@xmax}%
516 \setlength\tp@right@xmid{\dimexpr((\tp@right@xmax+\tp@right@xmin)/2)\relax}%
517 \setlength\tp@right@ymin{\tp@body@ymin}%
518 \setlength\tp@right@ymax{\tp@body@ymax}%
519 \setlength\tp@right@ymid{\dimexpr((\tp@right@ymax+\tp@right@ymin)/2)\relax}%
520 }%% \end{macrocode}
521
522 % \begin{docCommand}{@tp@genanchors}{\marg{block name}}
523 % Generate all 9 anchors (|northwest|, |north|, |northest|, |west|,
524 % |center|, |east|, |southwest|, |south|, |southest|) for \meta{block name}.
525 % \end{docCommand}
526
527 % \begin{macrocode}
528 \def\@tp@genanchors#1{%
529 \anchor{#1 north}{\pgf@x=\csname tp@#1@xmid\endcsname \pgf@y=\csname tp@#1@ymax\endcsname}%
530 \anchor{#1 south}{\pgf@x=\csname tp@#1@xmid\endcsname \pgf@y=\csname tp@#1@ymin\endcsname}%
531 \anchor{#1 west}{\pgf@x=\csname tp@#1@xmin\endcsname \pgf@y=\csname tp@#1@ymid\endcsname}%
532 \anchor{#1 northwest}{\pgf@x=\csname tp@#1@xmin\endcsname \pgf@y=\csname tp@#1@ymax\endcsname}%
533 \anchor{#1 southwest}{\pgf@x=\csname tp@#1@xmin\endcsname \pgf@y=\csname tp@#1@ymin\endcsname}%
534 \anchor{#1 east}{\pgf@x=\csname tp@#1@xmax\endcsname \pgf@y=\csname tp@#1@ymid\endcsname}%
535 \anchor{#1 northeast}{\pgf@x=\csname tp@#1@xmax\endcsname \pgf@y=\csname tp@#1@ymax\endcsname}%
536 \anchor{#1 southeast}{\pgf@x=\csname tp@#1@xmax\endcsname \pgf@y=\csname tp@#1@ymin\endcsname}%
537 \anchor{#1 center}{\pgf@x=\csname tp@#1@xmid\endcsname \pgf@y=\csname tp@#1@ymid\endcsname}%
538 }%
539 % \end{macrocode}
540
541 % \begin{macrocode}
542 \newcommand\tp@pgfdeclareanchoralias[3]{%
543 \expandafter\def\csname pgf@anchor@#1@#3\expandafter\endcsname
544 \expandafter{\csname pgf@anchor@#1@#2\endcsname}}
545 % \end{macrocode}
546
547 % \begin{macrocode}
548 \pgfdeclareshape{page}{
549 \backgroundpath{
550 \pgfpathmoveto{\pgfpoint{\tp@page@xmin}{\tp@page@ymin}}
551 \pgfpathlineto{\pgfpoint{\tp@page@xmin}{\tp@page@ymax}}
552 \pgfpathlineto{\pgfpoint{\tp@page@xmax}{\tp@page@ymax}}
553 \pgfpathlineto{\pgfpoint{\tp@page@xmax}{\tp@page@xmin}}
554 \pgfpathclose
555 }
556 %% basic anchors
557 \anchor{north}{\pgf@x=\tp@page@xmid \pgf@y=\tp@page@ymax}%
558 \anchor{south}{\pgf@x=\tp@page@xmid \pgf@y=\tp@page@ymin}%
559 \anchor{west}{\pgf@x=\tp@page@xmin \pgf@y=\tp@page@ymid}%
560 \anchor{northwest}{\pgf@x=\tp@page@xmin \pgf@y=\tp@page@ymax}%
561 \anchor{southwest}{\pgf@x=\tp@page@xmin \pgf@y=\tp@page@ymin}%
562 \anchor{east}{\pgf@x=\tp@page@xmax \pgf@y=\tp@page@ymid}%
563 \anchor{northeast}{\pgf@x=\tp@page@xmax \pgf@y=\tp@page@ymax}%
564 \anchor{southeast}{\pgf@x=\tp@page@xmax \pgf@y=\tp@page@ymin}%
565 %\anchor{center}{\pgfpointorigin}
566 \anchor{center}{\pgf@x=\tp@page@xmid \pgf@y=\tp@page@ymid}
567 \anchor{origin}{\pgfpointorigin}%\pgf@x=0pt \pgf@y=0pt}
568 \@tp@genanchors{page}
569 %% Body anchors
570 \@tp@genanchors{body}
571 \@tp@genanchors{marginpar}
572 \@tp@genanchors{header}
573 \@tp@genanchors{footer}
574 \@tp@genanchors{top}
575 \@tp@genanchors{bottom}
576 \@tp@genanchors{left}
577 \@tp@genanchors{right}
578 }
579 % \end{macrocode}
580
581
582 %Create a new |tpx| mark to show anchor location when using
583 %\refCom{tikzpageputanchors} to display anchors on the page.
584 %
585 % \begin{macrocode}
586 \newdimen\tp@linewidth
587 \newdimen\tp@marksize
588 \setlength\tp@marksize{3pt}
589 \pgfdeclareplotmark{tpx}{
590 \setlength{\tp@linewidth}{\pgflinewidth}
591 \pgfsetlinewidth{0.1pt}
592 \pgfpathmoveto{\pgfpoint{-\tp@marksize}{-\tp@marksize}}
593 \pgfpathlineto{\pgfpoint{\tp@marksize}{\tp@marksize}}
594 \pgfpathmoveto{\pgfpoint{-\tp@marksize}{\tp@marksize}}
595 \pgfpathlineto{\pgfpoint{\tp@marksize}{-\tp@marksize}}
596 \pgfusepathqstroke
597 \setlength{\pgflinewidth}{\tp@linewidth}
598 }
599 % \end{macrocode}
600
601
602 % Anchors can be displayed block by block (using
603 % \cs{tikzpageputanchorsdefaults}, \cs{tikzpageputanchors}
604 % \cs{tikzpageputanchorsmarginpar}, \cs{tikzpageputanchorsheader},
605 % \cs{tikzpageputanchorsfooter}, \cs{tikzpageputanchorstop},
606 % \cs{tikzpageputanchorsright}, \cs{tikzpageputanchorsbottom},
607 % \cs{tikzpageputanchorsleft}) or globally (using \refCom{tikzpageputanchors}).
608
609 % \begin{macrocode}
610 \def\tikzpageputanchorsdefaults{
611 \foreach \anchor/\placement in {%
612 northwest/below right%
613 ,north/below%
614 ,northeast/below left%
615 ,west/right%
616 ,center/below%
617 ,east/left%
618 ,southwest/above right%
619 ,south/above%
620 ,southeast/above left%
621 } \draw[red,shift=(page.\anchor)] plot[mark=tpx%% my plot mark
622 ] coordinates{(0,0)}
623 node[blue,\placement] {\scriptsize\texttt{(page.\anchor)}};
624 }
625
626 \def\tikzpageputanchorsbody{
627 \foreach \anchor/\placement in {%
628 body northwest/below right%
629 ,body north/below%
630 ,body northeast/below left%
631 ,body west/right%
632 ,body center/below%
633 ,body east/left%
634 ,body southwest/above right%
635 ,body south/above%
636 ,body southeast/above left%
637 } \draw[red,shift=(page.\anchor)] plot[mark=tpx%% my plot mark
638 ] coordinates{(0,0)}
639 node[blue,\placement] {\scriptsize\texttt{(page.\anchor)}};
640 }
641
642
643 \def\tikzpageputanchorsmarginpar{
644 \foreach \anchor/\placement in {%
645 marginpar northwest/below left%
646 ,marginpar north/left%
647 ,marginpar northeast/above left%
648 ,marginpar west/below%
649 ,marginpar center/below%
650 ,marginpar east/above%
651 ,marginpar southwest/below right%
652 ,marginpar south/right%
653 ,marginpar southeast/above right%
654 } \draw[red,shift=(page.\anchor)] plot[mark=tpx%% my plot mark
655 ] coordinates{(0,0)}
656 node[blue,\placement, rotate=90] {\scriptsize\texttt{(page.\anchor)}};
657 }
658
659
660 \def\tikzpageputanchorsheader{
661 \foreach \anchor/\placement in {%
662 header northwest/above right%
663 ,header north/above%
664 ,header northeast/above left%
665 ,header west/right%
666 ,header center/right%
667 ,header east/left%
668 ,header southwest/below right%
669 ,header south/below%
670 ,header southeast/below left%
671 } \draw[red,shift=(page.\anchor)] plot[mark=tpx%% my plot mark
672 ] coordinates{(0,0)}
673 node[blue,\placement] {\scriptsize\texttt{(page.\anchor)}};
674 }
675
676
677 \def\tikzpageputanchorsfooter{
678 \foreach \anchor/\placement in {%
679 footer northwest/above right%
680 ,footer north/above%
681 ,footer northeast/above left%
682 ,footer west/right%
683 ,footer center/right%
684 ,footer east/left%
685 ,footer southwest/below right%
686 ,footer south/below%
687 ,footer southeast/below left%
688 } \draw[red,shift=(page.\anchor)] plot[mark=tpx%% my plot mark
689 ] coordinates{(0,0)}
690 node[blue,\placement] {\scriptsize\texttt{(page.\anchor)}};
691 }
692
693 \def\tikzpageputanchorstop{
694 \foreach \anchor/\placement in {%
695 top northwest/below right%
696 ,top north/below%
697 ,top northeast/below left%
698 ,top west/right%
699 ,top center/below%
700 ,top east/left%
701 ,top southwest/above right%
702 ,top south/above%
703 ,top southeast/above left%
704 } \draw[red,shift=(page.\anchor)] plot[mark=tpx%% my plot mark
705 ] coordinates{(0,0)}
706 node[blue,\placement] {\scriptsize\texttt{(page.\anchor)}};
707 }
708
709
710 \def\tikzpageputanchorsbottom{
711 \foreach \anchor/\placement in {%
712 bottom northwest/below right%
713 ,bottom north/below%
714 ,bottom northeast/below left%
715 ,bottom west/right%
716 ,bottom center/below%
717 ,bottom east/left%
718 ,bottom southwest/above right%
719 ,bottom south/above%
720 ,bottom southeast/above left%
721 } \draw[red,shift=(page.\anchor)] plot[mark=tpx%% my plot mark
722 ] coordinates{(0,0)}
723 node[blue,\placement] {\scriptsize\texttt{(page.\anchor)}};
724 }
725
726
727 \def\tikzpageputanchorsleft{
728 \foreach \anchor/\placement in {%
729 left northwest/below left%
730 ,left north/left%
731 ,left northeast/above left%
732 ,left west/below%
733 ,left center/below%
734 ,left east/above%
735 ,left southwest/below right%
736 ,left south/right%
737 ,left southeast/above right%
738 } \draw[red,shift=(page.\anchor)] plot[mark=tpx%% my plot mark
739 ] coordinates{(0,0)}
740 node[blue,\placement, rotate=90] {\scriptsize\texttt{(page.\anchor)}};
741 }
742
743 \def\tikzpageputanchorsright{
744 \foreach \anchor/\placement in {%
745 right northwest/below left%
746 ,right north/left%
747 ,right northeast/above left%
748 ,right west/below%
749 ,right center/below%
750 ,right east/above%
751 ,right southwest/below right%
752 ,right south/right%
753 ,right southeast/above right%
754 } \draw[red,shift=(page.\anchor)] plot[mark=tpx%% my plot mark
755 ] coordinates{(0,0)}
756 node[blue,\placement, rotate=90] {\scriptsize\texttt{(page.\anchor)}};
757 }
758 % \end{macrocode}
759
760 % \begin{docCommand}{tikzpageputanchors}{}
761 % A simple short hand to display all anchors at once.
762 % \end{docCommand}
763 % \begin{macrocode}
764 \def\tikzpageputanchors{
765 \tikzpageputanchorsdefaults
766 \tikzpageputanchorsbody
767 \tikzpageputanchorsmarginpar
768 \tikzpageputanchorsheader
769 \tikzpageputanchorsfooter
770 \tikzpageputanchorstop
771 \tikzpageputanchorsbottom
772 \tikzpageputanchorsleft
773 \tikzpageputanchorsright
774 }
775 % \end{macrocode}
776
777
778
779 % \begin{docCommand}{tpshowframes}{}
780 %
781 % Display |top|, |right|, |bottom| and |left| block using a specific
782 % background. This can be used in conjunction with \refCom{tikzpageputanchors} for
783 % debuging purposes.
784 %
785 % \end{docCommand}
786 % \begin{macrocode}
787 \def\tpshowframes{
788 \draw[fill=blue!50, opacity=.3, draw] (page.bottom northwest) rectangle (page.bottom southeast);
789 \draw[fill=yellow!50, opacity=.3, draw] (page.top northwest) rectangle (page.top southeast);
790 \draw[fill=red!50, opacity=.3, draw] (page.left northwest) rectangle (page.left southeast);
791 \draw[fill=green!50, opacity=.3, draw] (page.right northwest) rectangle (page.right southeast);
792 }
793 % \end{macrocode}
794
795
796 % \begin{docCommand}{tpfancyhdrdefault}{}
797 % An example to display headers and footer as |fancyhdr| does.
798 % \end{docCommand}
799 % \begin{macrocode}
800 \def\tpfancyhdrdefault{
801 \node [outer sep=0,inner sep=0, anchor=mid] at (page.header center) {};
802 \node [outer sep=0,inner sep=0, anchor=mid east] at (page.header east) {\tpflip{\sl\leftmark}{\sl\rightmark}};
803 \node [outer sep=0,inner sep=0, anchor=mid west] at (page.header west) {\tpflip{\sl\rightmark}{\sl\leftmark}};
804 \node [outer sep=0,inner sep=0, anchor=base east] at (page.footer east) {};
805 \node [,outer sep=0,inner sep=0,anchor=base] at (page.footer center) {\thepage};
806 \node [outer sep=0,inner sep=0, anchor=base west] at (page.footer west) {};
807 }
808 % \end{macrocode}
809
810 % \begin{docCommand}{tikzpage}{}
811 % Generate a |tikzpicture| for the whole page. if a \cs{tikzpagelayout}
812 % command exists, it will be executed.
813 % \end{docCommand}
814 % \begin{macrocode}
815 \newcommand{\tikzpage}{
816 \if@tp@use@textpos
817 \begin{textblock*}{\textwidth}[0,0](0pt,0pt)%
818 \fi
819 \tp@compute@margins%
820 \if@tp@use@textpos
821 \begin{tikzpicture}[]%
822 \clip (0,0) rectangle (\paperwidth, \paperheight);
823 \else
824 \begin{tikzpicture}[remember picture, overlay]%
825 \fi
826 \if@tp@use@textpos
827 \node[anchor=origin,shape=page] (page) {};
828 \else
829 \node[anchor=origin,shape=page] (page) at (current page.south west) {};
830 \fi
831 \@ifundefined{tikzpagelayout}{}{\tikzpagelayout}
832 \end{tikzpicture}%
833 \if@tp@use@textpos
834 \end{textblock*}%
835 \fi
836 }
837 % \end{macrocode}
838
839
840 \fancypagestyle{plain}{
841 \fancyhf{}
842 \chead{\tikzpage}
843 }
844 \fancypagestyle{empty}{
845 \fancyhf{}
846 \chead{\tikzpage}
847 }
848
849
850 %
851 \makeatother
852 % \iffalse
853 %</tikz-page>
854 % \fi
855 %
856 % \Finale
857 %
858 %
859 % \iffalse
860 % <*example>
861 % \fi
862 % \begin{thebibliography}{9}
863
864 % \bibitem{Graphical Decoration} Trying to do graphical decorations in
865 % “ClassicThesis style” \url{http://tex.stackexchange.com/questions/86294}
866 % \end{thebibliography}
867 % \iffalse
868 % </example>
869 % \fi
870
871 \endinput