diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/tikz-page')
-rw-r--r-- | Master/texmf-dist/source/latex/tikz-page/tikz-page.dtx | 871 |
1 files changed, 871 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/tikz-page/tikz-page.dtx b/Master/texmf-dist/source/latex/tikz-page/tikz-page.dtx new file mode 100644 index 00000000000..27ffe0b964a --- /dev/null +++ b/Master/texmf-dist/source/latex/tikz-page/tikz-page.dtx @@ -0,0 +1,871 @@ +% \iffalse meta-comment % -*- latex -*- +% +%<*ignore> +\begingroup + \catcode123=1 % + \catcode125=2 % + \def\x{LaTeX2e}% +\expandafter\endgroup +\ifcase 0\ifx\install y1\fi\expandafter + \ifx\csname processbatchFile\endcsname\relax\else1\fi + \ifx\fmtname\x\else 1\fi\relax +\else\csname fi\endcsname +%</ignore> +%<*install> +\input docstrip.tex +\keepsilent + +\usedir{tex/latex/tikz-page} + +\let\MetaPrefix\relax +\preamble +This is a generated file. + +Copyright © 2016 by Sébastien Gross <seb•ɑƬ•chezwam•ɖɵʈ•org> + +This program is free software. It comes without any warranty, to the extent +permitted by applicable law. You can redistribute it and/or modify it under +the terms of the Do What The Fuck You Want To Public License, Version 2, as +published by Sam Hocevar. See http://sam.zoy.org/wtfpl/COPYING for more +details. + +This file may be distributed and/or modified under the conditions of +the LaTeX Project Public License, either version 1.3c 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.3c or later is part of all distributions of LaTeX +version 2006/05/20 or later. + +\endpreamble% +\let\MetaPrefix\DoubleperCent + + +\generate{\file{tikz-page.sty}{\from{tikz-page.dtx}{tikz-page}}} + +\obeyspaces +\Msg{*************************************************************} +\Msg{* *} +\Msg{* To finish the installation you have to move the following *} +\Msg{* file into a directory searched by TeX: *} +\Msg{* *} +\Msg{* tikz-page.sty *} +\Msg{* *} +\Msg{* To produce the documentation run the file mypackage.dtx *} +\Msg{* through LaTeX. *} +\Msg{* *} +\Msg{* Happy TeXing! *} +\Msg{* *} +\Msg{*************************************************************} +\endbatchfile +%</install> +%<*ignore> +\fi +%</ignore> +%<*driver> +\ProvidesFile{tikz-page.drv} +\documentclass{ltxdoc} +\EnableCrossrefs +\CodelineIndex +\RecordChanges +\usepackage[english]{babel} +\usepackage[T1]{fontenc} +\usepackage[utf8]{inputenc} +\usepackage{tcolorbox} +\tcbuselibrary{listings,documentation} +\tcbuselibrary{documentation,listings,minted} +\tcbuselibrary{breakable} +\tcbuselibrary{skins,raster} +\tcbset{listing engine=minted} +\usepackage{url} +\usepackage{minted} +\usepackage{calc} +\usepackage{makeidx} +\usepackage[textpos]{tikz-page} +\renewcommand{\headrulewidth}{0pt} +\makeindex +\definecolor{halfgray}{gray}{0.55} +\newcommand\anglei{-45} +\newcommand\angleii{45} +\newcommand\angleiii{225} +\newcommand\angleiv{135} +\newcommand{\pagedecoration}{ + \tpflip{ + \coordinate (aux1) at ([yshift=-15pt]page.northeast); + \coordinate (aux2) at ([yshift=-410pt]page.northeast); + \coordinate (aux3) at ([xshift=-4.5cm]page.northeast); + \coordinate (aux4) at ([yshift=-150pt]page.northeast); + }{ + \coordinate (aux1) at ([yshift=-15pt]page.northwest); + \coordinate (aux2) at ([yshift=-410pt]page.northwest); + \coordinate (aux3) at ([xshift=4.5cm]page.northwest); + \coordinate (aux4) at ([yshift=-150pt]page.northwest); + \renewcommand\anglei{-135} + \renewcommand\angleii{135} + \renewcommand\angleiii{-45} + \renewcommand\angleiv{45} + } + \begin{scope}[halfgray!40,line width=12pt,rounded corners=12pt] + \draw (aux1) -- coordinate (a) ++(\angleiii:5) -- ++(\anglei:5.1) coordinate (b); + \draw[shorten <= -10pt] (aux3) -- (a) -- (aux1); + \draw[opacity=0.6,halfgray,shorten <= -10pt] (b) -- ++(\angleiii:2.2) -- ++(\anglei:2.2); + \end{scope} + \draw[halfgray,line width=8pt,rounded corners=8pt,shorten <= -10pt] + (aux4) -- ++(\angleiii:0.8) -- ++(\anglei:0.8); + \begin{scope}[halfgray!70,line width=6pt,rounded corners=8pt] + \draw[shorten <= -10pt] (aux2) -- ++(\angleiii:3) coordinate[pos=0.45] (c) -- ++(\anglei:3.1); + \draw (aux2) -- (c) -- ++(\angleiv:2.5) -- ++(\angleii:2.5) -- ++(\anglei:2.5) coordinate[pos=0.3] (d); + \draw (d) -- +(\angleii:1); + \end{scope} +} + +\newcommand{\tikzpagelayout}{ + \pagedecoration + \node [,outer sep=0,inner sep=0,anchor=base] at (page.footer center) {\thepage}; + \node [,outer sep=0,inner sep=0,anchor=base, rotate=90, color=black!10] at (page.left south) {\footnotesize{tikz-page \pkgfileversion}}; +} +\fancypagestyle{plain}{ + \fancyhf{} + \chead{\tikzpage} +} +\fancypagestyle{titlepage}{ + \fancyhf{} + \chead{\tikzpage} +} +\pagestyle{plain} +\begin{document} +\DocInput{tikz-page.dtx} +\printindex + +\end{document} +%</driver> +%<*README> + +%</README> + +% \fi + +% \iffalse +%% DeclareTCBListing{macrocode} leave a blank line after code. +% \fi + +% \expandafter \let \csname macrocode\endcsname \relax \expandafter \let \csname endmacrocode\endcsname \relax +% \expandafter \let \csname macrocode*\endcsname \relax \expandafter \let \csname endmacrocode*\endcsname \relax +% \newminted[macrocode]{latex}{breaklines,breakafter=()/+-\\,baselinestretch=0.5,fontsize=\footnotesize,linenos,numbersep=3mm,firstnumber=last} +% +% \BeforeBeginEnvironment{macrocode}{% +% \begin{tcolorbox}[boxrule=0.1pt,colframe=red!75!black,left=8mm,width=\linewidth,breakable=true,colback=white,enhanced]} +% \AfterEndEnvironment{macrocode}{\end{tcolorbox}}% + + +% \newminted[example]{latex}{breaklines,breakafter=()/+-\\,baselinestretch=0.5,fontsize=\footnotesize} +% \BeforeBeginEnvironment{example}{% +% \begin{tcolorbox}[boxrule=0.1pt,colframe=red!75!black,left=8mm,width=\linewidth,breakable=true,colback=white,enhanced]} +% \AfterEndEnvironment{example}{\end{tcolorbox}}% + +% \tcbset{ +% tpexample/.style = {% +% enhanced jigsaw, +% lower separated=false, +% leftlower=0pt, +% rightlower=0pt, +% boxrule=0.1pt, +% breakable=true, +% colframe=red!75!black, +% colback=white, +% listing engine=minted, +% minted options={breaklines,breakafter=()/+-\\,baselinestretch=0.5,fontsize=\footnotesize}, +% listing and comment, +% pdf comment, +% compilable listing, +% run pdflatex} +% } + + +% \iffalse +%<*tikz-page> +% \fi +\def\pkgfileversion{1.0} +\def\pkgfiledate{2016/08/22} +% \iffalse +%</tikz-page> +% \fi + +% \title{the \textsc{tikz-page} package } +% \author {Sébastien Gross <seb chezwam org>} +% \date{This file describes version \pkgfileversion\ (\pkgfiledate)} +% \maketitle +% \tableofcontents + + +% \section{Introduction} + +% There are many ways to embelish a page with \LaTeX. One of the most +% easiest way is to use |fancyhdr| which allows to redefine both headers and +% footer. The |geometry| package is also useful to setup correct margins. If +% you need to put some background materials this might become painful, +% especially if you need your background to reach the page borders. + +% There are some trick that help you in this task. |tikz-page| helps you in +% this way by the use of semeral mechanisms. Either you can use plain |tikz| +% picture on the background of your page, or use the \meta{textpos} option +% which enables absolute |textpos| positionning. Each method has its +% benefits and nuisances. With |tikz| you have to compile your document +% twice (which can be painful while you are designing your page layout) and +% with |textpos| you can get some incompatibility issues (please refer to +% |textpos| documentation). + +% |tikz-page| is trying to give you best of both world by creating a new +% page object in a |tikzpicture| with many anchors. So you can easily place +% your page material at its correct position. + + +% \section{Usage} + +% Basically you only need to add \mintinline{latex}{\usepackage{tikz-page}} +% at the begining of your document. Then you have to declare a +% \docAuxCommand{tikzpagelayout} command which is executed inside the +% background |tikzpicture|. Thus you can access the |page| shape and all its +% anchors. For example the following simple example add the page number to +% the footer center: + +% \iffalse +%<*example> +% \fi +% \begin{example} +\newcommand{tikzpagelayout}{% + \node [outer sep=0,inner sep=0,anchor=base] at (page.footer center) {\thepage}; +} +% \end{example} +% \iffalse +%</example> +% \fi + + +% If you want to simulate the default |fancyhdr| behaviour you can define the +% \docAuxCommand{tikzpagelayout} as following: + + +% \iffalse +%<*example> +% \fi +% \begin{example} +\newcommand{tikzpagelayout}{% + \node [outer sep=0,inner sep=0, anchor=mid east] at (page.header east) {\tpflip{\sl\leftmark}{\sl\rightmark}}; + \node [outer sep=0,inner sep=0, anchor=mid west] at (page.header west) {\tpflip{\sl\rightmark}{\sl\leftmark}}; + \node [,outer sep=0,inner sep=0,anchor=base] at (page.footer center) {\thepage}; +% \end{example} +% \iffalse +%</example> +% \fi + +% A minimum working example: +% \iffalse +%<*example> +% \fi +%\begin{tcblisting}{tpexample} +\documentclass{article} +\usepackage{tikz-page} +\usepackage{lipsum} +\newcommand{\tikzpagelayout}{ + \tpshowframes + \tikzpageputanchors +} +\pagestyle{plain} +\begin{document} +\lipsum +\end{document} +% \end{tcblisting} +% \iffalse +%</example> +% \fi + + +% A more complex example\cite{Graphical Decoration}: +% \iffalse +%<*example> +% \fi +%\begin{tcblisting}{tpexample} +\documentclass{article} +\usepackage{tikz-page} +\usepackage{lipsum} +\definecolor{halfgray}{gray}{0.55} +\newcommand\anglei{-45} +\newcommand\angleii{45} +\newcommand\angleiii{225} +\newcommand\angleiv{135} +\newcommand{\tikzpagelayout}{ + \tpflip{ + \coordinate (aux1) at ([yshift=-15pt]page.northeast); + \coordinate (aux2) at ([yshift=-410pt]page.northeast); + \coordinate (aux3) at ([xshift=-4.5cm]page.northeast); + \coordinate (aux4) at ([yshift=-150pt]page.northeast); + }{ + \coordinate (aux1) at ([yshift=-15pt]page.northwest); + \coordinate (aux2) at ([yshift=-410pt]page.northwest); + \coordinate (aux3) at ([xshift=4.5cm]page.northwest); + \coordinate (aux4) at ([yshift=-150pt]page.northwest); + \renewcommand\anglei{-135} + \renewcommand\angleii{135} + \renewcommand\angleiii{-45} + \renewcommand\angleiv{45} + } + \begin{scope}[halfgray!40,line width=12pt,rounded corners=12pt] + \draw (aux1) -- coordinate (a) ++(\angleiii:5) -- ++(\anglei:5.1) coordinate (b); + \draw[shorten <= -10pt] (aux3) -- (a) -- (aux1); + \draw[opacity=0.6,halfgray,shorten <= -10pt] (b) -- ++(\angleiii:2.2) -- ++(\anglei:2.2); + \end{scope} + \draw[halfgray,line width=8pt,rounded corners=8pt,shorten <= -10pt] + (aux4) -- ++(\angleiii:0.8) -- ++(\anglei:0.8); + \begin{scope}[halfgray!70,line width=6pt,rounded corners=8pt] + \draw[shorten <= -10pt] (aux2) -- ++(\angleiii:3) coordinate[pos=0.45] (c) -- ++(\anglei:3.1); + \draw (aux2) -- (c) -- ++(\angleiv:2.5) -- ++(\angleii:2.5) -- ++(\anglei:2.5) coordinate[pos=0.3] (d); + \draw (d) -- +(\angleii:1); + \end{scope} +} +\pagestyle{plain} +\begin{document} +\lipsum +\end{document} +% \end{tcblisting} +% \iffalse +%</example> +% \fi + + + +% \iffalse +%<*tikz-page> +% \fi + +% \iffalse +%% Reset the FancyVerbLine counter to have the correct lines number in front +%% of implementation. +% \fi +% \setcounter{FancyVerbLine}{0} + +% \section{Implementation} + +% \begin{macrocode} +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{tikz-page}[\pkgfiledate\space (v\pkgfileversion)] +% \end{macrocode} + +% The \meta{textpos} option can be used if you want to use |textpos| +% \meta{overlay} option instead of |current page| to position the page +% layout. Beware that |textpos| with \meta{overlay} option maybe incompatible +% with some other packages. On the other hand |tikz| |current page| requires +% at least 2 compilation to work correctly. Thus you might want to use +% \meta{textpos} at conception time and remove this option for your final +% build or if you have incompatibility issues. + +% \begin{macrocode} +\newif\if@tp@use@textpos\@tp@use@textposfalse +\DeclareOption{textpos}{\@tp@use@textpostrue} +\ProcessOptions + +\if@tp@use@textpos +\RequirePackage[absolute]{textpos} +\fi +% \end{macrocode} + +% \begin{macrocode} +\RequirePackage{fancyhdr} +\RequirePackage{tikz} +\usetikzlibrary{plotmarks,calc,shapes,positioning,decorations.text} +\RequirePackage{graphicx} +\RequirePackage{calc} +% \end{macrocode} + + +\makeatletter + +% All margin sizes are defined in\docLength{@tp@left@margin}, +% \docLength{@tp@right@margin}, \docLength{@tp@top@margin}, +% \docLength{@tp@bottom@margin} their values are computed by the +% \refCom{tp@compute@margins}. + +% \begin{macrocode} +\newlength{\@tp@left@margin} +\newlength{\@tp@right@margin} +\newlength{\@tp@top@margin} +\newlength{\@tp@bottom@margin} +% \end{macrocode} + + +% \begin{docCommand}{@tp@create@length}{\marg{block name}\marg{length name}} + +% Generate a \cs{tp@\meta{block name}@\meta{length name}} length. This +% command is intended to be only used to create block length defined below. + +% \begin{macrocode} +\newcommand\@tp@create@length[2]{% + \expandafter\newskip\csname tp@#1@#2\endcsname% +}% +% \end{macrocode} +% \end{docCommand} +% + +% For each standard blocks in the page (|page|, |body|, |marginpar|, +% |header|, |footer|) and additionnal blocks (|top|, |right|, |bottom|, +% |left|), 6 lenths are computed in order to define their anchors. Each +% length is defined using the \refCom{@tp@create@length} macro. + +% \begin{macrocode} +\foreach\@@tp@element in {page,body,marginpar,header,footer,top,right,bottom,left}{% + \foreach\@@tp@len in {xmin,xmax,xmid,ymin,ymax,ymid}{% + \@tp@create@length{\@@tp@element}{\@@tp@len}% +}}% +% \end{macrocode} + +% \begin{docCommand}{tcflip}{\marg{odd page code}\marg{even page code}} +% Execute \meta{odd page even code} on odd pages and \meta{even page code} +% on even ones. +% \end{docCommand} +% \begin{macrocode} +\newcommand{\tpflip}[2]{\ifodd\thepage#1\else#2\fi} +% \end{macrocode} + +% \begin{docCommand}{tp@compute@margins}{} +% +% This is where the magic happens. This command sets all \cs{tp@\meta{block +% name}@\meta{length name}} lengths. +% +% \end{docCommand} + +% \begin{macrocode} +\def\tp@compute@margins{% + \setlength{\tp@page@xmin}{0pt}% + \setlength{\tp@page@ymin}{0pt}% + \setlength{\tp@page@xmax}{\paperwidth}% + \setlength{\tp@page@ymax}{\paperheight}% + \setlength{\tp@page@xmid}{\dimexpr(\tp@page@xmin+\tp@page@xmax)/2\relax}% + \setlength{\tp@page@ymid}{\dimexpr(\tp@page@ymin+\tp@page@ymax)/2\relax}% + % + \setlength\@tp@left@margin{\dimexpr(1in+\hoffset+\tpflip{\oddsidemargin}{\evensidemargin})\relax}% + \setlength\@tp@right@margin{\dimexpr(\paperwidth-\@tp@left@margin-\textwidth)\relax}% + \setlength\@tp@top@margin{\dimexpr(1in+\voffset+\topmargin+\headheight+\headsep)\relax}% + \setlength\@tp@bottom@margin{\dimexpr(\paperheight-(\textheight+\@tp@top@margin))\relax}% + %% Body computation + \setlength\tp@body@xmin{\dimexpr\tp@page@xmin+\@tp@left@margin\relax}% + \setlength\tp@body@xmax{\dimexpr\tp@page@xmax-\@tp@right@margin\relax}% + \setlength\tp@body@xmid{\dimexpr((\tp@body@xmax+\tp@body@xmin)/2)\relax}% + \setlength\tp@body@ymax{\dimexpr(\tp@page@ymax-\@tp@top@margin)\relax}% + \setlength\tp@body@ymin{\dimexpr\tp@body@ymin+\@tp@bottom@margin\relax}% + \setlength\tp@body@ymid{\dimexpr(\tp@body@ymin+(\tp@body@ymax-\tp@body@ymin)/2)\relax}% + % + %% Margin computation + % + \tpflip{% + \setlength\tp@marginpar@xmin{\dimexpr\tp@body@xmax+\marginparsep\relax} + \setlength\tp@marginpar@xmax{\dimexpr\tp@marginpar@xmin+\marginparwidth\relax}% + }{% + \setlength\tp@marginpar@xmax{\dimexpr\tp@body@xmin-\marginparsep\relax}% + \setlength\tp@marginpar@xmin{\dimexpr\tp@marginpar@xmax-\marginparwidth\relax}% + }% + \setlength\tp@marginpar@xmid{\dimexpr((\tp@marginpar@xmax+\tp@marginpar@xmin)/2)\relax}% + \setlength\tp@marginpar@ymax{\tp@body@ymax}% + \setlength\tp@marginpar@ymin{\tp@body@ymin}% + \setlength\tp@marginpar@ymid{\tp@body@ymid}% + % + %% header + % + \setlength\tp@header@xmax{\tp@body@xmax}% + \setlength\tp@header@xmin{\tp@body@xmin}% + \setlength\tp@header@xmid{\tp@body@xmid}% + \setlength\tp@header@ymin{\dimexpr\tp@body@ymax+\headsep\relax}% + \setlength\tp@header@ymax{\dimexpr\tp@header@ymin+\headheight\relax}% + \setlength\tp@header@ymid{\dimexpr((\tp@header@ymax+\tp@header@ymin)/2)\relax}% + % + %% footer + % + \setlength\tp@footer@xmax{\tp@body@xmax}% + \setlength\tp@footer@xmin{\tp@body@xmin}% + \setlength\tp@footer@xmid{\tp@body@xmid}% + \setlength\tp@footer@ymin{\dimexpr\tp@body@ymin-\footskip\relax}% + \setlength\tp@footer@ymax{\tp@footer@ymin}% + \setlength\tp@footer@ymid{\dimexpr((\tp@footer@ymax+\tp@footer@ymin)/2)\relax}% + %% + %% blocks% + %% + \setlength\tp@top@xmin{\tp@page@xmin}% + \setlength\tp@top@xmax{\tp@page@xmax}% + \setlength\tp@top@xmid{\dimexpr((\tp@top@xmax+\tp@top@xmin)/2)\relax}% + \setlength\tp@top@ymin{\tp@body@ymax}% + \setlength\tp@top@ymax{\tp@page@ymax}% + \setlength\tp@top@ymid{\dimexpr((\tp@top@ymax+\tp@top@ymin)/2)\relax}% + %% + \setlength\tp@bottom@xmin{\tp@page@xmin}% + \setlength\tp@bottom@xmax{\tp@page@xmax}% + \setlength\tp@bottom@xmid{\dimexpr((\tp@bottom@xmax+\tp@bottom@xmin)/2)\relax}% + \setlength\tp@bottom@ymin{\tp@page@ymin}% + \setlength\tp@bottom@ymax{\tp@body@ymin}% + \setlength\tp@bottom@ymid{\dimexpr((\tp@bottom@ymax+\tp@bottom@ymin)/2)\relax}% + %% + \setlength\tp@left@xmin{\tp@page@xmin}% + \setlength\tp@left@xmax{\tp@body@xmin}% + \setlength\tp@left@xmid{\dimexpr((\tp@left@xmax+\tp@left@xmin)/2)\relax}% + \setlength\tp@left@ymin{\tp@body@ymin}% + \setlength\tp@left@ymax{\tp@body@ymax}% + \setlength\tp@left@ymid{\dimexpr((\tp@left@ymax+\tp@left@ymin)/2)\relax}% + %% + \setlength\tp@right@xmin{\tp@body@xmax}% + \setlength\tp@right@xmax{\tp@page@xmax}% + \setlength\tp@right@xmid{\dimexpr((\tp@right@xmax+\tp@right@xmin)/2)\relax}% + \setlength\tp@right@ymin{\tp@body@ymin}% + \setlength\tp@right@ymax{\tp@body@ymax}% + \setlength\tp@right@ymid{\dimexpr((\tp@right@ymax+\tp@right@ymin)/2)\relax}% +}%% \end{macrocode} + +% \begin{docCommand}{@tp@genanchors}{\marg{block name}} +% Generate all 9 anchors (|northwest|, |north|, |northest|, |west|, +% |center|, |east|, |southwest|, |south|, |southest|) for \meta{block name}. +% \end{docCommand} + +% \begin{macrocode} +\def\@tp@genanchors#1{% + \anchor{#1 north}{\pgf@x=\csname tp@#1@xmid\endcsname \pgf@y=\csname tp@#1@ymax\endcsname}% + \anchor{#1 south}{\pgf@x=\csname tp@#1@xmid\endcsname \pgf@y=\csname tp@#1@ymin\endcsname}% + \anchor{#1 west}{\pgf@x=\csname tp@#1@xmin\endcsname \pgf@y=\csname tp@#1@ymid\endcsname}% + \anchor{#1 northwest}{\pgf@x=\csname tp@#1@xmin\endcsname \pgf@y=\csname tp@#1@ymax\endcsname}% + \anchor{#1 southwest}{\pgf@x=\csname tp@#1@xmin\endcsname \pgf@y=\csname tp@#1@ymin\endcsname}% + \anchor{#1 east}{\pgf@x=\csname tp@#1@xmax\endcsname \pgf@y=\csname tp@#1@ymid\endcsname}% + \anchor{#1 northeast}{\pgf@x=\csname tp@#1@xmax\endcsname \pgf@y=\csname tp@#1@ymax\endcsname}% + \anchor{#1 southeast}{\pgf@x=\csname tp@#1@xmax\endcsname \pgf@y=\csname tp@#1@ymin\endcsname}% + \anchor{#1 center}{\pgf@x=\csname tp@#1@xmid\endcsname \pgf@y=\csname tp@#1@ymid\endcsname}% +}% +% \end{macrocode} + +% \begin{macrocode} +\newcommand\tp@pgfdeclareanchoralias[3]{% + \expandafter\def\csname pgf@anchor@#1@#3\expandafter\endcsname + \expandafter{\csname pgf@anchor@#1@#2\endcsname}} +% \end{macrocode} + +% \begin{macrocode} +\pgfdeclareshape{page}{ + \backgroundpath{ + \pgfpathmoveto{\pgfpoint{\tp@page@xmin}{\tp@page@ymin}} + \pgfpathlineto{\pgfpoint{\tp@page@xmin}{\tp@page@ymax}} + \pgfpathlineto{\pgfpoint{\tp@page@xmax}{\tp@page@ymax}} + \pgfpathlineto{\pgfpoint{\tp@page@xmax}{\tp@page@xmin}} + \pgfpathclose + } + %% basic anchors + \anchor{north}{\pgf@x=\tp@page@xmid \pgf@y=\tp@page@ymax}% + \anchor{south}{\pgf@x=\tp@page@xmid \pgf@y=\tp@page@ymin}% + \anchor{west}{\pgf@x=\tp@page@xmin \pgf@y=\tp@page@ymid}% + \anchor{northwest}{\pgf@x=\tp@page@xmin \pgf@y=\tp@page@ymax}% + \anchor{southwest}{\pgf@x=\tp@page@xmin \pgf@y=\tp@page@ymin}% + \anchor{east}{\pgf@x=\tp@page@xmax \pgf@y=\tp@page@ymid}% + \anchor{northeast}{\pgf@x=\tp@page@xmax \pgf@y=\tp@page@ymax}% + \anchor{southeast}{\pgf@x=\tp@page@xmax \pgf@y=\tp@page@ymin}% + %\anchor{center}{\pgfpointorigin} + \anchor{center}{\pgf@x=\tp@page@xmid \pgf@y=\tp@page@ymid} + \anchor{origin}{\pgfpointorigin}%\pgf@x=0pt \pgf@y=0pt} + \@tp@genanchors{page} + %% Body anchors + \@tp@genanchors{body} + \@tp@genanchors{marginpar} + \@tp@genanchors{header} + \@tp@genanchors{footer} + \@tp@genanchors{top} + \@tp@genanchors{bottom} + \@tp@genanchors{left} + \@tp@genanchors{right} +} +% \end{macrocode} + + +%Create a new |tpx| mark to show anchor location when using +%\refCom{tikzpageputanchors} to display anchors on the page. +% +% \begin{macrocode} +\newdimen\tp@linewidth +\newdimen\tp@marksize +\setlength\tp@marksize{3pt} +\pgfdeclareplotmark{tpx}{ + \setlength{\tp@linewidth}{\pgflinewidth} + \pgfsetlinewidth{0.1pt} + \pgfpathmoveto{\pgfpoint{-\tp@marksize}{-\tp@marksize}} + \pgfpathlineto{\pgfpoint{\tp@marksize}{\tp@marksize}} + \pgfpathmoveto{\pgfpoint{-\tp@marksize}{\tp@marksize}} + \pgfpathlineto{\pgfpoint{\tp@marksize}{-\tp@marksize}} + \pgfusepathqstroke + \setlength{\pgflinewidth}{\tp@linewidth} +} +% \end{macrocode} + + +% Anchors can be displayed block by block (using +% \cs{tikzpageputanchorsdefaults}, \cs{tikzpageputanchors} +% \cs{tikzpageputanchorsmarginpar}, \cs{tikzpageputanchorsheader}, +% \cs{tikzpageputanchorsfooter}, \cs{tikzpageputanchorstop}, +% \cs{tikzpageputanchorsright}, \cs{tikzpageputanchorsbottom}, +% \cs{tikzpageputanchorsleft}) or globally (using \refCom{tikzpageputanchors}). + +% \begin{macrocode} +\def\tikzpageputanchorsdefaults{ + \foreach \anchor/\placement in {% + northwest/below right% + ,north/below% + ,northeast/below left% + ,west/right% + ,center/below% + ,east/left% + ,southwest/above right% + ,south/above% + ,southeast/above left% + } \draw[red,shift=(page.\anchor)] plot[mark=tpx%% my plot mark + ] coordinates{(0,0)} + node[blue,\placement] {\scriptsize\texttt{(page.\anchor)}}; +} + +\def\tikzpageputanchorsbody{ + \foreach \anchor/\placement in {% + body northwest/below right% + ,body north/below% + ,body northeast/below left% + ,body west/right% + ,body center/below% + ,body east/left% + ,body southwest/above right% + ,body south/above% + ,body southeast/above left% + } \draw[red,shift=(page.\anchor)] plot[mark=tpx%% my plot mark + ] coordinates{(0,0)} + node[blue,\placement] {\scriptsize\texttt{(page.\anchor)}}; +} + + +\def\tikzpageputanchorsmarginpar{ + \foreach \anchor/\placement in {% + marginpar northwest/below left% + ,marginpar north/left% + ,marginpar northeast/above left% + ,marginpar west/below% + ,marginpar center/below% + ,marginpar east/above% + ,marginpar southwest/below right% + ,marginpar south/right% + ,marginpar southeast/above right% + } \draw[red,shift=(page.\anchor)] plot[mark=tpx%% my plot mark + ] coordinates{(0,0)} + node[blue,\placement, rotate=90] {\scriptsize\texttt{(page.\anchor)}}; +} + + +\def\tikzpageputanchorsheader{ + \foreach \anchor/\placement in {% + header northwest/above right% + ,header north/above% + ,header northeast/above left% + ,header west/right% + ,header center/right% + ,header east/left% + ,header southwest/below right% + ,header south/below% + ,header southeast/below left% + } \draw[red,shift=(page.\anchor)] plot[mark=tpx%% my plot mark + ] coordinates{(0,0)} + node[blue,\placement] {\scriptsize\texttt{(page.\anchor)}}; +} + + +\def\tikzpageputanchorsfooter{ + \foreach \anchor/\placement in {% + footer northwest/above right% + ,footer north/above% + ,footer northeast/above left% + ,footer west/right% + ,footer center/right% + ,footer east/left% + ,footer southwest/below right% + ,footer south/below% + ,footer southeast/below left% + } \draw[red,shift=(page.\anchor)] plot[mark=tpx%% my plot mark + ] coordinates{(0,0)} + node[blue,\placement] {\scriptsize\texttt{(page.\anchor)}}; +} + +\def\tikzpageputanchorstop{ + \foreach \anchor/\placement in {% + top northwest/below right% + ,top north/below% + ,top northeast/below left% + ,top west/right% + ,top center/below% + ,top east/left% + ,top southwest/above right% + ,top south/above% + ,top southeast/above left% + } \draw[red,shift=(page.\anchor)] plot[mark=tpx%% my plot mark + ] coordinates{(0,0)} + node[blue,\placement] {\scriptsize\texttt{(page.\anchor)}}; +} + + +\def\tikzpageputanchorsbottom{ + \foreach \anchor/\placement in {% + bottom northwest/below right% + ,bottom north/below% + ,bottom northeast/below left% + ,bottom west/right% + ,bottom center/below% + ,bottom east/left% + ,bottom southwest/above right% + ,bottom south/above% + ,bottom southeast/above left% + } \draw[red,shift=(page.\anchor)] plot[mark=tpx%% my plot mark + ] coordinates{(0,0)} + node[blue,\placement] {\scriptsize\texttt{(page.\anchor)}}; +} + + +\def\tikzpageputanchorsleft{ + \foreach \anchor/\placement in {% + left northwest/below left% + ,left north/left% + ,left northeast/above left% + ,left west/below% + ,left center/below% + ,left east/above% + ,left southwest/below right% + ,left south/right% + ,left southeast/above right% + } \draw[red,shift=(page.\anchor)] plot[mark=tpx%% my plot mark + ] coordinates{(0,0)} + node[blue,\placement, rotate=90] {\scriptsize\texttt{(page.\anchor)}}; +} + +\def\tikzpageputanchorsright{ + \foreach \anchor/\placement in {% + right northwest/below left% + ,right north/left% + ,right northeast/above left% + ,right west/below% + ,right center/below% + ,right east/above% + ,right southwest/below right% + ,right south/right% + ,right southeast/above right% + } \draw[red,shift=(page.\anchor)] plot[mark=tpx%% my plot mark + ] coordinates{(0,0)} + node[blue,\placement, rotate=90] {\scriptsize\texttt{(page.\anchor)}}; +} +% \end{macrocode} + +% \begin{docCommand}{tikzpageputanchors}{} +% A simple short hand to display all anchors at once. +% \end{docCommand} +% \begin{macrocode} +\def\tikzpageputanchors{ + \tikzpageputanchorsdefaults + \tikzpageputanchorsbody + \tikzpageputanchorsmarginpar + \tikzpageputanchorsheader + \tikzpageputanchorsfooter + \tikzpageputanchorstop + \tikzpageputanchorsbottom + \tikzpageputanchorsleft + \tikzpageputanchorsright +} +% \end{macrocode} + + + +% \begin{docCommand}{tpshowframes}{} +% +% Display |top|, |right|, |bottom| and |left| block using a specific +% background. This can be used in conjunction with \refCom{tikzpageputanchors} for +% debuging purposes. +% +% \end{docCommand} +% \begin{macrocode} +\def\tpshowframes{ + \draw[fill=blue!50, opacity=.3, draw] (page.bottom northwest) rectangle (page.bottom southeast); + \draw[fill=yellow!50, opacity=.3, draw] (page.top northwest) rectangle (page.top southeast); + \draw[fill=red!50, opacity=.3, draw] (page.left northwest) rectangle (page.left southeast); + \draw[fill=green!50, opacity=.3, draw] (page.right northwest) rectangle (page.right southeast); +} +% \end{macrocode} + + +% \begin{docCommand}{tpfancyhdrdefault}{} +% An example to display headers and footer as |fancyhdr| does. +% \end{docCommand} +% \begin{macrocode} +\def\tpfancyhdrdefault{ + \node [outer sep=0,inner sep=0, anchor=mid] at (page.header center) {}; + \node [outer sep=0,inner sep=0, anchor=mid east] at (page.header east) {\tpflip{\sl\leftmark}{\sl\rightmark}}; + \node [outer sep=0,inner sep=0, anchor=mid west] at (page.header west) {\tpflip{\sl\rightmark}{\sl\leftmark}}; + \node [outer sep=0,inner sep=0, anchor=base east] at (page.footer east) {}; + \node [,outer sep=0,inner sep=0,anchor=base] at (page.footer center) {\thepage}; + \node [outer sep=0,inner sep=0, anchor=base west] at (page.footer west) {}; +} +% \end{macrocode} + +% \begin{docCommand}{tikzpage}{} +% Generate a |tikzpicture| for the whole page. if a \cs{tikzpagelayout} +% command exists, it will be executed. +% \end{docCommand} +% \begin{macrocode} +\newcommand{\tikzpage}{ + \if@tp@use@textpos + \begin{textblock*}{\textwidth}[0,0](0pt,0pt)% + \fi + \tp@compute@margins% + \if@tp@use@textpos + \begin{tikzpicture}[]% + \clip (0,0) rectangle (\paperwidth, \paperheight); + \else + \begin{tikzpicture}[remember picture, overlay]% + \fi + \if@tp@use@textpos + \node[anchor=origin,shape=page] (page) {}; + \else + \node[anchor=origin,shape=page] (page) at (current page.south west) {}; + \fi + \@ifundefined{tikzpagelayout}{}{\tikzpagelayout} + \end{tikzpicture}% + \if@tp@use@textpos + \end{textblock*}% + \fi +} +% \end{macrocode} + + +\fancypagestyle{plain}{ + \fancyhf{} + \chead{\tikzpage} +} +\fancypagestyle{empty}{ + \fancyhf{} + \chead{\tikzpage} +} + + +% +\makeatother +% \iffalse +%</tikz-page> +% \fi +% +% \Finale +% +% +% \iffalse +% <*example> +% \fi +% \begin{thebibliography}{9} + +% \bibitem{Graphical Decoration} Trying to do graphical decorations in +% “ClassicThesis style” \url{http://tex.stackexchange.com/questions/86294} +% \end{thebibliography} +% \iffalse +% </example> +% \fi + +\endinput |