diff options
author | Karl Berry <karl@freefriends.org> | 2011-11-30 00:22:50 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-11-30 00:22:50 +0000 |
commit | 48df2893eabf94eb57774ff2ac2f83efe5290522 (patch) | |
tree | e60bf855f762248b0a6ba58a5e65b28133a7a3e3 /Master/texmf-dist/doc/latex/tikz-dependency | |
parent | 4f4a0f8edf2f2697b307f2df2e2cafac81e1ca48 (diff) |
tikz-dependency (29nov11)
git-svn-id: svn://tug.org/texlive/trunk@24700 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/tikz-dependency')
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-dependency/LICENSE | 22 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-dependency/README | 2 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-dependency/pgfmanual-en-macros.tex | 1209 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-dependency/pgfmanual.code.tex | 65 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-dependency/pgfmanual.pdflinks.code.tex | 414 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-dependency/pgfmanual.prettyprinter.code.tex | 1095 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-dependency/tikz-dependency-doc.pdf (renamed from Master/texmf-dist/doc/latex/tikz-dependency/tikz-dependency.pdf) | bin | 637283 -> 637292 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-dependency/tikz-dependency-doc.tex | 1361 |
8 files changed, 4162 insertions, 6 deletions
diff --git a/Master/texmf-dist/doc/latex/tikz-dependency/LICENSE b/Master/texmf-dist/doc/latex/tikz-dependency/LICENSE index b6dccc64c84..9787aa0cb56 100644 --- a/Master/texmf-dist/doc/latex/tikz-dependency/LICENSE +++ b/Master/texmf-dist/doc/latex/tikz-dependency/LICENSE @@ -4,16 +4,28 @@ Licenses for the TikZ-dependency package Different parts of the TikZ-dependency package are distributed under different licenses: -1. The code of the package is dual-license. This means that - you can decide which license you wish to use when using the - TikZ-dependency package. The two options are: +1. The code of the package (i.e., tikz-dependency.sty) is + dual-license. This means that you can decide which license you + wish to use when using the TikZ-dependency package. + The two options are: a) You can use the GNU Public License, version 2. b) You can use the LaTeX Project Public License, version 1.3c. -2. The documentation of the package is also dual-license. Again, - you can choose between two options: +2. The original documentation of the package (i.e., the file + tikz-dependency-doc.tex) is also dual-license. Again, you can + choose between two options: a) You can use the GNU Free Documentation License, version 1.2. b) You can use the LaTeX Project Public License, version 1.3c. +The following files are intellectual property of Till Tantau and/or +Christian Feuersänger: + + - pgfmanual.code.tex + - pgfmanual.prettyprinter.code.tex + - pgfmanual-en-macros.tex + - pgfmanual.pdflinks.code.tex + +They follow the same licensing scheme of tikz-dependency-doc.tex, +but credits should go to the respective authors. diff --git a/Master/texmf-dist/doc/latex/tikz-dependency/README b/Master/texmf-dist/doc/latex/tikz-dependency/README index 19158070305..1de8cf23449 100644 --- a/Master/texmf-dist/doc/latex/tikz-dependency/README +++ b/Master/texmf-dist/doc/latex/tikz-dependency/README @@ -6,7 +6,7 @@ TikZ-dependency allows you to draw dependency graphs with little or no effort. It also comes with a lot of styling facilities, to let you personalize the look and feel of the graphs at your liking. -Read the documentation in tikz-dependency.pdf for installation and +Read the documentation in tikz-dependency-doc.pdf for installation and usage instructions. Licensing information is in the LICENSE file. diff --git a/Master/texmf-dist/doc/latex/tikz-dependency/pgfmanual-en-macros.tex b/Master/texmf-dist/doc/latex/tikz-dependency/pgfmanual-en-macros.tex new file mode 100644 index 00000000000..fb85bcd8851 --- /dev/null +++ b/Master/texmf-dist/doc/latex/tikz-dependency/pgfmanual-en-macros.tex @@ -0,0 +1,1209 @@ +% Copyright 2006 by Till Tantau +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Free Documentation License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +% $Header: /cvsroot/pgf/pgf/doc/generic/pgf/macros/pgfmanual-en-macros.tex,v 1.45 2009/11/15 13:13:24 ludewich Exp $ + + + +\providecommand\href[2]{\texttt{#1}} +\providecommand\hypertarget[2]{\texttt{#1}} +\providecommand\hyperlink[2]{\texttt{#1}} + + +\colorlet{examplefill}{yellow!80!black} +\definecolor{graphicbackground}{rgb}{0.96,0.96,0.8} +\definecolor{codebackground}{rgb}{0.8,0.8,1} + +\newenvironment{pgfmanualentry}{\list{}{\leftmargin=2em\itemindent-\leftmargin\def\makelabel##1{\hss##1}}}{\endlist} +\newcommand\pgfmanualentryheadline[1]{\itemsep=0pt\parskip=0pt\item\strut{#1}\par\topsep=0pt} +\newcommand\pgfmanualbody{\parskip3pt} + + + +\newenvironment{pgflayout}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{\texttt{\string\pgfpagesuselayout\char`\{\declare{#1}\char`\}}\oarg{options}} + \index{#1@\protect\texttt{#1} layout}% + \index{Page layouts!#1@\protect\texttt{#1}}% + \pgfmanualpdflabel{#1}{}% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + + +\newenvironment{command}[1]{ + \begin{pgfmanualentry} + \extractcommand#1\@@ + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\newenvironment{commandlist}[1]{% + \begin{pgfmanualentry} + \foreach \xx in {#1} {% + \expandafter\extractcommand\xx\@@ + }% + \pgfmanualbody +}{% + \end{pgfmanualentry} +}% + +% \begin{internallist}[register]{\pgf@xa} +% \end{internallist} +% +% \begin{internallist}[register]{\pgf@xa,\pgf@xb} +% \end{internallist} +\newenvironment{internallist}[2][register]{% + \begin{pgfmanualentry} + \foreach \xx in {#2} {% + \expandafter\extractinternalcommand\expandafter{\xx}{#1}% + }% + \pgfmanualbody +}{% + \end{pgfmanualentry} +}% +\def\extractinternalcommand#1#2{% + \pgfmanualentryheadline{Internal #2 \declare{\texttt{\string#1}}}% + \removeats{#1}% + \index{Internals!\strippedat @\protect\myprintocmmand{\strippedat}}% + \index{\strippedat @\protect\myprintocmmand{\strippedat}}% + \pgfmanualpdflabel{\textbackslash\strippedat}{}% +} + +%% MW: START MATH MACROS +\def\mvar#1{{\ifmmode\textrm{\textit{#1}}\else\rmfamily\textit{#1}\fi}} + +\makeatletter + +\def\extractmathfunctionname#1{\extractmathfunctionname@#1(,)\tmpa\tmpb} +\def\extractmathfunctionname@#1(#2)#3\tmpb{\def\mathname{#1}} + +\makeatother + +\newenvironment{math-function}[1]{ + \def\mathdefaultname{#1} + \extractmathfunctionname{#1} + \edef\mathurl{{math:\mathname}}\expandafter\hypertarget\expandafter{\mathurl}{}% + \begin{pgfmanualentry} + \pgfmanualentryheadline{\texttt{#1}}% + \index{\mathname @\protect\texttt{\mathname} math function}% + \index{Math functions!\mathname @\protect\texttt{\mathname}}% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\def\pgfmanualemptytext{} +\def\pgfmanualvbarvbar{\char`\|\char`\|} + +\newenvironment{math-operator}[4][]{% + \begin{pgfmanualentry} + \csname math#3operator\endcsname{#2}{#4} + \def\mathtest{#4}% + \ifx\mathtest\pgfmanualemptytext% + \def\mathtype{(#3 operator)} + \else% + \def\mathtype{(#3 operator; uses the \texttt{#4} function)} + \fi% + \pgfmanualentryheadline{\mathexample\hfill\mathtype}% + \def\mathtest{#1}% + \ifx\mathtest\pgfmanualemptytext% + \index{#2@\protect\texttt{#2} #3 math operator}% + \index{Math operators!#2@\protect\texttt{#2}}% + \fi% + \pgfmanualbody +} +{\end{pgfmanualentry}} + +\newenvironment{math-operators}[5][]{% + \begin{pgfmanualentry} + \csname math#4operator\endcsname{#2}{#3} + \def\mathtest{#5}% + \ifx\mathtest\pgfmanualemptytext% + \def\mathtype{(#4 operators)} + \else% + \def\mathtype{(#4 operators; use the \texttt{#5} function)} + \fi% + \pgfmanualentryheadline{\mathexample\hfill\mathtype}% + \def\mathtest{#1}% + \ifx\mathtest\pgfmanualemptytext% + \index{#2#3@\protect\texttt{#2\protect\ #3} #4 math operators}% + \index{Math operators!#2#3@\protect\texttt{#2\protect\ #3}}% + \fi% + \pgfmanualbody +} +{\end{pgfmanualentry}} + +\def\mathinfixoperator#1#2{% + \def\mathoperator{\texttt{#1}}% + \def\mathexample{\mvar{x}\space\texttt{#1}\space\mvar{y}}% +} + +\def\mathprefixoperator#1#2{% + \def\mathoperator{\texttt{#1}}% + \def\mathexample{\texttt{#1}\mvar{x}}% +} + +\def\mathpostfixoperator#1#2{% + \def\mathoperator{\texttt{#1}} + \def\mathexample{\mvar{x}\texttt{#1}}% +} + +\def\mathgroupoperator#1#2{% + \def\mathoperator{\texttt{#1\ #2}}% + \def\mathexample{\texttt{#1}\mvar{x}\texttt{#2}}% +} + +\expandafter\let\csname matharray accessoperator\endcsname=\mathgroupoperator +\expandafter\let\csname matharrayoperator\endcsname=\mathgroupoperator + +\def\mathconditionaloperator#1#2{% + \def\mathoperator{#1\space#2} + \def\mathexample{\mvar{x}\ \texttt{#1}\ \mvar{y}\ {\texttt{#2}}\ \mvar{z}} +} + +\newcommand\mathcommand[1][\mathdefaultname]{% + \expandafter\makemathcommand#1(\empty)\stop% + \expandafter\extractcommand\mathcommandname\@@% + \medskip +} +\makeatletter + +\def\makemathcommand#1(#2)#3\stop{% + \expandafter\def\expandafter\mathcommandname\expandafter{\csname pgfmath#1\endcsname}% + \ifx#2\empty% + \else% + \@makemathcommand#2,\stop, + \fi} +\def\@makemathcommand#1,{% + \ifx#1\stop% + \else% + \expandafter\def\expandafter\mathcommandname\expandafter{\mathcommandname{\ttfamily\char`\{#1\char`\}}}% + \expandafter\@makemathcommand% + \fi} +\makeatother + +\def\calcname{\textsc{calc}} +%% MW: END MATH MACROS + + +\def\extractcommand#1#2\@@{% + \pgfmanualentryheadline{\declare{\texttt{\string#1}}#2}% + \removeats{#1}% + \index{\strippedat @\protect\myprintocmmand{\strippedat}} + \pgfmanualpdflabel{\textbackslash\strippedat}{}% +} + + +% \begin{environment}{{name}\marg{arguments}} +\renewenvironment{environment}[1]{ + \begin{pgfmanualentry} + \extractenvironement#1\@@ + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\def\extractenvironement#1#2\@@{% + \pgfmanualentryheadline{{\ttfamily\char`\\begin\char`\{\declare{#1}\char`\}}#2}% + \pgfmanualentryheadline{{\ttfamily\ \ }\meta{environment contents}}% + \pgfmanualentryheadline{{\ttfamily\char`\\end\char`\{\declare{#1}\char`\}}}% + \index{#1@\protect\texttt{#1} environment}% + \index{Environments!#1@\protect\texttt{#1}} + \pgfmanualpdflabel{#1}{}% +} + + +\newenvironment{plainenvironment}[1]{ + \begin{pgfmanualentry} + \extractplainenvironement#1\@@ + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\def\extractplainenvironement#1#2\@@{% + \pgfmanualentryheadline{{\ttfamily\declare{\char`\\#1}}#2}% + \pgfmanualentryheadline{{\ttfamily\ \ }\meta{environment contents}}% + \pgfmanualentryheadline{{\ttfamily\declare{\char`\\end#1}}}% + \index{#1@\protect\texttt{#1} environment}% + \index{Environments!#1@\protect\texttt{#1}}% +} + + +\newenvironment{contextenvironment}[1]{ + \begin{pgfmanualentry} + \extractcontextenvironement#1\@@ + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\def\extractcontextenvironement#1#2\@@{% + \pgfmanualentryheadline{{\ttfamily\declare{\char`\\start#1}}#2}% + \pgfmanualentryheadline{{\ttfamily\ \ }\meta{environment contents}}% + \pgfmanualentryheadline{{\ttfamily\declare{\char`\\stop#1}}}% + \index{#1@\protect\texttt{#1} environment}% + \index{Environments!#1@\protect\texttt{#1}}} + + +\newenvironment{shape}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{Shape {\ttfamily\declare{#1}}}% + \index{#1@\protect\texttt{#1} shape}% + \index{Shapes!#1@\protect\texttt{#1}} + \pgfmanualpdflabel{#1}{}% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\newenvironment{shading}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{Shading {\ttfamily\declare{#1}}}% + \index{#1@\protect\texttt{#1} shading}% + \index{Shadings!#1@\protect\texttt{#1}} + \pgfmanualpdflabel{#1}{}% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + + +\newenvironment{dataformat}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{Format {\ttfamily\declare{#1}}}% + \index{#1@\protect\texttt{#1} format}% + \index{Formats!#1@\protect\texttt{#1}} + \pgfmanualpdflabel{#1}{}% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\newenvironment{handler}[1]{ + \begin{pgfmanualentry} + \extracthandler#1\@nil% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\def\gobble#1{} +\def\extracthandler#1#2\@nil{% + \pgfmanualentryheadline{Key handler \meta{key}{\ttfamily/\declare{#1}}#2}% + \index{\gobble#1@\protect\texttt{#1} handler}% + \index{Key handlers!#1@\protect\texttt{#1}} + \pgfmanualpdflabel{/handlers/#1}% +} + + +\makeatletter + + +\newenvironment{stylekey}[1]{ + \begin{pgfmanualentry} + \def\extrakeytext{style, } + \extractkey#1\@nil% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\def\choicesep{$\vert$}% +\def\choicearg#1{\texttt{#1}} + +\newif\iffirstchoice + +% \mchoice{choice1,choice2,choice3} +\newcommand\mchoice[1]{% + \begingroup + \firstchoicetrue + \foreach \mchoice@ in {#1} {% + \iffirstchoice + \global\firstchoicefalse + \else + \choicesep + \fi + \choicearg{\mchoice@}% + }% + \endgroup +}% + +% \begin{key}{/path/x=value} +% \begin{key}{/path/x=value (initially XXX)} +% \begin{key}{/path/x=value (default XXX)} +\newenvironment{key}[1]{ + \begin{pgfmanualentry} + \def\extrakeytext{} + %\def\altpath{\emph{\color{gray}or}}% + \extractkey#1\@nil% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +% \insertpathifneeded{a key}{/pgf} -> assign mykey={/pgf/a key} +% \insertpathifneeded{/tikz/a key}{/pgf} -> assign mykey={/tikz/a key} +% +% #1: the key +% #2: a default path (or empty) +\def\insertpathifneeded#1#2{% + \def\insertpathifneeded@@{#2}% + \ifx\insertpathifneeded@@\empty + \def\mykey{#1}% + \else + \insertpathifneeded@#2\@nil + \ifpgfutil@in@ + \def\mykey{#2/#1}% + \else + \def\mykey{#1}% + \fi + \fi +}% +\def\insertpathifneeded@#1#2\@nil{% + \def\insertpathifneeded@@{#1}% + \def\insertpathifneeded@@@{/}% + \ifx\insertpathifneeded@@\insertpathifneeded@@@ + \pgfutil@in@true + \else + \pgfutil@in@false + \fi +}% + +% \begin{keylist}[default path] +% {/path/option 1=value,/path/option 2=value2} +% \end{keylist} +\newenvironment{keylist}[2][]{% + \begin{pgfmanualentry} + \def\extrakeytext{}% + \foreach \xx in {#2} {% + \expandafter\insertpathifneeded\expandafter{\xx}{#1}% + \expandafter\extractkey\mykey\@nil% + }% + \pgfmanualbody +}{% + \end{pgfmanualentry} +}% + +\def\extractkey#1\@nil{% + \pgfutil@in@={#1}% + \ifpgfutil@in@% + \extractkeyequal#1\@nil + \else% + \pgfutil@in@{(initial}{#1}% + \ifpgfutil@in@% + \extractequalinitial#1\@nil% + \else + \pgfmanualentryheadline{{\ttfamily\declare{#1}}\hfill(\extrakeytext no value)}% + \def\mykey{#1}% + \def\mypath{}% + \def\myname{}% + \firsttimetrue% + \decompose#1/\nil% + \fi + \fi% +} + +\def\extractkeyequal#1=#2\@nil{% + \pgfutil@in@{(default}{#2}% + \ifpgfutil@in@% + \extractdefault{#1}#2\@nil% + \else% + \pgfutil@in@{(initial}{#2}% + \ifpgfutil@in@% + \extractinitial{#1}#2\@nil% + \else + \pgfmanualentryheadline{{\ttfamily\declare{#1}=}#2\hfill(\extrakeytext no default)}% + \fi% + \fi% + \def\mykey{#1}% + \def\mypath{}% + \def\myname{}% + \firsttimetrue% + \decompose#1/\nil% +} + +\def\extractdefault#1#2(default #3)\@nil{% + \pgfmanualentryheadline{{\ttfamily\declare{#1}\opt{=}}\opt{#2}\hfill (\extrakeytext default {\ttfamily#3})}% +} + +\def\extractinitial#1#2(initially #3)\@nil{% + \pgfmanualentryheadline{{\ttfamily\declare{#1}=}#2\hfill (\extrakeytext no default, initially {\ttfamily#3})}% +} + +\def\extractequalinitial#1 (initially #2)\@nil{% + \pgfmanualentryheadline{{\ttfamily\declare{#1}}\hfill (\extrakeytext initially {\ttfamily#2})}% + \def\mykey{#1}% + \def\mypath{}% + \def\myname{}% + \firsttimetrue% + \decompose#1/\nil% +} + +% Introduces a key alias '/#1/<name of current key>' +% to be used inside of \begin{key} ... \end{key} +\def\keyalias#1{\vspace{-3pt}\item{\small alias {\ttfamily/#1/\myname}}\vspace{-2pt}\par + \pgfmanualpdflabel{/#1/\myname}{}% +} + +\newif\iffirsttime + +\makeatother + +\def\decompose/#1/#2\nil{% + \def\test{#2}% + \ifx\test\empty% + % aha. + \index{#1@\protect\texttt{#1} key}% + \index{\mypath#1@\protect\texttt{#1}}% + \def\myname{#1}% + \else% + \iffirsttime + \begingroup + % also make a pdf link anchor with full key path. + \def\hyperlabelwithoutslash##1/\nil{% + \pgfmanualpdflabel{##1}{}% + }% + \hyperlabelwithoutslash/#1/#2\nil + \endgroup + \def\mypath{#1@\protect\texttt{/#1/}!}% + \firsttimefalse + \else + \expandafter\def\expandafter\mypath\expandafter{\mypath#1@\protect\texttt{#1/}!}% + \fi + \def\firsttime{} + \decompose/#2\nil% + \fi% +} + +\def\indexkey#1{% + \def\mypath{}% + \decompose#1/\nil% +} + +\newenvironment{predefinedmethod}[1]{ + \begin{pgfmanualentry} + \extractpredefinedmethod#1\@nil + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} +\def\extractpredefinedmethod#1(#2)\@nil{% + \pgfmanualentryheadline{Method \declare{\ttfamily #1}\texttt(#2\texttt) \hfill(predefined for all classes)} + \index{#1@\protect\texttt{#1} method}% + \index{Methods!#1@\protect\texttt{#1}} + \pgfmanualpdflabel{#1}{}% +} + + +\newenvironment{ooclass}[1]{ + \begin{pgfmanualentry} + \def\currentclass{#1} + \pgfmanualentryheadline{Class \declare{\texttt{#1}}} + \index{#1@\protect\texttt{#1} class}% + \index{Class #1@Class \protect\texttt{#1}}% + \index{Classes!#1@\protect\texttt{#1}} + \pgfmanualpdflabel{#1}{}% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\newenvironment{method}[1]{ + \begin{pgfmanualentry} + \extractmethod#1\@nil + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} +\def\extractmethod#1(#2)\@nil{% + \def\test{#1} + \ifx\test\currentclass + \pgfmanualentryheadline{Constructor \declare{\ttfamily #1}\texttt(#2\texttt)} + \else + \pgfmanualentryheadline{Method \declare{\ttfamily #1}\texttt(#2\texttt)} + \fi + \index{#1@\protect\texttt{#1} method}% + \index{Methods!#1@\protect\texttt{#1}} + \index{Class \currentclass!#1@\protect\texttt{#1}}% + \pgfmanualpdflabel{#1}{}% +} + +\newenvironment{attribute}[1]{ + \begin{pgfmanualentry} + \extractattribute#1\@nil + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} +\def\extractattribute#1=#2;\@nil{% + \def\test{#2}% + \ifx\test\@empty + \pgfmanualentryheadline{Private attribute \declare{\ttfamily #1} \hfill (initially empty)} + \else + \pgfmanualentryheadline{Private attribute \declare{\ttfamily #1} \hfill (initially {\ttfamily #2})} + \fi + \index{#1@\protect\texttt{#1} attribute}% + \index{Attributes!#1@\protect\texttt{#1}} + \index{Class \currentclass!#1@\protect\texttt{#1}}% + \pgfmanualpdflabel{#1}{}% +} + + + +\newenvironment{predefinednode}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{Predefined node {\ttfamily\declare{#1}}}% + \index{#1@\protect\texttt{#1} node}% + \index{Predefined node!#1@\protect\texttt{#1}} + \pgfmanualpdflabel{#1}{}% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\newenvironment{coordinatesystem}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{Coordinate system {\ttfamily\declare{#1}}}% + \index{#1@\protect\texttt{#1} coordinate system}% + \index{Coordinate systems!#1@\protect\texttt{#1}} + \pgfmanualpdflabel{#1}{}% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\newenvironment{snake}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{Snake {\ttfamily\declare{#1}}}% + \index{#1@\protect\texttt{#1} snake}% + \index{Snakes!#1@\protect\texttt{#1}} + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + +\newenvironment{decoration}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{Decoration {\ttfamily\declare{#1}}}% + \index{#1@\protect\texttt{#1} decoration}% + \index{Decorations!#1@\protect\texttt{#1}} + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + + +\def\pgfmanualbar{\char`\|} +\makeatletter +\newenvironment{pathoperation}[3][]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{\textcolor{gray}{{\ttfamily\char`\\path}\ + \ \dots} + \declare{\texttt{#2}}#3\ \textcolor{gray}{\dots\texttt{;}}}% + \def\pgfmanualtest{#1}% + \ifx\pgfmanualtest\@empty% + \index{#2@\protect\texttt{#2} path operation}% + \index{Path operations!#2@\protect\texttt{#2}}% + \pgfmanualpdflabel{#2}{}% + \fi% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} +\newenvironment{datavisualizationoperation}[3][]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{\textcolor{gray}{{\ttfamily\char`\\datavisualization}\ + \ \dots} + \declare{\texttt{#2}}#3\ \textcolor{gray}{\dots\texttt{;}}}% + \def\pgfmanualtest{#1}% + \ifx\pgfmanualtest\@empty% + \index{#2@\protect\texttt{#2} (data visualization)}% + \index{Data visualization!#2@\protect\texttt{#2}}% + \pgfmanualpdflabel{#2}{}% + \fi% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} +\makeatother + +\def\extractcommand#1#2\@@{% + \pgfmanualentryheadline{\declare{\texttt{\string#1}}#2}% + \removeats{#1}% + \index{\strippedat @\protect\myprintocmmand{\strippedat}} + \pgfmanualpdflabel{\textbackslash\strippedat}{}% +} + +\def\doublebs{\texttt{\char`\\\char`\\}} + + +\newenvironment{package}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{{\ttfamily\char`\\usepackage\char`\{\declare{#1}\char`\}\space\space \char`\%\space\space \LaTeX}} + \index{#1@\protect\texttt{#1} package}% + \index{Packages and files!#1@\protect\texttt{#1}}% + \pgfmanualentryheadline{{\ttfamily\char`\\input \declare{#1}.tex\space\space\space \char`\%\space\space plain \TeX}} + \pgfmanualentryheadline{{\ttfamily\char`\\usemodule[\declare{#1}]\space\space \char`\%\space\space Con\TeX t}} + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + + +\newenvironment{pgfmodule}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{{\ttfamily\char`\\usepgfmodule\char`\{\declare{#1}\char`\}\space\space\space + \char`\%\space\space \LaTeX\space and plain \TeX\space and pure pgf}} + \index{#1@\protect\texttt{#1} module}% + \index{Modules!#1@\protect\texttt{#1}}% + \pgfmanualentryheadline{{\ttfamily\char`\\usepgfmodule[\declare{#1}]\space\space \char`\%\space\space Con\TeX t\space and pure pgf}} + \pgfmanualbody + \pgfmanualpdflabel{#1}{}% +} +{ + \end{pgfmanualentry} +} + +\newenvironment{pgflibrary}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{{\ttfamily\char`\\usepgflibrary\char`\{\declare{#1}\char`\}\space\space\space + \char`\%\space\space \LaTeX\space and plain \TeX\space and pure pgf}} + \index{#1@\protect\texttt{#1} library}% + \index{Libraries!#1@\protect\texttt{#1}}% + \pgfmanualentryheadline{{\ttfamily\char`\\usepgflibrary[\declare{#1}]\space\space \char`\%\space\space Con\TeX t\space and pure pgf}} + \pgfmanualentryheadline{{\ttfamily\char`\\usetikzlibrary\char`\{\declare{#1}\char`\}\space\space + \char`\%\space\space \LaTeX\space and plain \TeX\space when using \tikzname}} + \pgfmanualentryheadline{{\ttfamily\char`\\usetikzlibrary[\declare{#1}]\space + \char`\%\space\space Con\TeX t\space when using \tikzname}} + \pgfmanualbody + \pgfmanualpdflabel{#1}{}% +} +{ + \end{pgfmanualentry} +} + +\newenvironment{tikzlibrary}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{{\ttfamily\char`\\usetikzlibrary\char`\{\declare{#1}\char`\}\space\space \char`\%\space\space \LaTeX\space and plain \TeX}} + \index{#1@\protect\texttt{#1} library}% + \index{Libraries!#1@\protect\texttt{#1}}% + \pgfmanualentryheadline{{\ttfamily\char`\\usetikzlibrary[\declare{#1}]\space \char`\%\space\space Con\TeX t}} + \pgfmanualbody + \pgfmanualpdflabel{#1}{}% +} +{ + \end{pgfmanualentry} +} + + + +\newenvironment{filedescription}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{File {\ttfamily\declare{#1}}}% + \index{#1@\protect\texttt{#1} file}% + \index{Packages and files!#1@\protect\texttt{#1}}% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + + +\newenvironment{packageoption}[1]{ + \begin{pgfmanualentry} + \pgfmanualentryheadline{{\ttfamily\char`\\usepackage[\declare{#1}]\char`\{pgf\char`\}}} + \index{#1@\protect\texttt{#1} package option}% + \index{Package options for \textsc{pgf}!#1@\protect\texttt{#1}}% + \pgfmanualbody +} +{ + \end{pgfmanualentry} +} + + + +\newcommand\opt[1]{{\color{black!50!green}#1}} +\newcommand\ooarg[1]{{\ttfamily[}\meta{#1}{\ttfamily]}} + +\def\opt{\afterassignment\pgfmanualopt\let\next=} +\def\pgfmanualopt{\ifx\next\bgroup\bgroup\color{black!50!green}\else{\color{black!50!green}\next}\fi} + + + +\def\beamer{\textsc{beamer}} +\def\pdf{\textsc{pdf}} +\def\eps{\texttt{eps}} +\def\pgfname{\textsc{pgf}} +\def\tikzname{Ti\emph{k}Z} +\def\pstricks{\textsc{pstricks}} +\def\prosper{\textsc{prosper}} +\def\seminar{\textsc{seminar}} +\def\texpower{\textsc{texpower}} +\def\foils{\textsc{foils}} + +{ + \makeatletter + \global\let\myempty=\@empty + \global\let\mygobble=\@gobble + \catcode`\@=12 + \gdef\getridofats#1@#2\relax{% + \def\getridtest{#2}% + \ifx\getridtest\myempty% + \expandafter\def\expandafter\strippedat\expandafter{\strippedat#1} + \else% + \expandafter\def\expandafter\strippedat\expandafter{\strippedat#1\protect\printanat} + \getridofats#2\relax% + \fi% + } + + \gdef\removeats#1{% + \let\strippedat\myempty% + \edef\strippedtext{\stripcommand#1}% + \expandafter\getridofats\strippedtext @\relax% + } + + \gdef\stripcommand#1{\expandafter\mygobble\string#1} +} + +\def\printanat{\char`\@} + +\def\declare{\afterassignment\pgfmanualdeclare\let\next=} +\def\pgfmanualdeclare{\ifx\next\bgroup\bgroup\color{red!75!black}\else{\color{red!75!black}\next}\fi} + + +\let\textoken=\command +\let\endtextoken=\endcommand + +\def\myprintocmmand#1{\texttt{\char`\\#1}} + +\def\example{\par\smallskip\noindent\textit{Example: }} +\def\themeauthor{\par\smallskip\noindent\textit{Theme author: }} + + +\def\indexoption#1{% + \index{#1@\protect\texttt{#1} option}% + \index{Graphic options and styles!#1@\protect\texttt{#1}}% +} + +\def\itemcalendaroption#1{\item \declare{\texttt{#1}}% + \index{#1@\protect\texttt{#1} date test}% + \index{Date tests!#1@\protect\texttt{#1}}% +} + + + +\def\class#1{\list{}{\leftmargin=2em\itemindent-\leftmargin\def\makelabel##1{\hss##1}}% +\extractclass#1@\par\topsep=0pt} +\def\endclass{\endlist} +\def\extractclass#1#2@{% +\item{{{\ttfamily\char`\\documentclass}#2{\ttfamily\char`\{\declare{#1}\char`\}}}}% + \index{#1@\protect\texttt{#1} class}% + \index{Classes!#1@\protect\texttt{#1}}} + +\def\partname{Part} + +\makeatletter +\def\index@prologue{\section*{Index}\addcontentsline{toc}{section}{Index} + %This index contains pointers to all the commands and configuration keys + %described somewhere in the documentation. In addition, it contains some + %keywords that, hopefully, will make it easier to find what you are looking + %for. + %%index should also contain carefully selected keywords. This index is + %%not a good index. + %\bigskip +} +\c@IndexColumns=2 + \def\theindex{\@restonecoltrue + \columnseprule \z@ \columnsep 29\p@ + \twocolumn[\index@prologue]% + \parindent -30pt + \columnsep 15pt + \parskip 0pt plus 1pt + \leftskip 30pt + \rightskip 0pt plus 2cm + \small + \def\@idxitem{\par}% + \let\item\@idxitem \ignorespaces} + \def\endtheindex{\onecolumn} +\def\noindexing{\let\index=\@gobble} + + + +\newcommand\symarrow[1]{ + \index{#1@\protect\texttt{#1} arrow tip}% + \index{Arrow tips!#1@\protect\texttt{#1}} + \texttt{#1}& yields thick + \begin{tikzpicture}[arrows={#1-#1},thick,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); + \draw (0pt,.5ex) -- (1cm,.5ex); + \end{tikzpicture} and thin + \begin{tikzpicture}[arrows={#1-#1},thin,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); + \draw (0pt,.5ex) -- (1cm,.5ex); + \end{tikzpicture} +} +\newcommand\symarrowdouble[1]{ + \index{#1@\protect\texttt{#1} arrow tip}% + \index{Arrow tips!#1@\protect\texttt{#1}} + \texttt{#1}& yields thick + \begin{tikzpicture}[arrows={#1-#1},thick,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); + \draw (0pt,.5ex) -- (1cm,.5ex); + \end{tikzpicture} + and thin + \begin{tikzpicture}[arrows={#1-#1},thin,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); + \draw (0pt,.5ex) -- (1cm,.5ex); + \end{tikzpicture}, double + \begin{tikzpicture}[arrows={#1-#1},thick,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); + \draw[double,double equal sign distance] (0pt,.5ex) -- (1cm,.5ex); + \end{tikzpicture} and + \begin{tikzpicture}[arrows={#1-#1},thin,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); + \draw[double,double equal sign distance] (0pt,.5ex) -- (1cm,.5ex); + \end{tikzpicture} +} + +\newcommand\sarrow[2]{ + \index{#1@\protect\texttt{#1} arrow tip}% + \index{Arrow tips!#1@\protect\texttt{#1}} + \index{#2@\protect\texttt{#2} arrow tip}% + \index{Arrow tips!#2@\protect\texttt{#2}} + \texttt{#1-#2}& yields thick + \begin{tikzpicture}[arrows={#1-#2},thick,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); + \draw (0pt,.5ex) -- (1cm,.5ex); + \end{tikzpicture} and thin + \begin{tikzpicture}[arrows={#1-#2},thin,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); + \draw (0pt,.5ex) -- (1cm,.5ex); + \end{tikzpicture} +} + +\newcommand\sarrowdouble[2]{ + \index{#1@\protect\texttt{#1} arrow tip}% + \index{Arrow tips!#1@\protect\texttt{#1}} + \index{#2@\protect\texttt{#2} arrow tip}% + \index{Arrow tips!#2@\protect\texttt{#2}} + \texttt{#1-#2}& yields thick + \begin{tikzpicture}[arrows={#1-#2},thick,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); + \draw (0pt,.5ex) -- (1cm,.5ex); + \end{tikzpicture} and thin + \begin{tikzpicture}[arrows={#1-#2},thin,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); + \draw (0pt,.5ex) -- (1cm,.5ex); + \end{tikzpicture}, double + \begin{tikzpicture}[arrows={#1-#2},thick,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); + \draw[double,double equal sign distance] (0pt,.5ex) -- (1cm,.5ex); + \end{tikzpicture} and + \begin{tikzpicture}[arrows={#1-#2},thin,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); + \draw[double,double equal sign distance] (0pt,.5ex) -- (1cm,.5ex); + \end{tikzpicture} +} + +\newcommand\carrow[1]{ + \index{#1@\protect\texttt{#1} arrow tip}% + \index{Arrow tips!#1@\protect\texttt{#1}} + \texttt{#1}& yields for line width 1ex + \begin{tikzpicture}[arrows={#1-#1},line width=1ex,baseline] + \useasboundingbox (0pt,-0.5ex) rectangle (1.5cm,2ex); + \draw (0pt,.5ex) -- (1.5cm,.5ex); + \end{tikzpicture} +} +\def\myvbar{\char`\|} +\newcommand\plotmarkentry[1]{% + \index{#1@\protect\texttt{#1} plot mark}% + \index{Plot marks!#1@\protect\texttt{#1}} + \texttt{\char`\\pgfuseplotmark\char`\{\declare{#1}\char`\}} & + \tikz\draw[color=black!25] plot[mark=#1,mark options={fill=examplefill,draw=black}] coordinates{(0,0) (.5,0.2) (1,0) (1.5,0.2)};\\ +} +\newcommand\plotmarkentrytikz[1]{% + \index{#1@\protect\texttt{#1} plot mark}% + \index{Plot marks!#1@\protect\texttt{#1}} + \texttt{mark=\declare{#1}} & \tikz\draw[color=black!25] + plot[mark=#1,mark options={fill=examplefill,draw=black}] + coordinates {(0,0) (.5,0.2) (1,0) (1.5,0.2)};\\ +} + + + +\ifx\scantokens\@undefined + \PackageError{pgfmanual-macros}{You need to use extended latex + (elatex) or (pdfelatex) to process this document}{} +\fi + +\begingroup +\catcode`|=0 +\catcode`[= 1 +\catcode`]=2 +\catcode`\{=12 +\catcode `\}=12 +\catcode`\\=12 |gdef|find@example#1\end{codeexample}[|endofcodeexample[#1]] +|endgroup + +% define \returntospace. +% +% It should define NEWLINE as {}, spaces and tabs as \space. +\begingroup +\catcode`\^=7 +\catcode`\^^M=13 +\catcode`\^^I=13 +\catcode`\ =13% +\gdef\returntospace{\catcode`\ =13\def {\space}\catcode`\^^I=13\def^^I{\space}} +\gdef\showreturn{\show^^M} +\endgroup + +\begingroup +\catcode`\%=13 +\catcode`\^^M=13 +\gdef\commenthandler{\catcode`\%=13\def%{\@gobble@till@return}} +\gdef\@gobble@till@return#1^^M{} +\gdef\@gobble@till@return@ignore#1^^M{\ignorespaces} +\gdef\typesetcomment{\catcode`\%=13\def%{\@typeset@till@return}} +\gdef\@typeset@till@return#1^^M{{\def%{\char`\%}\textsl{\char`\%#1}}\par} +\endgroup + +% Define tab-implementation functions +% \codeexample@tabinit@replacementchars@ +% and +% \codeexample@tabinit@catcode@ +% +% They should ONLY be used in case that tab replacement is active. +% +% This here is merely a preparation step. +% +% Idea: +% \codeexample@tabinit@catcode@ will make TAB active +% and +% \codeexample@tabinit@replacementchars@ will insert as many spaces as +% /codeexample/tabsize contains. +{ +\catcode`\^^I=13 +% ATTENTION: do NOT use tabs in these definitions!! +\gdef\codeexample@tabinit@replacementchars@{% + \begingroup + \count0=\pgfkeysvalueof{/codeexample/tabsize}\relax + \toks0={}% + \loop + \ifnum\count0>0 + \advance\count0 by-1 + \toks0=\expandafter{\the\toks0\ }% + \repeat + \xdef\codeexample@tabinit@replacementchars@@{\the\toks0}% + \endgroup + \let^^I=\codeexample@tabinit@replacementchars@@ +}% +\gdef\codeexample@tabinit@catcode@{\catcode`\^^I=13}% +}% + +% Called after any options have been set. It assigns +% \codeexample@tabinit@catcode +% and +% \codeexample@tabinit@replacementchars +% which are used inside of +%\begin{codeexample} +% ... +%\end{codeexample} +% +% \codeexample@tabinit@catcode is either \relax or it makes tab +% active. +% +% \codeexample@tabinit@replacementchars is either \relax or it inserts +% a proper replacement sequence for tabs (as many spaces as +% configured) +\def\codeexample@tabinit{% + \ifnum\pgfkeysvalueof{/codeexample/tabsize}=0\relax + \let\codeexample@tabinit@replacementchars=\relax + \let\codeexample@tabinit@catcode=\relax + \else + \let\codeexample@tabinit@catcode=\codeexample@tabinit@catcode@ + \let\codeexample@tabinit@replacementchars=\codeexample@tabinit@replacementchars@ + \fi +} + +\pgfqkeys{/codeexample}{% + width/.code= {\setlength\codeexamplewidth{#1}}, + graphic/.code= {\colorlet{graphicbackground}{#1}}, + code/.code= {\colorlet{codebackground}{#1}}, + execute code/.is if=code@execute, + code only/.code= {\code@executefalse}, + pre/.store in=\code@pre, + post/.store in=\code@post, + % #1 is the *complete* environment contents as it shall be + % typeset. In particular, the catcodes are NOT the normal ones. + typeset listing/.code= {#1}, + render instead/.store in=\code@render, + vbox/.code= {\def\code@pre{\vbox\bgroup\setlength{\hsize}{\linewidth-6pt}}\def\code@post{\egroup}}, + ignorespaces/.code= {\let\@gobble@till@return=\@gobble@till@return@ignore}, + leave comments/.code= {\def\code@catcode@hook{\catcode`\%=12}\let\commenthandler=\relax\let\typesetcomment=\relax}, + tabsize/.initial=0,% FIXME : this here is merely used for indentation. It is just a TAB REPLACEMENT. + every codeexample/.style={width=4cm+7pt}, +} + +\let\code@pre\pgfutil@empty +\let\code@post\pgfutil@empty +\let\code@render\pgfutil@empty +\def\code@catcode@hook{} + +\newdimen\codeexamplewidth +\newif\ifcode@execute +\newbox\codeexamplebox +\def\codeexample[#1]{% + \begingroup% + \code@executetrue + \pgfqkeys{/codeexample}{every codeexample,#1}% + \codeexample@tabinit% assigns \codeexample@tabinit@[catcode,replacementchars] + \parindent0pt + \begingroup% + \par% + \medskip% + \let\do\@makeother% + \dospecials% + \obeylines% + \@vobeyspaces% + \catcode`\%=13% + \catcode`\^^M=13% + \code@catcode@hook% + \codeexample@tabinit@catcode + \relax% + \find@example} +\def\endofcodeexample#1{% + \endgroup% + \ifcode@execute% + \setbox\codeexamplebox=\hbox{% + \ifx\code@render\pgfutil@empty% + {% + {% + \returntospace% + \commenthandler% + \xdef\code@temp{#1}% removes returns and comments + }% + \catcode`\^^M=9% + \colorbox{graphicbackground}{\color{black}\ignorespaces% + \code@pre\expandafter\scantokens\expandafter{\code@temp\ignorespaces}\code@post\ignorespaces}% + }% + \else% + \colorbox{graphicbackground}{\color{black}\ignorespaces% + \code@render}% + \fi% + }% + \ifdim\wd\codeexamplebox>\codeexamplewidth% + \def\code@start{\par}% + \def\code@flushstart{}\def\code@flushend{}% + \def\code@mid{\parskip2pt\par\noindent}% + \def\code@width{\linewidth-6pt}% + \def\code@end{}% + \else% + \def\code@start{% + \linewidth=\textwidth% + \parshape \@ne 0pt \linewidth + \leavevmode% + \hbox\bgroup}% + \def\code@flushstart{\hfill}% + \def\code@flushend{\hbox{}}% + \def\code@mid{\hskip6pt}% + \def\code@width{\linewidth-12pt-\codeexamplewidth}% + \def\code@end{\egroup}% + \fi% + \code@start% + \noindent% + \begin{minipage}[t]{\codeexamplewidth}\raggedright + \hrule width0pt% + \footnotesize\vskip-1em% + \code@flushstart\box\codeexamplebox\code@flushend% + \vskip-1ex + \leavevmode% + \end{minipage}% + \else% + \def\code@mid{\par} + \def\code@width{\linewidth-6pt} + \def\code@end{} + \fi% + \code@mid% + \colorbox{codebackground}{% + \begin{minipage}[t]{\code@width}% + {% + \let\do\@makeother + \dospecials + \frenchspacing\@vobeyspaces + \normalfont\ttfamily\footnotesize + \typesetcomment% + \codeexample@tabinit@replacementchars + \@tempswafalse + \def\par{% + \if@tempswa + \leavevmode \null \@@par\penalty\interlinepenalty + \else + \@tempswatrue + \ifhmode\@@par\penalty\interlinepenalty\fi + \fi}% + \obeylines + \everypar \expandafter{\the\everypar \unpenalty}% + \pgfkeysvalueof{/codeexample/typeset listing/.@cmd}{#1}\pgfeov + } + \end{minipage}}% + \code@end% + \par% + \medskip + \end{codeexample} +} + +\def\endcodeexample{\endgroup} + + +\makeatother + +\usepackage{pgfmanual} + +\makeatletter +% \pgfautoxrefs will be defined by 'make dist' +\pgfutil@ifundefined{pgfautoxrefs}{% + \def\pgfmanualpdflabel#1#2{#2}% NO-OP + \def\pgfmanualpdfref#1#2{#2}% + \pgfkeys{ + /pdflinks/codeexample links=false,% DISABLED. + }% +}{} +\makeatother + +%%% Local Variables: +%%% mode: latex +%%% TeX-master: "beameruserguide" +%%% End: diff --git a/Master/texmf-dist/doc/latex/tikz-dependency/pgfmanual.code.tex b/Master/texmf-dist/doc/latex/tikz-dependency/pgfmanual.code.tex new file mode 100644 index 00000000000..0160878cb99 --- /dev/null +++ b/Master/texmf-dist/doc/latex/tikz-dependency/pgfmanual.code.tex @@ -0,0 +1,65 @@ +% Copyright 2009 by Till Tantau and Christian Feuersänger +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +\input pgfmanual.prettyprinter.code.tex +\input pgfmanual.pdflinks.code.tex + +% TODO for auto xrefs: +% 1. check the already identified labels, preferrably using +% /pdflinks/show labels=true +% and the image externalization debug mode (see pgfmanual-en-main.tex) +% (to strip almost all images away) +% +% 2. Insert '\declareandlabel' in the document whenever something has been +% defined in the text, so it should get a pdf anchor (see +% pgfmanual.pdflinks.code.tex ) +% +% 2.1 perhaps insert \pgfmanualpdflabel{<label>}{} where needed. +% +% 3. Verify that the |...| commands occuring in situations where catcodes can't +% be changed (footnotes or macro arguments) work as expected. +% +% 4. Consider telling the pretty printer that several control sequences +% have arguments which are options (see below for the predefined list). +% This may apply to \pgfpageslogicalpageoptions or so. +% +% 5. @Christian: consider extensions of the parser such that it identifies path commands (at least partially) +% +% + +\def\pgfmanual@warning#1{\immediate\write16{! Package pgfmanual Warning: #1}}% + + +\pgfkeys{ + % set this to 'false' to disable auto reference generation. + % However, a little bit runtime overhead will still remain + % (and the \pgfmanualpdflabel commands will still be used) + /pdflinks/codeexample links=true, + % + /codeexample/prettyprint/cs arguments/tikzset/.initial=1, + /codeexample/prettyprint/cs/tikzset/.code 2 args={\pgfmanualpdfref{#1}{#1}\{\pgfmanualprettyprintpgfkeys{#2}\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/usetikzlibrary/.initial=1, + /codeexample/prettyprint/cs/usetikzlibrary/.code 2 args={\pgfmanualpdfref{#1}{#1}\{\pgfmanualpdfref{#2}{#2}\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/usepgflibrary/.initial=1, + /codeexample/prettyprint/cs/usepgflibrary/.code 2 args={\pgfmanualpdfref{#1}{#1}\{\pgfmanualpdfref{#2}{#2}\pgfmanualclosebrace}, + % + % + % + % whenever an unqualified key is found, the following key prefix + % list is tried to find a match. + /pdflinks/search key prefixes in={/tikz/,/pgf/,/depgraph/}, + % + % the link prefix written to the pdf file: + /pdflinks/internal link prefix=pgf, + % + /pdflinks/warnings=false, + % for debugging: + /pdflinks/show labels=false, +}% + diff --git a/Master/texmf-dist/doc/latex/tikz-dependency/pgfmanual.pdflinks.code.tex b/Master/texmf-dist/doc/latex/tikz-dependency/pgfmanual.pdflinks.code.tex new file mode 100644 index 00000000000..e507d30e85c --- /dev/null +++ b/Master/texmf-dist/doc/latex/tikz-dependency/pgfmanual.pdflinks.code.tex @@ -0,0 +1,414 @@ +%-------------------------------------------- +% +% Package pgfplots +% +% Provides a user-friendly interface to create function plots (normal +% plots, semi-logplots and double-logplots). +% +% It is based on Till Tantau's PGF package. +% +% Copyright 2007/2008/2009 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see <http://www.gnu.org/licenses/>. +% +%-------------------------------------------- + +% This file provides an interface to the +% pgfmanual.prettyprint.code.tex thing -- it allows to +% *generate pdf crossrefs inside of codeexamples automatically* +% without any user input. +% +% Thus, you write +% \begin{codeexample}[] +% \begin{tikzpicture}[options] +% \end{tikzpicture} +% \end{codeexample} +% and pdf cross references to the definitions of 'tikzpicture' +% and any options will be generated automatically. +% +% Furthermore, pdf cross references will be generated for everything +% within vertical bars, |....|. +% +% +% +% +% +% The only necessary thing is that \pgfmanualpdflabel has been called +% for every (fully qualified) key, control sequence, environment or +% whatever. + +\newif\ifpgfmanualpdfwarnings +\pgfmanualpdfwarningstrue + +\newif\ifpgfmanualshowlabels + +\pgfkeys{% + /codeexample/prettyprint/cs arguments/pgfkeys/.initial=1, + /codeexample/prettyprint/cs/pgfkeys/.code 2 args={\pgfmanualpdfref{#1}{#1}\{\pgfmanualprettyprintpgfkeys{#2}\pgfmanualclosebrace}, + % + /codeexample/prettyprint/autolinks/.style={% + /codeexample/prettyprint/key name/.code={\pgfmanualpdfref{##1}{##1}}, + /codeexample/prettyprint/key name with handler/.code 2 args={\pgfmanualpdfref{##1}{##1}/\pgfmanualpdfref{/handlers/##2}{##2}}, + /codeexample/prettyprint/key value display only/.code={\pgfmanualprettyprintcode{##1}}, + /codeexample/prettyprint/cs/.code={\pgfmanualpdfref{##1}{##1}}, + /codeexample/prettyprint/cs with args/.code 2 args={\pgfmanualpdfref{##1}{##1}\{\pgfmanualprettyprintcode{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/pgfkeys/.initial=1, + /codeexample/prettyprint/cs/pgfkeys/.code 2 args={\pgfmanualpdfref{##1}{##1}\{\pgfmanualprettyprintpgfkeys{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/begin/.initial=1, + /codeexample/prettyprint/cs/begin/.code 2 args={##1\{\pgfmanualpdfref{##2}{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/end/.initial=1, + /codeexample/prettyprint/cs/end/.code 2 args={##1\{\pgfmanualpdfref{##2}{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/word/.code={\begingroup\pgfkeyssetvalue{/pdflinks/search key prefixes in}{}\pgfmanualpdfref{##1}{##1}\endgroup}, + /codeexample/prettyprint/point/.code={##1},% + /codeexample/prettyprint/point with cs/.code 2 args={(\pgfmanualpdfref{##1}{##1}:##2},% + },% + /codeexample/prettyprint/autolinks, +}% + +\pgfkeys{ + % + % Enables or disables the parsing of codeexamples. + /pdflinks/codeexample links/.is if=pgfmanualprettyenabled, + /pdflinks/codeexample links/.default=true, + % + % whenever an unqualified key is found, the following key prefix + % list is tried to find a match. + /pdflinks/search key prefixes in/.initial={/tikz/,/pgf/}, + % + % Enables or disables warnings for failed auto links: + /pdflinks/warnings/.is if=pgfmanualpdfwarnings, + /pdflinks/warnings/.default=true, + % + % Shows the autogenerated labels. This is useful to check if the + % 'search key prefixes in' worked as it ought to. + /pdflinks/show labels/.is if=pgfmanualshowlabels, + /pdflinks/show labels/.default=true, + /pdflinks/show labels=false, + % will be invoked with '#1' set to the generated label. + /pdflinks/show labels code/.code={ + \hbox to 0pt{% + \vbox to 0pt{\hsize=0pt + \vskip-\baselineskip + \hbox to \hsize{% + \hss + {\footnotesize\ttfamily\textcolor{red}{#1}}% + \hss + }% + \vss + }% + \vbox to 0pt{\hsize=0pt + \vss + \hbox to \hsize{% + \hss + {\footnotesize\ttfamily\textcolor{red}{$\vert$}}% + \hss + }% + }% + \vsize=0pt + }% + }, + % + % the link prefix written to the pdf file: + /pdflinks/internal link prefix/.initial=pgf, +} + +\gdef\pgfmanualpdf@installreplacements{% + \def\marg##1{{##1}}% + \def\oarg##1{[##1]}% + \def\meta##1{<##1>}% + \def\x{x}% + \def\textbackslash{<CS>}% + \def\\{\textbackslash}% + \def\space{:}% + \edef\ {\space}% + \edef\#{}% + \def\printanat{@}% + \def\protect{}% + \def\textasciicircum{o}% + \expandafter\edef\pgfmanual@verb@activebar{\pgfmanual@verb@bar}% +}% + +% Defines a new pdf cross ref label for use with \pgfmanualpdfref. +% +% Usage: +% \pgfmanualpdflabel{<label>}{<text>} +% #1: the label. +% The text #2 will be shown in the resulting pdf (if it is not empty). +% +% There is also support for catcode changes if <label> contains +% something which shouldn't be written as-is into .aux files: +% \pgfmanualpdflabel[\catcode`\|=12 ]{|-}{} +% -> this will write +% \begingroup \catcode `\|=12 +% <code to deal with the label |- > +% \endgroup +% into the .aux file. +% +\def\pgfmanualpdflabel{\pgfutil@ifnextchar[{\pgfmanualpdflabel@opt}{\pgfmanualpdflabel@opt[]}}% +\def\pgfmanualpdflabel@opt[#1]#2#3{% + \begingroup + % + \def\pgfmanualpdf@catcode{#1}% + \pgfmanualpdf@catcode + % + \pgfmanualpdflabel@generate{#2}{#3}% + % + % this is pgfplots-specific: pgfplots supports generic styles which + % contain '\x' where '\x' iterates through 'x,y,z'. + \pgfutil@in@\x{#2}% + \ifpgfutil@in@ + \def\x{y}% + \pgfmanualpdflabel@generate{#2}{#3}% + \def\x{z}% + \pgfmanualpdflabel@generate{#2}{#3}% + \fi + \endgroup +}% +\def\pgfmanualpdflabel@generate#1#2{% + \pgfmanual@handlespeciallabeltokens@in{#1}% + % + \def\pgfmanualpdflabel@generateone{0}% + \pgfutil@ifundefined{pgfd@lbl@\pgfmanualpdflabel@@}{% + % ok, no such label is known. + \def\pgfmanualpdflabel@generateone{1}% + }{% + \if\csname pgfd@lbl@\pgfmanualpdflabel@@\endcsname a% "a"ux + % ah, it is "just" known from a previous run, but there is + % no code in the pdf! Write it! + \def\pgfmanualpdflabel@generateone{1}% + \else + % ok, we already wrote one before. Skip. + \fi + }% + \if\pgfmanualpdflabel@generateone1% + \ifpgfmanualshowlabels + \pgfkeysvalueof{/pdflinks/show labels code/.@cmd}{\pgfmanualpdflabel@@}\pgfeov + \fi + % + \if@filesw + \ifx\pgfmanualpdf@catcode\pgfutil@empty + \else + \toks0=\expandafter{\pgfmanualpdf@catcode}% + \immediate\write\@auxout{% + \noexpand\begingroup + \the\toks0 + }% + \fi + \immediate\write\@auxout{% + \noexpand\expandafter\noexpand\gdef + \noexpand\csname pgfd@lbl@\pgfmanualpdflabel@@\noexpand\endcsname{a}% a = known in "a"ux file + }% + \ifx\pgfmanualpdf@catcode\pgfutil@empty + \else + \immediate\write\@auxout{\noexpand\endgroup}% + \fi + \fi + \expandafter\gdef\csname pgfd@lbl@\pgfmanualpdflabel@@\endcsname{w}% 1. remember the label AND remember that we "w"rote it into the pdf. + \edef\pgfmanualpdflabel@@{\pgfkeysvalueof{/pdflinks/internal link prefix}.\pgfmanualpdflabel@@}% + \expandafter\hypertarget\expandafter{\pgfmanualpdflabel@@}{#2}% + \else + #2% + \fi +}% + +% A pdf reference to label `#1' with (TeX) text `#2'. +% @see also \verbpdfref. +\def\pgfmanualpdfref#1#2{% + \begingroup + \pgfmanual@handlespeciallabeltokens@in{#1}% + % + \ifcsname pgfd@lbl@\pgfmanualpdflabel@@\endcsname + \else + \global\let\pgfmanual@glob=\pgfmanualpdflabel@@ + \def\pgfmanual@tempa{\foreach \prefix in }% + \pgfkeysgetvalue{/pdflinks/search key prefixes in}\pgfmanual@tempb + \expandafter\pgfmanual@tempa\expandafter{\pgfmanual@tempb}{% + \edef\pgfmanualpdflabel@@{\prefix\pgfmanualpdflabel@@}% + \expandafter\pgfmanual@handlespeciallabeltokens@in\expandafter{\pgfmanualpdflabel@@}% + \ifcsname pgfd@lbl@\pgfmanualpdflabel@@\endcsname + \xdef\pgfmanual@glob{\pgfmanualpdflabel@@}% + \breakforeach + \fi + }% + \let\pgfmanualpdflabel@@=\pgfmanual@glob + \ifcsname pgfd@lbl@\pgfmanualpdflabel@@\endcsname + \else + \ifpgfmanualpdfwarnings + \begingroup + \toks0={#1}% + \pgfmanual@warning{pgfmanualpdfref{\the\toks0 }: target label does not exist.}% + \endgroup + \fi + #2% + \let\pgfmanualpdflabel@@=\pgfutil@empty + \fi + \fi + \ifx\pgfmanualpdflabel@@\pgfutil@empty + \else + \expandafter\pgfmanualpdfref@\expandafter{\pgfmanualpdflabel@@}{#2}% + \fi + \endgroup +}% +\def\pgfmanualpdfref@#1#2{% + \pgfkeysgetvalue{/pdflinks/internal link prefix}\pgfmanual@temp + \expandafter\hyperlink\expandafter{\pgfmanual@temp.#1}{#2}% + \ifpgfmanualshowlabels + \pgfkeysvalueof{/pdflinks/show labels code/.@cmd}{#1}\pgfeov + \fi +}% + +% Handles special tokens in a pdf label which should be treated with +% care. +% +% For example, backslashes might produce problems. +% This occurs quite frequently with automatically generated hyperrefs +% inside of codeexamples where \pgfmanualpdfref will be invoked - +% there, we get the catcode 12 backslashes. +% Check for them! +% +% #1: a token list which shall be used either as cross ref or as +% label. +% +% On output, the macro \pgfmanualpdflabel@@ will be '\edef'ed to the +% new, possibly modified value. +\def\pgfmanual@handlespeciallabeltokens@in#1{% + \begingroup + \pgfmanualpdf@installreplacements + \expandafter\pgfutil@in@\pgfmanual@pretty@backslash{#1}% + \ifpgfutil@in@ + % assume the backslash is the first char and substitute it: + \pgfmanualpdfref@substitute@backslash#1\relax + \else + \edef\pgfmanualpdflabel@@{#1}% + \fi + \def\pgfmanual@tmp{\pgfutilstrreplace{ }{\space}}% + \expandafter\pgfmanual@tmp\expandafter{\pgfmanualpdflabel@@}% + \edef\pgfmanualpdflabel@@{\pgfretval}% + \pgfmath@smuggleone\pgfmanualpdflabel@@ + \endgroup +}% + +\expandafter\def\expandafter\pgfmanualpdfref@substitute@backslash\expandafter#\expandafter1\pgfmanual@pretty@backslash#2\relax{% + \edef\pgfmanualpdflabel@@{#1\textbackslash #2}% +}% + +% Typesets '#1' in red,\texttt like every declaration. It will also +% generate a pdf cross ref anchor for #1. +% +% WARNING: this changes catcodes! In case this is not acceptable in +% your context, you will need to generate a \pgfmanualpdflabel +% manually. +% +% \declareandlabel{\controlsequence} can be used as |\controlsequence| +\def\declareandlabel{% + \begingroup + \pgfmanual@verb@preparecatcodes@ + \def\pgfmanualprettyprinterhandlecollectedargs##1{% + \pgfmanualpdflabel##1{\texttt{\declare##1}}% mark: '##1' contains already braces. + \endgroup + }% + \pgfmanualprettyprintercollectargcount1{\relax}% +} + +% +% \verbpdfref{\controlsequence more stuff} +% is the same as writing |\controlsequence more stuff|, but the +% *complete* argument is supposed to be one label. +% +% The difference to \pgfmanualpdfref{...}{} is that the argument is +% supposed to be verbatim text. +\def\verbpdfref{% + \begingroup + \pgfmanual@verb@preparecatcodes@ + \def\pgfmanualprettyprinterhandlecollectedargs##1{% + \pgfmanualpdfref##1{\texttt{##1}}% mark: '##1' contains already braces. + \endgroup + }% + \pgfmanualprettyprintercollectargcount1{\relax}% +} + +% Prepare active vertical bars, |....| for auto-pretty cross +% referencing. +% +% Example: +% |\pgfkeys| -> will generate a hyperref! +{ + \catcode`\|=12 + \gdef\pgfmanual@verb@bar{|}% +% \gdef\pgfmanual@verb@collect#1|{% +% % this command will also handle control sequences. +% \texttt{\pgfmanualprettyprintpgfkeys{#1}}% +% \endgroup +% }% + \catcode`\|=13 + \gdef\pgfmanual@verb@activebar{|}% +} +\def\pgfmanual@verb{% + \begingroup + \pgfmanual@verb@preparecatcodes@ + \toksdef\t@pgfmanual@verb=0 + \t@pgfmanual@verb={}% + \pgfmanual@verb@collect +} +% this version of \pgfmanual@verb@collect is less efficient than the +% one uncommented above. BUT: it can auto-detect the case when +% |...| has been provided somewhere where I can't change catcodes! +% The other one would simply fail to compile. +\def\pgfmanual@verb@collect#1{% + \def\pgfmanual@temp{#1}% + \ifx\pgfmanual@temp\pgfmanual@verb@bar + % ok, finish: + \edef\pgfmanual@verb@collect@next{% + % this command will also handle control sequences. + \noexpand\endgroup + \noexpand\texttt{\noexpand\pgfmanualprettyprintpgfkeys{\the\t@pgfmanual@verb}}% + }% + \else + \ifx\pgfmanual@temp\pgfmanual@verb@activebar + % ohoh... that should not happen! It means someone invoked + % |...| within an argument; I couln't change catcodes. + % Ok, resort to a simple fallback solution. + % FIXME : I have just realized that THIS DOESN'T PRESERVE SPACES + \edef\pgfmanual@verb@collect@next{% + \noexpand\endgroup + \noexpand\texttt{\the\t@pgfmanual@verb}% + }% + \else + \t@pgfmanual@verb=\expandafter{\the\t@pgfmanual@verb #1}% + \let\pgfmanual@verb@collect@next=\pgfmanual@verb@collect + \fi + \fi + \pgfmanual@verb@collect@next +}% + +\AtBeginDocument{% + \ifpgfmanualprettyenabled + \catcode`\|=13 + \expandafter\let\pgfmanual@verb@activebar=\pgfmanual@verb + \fi +}% + +\def\pgfmanual@verb@preparecatcodes@{% + \let\do\@makeother% + \dospecials% + \catcode`\%=12 % THATS IMPORTANT! Do *not* handle comments! + % these catcodes are expected by the pretty printer... + %\catcode`\^^M=13 + \catcode`\ =13 + \catcode`\^^I=13 + \expandafter\def\pgfmanual@pretty@activespace{\space}% + \expandafter\def\pgfmanual@pretty@activetab{\space\space\space\space}% +}% +\endinput +% vi: ts=4 sw=4 diff --git a/Master/texmf-dist/doc/latex/tikz-dependency/pgfmanual.prettyprinter.code.tex b/Master/texmf-dist/doc/latex/tikz-dependency/pgfmanual.prettyprinter.code.tex new file mode 100644 index 00000000000..85482fedaaf --- /dev/null +++ b/Master/texmf-dist/doc/latex/tikz-dependency/pgfmanual.prettyprinter.code.tex @@ -0,0 +1,1095 @@ +%-------------------------------------------- +% +% Package pgfplots +% +% Provides a user-friendly interface to create function plots (normal +% plots, semi-logplots and double-logplots). +% +% It is based on Till Tantau's PGF package. +% +% Copyright 2007/2008/2009 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see <http://www.gnu.org/licenses/>. +% +%-------------------------------------------- + +% this is some kind of "plug-in" for pgfmanual-en-macros.tex which +% provides pretty printing of the code lines in 'codeexample'. +% +% It requires to be invoked with \pgfmanualprettyprintcode{#1} at the +% right place. +% +% ATTENTION: +% this is NOT a sophisticated syntax highlighter like lstlistings! +% It has rather strict assumptions about how to use it (the input must +% have been read verbatim, for example). + +% Special code for syntax highlighting: +% +% +% USER INTERFACE +\pgfkeys{% + % this is the public hook into + % \begin{codeexample}...\end{codeexample} which triggers pretty + % printing: + /codeexample/typeset listing/.code= {\pgfmanualprettyprintcode{#1}}, + % + % this key will be invoked whenever a key in key-value context has been identified. + % + % It won't be invoked for handled keys like |my style/.style=....|, see below. + % + % #1 will be the keys name. + /codeexample/prettyprint/key name/.code={#1}, + % + % A variant which will be used instead of |key name| if the key + % has a key handler. For example, when the pretty printer finds + % |my style/.style|, it will call + % |key name with handler={my style}{.style}. + /codeexample/prettyprint/key name with handler/.code 2 args={#1/#2}, + % + % Will be invoked whenever the value of a key has been found. + % It will be invoked AFTER 'key name' and not at all if there was + % no value. + % + % #1: the key's name + % #2: the key's value. + % + % The default implementation checks if there is a special handler + % for the key name '#1', in + % /codeexample/prettyprint/key value/#1. + % For example: + % /codeexample/prettyprint/key value/my key/.code 2 args={name=#1, value =#2} + % If such a key exists, it will be invoked with {#1}{#2} as + % arguments. Otherwise, the generic method + % /codeexample/prettyprint/key value with style detection={#1}{#2} + % will be invoked. + /codeexample/prettyprint/key value/.code 2 args={% + \pgfkeysifdefined{/codeexample/prettyprint/key value/#1}{% + \pgfkeysalso{/codeexample/prettyprint/key value/#1={#1}{#2}}% + }{% + \pgfkeysalso{/codeexample/prettyprint/key value with style detection={#1}{#2}}% + }% + }, + % A helper macro for the default 'key value' implementation. + /codeexample/prettyprint/key value with style detection/.code 2 args={% + \pgfutil@in@{style}{#1}% + \ifpgfutil@in@ + \pgfmanualprettyprintpgfkeys{#2}% + \else + \pgfkeysalso{/codeexample/prettyprint/key value display only={#2}}% + \fi + },% + % + % Will be invoked by the default 'key value' implementation to + % typeset the value as such. + /codeexample/prettyprint/key value display only/.code={#1}, + % + % Used to typeset a single word. A word is something which has not + % been identified in any other context; a maximal sequence of + % non-white-space tokens. + /codeexample/prettyprint/word/.code={#1}, + % + % A two-argument code key which invokes '#1' if spaces shall + % delimit words and '#2' if not. + % This may be useless. Handle with care! + /codeexample/prettyprint/if space is word delim/.code 2 args={% + #1% + },% + % + % A three-argument code key which should invoke '#2' if the single + % token '#1' is a word delimiter and '#3' if that is not the case. + % Note that '#1' doesn't have the usual catcodes (see the + % \pgfmanual@pretty@** macros)! + % Furthermore, white spaces are treated separately. + /codeexample/prettyprint/if is word delim/.code args={#1#2#3}{% + \edef\pgfmanual@check{,;().;\pgfmanual@pretty@lbrace\pgfmanual@pretty@rbrace}% + \def\pgfmanual@check@{\pgfutil@in@{#1}}% + \expandafter\pgfmanual@check@\expandafter{\pgfmanual@check}% + \ifpgfutil@in@ #2\else #3\fi + },% + % + % Used to typeset a single control sequence. + % #1 is the control sequence's name as a sequence of catcode 12 + % tokens. + /codeexample/prettyprint/cs/.code={#1}, + % + % Used to typeset a single control sequence together with one or + % more arguments. + % + % #1 is the control sequence's name (including the backslash as + % literal string) and + % #2,#3,...,#9 are the arguments. The number of arguments depends + % on the 'cs arguments/<CS NAME>' key; it contains the integer + % number. + % + % For example, if + % |cs arguments/pgfkeys/.initial=1|, + % the pretty printer invokes + % |cs with args={\pgfkeys}{<argument>}. + % + % If + % |cs arguments/mycommand/.initial=2|, + % the pretty printer invokes + % |cs with args={\pgfkeys}{<argument1>}{<argument2>}. + % In this case, 'cs with args' needs to be defined in a way which + % allows to deal with 3 arguments. + % + % Please note that the value do not contain braces! The braces + % need to be inserted manually. + % + % Special cases: + % 1. If end-of-input is encountered BEFORE the expected number of + % arguments has been found, the following happens: + % - if not even one (partial) argument has been found, the + % /codeexample/prettyprint/cs/.@cmd key will be used instead. + % - the \ifpgfmanualprettyprinterarghasunmatchedbraces boolean + % indicates if the trailing brace is missing. + /codeexample/prettyprint/cs with args/.code 2 args={#1\{#2\pgfmanualclosebrace}, + % + % For every identified control sequence, the key + % /codeexample/prettyprint/cs arguments/<CSNAME> + % will be checked. If it exists, it contains an integer with the + % number of arguments it takes. + % The <CSNAME> must not contain the '\'. + /codeexample/prettyprint/cs arguments/pgfkeys/.initial=1, + % + % For every identified control sequence, the key + % /codeexample/prettyprint/cs/<CSNAME>/.@cmd + % will be checked. If it exists, it will be used instead of + % 'cs with args' (with the same special case restrictions for + % early end-of-input). + % + % The <CSNAME> must not contain the '\'. + % + % This allows special treatment for special + % commands like \pgfkeys: + /codeexample/prettyprint/cs/pgfkeys/.code 2 args={#1\{\pgfmanualprettyprintpgfkeys{#2}\pgfmanualclosebrace}, + % + % recognise environments: + /codeexample/prettyprint/cs arguments/begin/.initial=1, + /codeexample/prettyprint/cs/begin/.code 2 args={#1\{#2\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/end/.initial=1, + /codeexample/prettyprint/cs/end/.code 2 args={#1\{#2\pgfmanualclosebrace}, + % + % a point coordinate (#1) + % Note that '#1' will contain the braces (if there was one), + /codeexample/prettyprint/point/.code={#1},% + % + % a point coordinate with explicit coordinate system: (#1:#2) + % Note that '#2' will contain the terminating brace (if there was one) + % #1: the coordinate system name (*without* the leading brace). + % The leading brace must be re-inserted by this style. + /codeexample/prettyprint/point with cs/.code 2 args={(#1:#2},% + % the same with specialised code: + %/codeexample/prettyprint/point with cs/<CS NAME>/.code 2 args={(#1:#2},% + % + % + % A predefined style which colors every identified token. It's + % purpose is only debugging. + /codeexample/prettyprint/colored/.style={% + /codeexample/prettyprint/key name/.code={\textcolor{red!75!black}{##1}}, + /codeexample/prettyprint/key name with handler/.code 2 args={\textcolor{red!75!black}{##1}/\textcolor{red!90!black}{##2}}, + /codeexample/prettyprint/key value display only/.code={\textcolor{yellow}{##1}}, + /codeexample/prettyprint/cs/.code={\textcolor{green}{##1}}, + /codeexample/prettyprint/cs with args/.code 2 args={\textcolor{green}{##1}\{\textcolor{orange}{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/pgfkeys/.initial=1, + /codeexample/prettyprint/cs/pgfkeys/.code 2 args={\textcolor{green}{##1}\{\pgfmanualprettyprintpgfkeys{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/begin/.initial=1, + /codeexample/prettyprint/cs/begin/.code 2 args={\textcolor{green}{##1}\{\textcolor{orange}{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/end/.initial=1, + /codeexample/prettyprint/cs/end/.code 2 args={\textcolor{green}{##1}\{\textcolor{orange}{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/word/.code={\textcolor{brown}{##1}}, + /codeexample/prettyprint/point/.code={\textcolor{red}{##1}},% + /codeexample/prettyprint/point with cs/.code 2 args={(\textcolor{green}{##1}:\textcolor{red}{##2}},% + },% + % A further debuggin helper. + /codeexample/prettyprint/colored and verbose/.style={% + /codeexample/prettyprint/colored, + /codeexample/prettyprint/key name/.code={\message{[key name=##1]}\textcolor{red!75!black}{##1}}, + /codeexample/prettyprint/key name with handler/.code 2 args={\message{[key name with handler=##1/##2]}\textcolor{red!75!black}{##1}/\textcolor{red!90!black}{##2}}, + /codeexample/prettyprint/key value display only/.code={\def\temp{##1}\message{[key value=\meaning\temp]}\textcolor{yellow}{##1}}, + /codeexample/prettyprint/cs/.code={\message{[cs=##1]}\textcolor{green}{##1}}, + /codeexample/prettyprint/cs with args/.code 2 args={\def\temp{##2}\message{[cs with args={##1}{\meaning\temp}]}\textcolor{green}{##1}\{\textcolor{orange}{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/word/.code={\message{[word=##1]}\textcolor{brown}{##1}}, + /codeexample/prettyprint/point/.code={\message{[point=##1]}\textcolor{red}{##1}},% + /codeexample/prettyprint/point with cs/.code 2 args={\message{[point with cs={##1}{##2}]}(\textcolor{green}{##1}:\textcolor{red}{##2}},% + },% + %/codeexample/prettyprint/colored, + %/codeexample/prettyprint/colored and verbose, +}% + +\newif\ifpgfmanualprettyenabled +\pgfmanualprettyenabledtrue + +% User interface command to handle unmatched braces: +% +% It expands to '\}' unless the preceding argument had unmatched braces. +\def\pgfmanualclosebrace{% + \ifpgfmanualprettyprinterarghasunmatchedbraces + \else + \}% + \fi +}% + + +% Typesets '#1', possibly using some sort of pretty printer. +% +% The argument '#1' is expected to be a long token list in which +% 1. all characters have catcode 11 or 12 (normal letters), +% 2. white spaces, tabs and newlines have catcode 13 (are active). +% +% @see \pgfmanualprettyprintpgfkeys +\long\def\pgfmanualprettyprintcode#1{% +%\def\temp{#1}\message{STARTING PRETTY PRINTING for \meaning\temp}% + \ifpgfmanualprettyenabled + \begingroup + \pgfmanualprettyprintstyles + \pgfmanual@pretty@mainloop#1\pgfmanual@EOI + \endgroup + \else + #1% + \fi +}% +% DISABLE: +%\long\def\pgfmanualprettyprintcode#1{#1}% + +\def\pgfmanualprettyprintstyles{% +%\tracingmacros=2 \tracingcommands=2 \message{PRETTYPRINT INIT}% + \def\{{\pgfmanual@pretty@lbrace}% + \def\}{\pgfmanual@pretty@rbrace}% + \pgfmanual@pretty@installcommenthandler + \let\pgfmanualprettyprintstyles=\relax +}% + + +\newif\ifpgfmanualprettycommentactive + +% we can't use the \@typeset@till@return method for comments because +% the pretty printer needs full control over the token list. +% +% We try a replacement here. +% +% FIXME +% THIS INTRODUCES A NEW GROUP! Does that hurt the pretty printer?? +% +\def\pgfmanual@pretty@installcommenthandler{% + \expandafter\def\pgfmanual@pretty@activepercent{% + \begingroup + \pgfmanualprettycommentactivetrue + \expandafter\let\pgfmanual@pretty@activenl=\pgfmanual@pretty@recoveraftercomment + \expandafter\def\pgfmanual@pretty@activepercent{\%}% + %\tt + \% % + }% +}% +\def\pgfmanual@pretty@recoveraftercomment{% + \endgroup + \pgfmanual@pretty@activenl +}% + +\def\pgfmanual@EOI{\pgfmanual@EOI}% + +{ + \catcode`\[=0 + \catcode`\\=12 + [gdef[pgfmanual@pretty@backslash{\}% +} +\begingroup + \catcode`\:=12 + \catcode`\(=12 + \catcode`\)=12 + \gdef\pgfmanual@pretty@colon{:}% + \gdef\pgfmanual@pretty@lroundbrace{(}% + \gdef\pgfmanual@pretty@rroundbrace{)}% + \catcode`\[=1 + \catcode`\]=2 + \catcode`\{=12 + \catcode`\}=12 + \gdef\pgfmanual@pretty@lbrace[{]% + \gdef\pgfmanual@pretty@rbrace[}]% + \catcode`\{=1 + \catcode`\}=2 + \catcode`\[=12 + \catcode`\]=12 + \catcode`\,=12 + \catcode`\ =10\relax\gdef\pgfmanual@pretty@space{ }% + \gdef\pgfmanual@pretty@lbracket{[}% + \gdef\pgfmanual@pretty@rbracket{]}% + \gdef\pgfmanual@pretty@comma{,}% + \catcode`\==12 + \gdef\pgfmanual@pretty@eq{=}% +\endgroup +\begingroup + \catcode`\%=12 + \gdef\pgfmanual@pretty@percent{%} + \catcode`\%=13 + \gdef\pgfmanual@pretty@activepercent{%} + \catcode`\^^M=13 + \gdef\pgfmanual@pretty@activenl{^^M}\endgroup +\begingroup +\catcode`\^^I=13\relax\gdef\pgfmanual@pretty@activetab{^^I}% +\catcode`\ =13\relax\gdef\pgfmanual@pretty@activespace{ }\endgroup + +% loops through all tokens. +% #1 is a single token. +\def\pgfmanual@pretty@mainloop{% + \def\pgfmanual@pretty@mainloop@currentword{}% + \pgfmanual@pretty@mainloop@ +}% +\long\def\pgfmanual@pretty@mainloop@#1{% + \def\pgfmanual@loc@TMPa{#1}% + \let\pgfmanual@pretty@mainloop@NEXT=\pgfmanual@pretty@mainloop@ + \ifx\pgfmanual@loc@TMPa\pgfmanual@EOI + % stop iteration. + \pgfmanual@pretty@mainloop@finishword + \let\pgfmanual@pretty@mainloop@NEXT=\relax + \else + \ifpgfmanualprettycommentactive + #1% + \else + \ifx\pgfmanual@loc@TMPa\pgfmanual@pretty@lbracket% + % we found the start of OPTIONS '[ ... ]'. + \pgfmanual@pretty@mainloop@finishword + % Attempt syntax highlighting for pgfkeys: + \let\pgfmanual@pretty@mainloop@NEXT=\pgfmanual@pretty@pgfkeys + \else + \ifx\pgfmanual@loc@TMPa\pgfmanual@pretty@backslash + % we found the start of a control sequence '\command' + \pgfmanual@pretty@mainloop@finishword + % + % collect the control sequence name into + % \pgfmanual@loc@TMPa, but without the backslash: + \let\pgfmanual@loc@TMPa=\pgfutil@empty + \let\pgfmanual@pretty@mainloop@NEXT=\pgfmanual@pretty@collectcs@loop + \else + \ifx\pgfmanual@loc@TMPa\pgfmanual@pretty@lroundbrace% + \pgfmanual@pretty@mainloop@finishword + \let\pgfmanual@pretty@mainloop@NEXT=\pgfmanual@pretty@collectpoint + \else + \def\pgfmanual@isspace{0}% + \ifnum13=\catcode`#1 + % we found a white space (space, TAB or NL) or comment + \def\pgfmanual@isspace{1}% + \else + \ifnum10=\catcode`#1 + \def\pgfmanual@isspace{1}% + \fi + \fi + \if\pgfmanual@isspace1% + \pgfkeysvalueof{/codeexample/prettyprint/if space is word delim/.@cmd}{% + \pgfmanual@pretty@mainloop@finishword + #1% ok, show it. + }{% + % collect the word. + \expandafter\def\expandafter\pgfmanual@pretty@mainloop@currentword\expandafter{\pgfmanual@pretty@mainloop@currentword #1}% + }% + \else + \pgfkeysvalueof{/codeexample/prettyprint/if is word delim/.@cmd}{#1}{% + \pgfmanual@pretty@mainloop@finishword + #1% ok, show the delimiter. + }{% + % collect the word. + \expandafter\def\expandafter\pgfmanual@pretty@mainloop@currentword\expandafter{\pgfmanual@pretty@mainloop@currentword #1}% + }\pgfeov% + \fi + \fi + \fi + \fi + \fi + \fi + \pgfmanual@pretty@mainloop@NEXT +}% + +\def\pgfmanual@pretty@mainloop@finishword{% + \ifx\pgfmanual@pretty@mainloop@currentword\pgfutil@empty + \else + \def\pgfmanual@loc@TMPa{\pgfkeysvalueof{/codeexample/prettyprint/word/.@cmd}}% + \expandafter\pgfmanual@loc@TMPa\pgfmanual@pretty@mainloop@currentword\pgfeov + \let\pgfmanual@pretty@mainloop@currentword=\pgfutil@empty + \fi +}% + +\def\pgfmanual@pretty@collectpoint{% + \let\pgfmanualprettyprinterhandlecollectedargs=\pgfmanual@pretty@collectargs@finish@collectpoint + \expandafter\pgfmanualprettyprintercollectupto\pgfmanual@pretty@rroundbrace + {\afterpgfmanual@pretty@collectpoint}% +} + +{ +\catcode`\:=12 +\gdef\pgfmanual@pretty@collectargs@finish@collectpoint#1{% + \expandafter\pgfutil@in@\pgfmanual@pretty@colon{#1}% + \ifpgfutil@in@ + \def\pgfmanual@pretty@collectpoint@getcoordsystem##1:##2\relax{% + \begingroup + \pgfmanual@pretty@restorespaces + % remove active spaces from ##1: + \xdef\pgfmanual@pretty@glob@TMPa{##1}% + \endgroup + \pgfkeysifdefined{/codeexample/prettyprint/point with cs/\pgfmanual@pretty@glob@TMPa/.@cmd}{% + \def\pgfmanual@loc@TMPb{\pgfkeysvalueof{/codeexample/prettyprint/point with cs/\pgfmanual@pretty@glob@TMPa/.@cmd}}% + }{% + \def\pgfmanual@loc@TMPb{\pgfkeysvalueof{/codeexample/prettyprint/point with cs/.@cmd}}% + }% + \expandafter\def\expandafter\pgfmanual@loc@TMPa\expandafter{\expandafter{\pgfmanual@pretty@glob@TMPa}{##2}}% + \expandafter\pgfmanual@loc@TMPb\pgfmanual@loc@TMPa\pgfeov + }% + \ifpgfmanualprettyprinterfoundterminator + \pgfmanual@pretty@collectpoint@getcoordsystem#1)\relax + \else + \pgfmanual@pretty@collectpoint@getcoordsystem#1\relax + \fi + \else + \def\pgfmanual@loc@TMPb{\pgfkeysvalueof{/codeexample/prettyprint/point/.@cmd}}% + \ifpgfmanualprettyprinterfoundterminator + \pgfmanual@loc@TMPb(#1)\pgfeov + \else + \pgfmanual@loc@TMPb(#1\pgfeov + \fi + \fi +}% +} +\def\afterpgfmanual@pretty@collectpoint{\pgfmanual@pretty@mainloop}% + +% loops through all tokens, assembling the cs name as it goes. +% #1 is a single token. +\def\pgfmanual@pretty@collectcs@loop#1{% + \let\pgfmanual@pretty@collectcs@loop@NEXT=\pgfmanual@pretty@collectcs@loop + \def\pgfmanual@loc@TMPb{#1}% + \ifx\pgfmanual@loc@TMPb\pgfmanual@EOI + \def\pgfmanual@pretty@collectcs@loop@NEXT{\pgfmanual@pretty@collectcs@loop@END #1}% + \else + % a csname may only use letters. And: only letters have a + % positive lcccode! + \ifnum\lccode`#1=0 + \ifx\pgfmanual@loc@TMPb @% + % ok, we may also accept an `@': + \edef\pgfmanual@loc@TMPa{\pgfmanual@loc@TMPa #1}% + \else + % This here is the first non-letter. + \def\pgfmanual@pretty@collectcs@loop@NEXT{\pgfmanual@pretty@collectcs@loop@END #1}% + \fi + \else + % continue iterating and assemble the csname... + \edef\pgfmanual@loc@TMPa{\pgfmanual@loc@TMPa #1}% + \fi + \fi + \pgfmanual@pretty@collectcs@loop@NEXT +}% +\def\afterpgfmanual@pretty@cs{\pgfmanual@pretty@mainloop}% + +\def\pgfmanual@pretty@collectcs@loop@END{% + \pgfkeysifdefined{/codeexample/prettyprint/cs arguments/\pgfmanual@loc@TMPa}{% + % oh. The collected control sequence expects arguments. That + % means a lot of work since there are no nestable braces in + % the token list! All of them have catcode 12... we need to do + % that manually. + \let\pgfmanualprettyprinterhandlecollectedargs=\pgfmanual@pretty@collectargs@finish@cs + \def\pgfmanual@pretty@collectcs@loop@END@next{% + \pgfmanualprettyprintercollectargcount + {\pgfkeysvalueof{/codeexample/prettyprint/cs arguments/\pgfmanual@loc@TMPa}}% + {\afterpgfmanual@pretty@cs}% + }% + }{% + % re-insert the backslash: + \edef\pgfmanual@loc@TMPa{\pgfmanual@pretty@backslash \pgfmanual@loc@TMPa}% + % ok, report the macro and continue with the main loop. + \def\pgfmanual@loc@TMPb{\pgfkeysvalueof{/codeexample/prettyprint/cs/.@cmd}}% + \expandafter\pgfmanual@loc@TMPb\pgfmanual@loc@TMPa\pgfeov + \let\pgfmanual@pretty@collectcs@loop@END@next=\afterpgfmanual@pretty@cs + }% + \pgfmanual@pretty@collectcs@loop@END@next +}% + +\newif\ifpgfmanualprettyprinterarghasunmatchedbraces + +% Collects arguments inside of a token list, dealing with nested +% catcode-12-braces. +% +% #1: is the NUMBER of arguments to collect. +% #2: is TeX code which shall be invoked after +% \pgfmanualprettyprinterhandlecollectedargs has been invoked (see +% below). +% +% PRECONDITION: +% there is a large token list following +% \pgfmanualprettyprintercollectargcount with balanced braces. The braces +% have \catcode 12. +% POSTCONDITION: +% 1. the arguments will be collected as +% '<result> := {<first arg>}{<second arg>}', +% 2.1 the macro \pgfmanualprettyprinternumcollectedargs will contain +% the *actual* number of *completely* collected arguments, +% 2.2 the if \ifpgfmanualprettyprinterarghasunmatchedbraces will be +% set to \c true if the last found argument had an unmatched brace, +% 3. then, \pgfmanualprettyprinterhandlecollectedargs{<result>} will be +% invoked. Just define \pgfmanualprettyprinterhandlecollectedargs +% properly. +% Afterwards, #2 will be invoked to recover from the argument +% collection. +% +% +% Example: +% \pgfmanualprettyprintercollectargcount{2}{\donnextstep} +% {_12 first argument }_12 {_12 second argument }_12 next tokens% +% +% will result in the expansion +% \pgfmanualprettyprinterhandlecollectedargs{{_1 first argument }_2 {_1 second argument }_2 } +% \donnextstep +% next tokens +% +% +% +% ATTENTION: +% \pgfmanualprettyprinterhandlecollectedargs will be invoked with a SINGLE +% argument. The argument as such will contain extra braces, one pair +% of braces for each of the #1 arguments. These braces will have +% catcode 1 and 2, i.e. they can *really* be used in TeX. Thus, the +% finish routine will be invoked with +% \pgfmanualprettyprinterhandlecollectedargs{{<arg>}} +% for one argument and with +% \pgfmanualprettyprinterhandlecollectedargs{{<first arg>}{<second arg>}} +% for two and more arguments. Note the extra set of braces for one +% arg. +% It might happen that not all arguments have been found if +% end-of-input occured before. The +% \pgfmanualprettyprinterhandlecollectedargs routine has to check +% this using the macro \pgfmanualprettyprinternumcollectedargs which +% contains the actual number of collected args. +% +% @remark This macro checks for the end-of-input indicator, \pgfmanual@EOI. In case it encounters +% \pgfmanual@EOI, it +% 1. stops collecting, leaving the \pgfmanual@EOI as next token to be read, +% 2. sets \ifpgfmanualprettyprinterarghasunmatchedbraces to \iftrue if necessary, +% 3. assigns \pgfmanualprettyprinternumcollectedargs +% 4. invokes the finish routine. +% The \pgfmanual@EOI needs to be collected by following routines in +% this case. You can also use \pgfutil@ifnextchar\pgfmanual@EOI{}{} in +% following routines to check for \pgfmanual@EOI. +\def\pgfmanualprettyprintercollectargcount#1#2{% + \pgfmanualprettyprinterarghasunmatchedbracesfalse + \begingroup + \edef\pgfmanual@loc@csargcount{#1}% + \toksdef\t@afterpgfmanualprettyprinterhandlecollected=10 + \t@afterpgfmanualprettyprinterhandlecollected={#2}% + \let\c@pgfmanual@pretty@openbracecount=\c@pgf@counta + \let\c@pgfmanual@pretty@curargcount=\c@pgf@countb + % I will track open braces and the number of completely + % collected arguments here: + \c@pgfmanual@pretty@openbracecount=0 + \c@pgfmanual@pretty@curargcount=0 + % + % and I will accumulate the argument token lists as such here: + \toksdef\t@pgfmanual@currentarg=0 + \toksdef\t@pgfmanual@allargs=1 + \t@pgfmanual@currentarg={}% + \t@pgfmanual@allargs={}% + % + \pgfmanual@pretty@collectargs@loop +}% + +% loops through all tokens, collecting the required number of +% arguments. This involves to track nested braces manually. +% #1 is a single token. +\def\pgfmanual@pretty@collectargs@loop#1{% + \let\pgfmanual@pretty@collectargs@loop@NEXT=\pgfmanual@pretty@collectargs@loop + \def\pgfmanual@loc@TMPc{#1}% + \ifx\pgfmanual@loc@TMPc\pgfmanual@EOI + \ifnum\c@pgfmanual@pretty@openbracecount>0 + \ifpgfmanualpdfwarnings + \pgfplots@warning{The pretty printer did not found the closing curly brace!? This will potentially lead to display errors}% + \fi + \fi + \edef\pgfmanual@pretty@collectargs@loop@NEXT{% + \noexpand\endgroup + \ifnum\c@pgfmanual@pretty@openbracecount>0 + \noexpand\pgfmanualprettyprinterarghasunmatchedbracestrue + \fi + \noexpand\def\noexpand\pgfmanualprettyprinternumcollectedargs{\the\c@pgfmanual@pretty@curargcount}% + \noexpand\pgfmanualprettyprinterhandlecollectedargs{\the\t@pgfmanual@allargs\the\t@pgfmanual@currentarg}% + \the\t@afterpgfmanualprettyprinterhandlecollected + \noexpand\pgfmanual@EOI% <- put this token back into token list! + }% + \else + \ifpgfmanualprettycommentactive + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@activenl + \pgfmanualprettycommentactivefalse + \fi + \else + \ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@activepercent + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \pgfmanualprettycommentactivetrue + \else + \ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@lbrace + \advance\c@pgfmanual@pretty@openbracecount by1 + \ifnum\c@pgfmanual@pretty@openbracecount>1 + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \fi + \else + \ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@rbrace + \advance\c@pgfmanual@pretty@openbracecount by-1 + \ifnum\c@pgfmanual@pretty@openbracecount=0 + % we have one complete argument ready! + % append it -- with REAL braces if needed: + \edef\pgfmanual@loc@TMPc{\the\t@pgfmanual@allargs{\the\t@pgfmanual@currentarg}}% + \t@pgfmanual@allargs=\expandafter{\pgfmanual@loc@TMPc}% + \t@pgfmanual@currentarg={}% + % + % check it we need more arguments: + \advance\c@pgfmanual@pretty@curargcount by1 + \ifnum\c@pgfmanual@pretty@curargcount=\pgfmanual@loc@csargcount\relax + \edef\pgfmanual@pretty@collectargs@loop@NEXT{% + \noexpand\endgroup + \noexpand\def\noexpand\pgfmanualprettyprinternumcollectedargs{\the\c@pgfmanual@pretty@curargcount}% + \noexpand\pgfmanualprettyprinterhandlecollectedargs{\the\t@pgfmanual@allargs}% + \the\t@afterpgfmanualprettyprinterhandlecollected + }% + \fi + \else + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \fi + \else + \ifnum13=\catcode`#1 + % we found a white space (space, TAB or NL) or comment + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \else + \ifnum10=\catcode`#1 + % we found a white space (space, TAB + % or NL) with unexpected catcode + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \else + \ifnum\c@pgfmanual@pretty@openbracecount=0 + \ifpgfmanualpdfwarnings + \begingroup + \toks4{#1}% + \pgfplots@warning{The pretty printer did not find the expected \pgfmanual@loc@csargcount\space arguments (only token \the\toks4 )}% + \endgroup + \fi + \edef\pgfmanual@pretty@collectargs@loop@NEXT{% + \noexpand\endgroup + \noexpand\def\noexpand\pgfmanualprettyprinternumcollectedargs{\the\c@pgfmanual@pretty@curargcount}% + \noexpand\pgfmanualprettyprinterhandlecollectedargs{\the\t@pgfmanual@allargs\the\t@pgfmanual@currentarg}% + \the\t@afterpgfmanualprettyprinterhandlecollected + \noexpand#1% <- put this token back into token list! + }% + \else + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \fi + \fi + \fi + \fi + \fi + \fi + \fi + \fi + \pgfmanual@pretty@collectargs@loop@NEXT +}% + +\newif\ifpgfmanualprettyprinterfoundterminator + +% Collects tokens inside of a token list up to a single delimiting token, dealing with nested +% catcode-12-braces. +% +% #1: is the end token, the delimiter. It won't be collected. +% #2: is code to invoke after +% \pgfmanualprettyprinterhandlecollectedargs has been invoked. +% +% PRECONDITION: +% there is a large token list following +% \pgfmanualprettyprintercollectargcount with balanced braces. The braces +% have \catcode 12. +% POSTCONDITION: +% - the arguments will be collected as +% '<result> := <token list>' +% and then, \pgfmanualprettyprinterhandlecollectedargs{<result>} will be +% invoked. Just define \pgfmanualprettyprinterhandlecollectedargs +% properly. +% Then, #2 will be invoked. +% - The boolean \ifpgfmanualprettyprinterfoundterminator will be set to true if and only if '#1' has been found. +% +% @see \pgfmanualprettyprintercollectargcount for more details. +% +\def\pgfmanualprettyprintercollectupto#1#2{% + \pgfmanualprettyprinterarghasunmatchedbracesfalse + \pgfmanualprettyprinterfoundterminatortrue + \begingroup + \def\pgfmanual@loc@delimittoken{#1}% + \toksdef\t@afterpgfmanualprettyprinterhandlecollected=10 + \t@afterpgfmanualprettyprinterhandlecollected={#2}% + % + \let\c@pgfmanual@pretty@openbracecount=\c@pgf@counta + % I will track open braces here: + \c@pgfmanual@pretty@openbracecount=0 + % + % and I will accumulate the argument token lists as such here: + \toksdef\t@pgfmanual@currentarg=0 + \t@pgfmanual@currentarg={}% + % + \pgfmanual@pretty@collectupto@loop +}% + +% loops through all tokens, collecting the required number of +% arguments. This involves to track nested braces manually. +% #1 is a single token. +\def\pgfmanual@pretty@collectupto@loop#1{% + \let\pgfmanual@pretty@collectupto@loop@NEXT=\pgfmanual@pretty@collectupto@loop + \def\pgfmanual@loc@TMPc{#1}% + \ifx\pgfmanual@loc@TMPc\pgfmanual@EOI + \edef\pgfmanual@pretty@collectupto@loop@NEXT{% + \noexpand\endgroup + \ifnum\c@pgfmanual@pretty@openbracecount>0 + \noexpand\pgfmanualprettyprinterarghasunmatchedbracestrue + \fi + \noexpand\pgfmanualprettyprinterfoundterminatorfalse + \noexpand\pgfmanualprettyprinterhandlecollectedargs{\the\t@pgfmanual@currentarg}% + \the\t@afterpgfmanualprettyprinterhandlecollected + \noexpand\pgfmanual@EOI% <- put this token back into token list! + }% + \else + \ifpgfmanualprettycommentactive + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@activenl + \pgfmanualprettycommentactivefalse + \fi + \else + \ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@activepercent + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \pgfmanualprettycommentactivetrue + \else + \ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@lbrace + \advance\c@pgfmanual@pretty@openbracecount by1 + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \else + \ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@rbrace + \advance\c@pgfmanual@pretty@openbracecount by-1 + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \else + \ifx\pgfmanual@loc@TMPc\pgfmanual@loc@delimittoken + \ifnum\c@pgfmanual@pretty@openbracecount=0 + % do NOT include the delimit token. + \edef\pgfmanual@pretty@collectupto@loop@NEXT{% + \noexpand\endgroup + \noexpand\pgfmanualprettyprinterhandlecollectedargs{\the\t@pgfmanual@currentarg}% + \the\t@afterpgfmanualprettyprinterhandlecollected + }% + \else + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \fi + \else + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \fi + \fi + \fi + \fi + \fi + \fi + \pgfmanual@pretty@collectupto@loop@NEXT +}% + +\def\pgfmanual@pretty@collectargs@finish@cs#1{% + \def\pgfmanual@pretty@collectargs@finish@cs@hasargs{1}% + \ifnum\pgfmanualprettyprinternumcollectedargs=0 + \ifpgfmanualprettyprinterarghasunmatchedbraces + \else + \def\pgfmanual@pretty@collectargs@finish@cs@hasargs{0}% + \fi + \fi + \if\pgfmanual@pretty@collectargs@finish@cs@hasargs1% + % report the macro and its arguments: + \pgfkeysifdefined{/codeexample/prettyprint/cs/\pgfmanual@loc@TMPa/.@cmd}{% + % oh, we have a separate routine for this macro! Ok, use it: + \edef\pgfmanual@loc@TMPb{\noexpand\pgfkeysvalueof{/codeexample/prettyprint/cs/\pgfmanual@loc@TMPa/.@cmd}}% + }{% + % use the generic routine: + \edef\pgfmanual@loc@TMPb{\noexpand\pgfkeysvalueof{/codeexample/prettyprint/cs with args/.@cmd}}% + }% + % re-insert the backslash: + \edef\pgfmanual@loc@TMPa{{\pgfmanual@pretty@backslash\pgfmanual@loc@TMPa}}% + \expandafter\pgfmanual@loc@TMPb\pgfmanual@loc@TMPa #1\pgfeov + \else + % Oh. We probably got |\pgfkeys| instead of |\pgfkeys{arg}| + % re-insert the backslash: + \edef\pgfmanual@loc@TMPa{{\pgfmanual@pretty@backslash\pgfmanual@loc@TMPa}}% + \edef\pgfmanual@loc@TMPb{\noexpand\pgfkeysvalueof{/codeexample/prettyprint/cs/.@cmd}}% + \expandafter\pgfmanual@loc@TMPb\pgfmanual@loc@TMPa\pgfeov + #1\relax% simply typeset any encountered tokens after the control sequence. + \fi +}% + +% A user macro which pretty prints a set of keys. +% +% If '#1' is NOT an argument for \pgfkeys, +% \pgfmanualprettyprintpgfkeys will try to recognise at least control +% sequences (in the same way as usual). Thus, you can even use this +% method if there *could* be pgfkeys arguments in an automated pretty +% printing environment. +% +% However, '#1' should only have catcode 12 characters with the +% exception of catcode 13 for newlines, spaces and comments. +\long\def\pgfmanualprettyprintpgfkeys#1{% + \ifpgfmanualprettyenabled + \begingroup + \pgfmanualprettyprintstyles + \pgfmanual@pretty@pgfkeys@loop#1\pgfmanual@EOI + \endgroup + \else + #1% + \fi +} + +\def\pgfmanual@pretty@pgfkeys{% + \let\pgfmanualprettyprinterhandlecollectedargs=\pgfmanual@pretty@pgfkeys@start + \pgfmanualprettyprintercollectupto]{\pgfmanual@pretty@mainloop}%% +}% +\long\def\pgfmanual@pretty@pgfkeys@start#1{% + [% + \pgfmanual@pretty@pgfkeys@loop#1\pgfmanual@EOI + ]% +}% +% iterates through single tokens, detecting key names and values while +% it goes. +\long\def\pgfmanual@pretty@pgfkeys@loop#1{% + \def\pgfmanual@loc@TMPa{#1}% + \ifx\pgfmanual@loc@TMPa\pgfmanual@EOI + \def\pgfmanual@pretty@pgfkeys@loop@NEXT{\relax}% + \else + \def\pgfmanual@pretty@pgfkeys@loop@NEXT{\pgfmanual@pretty@pgfkeys@loop}% + \ifpgfmanualprettycommentactive + #1% + \else + \ifnum13=\catcode`#1 + % we found a white space (space, TAB or NL) or comment + #1% + \else + \ifx\pgfmanual@loc@TMPa\pgfmanual@pretty@comma% + %\let\pgfmanual@pretty@pgfkeys@loop@NEXT=\pgfmanual@pretty@pgfkeys@checkforEOI + ,% + \else + \ifnum10=\catcode`#1 + % another white space... I thought they'd have + % catcode 13. doesn't matter. + #1% + \else + \ifx\pgfmanual@loc@TMPa\pgfmanual@pretty@lbrace + % braces may not occur in the first place - + % but there are circumstances where it is + % convenient to deal with them here (when + % processing arguments of styles) + % Do it. + #1% + \else + \ifx\pgfmanual@loc@TMPa\pgfmanual@pretty@rbrace + #1% + \else + % found the beginning of a key! + % We will collect the key name into + % \toks0. + \toks0={}% + % + % Handle it: + % FIXME what if we found an opening brace!? + \def\pgfmanual@pretty@pgfkeys@loop@NEXT{\pgfmanual@pretty@pgfkeys@collectkey #1}% + \fi + \fi + \fi + \fi + \fi + \fi + \fi + \pgfmanual@pretty@pgfkeys@loop@NEXT +}% +\def\pgfmanual@pretty@pgfkeys@collectkey#1{% + \def\pgfmanual@loc@TMPb{#1}% + \def\pgfmanual@pretty@pgfkeys@collectkey@next{\pgfmanual@pretty@pgfkeys@collectkey}% + \ifx\pgfmanual@loc@TMPb\pgfmanual@EOI + % finish key name. + \edef\pgfmanual@loc@TMPb{\the\toks0 }% + \ifx\pgfmanual@loc@TMPb\pgfutil@empty + \else + \expandafter\pgfmanual@pretty@pgfkeys@processkey\expandafter{\the\toks0 }% + \fi + \def\pgfmanual@pretty@pgfkeys@collectkey@next{\relax}% + \else + \ifx\pgfmanual@loc@TMPb\pgfmanual@pretty@eq + % finish key name. + \expandafter\pgfmanual@pretty@pgfkeys@processkey\expandafter{\the\toks0 }% + #1% + % now, we do the same with the value - we collect it into + % \toks0. + \toks0={}% + \def\pgfmanual@pretty@pgfkeys@collectvalue@hasconsumedspaces{0}% + \def\pgfmanual@pretty@pgfkeys@collectkey@next{\pgfmanual@pretty@pgfkeys@collectvalue}% + \else + \ifx\pgfmanual@loc@TMPb\pgfmanual@pretty@comma + % finish key name. + \expandafter\pgfmanual@pretty@pgfkeys@processkey\expandafter{\the\toks0 }% + #1% + \def\pgfmanual@pretty@pgfkeys@collectkey@next{\pgfmanual@pretty@pgfkeys@loop}% + \else + \ifx\pgfmanual@loc@TMPb\pgfmanual@pretty@activenl + % finish key name before newline. This is not + % necessarily as in TeX, but its simpler here + % because we don't need special cases for comments + % and we don't need to gobble following white + % spaces. + \expandafter\pgfmanual@pretty@pgfkeys@processkey\expandafter{\the\toks0 }% + #1% + \def\pgfmanual@pretty@pgfkeys@collectkey@next{\pgfmanual@pretty@pgfkeys@loop}% + \else + \ifx\pgfmanual@loc@TMPb\pgfmanual@pretty@backslash + % This is confusing. I simply try to invoke + % the control sequence code and recover as + % good as possible. Let's see if that's + % useful. + \edef\pgfmanual@loc@TMPb{\the\toks0 }% + \ifx\pgfmanual@loc@TMPb\pgfutil@empty + \else + \expandafter\pgfmanual@pretty@pgfkeys@processkey\expandafter{\the\toks0 }% + \fi + % + % we found the start of a control sequence '\command': + % + % collect the control sequence name into + % \pgfmanual@loc@TMPa, but without the backslash: + \begingroup + \let\pgfmanual@loc@TMPa=\pgfutil@empty + \def\afterpgfmanual@pretty@cs{% + \endgroup + \pgfmanual@pretty@pgfkeys@loop + }% + \def\pgfmanual@pretty@pgfkeys@collectkey@next{\pgfmanual@pretty@collectcs@loop}% + \else + \ifx\pgfmanual@loc@TMPb\pgfmanual@pretty@lbrace + % Braces in key names are allowed (if they + % are not the first character of a key + % name) + \def\pgfmanualprettyprinterhandlecollectedargs##1{% + \toks1={##1}% + \edef\pgfmanual@loc@TMPc{% + \the\toks0 \pgfmanual@pretty@lbrace \the\toks1 + \ifpgfmanualprettyprinterarghasunmatchedbraces + \else + \pgfmanual@pretty@rbrace + \fi + }% + \toks0=\expandafter{\pgfmanual@loc@TMPc}% + }% + \def\pgfmanual@pretty@pgfkeys@collectkey@next{% + \pgfmanualprettyprintercollectargcount{1}{\pgfmanual@pretty@pgfkeys@collectkey}% + #1% + }% + \else + \ifx\pgfmanual@loc@TMPb\pgfmanual@pretty@rbrace + \expandafter\pgfmanual@pretty@pgfkeys@processkey\expandafter{\the\toks0 }% + #1% + \def\pgfmanual@pretty@pgfkeys@collectkey@next{\pgfmanual@pretty@pgfkeys@loop}% + \else + \toks0=\expandafter{\the\toks0 #1}% + \fi + \fi + \fi + \fi + \fi + \fi + \fi + \pgfmanual@pretty@pgfkeys@collectkey@next +}% +\def\pgfmanual@pretty@pgfkeys@collectvalue#1{% + \def\pgfmanual@loc@TMPb{#1}% + \let\pgfmanual@pretty@pgfkeys@collectvalue@next=\pgfmanual@pretty@pgfkeys@collectvalue + \ifx\pgfmanual@loc@TMPb\pgfmanual@EOI + % the key value is empty. + %\expandafter\pgfmanual@pretty@pgfkeys@processvalue\expandafter{\the\toks0 }% + \let\pgfmanual@pretty@pgfkeys@collectvalue@next=\relax + \else + \def\pgfmanual@pretty@isconsumed{0}% + \if\pgfmanual@pretty@pgfkeys@collectvalue@hasconsumedspaces0% + \ifnum13=\catcode`#1 + % we found a white space (space, TAB or NL) + #1% + \def\pgfmanual@pretty@isconsumed{1}% + \else + \ifnum10=\catcode`#1 + % another white space... I thought they'd have + % catcode 13. doesn't matter. + \def\pgfmanual@pretty@isconsumed{1}% + #1% + \fi + \fi + \fi + \if\pgfmanual@pretty@isconsumed0% + \def\pgfmanualprettyprinterhandlecollectedargs##1{\pgfmanual@pretty@pgfkeys@processvalue{##1}}% the braces will be handled separately. + \def\pgfmanual@pretty@pgfkeys@collectvalue@next{% + \pgfmanualprettyprintercollectupto,{\afterpgfmanual@pretty@collectargs@finish@value}#1% + }% + \fi + \fi + \pgfmanual@pretty@pgfkeys@collectvalue@next +}% +\def\afterpgfmanual@pretty@collectargs@finish@value{% + \pgfutil@ifnextchar\pgfmanual@EOI{% + \pgfmanual@pretty@pgfkeys@loop + }{% + \pgfmanual@pretty@pgfkeys@loop,% re-insert the gobbled comma here! + }% +}% + +{\catcode`\^^M=13 \catcode`\ =13\relax\catcode`\%=13\relax\gdef\pgfmanual@pretty@restorespaces{\def%{\pgfmanual@pretty@percent}\def^^M{\pgfmanual@pretty@space}\def {\pgfmanual@pretty@space}}} + +% #1: the key's name +\def\pgfmanual@pretty@pgfkeys@processkey#1{% + \begingroup + \pgfmanual@pretty@restorespaces + % remember this key name! It is used when we are dealing with + % its value later... (if it has a value) + \xdef\pgfmanual@pretty@pgfkeys@collectkey@keyname{#1}% + \endgroup + % + % check if it is a handled key. FIXME: this could be done in a + % rigorous way! This here assumes that all key handlers start with + % '.' and the '.' occurs never right after a '/' otherwise: + \def\pgfmanual@loc@TMPa{\pgfutil@in@{/.}}% + \expandafter\pgfmanual@loc@TMPa\expandafter{\pgfmanual@pretty@pgfkeys@collectkey@keyname}% + \ifpgfutil@in@ + % split into key name and handler name... + \def\pgfmanual@pretty@splitit##1/.##2\relax{% + \def\pgfmanual@loc@TMPb{{##1}{.##2}}% + }% + \expandafter\pgfmanual@pretty@splitit\pgfmanual@pretty@pgfkeys@collectkey@keyname\relax + % + % report key name AND handler: + \def\pgfmanual@loc@TMPa{\pgfkeysvalueof{/codeexample/prettyprint/key name with handler/.@cmd}}% + \expandafter\pgfmanual@loc@TMPa\pgfmanual@loc@TMPb\pgfeov + \else + % report key name ... + \def\pgfmanual@loc@TMPa{\pgfkeysvalueof{/codeexample/prettyprint/key name/.@cmd}}% + \expandafter\pgfmanual@loc@TMPa\pgfmanual@pretty@pgfkeys@collectkey@keyname\pgfeov + \fi +} +\def\pgfmanual@pretty@pgfkeys@processvalue#1{% + % report or process the value, depending on the keyname. + % After all, it *may* be a style which needs to be pretty printed + % as well. + \pgfkeysifdefined{/codeexample/prettyprint/key value/\pgfmanual@pretty@pgfkeys@collectkey@keyname/.@cmd}{% + % oh, we have a separate routine for this macro! Ok, use it: + \edef\pgfmanual@loc@TMPb{\noexpand\pgfkeysvalueof{/codeexample/prettyprint/key value/\pgfmanual@pretty@pgfkeys@collectkey@keyname/.@cmd}}% + }{% + % use the generic routine: + \edef\pgfmanual@loc@TMPb{\noexpand\pgfkeysvalueof{/codeexample/prettyprint/key value/.@cmd}}% + }% + \edef\pgfmanual@loc@TMPa{{\pgfmanual@pretty@pgfkeys@collectkey@keyname}}% + \expandafter\pgfmanual@loc@TMPb\pgfmanual@loc@TMPa{#1}\pgfeov +} + diff --git a/Master/texmf-dist/doc/latex/tikz-dependency/tikz-dependency.pdf b/Master/texmf-dist/doc/latex/tikz-dependency/tikz-dependency-doc.pdf Binary files differindex b5413dec7e8..03275941f39 100644 --- a/Master/texmf-dist/doc/latex/tikz-dependency/tikz-dependency.pdf +++ b/Master/texmf-dist/doc/latex/tikz-dependency/tikz-dependency-doc.pdf diff --git a/Master/texmf-dist/doc/latex/tikz-dependency/tikz-dependency-doc.tex b/Master/texmf-dist/doc/latex/tikz-dependency/tikz-dependency-doc.tex new file mode 100644 index 00000000000..feb85e73e71 --- /dev/null +++ b/Master/texmf-dist/doc/latex/tikz-dependency/tikz-dependency-doc.tex @@ -0,0 +1,1361 @@ +% Copyright 2011 by Daniele Pighin +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Free Documentation License. +% +% See the file doc/generic/tikz-dependency/licenses/LICENSE for more details. + +\documentclass[a4paper]{ltxdoc} +\def\pgfautoxrefs{1} + +\usepackage[a4paper,left=2.25cm,right=2.25cm,top=2.5cm,bottom=2.5cm,nohead]{geometry} +\usepackage[utf8]{inputenc} + +\usepackage{makeidx} +\makeindex + +\usepackage{hyperref} +\hypersetup{% + pdftitle={The tikz-dependency package}, + pdfsubject={A latex package based on tikz to draw dependency graphs}, + pdfauthor={Daniele Pighin}, + pdfkeywords={dependency parses, latex, tikz, pgf}, + colorlinks=true, % use true to enable colors below: + linkcolor=blue,%red, + filecolor=blue,%magenta, + urlcolor=blue,%cyan, + citecolor=blue, + pdfborder=0 0 0, +} +\usepackage{tikz} +\makeatletter +\input{pgfmanual.code} +\makeatother +%\usepackage{pgfmanual} +\usepackage{calc} % NEEDED by pgfmanual-en-macros +\input{pgfmanual-en-macros} + +\usepackage{tikz-dependency} +\usetikzlibrary{spy} +%\usepackage{palatino} + +\newcommand{\pipeescape}{\catcode`\|=12} + +\newcommand{\cmdname}[1]{\texttt{\color{red!75!black}\detokenize{#1}}} + +\def\pkgname{\tikzname{}\texttt{-dependency}} + +\newcommand{\options}[1][key-value-pairs]{\opt{\oarg{#1}}} + +\newcommand{\note}[2]{ + \begin{quote} + \textbf{#1}\par + #2 + \end{quote} +} + +\title{The \pkgname{} package} +\author{\normalsize Daniele Pighin\\\footnotesize{\href{mailto:daniele.pighin@gmail.com}{\texttt{daniele.pighin@gmail.com}}}\\\footnotesize{\url{http://danielepighin.net/cms}}} + +\makeatletter +\definecolor{graphicbackground}{rgb}{0.96,0.96,0.8} +\def\tikzcd@bgcolor{graphicbackground} +\makeatother + +\setlength{\parskip}{1ex} +\setlength{\parindent}{0pt} + +\newcommand{\displayarrow}[2][]{\texttt{#2} & yelds \tikz[baseline=-2.5pt] \draw[#2-#2, line width=0.44pt, #1] (0,0) -- (1,0);} +\newcommand{\displayarrowstyle}[2][]{\texttt{#2} & yelds \tikz[baseline=-2.5pt] \draw[/commutative diagrams/current arrows, #2, #1] (0,0) -- (0.4,0);} + +\begin{document} + +\maketitle + +If your work is in any way connected with linguistics or natural +language processing, chances are high that the moment will come when you will have +to draw a dependency graph: +\begin{center} +{\pipeescape% + \begin{dependency}[label style={font=\bfseries,fill=black,text=white}] + \tikzstyle{root}=[fill=yellow, text=black, font=\bfseries] + \tikzstyle{postag}=[font=\tiny] + \tikzset{arg/.style={rounded corners,inner sep=.4ex,top color=#1!60,draw=#1!60!black}} + \tikzset{rolelab/.style={inner sep=1ex,top color=#1!60,draw=#1!60!black,text=black}} + \begin{deptext}[column sep=.4cm, row sep=.5ex, row 1/.style = postag] + NN \& MD \& VB \& PRP\$ \& NN \& RBR \\ + \pkgname \& will \& make \& your \& life \& easier \\ + \end{deptext} + \deproot[label style=root]{3}{root} + \depedge{3}{1}{nsubj} + \depedge{3}{2}{aux} + \depedge{5}{4}{poss} + \depedge{3}{5}{dobj} + \depedge{3}{6}{advmod} + \wordgroup[arg=green]{2}{3}{3}{pred} + \wordgroup[arg=red]{2}{1}{1}{a0} + \wordgroup[arg=blue]{2}{4}{6}{a1} + \groupedge[edge below,red!60!black,label style={rolelab=red}]{pred}{a0}{ARG0}{5ex} + \groupedge[edge below,blue!60!black,label style={rolelab=blue}]{pred}{a1}{ARG1}{5ex} + \end{dependency}% +} +\end{center} + +\tikzname{} already has all the needed facilities to draw and style a dependency +graph, but diving into the documentation just to understand how to draw one or two +trees may turn out to be rather overwhelming. + +\pkgname{} is pretty flexible, and it can easily be used to draw quite complex graphs around sequences +of words, not necessarily related to dependency parsing, as shown by the following fancier examples. + + +\begin{center} +{\pipeescape% +\begin{dependency}[edge style={green!60!black,very thick}, + label style={fill=blue!60,font=\bfseries,text=white}] + \tikzstyle{POS}=[font=\footnotesize\bfseries,text=blue!60!black] + \tikzstyle{word}=[draw=blue!60!black, shade, text=black, + rotate=45, anchor=north east, inner sep=1ex, + font=\normalsize, top color=blue!60, rounded corners] + \begin{deptext}[column sep=.5cm, row sep=0, nodes={POS}] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + |[word]| My \& |[word]| dog \& |[word]| also \& + |[word]| likes \& |[word]| eating \& |[word]| sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge[edge style={blue!60!black,ultra thick}, + label style={fill=green!60,font=\bfseries,text=black, rotate=10}]{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} +\end{dependency}% +} + +{\pipeescape +\begin{dependency} + \tikzstyle{default}=[fill=white, draw=black, text = blue, solid] + \tikzstyle{pinky}=[fill=pink, draw=pink!60!black, text = black, solid] + \tikzstyle{wasp}=[fill=black, draw=orange, text = yellow, solid] + \tikzstyle{cooltext}=[draw=#1!60!black, thick, shade, top color=#1!60, bottom color=white, rounded corners = 2pt] + \depkeys{label style=default, edge below, font=\footnotesize} + \begin{deptext}[column sep = 5pt, nodes={cooltext=orange}] + You \&[.3cm] can \&[.8cm] |[cooltext=blue]| easily \& exaggerate \& if \& you \& feel \& like \&[1cm] doing \& so \\ + \end{deptext} + \depedge[hide label, dotted]{1}{2}{} + \depedge{1}{3}{link1} + \depedge[edge unit distance=1.25ex]{1}{10}{link2} + \depedge[edge above, label style={pinky}]{3}{2}{link3} + \depedge[edge above]{8}{6}{link4} + \depedge[edge unit distance=5ex, edge above, dotted]{8}{6}{or this?} + \depedge[label style={inner sep=1.5ex, scale=1.1}]{8}{9}{$\frac{e^{f(x)}}{g(x)}$} + \depedge[edge unit distance=4ex, label style={wasp}]{8}{10}{link6} + \depedge{5}{8}{link7} + \node (comment) [above of = \wordref{1}{1}] {Look at this one!}; + \draw [->,out=-90,in=135] (comment) to (\wordref{1}{2}); +\end{dependency} + } +\end{center} + +Hopefully, this package will make your life a little bit easier, and allow you to draw a +dependency graph without too much \tikzname{} prior knowledge. +It will also allow you to draw cute graphs, which won't increase your impact +factor but may help making your papers look more pleasant and elegant. + +\newpage + +\tableofcontents + +\section{Installation}\label{sec:installation} + +The simplest and fastest way to get things working is to copy the style file +|tikz-dependency.sty| in the root directory of your latex project. + +Alternatively, you can install it as you would install any other \LaTeX\ package, by copying it in some directory searched by \LaTeX{} and running |texhash|. +The |texmf| directory under your home directory is most likely one of such directories (even though there are chances that it does not exist). +If there is no |texmf| directory under your home, than create it: +\begin{codeexample}[code only] +$ cd ~ +$ mkdir -p texmf +\end{codeexample} + +Extract the \pkgname{} under this directory: +\begin{codeexample}[code only] +$ cd texmf +$ tar xvzf /path/to/tikz-dependency.tar.gz +\end{codeexample} + +Run |texhash| to let \LaTeX{} know about the newly installed package: +\begin{codeexample}[code only] +$ texhash texmf +\end{codeexample} +That should do it. Refer to \LaTeX\ documentation for more details or in case of non-standard \LaTeX{} installations. + +Please, not that PGF/\tikzname{} version 2.10 is required for \pkgname{} to work as expected. + +If \tikzname{} is not installed on your system, you can easily install it in the same way. +Visit \url{http://sourceforge.net/projects/pgf/} with your favorite browser, download the latest version of the package and uncompress in some of the directories searched by \LaTeX{}. The |texmf| directory under your home directory should be a good place to start: +\begin{codeexample}[code only] +$ cd ~ +$ unzip /path/to/pgf_version.zip -d texmf +\end{codeexample} +Run |texhash|: +\begin{codeexample}[code only] +$ texhash texmf +\end{codeexample} +Everything should be fine now. For more detailed instructions on how to install \tikzname{}, please refer to its manual at \url{http://ftp.gui.uva.es/sites/ctan.org/graphics/pgf/base/doc/generic/pgf/pgfmanual.pdf}. + +To use \pkgname{}, the first thing that you will need to do is to require it in your preamble: +\begin{codeexample}[code only] +\usepackage{tikz-dependency} +\end{codeexample} +\pkgname{} will automatically load \tikzname{} and its other requirements. + + +\section{A step-by-step introduction}\label{sec:stepbystep} + +In this section you will see how simple it is to draw a dependency graph. We will go throw all the required steps one by one, from the creation of a suitable environment, to the actual drawing of the graph, to the optional steps that can make your graph look nicer. + +We will start by trying to reproduce the following example: + +\begin{center} + \begin{dependency} + \begin{deptext}[column sep=0.2cm] + My \&[.5cm] dog \& also \&[.7cm] likes \&[.4cm] eating \& sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} + \end{dependency} +\end{center} + +But first let's agree on some terminology. I will call \textbf{words}\index{terminology!word} the tokens of the sentence, and \textbf{dependencies}\index{terminology!dependency} the relations between words. A dependency actually consists of two entities: the \textbf{edge}\index{terminology!edge} between the two words and its \textbf{label}\index{terminology!label}, which is the type of the relation. + +\subsection{An environment to draw dependency graphs} + +The first step will be to create a suitable environment to draw your dependency graphs. + +\begin{environment}{{dependency}\options} + All the commands and configuration keys that you will see in this document are available within a |dependency| environment. Since it is an overloaded version of |tikzpicture|, all the things that you would do within a |tikzpicture| environment (such as drawing paths, edges, nodes, whatever) you can also do within a |dependency|. At the moment, the only reason why you'd rather use a |dependency| environment is because you can pass it some optional configuration keys (i.e., \options) that can affect the style of the whole dependency graph. The documentation of these configuration keys is scattered around the documentation, though many of them are described in Section~\ref{sec:styling}. +\end{environment} + +So, to draw a new dependency tree you will generally start by writing something like this: + +\begin{codeexample}[] +\begin{dependency} + % The code to actually draw the + % dependency graph will go here +\end{dependency} +\end{codeexample} + +At this stage it looks pretty empty, so let's get started and fill it up with some contents. + +\subsection{Writing the sentence} + +\begin{environment}{{deptext}\options} + The |deptext| environment is used to lay out the words of the parsed sentence. + + Within |deptext|, you will write a sentence separating each word with \cmdname{\&}\index{\texttt{\textbackslash\&}}\index{word separator}, similarly to what you would do in a |tabular| environment. Please, not that in this + case the separator is actually a \LaTeX\ command (i.e., a backslash followed by an ampersand), and + not just a simple ampersand. To terminate the sentence, add the command \cmdname{\\}\index{\texttt{\textbackslash\textbackslash}}\index{line separator} (i.e., two consecutive backslashes) after the last word, just as you would do to end a row in a table. The \options\ can bee used to change the way the sentence looks, and more details about it are coming soon. +\end{environment} + +After adding the |deptext| environment with the text of our example sentence, the incomplete dependency graph would look like this: + +\begin{codeexample}[] +\begin{dependency} + \begin{deptext} + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} +\end{dependency} +\end{codeexample} + +For the \tikzname{}-savvy user, |deptext| is just a wrapper around \tikzname{}'s own matrix environment. The matrix is a matrix of nodes, with nodes in empty cells and some default styling. All the \options\ passed to the |deptext| are first parsed by \pkgname, then handed to the underlying |matrix|. If you know what you are doing and you want more control on the final result, you can have it. + +\subsection{Adding dependencies}\label{sec:adding-dependencies} + +\begin{command}{\depedge\options\marg{from-word}\marg{to-word}\marg{label}} + +This command is used to add dependencies between words. The \options\ argument is optional, and it can be used for styling the edge and its label (again, we will come to that part shortly). The three +mandatory arguments define the origin and destination of the dependency edge, and the label of the +dependency. The arguments \marg{from-word} and \marg{to-word} are the offsets of the words to be linked, counting from 1. \marg{label} is just any string, to be used as a label for the edge. +|\depedge| commands should be issued \emph{after} closing the |deptext| environment. +\end{command} + +To draw an edge between the words \emph{eating} and \emph{sausage} in the example, you would set \marg{from-word} to 5, \marg{to-word} to 6 and \marg{label} to \emph{dobj}. After adding this first edge, the example looks as follows: + +\begin{codeexample}[] +\begin{dependency} + \begin{deptext} + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \depedge{5}{6}{dobj} +\end{dependency} +\end{codeexample} + +By repeating this operation for all the dependencies in the sentence, we end up with a first complete version +of the dependency tree: + +\begin{codeexample}[] +\begin{dependency} + \begin{deptext} + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} +\end{dependency} +\end{codeexample} + +As you can see, \pkgname{} automatically does some basic routing of the edges of the graph, by drawing +dependency edges higher or lower depending on how far apart the two words are. The graph looks decent at +this stage, but it looks a little bit cramped and it could definitely use some more space between the words. + +\subsection{Getting word spacing right} + +You can either add some space between all words, or you can add some space between two specific words. Let's see how it is done. + +\subsubsection{Setting the space between every two words} + +When I first introduced the |deptext| environment, I said in passing that it can take some optional arguments. Since |deptext| is a wrapper around \tikzname{}'s own |matrix|, if you know some \tikzname{} you can pass to |deptext| any key-value pairs that |matrix| would understand. If you have absolutely no idea of how optional parameters (key-value configuration options) work in \tikzname{}, you are warmly invited to take a look at Appendix~\ref{sec:tikz}. If you do not understand what is going on, you will be able to copy the example but your ability to exploit the flexibility of the package will be largely impaired. + +As far as we are concerned here, what we want to discuss is the |/tikz/column sep| configuration key, which can be used to add more space between all the words in the sentence. + +In this documentation, I will always use the fully qualified name of a key when documenting it (see, for example, the description of |/tikz/column sep| immediately below. Anyway, you are not required to use the fully qualified name of keys when using them, and using their base name (e.g., |column sep|) is sufficient. In fact, in the examples I will generally use the shorter form. + +\begin{key}{/tikz/column sep=\meta{length} (default 0cm)} +If you want to add, say, 0.2cm between every two words, you can do it so by passing |column sep=0.2cm| as the optional argument of the |deptext| environment. + +\begin{codeexample}[] +\begin{dependency} + \begin{deptext}[column sep=0.2cm] + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} +\end{dependency} +\end{codeexample} + +It looks better already, but the fact that some dependency labels are longer than the horizontal segment of the edge doesn't look to nice. So, we could increase the space between all the words, for example to 0.7cm: + +\begin{codeexample}[] +\begin{dependency} + \begin{deptext}[column sep=0.7cm] + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} +\end{dependency} +\end{codeexample} + +\end{key} + +Now the labels are fine, but the words are a little bit too far apart, at least for my taste. So I would rather go back to |/tikz/column sep=0.2|, and find a more precise way of spacing only the problematic word pairs. In this case, they are adjacent words connected by a dependency with a long label, i.e., \emph{My/dog}, \emph{also/likes} and \emph{likes/eating}. + +\subsubsection{Spacing word individually} + +Additional space between two words can be added by using the optional argument of the \cmdname{\&} command that we used to separate words. For example, writing \cmdname{\&}|[0.5cm]| will add 0.5cm to the default word spacing set with via the |column sep| option. If we take care of the three problematic pairs individually, we can obtain something like this: + +\begin{codeexample}[] +\begin{dependency} + \begin{deptext}[column sep=0.2cm] + My \&[.5cm] dog \& also \&[.7cm] likes \&[.4cm] eating \& sausage \\ + \end{deptext} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} +\end{dependency} +\end{codeexample} + +\subsection{Adding a root node} + +If you want to add a \index{root node} to the dependency graph, you can do so by means of the |\deproot| command. + +\begin{command}{\deproot\options\marg{root-offset}\marg{label}} + It is basically a variant of |\depedge|. Instead of connecting two words, it will create a node labeled \meta{label} just above the word having offset \meta{root-offset}, and an arrow between them. In our example, the root word is the verb \emph{likes}, which occupies the fourth position: +\end{command} + +\begin{codeexample}[] +\begin{dependency} + \begin{deptext}[column sep=0.2cm] + My \&[.5cm] dog \& also \&[.7cm] likes \&[.4cm] eating \& sausage \\ + \end{deptext} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} + \deproot{4}{root} +\end{dependency} +\end{codeexample} + +This completes the crash course on the basics of dependency graph drawing. The next sections will tell you how to control edge positioning, how to build more complicated graphs with several layers of text, how to style the graphs to your liking and how to include your graphs in larger pictures. + +\section{Multiple layers of text} + +When drawing a dependency graph it is common to have a layer of part-of-speech (POS) tags just above the words. Achieving this with \pkgname{} is pretty straightforward. Since the |deptext| environment is already a matrix, all you have to do is to add another row of text to the matrix: + +\begin{codeexample}[] +\begin{dependency} + \begin{deptext}[column sep=.5cm] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} +\end{dependency} +\end{codeexample} + +In this case, we have added the POS tags on top of the words. Of course, we could have also added them below: + +\begin{codeexample}[] +\begin{dependency} + \begin{deptext}[column sep=.7cm] + My \& dog \& also \& likes \& eating \& sausage \\ + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} +\end{dependency} +\end{codeexample} + +\begin{key}{/tikz/row sep=\meta{length} (default 0cm)} + Similarly to how you can increase the space between columns in a matrix, you can also increase inter-row spacing. For example, to add 0.5ex between every two rows you can add |row sep=0.5ex| to the optional argument of the |deptext| environment: +\begin{codeexample}[] +\begin{dependency} + \begin{deptext}[column sep=.7cm, row sep=.5ex] + My \& dog \& also \& likes \& eating\\ + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG\\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \qquad +\end{dependency} +\quad +\begin{dependency} + \begin{deptext}[column sep=.7cm, row sep=2ex] + My \& dog \& also \& likes \& eating\\ + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG\\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} +\end{dependency} +\end{codeexample} +\end{key} + +\section{More control over edges} + +In Section~\ref{sec:adding-dependencies} I hinted to the fact that the height of the horizontal segment of a dependency edge is proportional to the distance between the linked words. As you may have already guessed, this can be a problem for \index{long dependencies}. Consider the following example, in which I added some more words and a long dependency: + +\begin{codeexample}[] +\begin{dependency} + \begin{deptext}[column sep=0.2cm] + My \&[.5cm] dog \& also \&[.7cm] likes \&[.4cm] eating \& sausage \& and \& more \& words \\ + \end{deptext} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} + \deproot{4}{root} + \depedge{9}{1}{rather-long} +\end{dependency} +\end{codeexample} + +To decide how high a dependency should be drawn, \pkgname{} uses the formula $s\vert x-y \vert$, where $x$ and $y$ are the offsets of the two words, and $s$ is the value of the optional parameter |/depgraph/edge unit distance|. + +\begin{key}{/depgraph/edge unit distance=\meta{length} (default 3ex)} + + This key represents the distance of the horizontal segment of the edge between two adjacent words. That is, if two words are 5 positions apart, the distance of the edge will be 5 times the value of |/depgraph/edge unit distance|. Whenever you draw a edge with |\depedge| you can override this value as part of the optional argument of the command. For example, by changing its value in the previous and setting it to |1.5ex| it is possible to halve the total height of the problematic edge: + +\begin{codeexample}[] +\begin{dependency} + \begin{deptext}[column sep=0.2cm] + My \&[.5cm] dog \& also \&[.7cm] likes \&[.4cm] eating \& sausage \& and \& more \& words \\ + \end{deptext} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} + \deproot{4}{root} + \depedge[edge unit distance=1.5ex]{9}{1}{rather-long} +\end{dependency} +\end{codeexample} + +|/depgraph/edge unit distance| can also be used to tune the distance of the root node\index{root node!distance} from the sentence. By default, the root node is set at a distance equal to 4 times the value of the parameter. By changing its value you can bring it closer of further: + +\begin{codeexample}[] +\begin{dependency} + \begin{deptext}[column sep=0.2cm] + My \&[.5cm] dog \& also \&[.7cm] likes \&[.4cm] \dots \\ + \end{deptext} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \deproot[edge unit distance=4ex]{4}{root} +\end{dependency} +\quad +\begin{dependency} + \begin{deptext}[column sep=0.2cm] + My \&[.5cm] dog \& also \&[.7cm] likes \&[.4cm] \dots \\ + \end{deptext} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \deproot[edge unit distance=2ex]{4}{root} +\end{dependency} +\end{codeexample} + +\end{key} + +At this point, you may be wondering: why are we always drawing dependencies above the text? Indeed, turning links around is not only possible, but also quite easy, and the next key-value pairs allow you to control this behaviour. + +\begin{keylist}{/depgraph/edge above=\meta{boolean} (default true),/depgraph/edge below=\meta{boolean} (default false)} + These two keys control the position of the links, which can be drawn either above or below the layer(s) of text. You can pass any of them as part of the optional arguments of the |dependency| environment, and change the position of all the links in the graph at once. Writing the name of the key is sufficient, so writing |edge below=true| or just |edge below| produces the same result: +\begin{codeexample}[] +\begin{dependency}[edge below] + \begin{deptext}[column sep=.7cm] + My \& dog \& also \& likes \& eating \& sausage \\ + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} +\end{dependency} +\end{codeexample} +|/depgraph/edge below| and |/depgraph/edge above| can also be used to control the positioning of individual edges. In this case, you won't pass the keys to the |dependency| environment, but instead to a specific |\depedge| or |\deproot| whose behaviour you want to modify. +Say that you wanted all the edges to be drawn below, but the \emph{root} and \emph{poss} edges should be on top. You can pass |/depgraph/edge below| to |dependency|, and |/depgraph/edge above| to the two |\depedge|s to be placed above: +\begin{codeexample}[] +\begin{dependency}[edge below] + \begin{deptext}[column sep=.7cm] + My \& dog \& also \& likes \& eating \& sausage \\ + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + \end{deptext} + \deproot[edge above]{4}{root} + \depedge[edge above]{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} +\end{dependency} +\end{codeexample} +\end{keylist} + +Other than |/depgraph/edge unit distance|, three more parameters can affect the way edges are drawn. As shown in Figure\ref{fig:edgedrawingparameters}, they control several aspects related to the spacing among edges and between edges and text, plus the inclination of the non-horizontal segments of the edge. All these properties can be set both at the |dependency| level (which will affect all the edges in the graph) or at the |\depedge| level, which will only affect individual links. + +\begin{figure} +\begin{center} +\def\zw{10cm} +\def\zh{5cm} +\def\zx{3cm} +\def\zy{-3.5cm} +\begin{dependency}[spy using overlays={magnification=5, width=\zw, height=\zh}] + \tikzset{postag/.style = {font=\tiny}} + \begin{deptext}[column sep=.5cm, row sep=.1em, row 1/.style = postag] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} + \spy [draw=green, pink!80!black, connect spies] + on ($(\wordref{1}{4}.north) + (0,1ex)$) + in node [draw] at (\zx,\zy); + \node (bl) at ($(\zx,\zy) - .5*(\zw,\zh)$) {}; + \node (tr) at ($(\zx,\zy) + .5*(\zw,\zh)$) {}; + \draw[step=.2cm, help lines, pink] (bl) grid (tr); + \draw[step=1cm, pink] (bl) grid (tr); + \draw [blue, thick, |-|] ($(bl)+(4.26,1.5)$) + -- node [below left,font=\bfseries\ttfamily\small] {edge horizontal padding} ++(.75,0); + \draw [blue, thick, |-|] ($(bl)+(5.7,4.1)$) + -- node [above,font=\bfseries\ttfamily\small] {edge slant} ++(.6,0); + \draw [blue, thick, dotted] ($(bl)+(5.7,1.8)$) -- ++(0,2.3); + \draw [blue, thick, |-|] ($(bl)+(6.1,1.7)$) + -- node [right,font=\bfseries\ttfamily\small] {edge vertical padding} ++(0,-.7); +\end{dependency} +\end{center} +\caption{Edge-drawing parameters.}\label{fig:edgedrawingparameters} +\end{figure} + +\begin{key}{/depgraph/edge slant=\meta{length} (default 3pt)} + |/depgraph/edge slant| controls the slant of the diagonal segments in a dependency edge. As shown in Figure~\ref{fig:edgedrawingparameters}, what it actually controls is the horizontal offset between the initial (final) of the edge and its first (second) corner. By default it is set to |3pt|, which makes the segments just slightly sloped. By setting it to |0|, you can make the lateral segments completely vertical; by increasing its value you can make the edges look less slender. +\begin{codeexample}[] +\begin{dependency}[edge slant=0] %edge slant=0 + \begin{deptext}[column sep=.7cm] + My \& dog \& also \& likes \& eating \\ + PRP\$ \& NN \& RB \& VBZ \& VBG \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} +\end{dependency} +\quad +\begin{dependency}[edge slant=10pt] %edge slant=10pt + \begin{deptext}[column sep=.3cm] + My \&[.4cm] dog \& also \&[.7cm] likes \&[.5cm] eating \\ + PRP\$ \& NN \& RB \& VBZ \& VBG \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} +\end{dependency} +\end{codeexample} +\end{key} + + +\begin{key}{/depgraph/edge horizontal padding=\meta{length} (default 4pt)} + \pkgname{} employs a very simple strategy to avoid edges outgoing from and incoming into a word to start/terminate on the same spot, thus making it easier to understand the direction of a dependency. The algorithm is very simple: all incoming links arrive in the middle of a word; all outgoing links heading left leave the node from a point which is a little bit to the left; all those heading right leave from a spot a little bit to the right. |/depgraph/edge horizontal padding| is the value of this ``little bit''. By setting it to |0|, all the edges will come and go from the same spot in the middle of the word. By increasing its value, the incoming and outgoing edges on a word will look more apart. +\begin{codeexample}[] +\begin{dependency}[edge horizontal padding=0] %edge horizontal padding=0 + \begin{deptext}[column sep=.7cm] + My \& dog \& also \& likes \& eating \\ + PRP\$ \& NN \& RB \& VBZ \& VBG \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} +\end{dependency} +\quad +\begin{dependency}[edge horizontal padding=10pt] %edge horizontal padding=10pt + \begin{deptext}[column sep=.7cm] + My \& dog \& also \&[.2cm] likes \& eating \\ + PRP\$ \& NN \& RB \& VBZ \& VBG \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} +\end{dependency} +\end{codeexample} +\end{key} + +\begin{key}{/depgraph/edge vertical padding=\meta{length} (default 0ex)} + |/depgraph/edge vertical padding| is the extra distance between a word and incoming/outgoing edges. By increasing (decreasing) its value, you can send the edges further (bring them closer) to the text. +\begin{codeexample}[] +\begin{dependency}[edge vertical padding=-.5ex] %edge vertical padding=-.5ex + \begin{deptext}[column sep=.7cm] + My \& dog \& also \& likes \& eating \\ + PRP\$ \& NN \& RB \& VBZ \& VBG \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} +\end{dependency} +\quad +\begin{dependency}[edge vertical padding=1ex] %edge horizontal padding=1ex + \begin{deptext}[column sep=.7cm] + My \& dog \& also \&[.2cm] likes \& eating \\ + PRP\$ \& NN \& RB \& VBZ \& VBG \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} +\end{dependency} +\end{codeexample} +\end{key} + +It may be worth repeating that even though you will generally want to set this properties at the |dependency| level, you can very well set them individually for each edge. And of course, you can combine them with all the properties that we saw before (e.g., |/depgraph/edge below|): +\begin{codeexample}[] +\begin{dependency}[edge vertical padding=.5ex] + \begin{deptext}[column sep=.7cm] + My \& dog \& also \&[.3cm] likes \& eating \\ + PRP\$ \& NN \& RB \& VBZ \& VBG \\ + \end{deptext} + \deproot{4}{root} + \depedge[edge vertical padding=0]{2}{1}{poss} + \depedge[edge below, edge vertical padding=.3cm]{4}{2}{nsubj} + \depedge[edge horizontal padding=10pt]{4}{3}{advmod} + \depedge[edge slant=0]{4}{5}{xcomp} +\end{dependency} +\end{codeexample} + +\section{Node groups and group linking} + +Another thing that you may want to do is to annotate relations between groups of nodes. I added this functionality thinking about semantic parsing, so that it would be possible to annotate on the same graph the syntactic and semantic layers of a sentence. You can think of many other ways of exploiting the functionality and use it for your own specific needs. Two new commands can be used to define word groups and to connect them. + +\begin{command}{\wordgroup\options\marg{row-offset}\marg{word-offset-beg}\marg{word-offset-end}\marg{gid}} + + This command creates a group spanning the words in the \marg{row-offset}-th row of the matrix from position \marg{word-offset-beg} to position \marg{word-offset-end}. \marg{gid} is a unique identifier for the group, that will be used to connect groups. From \tikzname{}' point of view, it is just the name of the node enclosing the group, so you can directly use it as you would use any other node. + +\begin{codeexample}[] +\begin{dependency} + \begin{deptext}[column sep=.5cm, row sep=.1ex] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} + % group on 2nd row, from word 4 to word 4, labeled "pred" + \wordgroup{2}{4}{4}{pred} + % group on 2nd row, from word 1 to word 2, labeled "a0" + \wordgroup{2}{1}{2}{a0} + % group on 2nd row, from word 5 to word 6, labeled "a1" + \wordgroup{2}{5}{6}{a1} +\end{dependency} +\end{codeexample} +\end{command} + +\begin{command}{\groupedge\options\marg{from-gid}\marg{to-gid}\marg{label}\marg{height}} + + This command draws an edge with label \marg{label} from the group identified with \marg{from-gid} to the group identified \marg{to-grid}. The horizontal segment of the edge will be \marg{height} distant from the words. Just as |\depedge|, also |\groupedge| honors the global edge positioning set via |dependency|. Also in this case, you can use the keys |/depgraph/edge below| and |/depgraph/edge above| to override the directive locally. More generally, all the key-value pairs that can be passed to |\depedge| (e.g., |edge slant|) can also be used with |\groupedge|. The two macros actually do the same thing, with the difference that |\depedge| automatically calculates a default height for the edge based on the word-distance between its endpoints. +\begin{codeexample}[] + \begin{dependency} + \begin{deptext}[column sep=.5cm, row sep=.1ex] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} + \wordgroup{2}{4}{4}{pred} + \wordgroup{2}{1}{2}{a0} + \wordgroup{2}{5}{6}{a1} + \groupedge[edge below]{pred}{a0}{ARG0}{4ex} % pred -> a0 (ARG0, 4ex) + \groupedge[edge below]{pred}{a1}{ARG1}{6ex} % pred -> a1 (ARG1, 6ex) +\end{dependency} +\end{codeexample} +\end{command} + +\section{Styling text, edges and labels}\label{sec:styling} + +This section covers the ways in which you can customize the look of the building blocks of the dependency graph: words, groups, edges and edge labels. Styling requires some basic knowledge of \tikzname{} styling facilities. For those who really don't want to read to read the glorious manual of \tikzname{}\footnote{\url{http://ftp.gui.uva.es/sites/ctan.org/graphics/pgf/base/doc/generic/pgf/pgfmanual.pdf}} (you really should, for your own sake), in Appendix~\ref{sec:tikz} I do my best to try to summarize a minimum of information that should be enough to get you started. + +\subsection{Using themes} + +\index{themes}\index{theming}The simplest way to change the look and feel of your dependency graphs is to use a pre-defined \emph{theme}. + +\begin{key}{/depgraph/theme=\meta{theme name} (default \{\})} + By passing this option to |dependency|, you can completely change the appearence of the graphs. At the moment of writing, the following five themes have been defined: |night|, |brazil|, |grassy|, |iron|, |copper|. They look like this: +\begin{codeexample}[] +\begin{dependency} + \begin{deptext}[column sep=.5cm, row sep=.1ex] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} +\end{dependency} +\end{codeexample} + +\begin{codeexample}[] +\begin{dependency}[theme=night] + \begin{deptext}[column sep=.5cm, row sep=.1ex] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} +\end{dependency} +\end{codeexample} + +\begin{codeexample}[] +\begin{dependency}[theme=brazil] + \begin{deptext}[column sep=.5cm, row sep=.1ex] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} +\end{dependency} +\end{codeexample} + +\begin{codeexample}[] +\begin{dependency}[theme=grassy] + \begin{deptext}[column sep=.5cm, row sep=.1ex] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} +\end{dependency} +\end{codeexample} + +\begin{codeexample}[] +\begin{dependency}[theme=iron] + \begin{deptext}[column sep=.5cm, row sep=.1ex] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} +\end{dependency} +\end{codeexample} + +\begin{codeexample}[] +\begin{dependency}[theme=copper] + \begin{deptext}[column sep=.5cm, row sep=.1ex] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} +\end{dependency} +\end{codeexample} +\end{key} + +\begin{keylist}[/depgraph]{edge theme,label theme,text theme} + Each of the aforementioned themes is actually a combination of three themes with the same name: one for edges, one for edge labels and one for the sentence text. These three themes can also be applied independently. So, for example, you could apply the |iron| theme globally and then use |copper| to draw the labels: +\begin{codeexample}[] +\begin{dependency}[theme=iron, label theme=copper] + \begin{deptext}[column sep=.5cm, row sep=.1ex] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} +\end{dependency} +\end{codeexample} +\end{keylist} + +Edges and labels can be styled locally, by passing the desired |theme|, |label theme| or |edge theme| to specific edges. In the following example, I will use |iron| as the base |theme|, globally overriding the |label theme| with |copper| and using |grassy| as the |theme| and |label theme| two special edges: +\begin{codeexample}[] +\begin{dependency}[theme=iron, label theme=copper] + \begin{deptext}[column sep=.5cm, row sep=.1ex] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge[theme=grassy]{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge[label theme=grassy]{4}{5}{xcomp} + \depedge{5}{6}{dobj} +\end{dependency} +\end{codeexample} + +\subsection{Styling elements individually} + +\begin{keylist}{/depgraph/hide label,/depgraph/show label} + By default, all labels are visible. Add |hide label| to the \options{} of |\depedge| or |\groupedge| to prevent the bounding box and the text of the label to be drawn. +\begin{codeexample}[] +\begin{dependency} + \begin{deptext}[column sep=.5cm, row sep=.1ex] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge[hide label]{5}{6}{dobj} +\end{dependency} +\end{codeexample} +If added to the options of |dependency|, all the labels will be suppressed. Local overriding is still possible by adding the |/depgraph/show label| key: +\begin{codeexample}[] +\begin{dependency}[hide label] + \begin{deptext}[column sep=.5cm, row sep=.1ex] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge[show label]{5}{6}{dobj} +\end{dependency} +\end{codeexample} +Please, note that the labels are still there, only they are transparent. +\end{keylist} + + +\begin{stylekey}{/depgraph/edge style=\meta{style} (default \{\})} + This style is applied to all the edges drawn by \pkgname{}. By setting its value you can alter the appearance of the dependency edges. The default style applied to every edge is: +\begin{codeexample}[code only] +\pgfkeys{% + /depgraph/reserved/edge style/.style = {% + ->, >=stealth, %arrow properties + black, solid, line cap=round, %line properties + rounded corners=2, %make corners round + },% +} +\end{codeexample} +By setting |edge style| at the |dependency| level, all the edges in the graph are affected: +\begin{codeexample}[] +\begin{dependency}[edge style={red,densely dotted}] + \begin{deptext}[column sep=.5cm, row sep=.1ex] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} +\end{dependency} +\end{codeexample} +As always, local settings at the edge level take precedence over global settings: +\begin{codeexample}[] +\begin{dependency}[edge style={green!60!black,very thick}] + \begin{deptext}[column sep=.5cm, row sep=.1ex] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge[edge style={blue!60!black,ultra thick}]{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} +\end{dependency} +\end{codeexample} +\end{stylekey} + +\begin{stylekey}{/depgraph/label style=\meta{style} (default \{\})} + The default style applied to every label is the following: +\begin{codeexample}[code only] +\pgfkeys{% + /depgraph/reserved/label style/.style = {% + draw, solid, black, %the outline of the label + scale=.7, %scale down the text, to make it smaller than the sentence text + text=black, %color of the text + text height=1.5ex, %needed to center text vertically + text depth=0.25ex, %needed to center text vertically + inner sep=.5ex, %padding between the text and the border of the node + fill=white, %background color + outer sep=0pt, + rounded corners=2pt, + anchor=mid, + },% +} +\end{codeexample} +The look of labels can be changed by defining the |label style| style, either locally to each edge or globally: +\begin{codeexample}[] +\begin{dependency}[edge style={green!60!black,very thick}, + label style={fill=yellow!60,font=\bfseries,thick}] + \begin{deptext}[column sep=.5cm, row sep=.1ex] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge[edge style={blue!60!black,ultra thick}, + label style={fill=green!60,font=\bfseries,text=black}]{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} +\end{dependency} +\end{codeexample} +\end{stylekey} + +\begin{stylekey}{/depgraph/group style=\meta{style} (default \{\})} + By default, when you create a group you will only see a box with rounded corners around the selected words: +\begin{codeexample}[] + \begin{dependency} + \begin{deptext}[column sep=.5cm, row sep=.1ex] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} + \wordgroup{2}{1}{2}{a0} + \wordgroup{2}{5}{6}{a1} +\end{dependency} +\end{codeexample} +The |group style| property allows you to redefine this style according to your taste and needs: +\begin{codeexample}[] + \begin{dependency} + \begin{deptext}[column sep=.5cm, row sep=.5ex] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} + \wordgroup[group style={fill=orange!40, draw=brown, inner sep=.6ex}]{2}{1}{2}{a0} +\end{dependency} +\end{codeexample} +Please, keep in mind that a group is just a box drawn \emph{underneath} the word nodes. They have no text themselves, as the text that they surround is actually the text of some word node. Therefore, you cannot use |group style| to change in any way the rendering of the words they group. +\end{stylekey} + +\begin{stylekey}{/tikz/nodes=\meta{style} (default \{\})} + This is an \tikzname{} style key used to render the nodes within a given scope. By using it within a |deptext|, you can assign a style to all the nodes in the matrix, i.e. the words in the sentence: +\begin{codeexample}[] +\begin{dependency}[edge style={green!60!black,very thick}, + label style={fill=blue!60,font=\bfseries,text=white}] + \begin{deptext}[column sep=.5cm, row sep=.1ex, + nodes={draw=red!80!black, shade, top color=red!60, rounded corners}] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge[edge style={blue!60!black,ultra thick}, + label style={fill=green!60,font=\bfseries,text=black}]{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} +\end{dependency} +\end{codeexample} +The style can be overridden on a per-node basis, by using a special syntax understood by matrix that allows to set style properties of each node individually. To to so, you need to add \cmdname{|[}|<style>|\cmdname{]|} before every word that you want to restyle, where \meta{style} is a style definition. The following example shows how you would apply a different style to all the nodes in the second row: +{\pipeescape +\begin{codeexample}[] +\begin{dependency}[edge style={green!60!black,very thick}, + label style={fill=blue!60,font=\bfseries,text=white}] + \tikzstyle{POS}=[font=\footnotesize\bfseries,text=blue!60!black] + \tikzstyle{word}=[draw=blue!60!black, shade, text=black, + rotate=45, anchor=north east, inner sep=1ex, + font=\normalsize, top color=blue!60, rounded corners] + \begin{deptext}[column sep=.5cm, row sep=0, nodes={POS}] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + |[word]| My \& |[word]| dog \& |[word]| also \& + |[word]| likes \& |[word]| eating \& |[word]| sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge[edge style={blue!60!black,ultra thick}, + label style={fill=green!60,font=\bfseries,text=black, rotate=10}]{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} +\end{dependency} +\end{codeexample} +} +When using this syntax, you should always consider that the |nodes| style is in any case applied to \emph{every node} in the |matrix|, then the style specified for each node (if any) is appended. This fact has the subtle implication that all the nodes inherit all the properties set via |nodes|, and per-node styles must explicitly overwrite all the properties that they don't need to use. As a rule of thumb, you should use |nodes| to set properties that all the nodes will share, and then use per-node options to add or override options. +\end{stylekey} + +\section{Interaction with \tikzname{}} + +Some function make it possible to reference the nodes in the graph so that it is easier to extend the graph with \tikzname{} drawing capabilities. Understanding what is going on here requires at least some basic knowledge of how to draw nodes and paths in \tikzname{}. + +\begin{command}{\matrixref} + Returns a reference to the |\matrix| used to lay out the sentence. You can use it to position other elements in the picture relative to it. +\begin{codeexample}[] +\begin{dependency} + \begin{deptext}[column sep=.5cm, row sep=.1ex] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} + \foreach \a/\pos in {south/below of,north/above of,east/right of,west/left of} { + \node (tmp) at (\matrixref.\a) [draw, circle, fill=red, inner sep=1pt] {}; + \node (tmp2) [\pos = tmp] {\a} -- (tmp); + \draw [->] (tmp2) -- (tmp); + }; +\end{dependency} +\end{codeexample} + +\end{command} + +\begin{command}{\wordref\marg{row-offset}\marg{word-offset}} + + Returns the reference to the matrix node in row \marg{row-offset} and column \marg{word-offset}. + +\begin{codeexample}[] +\begin{dependency} + \begin{deptext}[column sep=.5cm, row sep=.1ex] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} + \node (silly1) [above right of = \wordref{1}{6}, xshift = 2cm] {Top right}; + \node (silly2) [below left of = \wordref{2}{1}, xshift = -2cm] {Bottom left}; + \draw [->, very thick, red] (silly1) -- (\wordref{1}{6}); + \draw [->, very thick, red] (silly2) -- (\wordref{2}{1}); +\end{dependency} +\end{codeexample} +\end{command} + +\begin{command}{\rootref} + Returns a reference to the node holding the root label. +\begin{codeexample}[] +\begin{dependency} + \begin{deptext}[column sep=.5cm, row sep=.1ex] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} + \node (silly) [above right of = \rootref, xshift = 3cm] {This is the root node!}; + \draw [->, very thick, red] (silly) -- (\rootref); + \draw [thick, blue] (\rootref)--(\wordref{1}{2})--(\wordref{2}{6})--(\rootref); +\end{dependency} +\end{codeexample} + +\end{command} + +\begin{commandlist}{\storelabelnode\marg{macro},\storefirstcorner\marg{macro},\storesecondcorner\marg{macro}} + After adding a new edge with |\depedge| or |\groupedge|, three commands allow you to store the name of the nodes used to draw the label end the corners of the dependency edge. |\storelabelnode| can be used to store the name of the label in the macro \meta{macro}. You can then use \meta{macro} just as you would use any node, to draw something involving the label node. |\storefirstcorner| and |\storesecondcorner| work exactly in the same way, but they hold they point to the nodes holding the coordinates of the edge corners. + +\begin{codeexample}[] +\begin{dependency} + \begin{deptext}[column sep=.5cm, row sep=.1ex] + PRP\$ \& NN \& RB \&[.5cm] VBZ \& VBG \& NN \\ + My \& dog \& also \& likes \& eating \& sausage \\ + \end{deptext} + \deproot{4}{root} + \depedge{2}{1}{poss} + \storelabelnode\firstlab + \storefirstcorner\firstcorner + \depedge{4}{2}{nsubj} + \depedge{4}{3}{advmod} + \depedge{4}{5}{xcomp} + \depedge{5}{6}{dobj} + \storelabelnode\secondlab + \storesecondcorner\secondcorner + \draw [<->,out=90,in=-90, thick, red] (\firstlab) to + node [fill=red, text=white, font=\bfseries, above, near start, sloped] + {labels!} (\secondlab); + \draw [<->, out=-90,in=90, thick, blue!60] (\firstcorner) to + node [fill=blue!60, text=white, font=\bfseries, above, near end, sloped] + {edge corners!} (\secondcorner); +\end{dependency} +\end{codeexample} +\end{commandlist} + +\appendix + +\section{\tikzname{} crash course} \label{sec:tikz} + +\textbf{Disclaimer.} \textit{I am making a lot of rough simplifications here to make it possible to explain everything in as little space as possible. Really invite to read the full version of the manual, if you haven't already. It is the only way to really appreciate the elegance and beauty of this \tikzname{} and its incredible potential.} + +\vspace{1cm} + +PGF/\tikzname{} is a set of lower/higher level macros that allow you to draw extremely refined and sophisticated graphics directly in \LaTeX{}. If you don't know anything about it, then you are really missing on something, and you should run and check the manual\footnote{\url{http://ftp.gui.uva.es/sites/ctan.org/graphics/pgf/base/doc/generic/pgf/pgfmanual.pdf}}. I am repeating myself, but you really should. + +\subsection{\texttt{\textbackslash pgfkeys} and \texttt{\textbackslash tikzset}} + +\index{key!key-value pairs} +\tikzname{} is basically built on top of |pgfkeys|, which is a very flexible and sophisticated system to store key-value pairs. \tikzname{} (and derived packages), such as \pkgname{}, use this system for setting local or global variables, and to pass optional arguments to commands (macros) that can take a large number of configuration option. + +The definition of virtually all \tikzname{} macros follows the template: + +\cmdname\somecommand\options\marg{first}\dots\marg{last} + +The first argument, optional, is a set of key-value pairs that can be used to set a bunch of options. It is thus possible to reduce to a minimum the number of mandatory arguments \marg{first}\dots\marg{last}, and keep macro's interface lighter and simpler to use. All commands, first parse the key-value pairs, then do what they have to do based on the updated state of the variables. + +Key names and values can contain spaces, values can be assigned via the |=| sign and commas can be used to separate assignments. Braces can be used for grouping values. So, for example, the assignment |variable one = \{a, b\}, vartwo = c| would result in |a, b| being assigned to |variable one| and |c| to |vartwo|. + +The function which is responsible for parsing key-value pairs is |\pgfkeys|: + +\begin{command}{\pgfkeys\marg{keys}} + The |\pgfkeys| command parses a string containing a sequence of keys and stores their value, e.g.: +\begin{codeexample}[code only] + \pgfkeys{a=1, b=2, c={d=3,e=4}} +\end{codeexample} +In this case, the value of the key |a| is set to |a| and |b| to 2. |c| contains two keys, |d| and |e|, whose values are |3| and |4|, respectively. How this values can be accessed is of no interest for the scope of this document. We only want to be able to set those keys. Please, note that you can only set the values for keys that already exist. How a key can be created is also of no interest for us, as we only want to be able to change the values of existing keys. +\end{command} + +Keys can be arranged hierarchically, as in a directory structure. This property allows every sub-package to define its own protected space of keys, making it less likely to cause interaction problems. All \tikzname{} keys are stored under the root key |/tikz/|. So, for example, |/tikz/fill=blue| assigns the value |blue| to the |fill| key within the namespace |/tikz/|. \pkgname{} defines its own namespace, which is |/depgraph/|, and defines its own subset of keys that interact with \tikzname{}' own. + +As a convenience function, \tikzname{} also defines the following macro: + +\begin{command}{\tikzset\marg{keys}} + |\tikzset| is just a wrapper around |\pgfkeys|, that prefixes all keys with |/tikz/|. The two following instructions are (for us) equivalent: +\begin{codeexample}[code only] + \pgfkeys{/tikz/text=red, /tikz/fill=white} + \tikzset{text=red, fill=white} +\end{codeexample} +\end{command} + +Some keys only have a name\index{key!without a value} and no value. Without going into details, it won't hurt to know that such keys are either \emph{binary}\index{key!binary} flags or one of a set of alternative options (\emph{choice} keys)\index{key!choice}, so that activating one automatically deactivates the other alternatives in the set. + +Conveniently, |\pgfkeys| also define an inheritance mechanism that allows sub-packages to consume the keys that they can understand, and then pass on to \tikzname{} all the keys that haven't been handled. This fact also makes it possible for a user to specify a key without using its fully qualified name. When introducing a key for the first time, I will always use its fully qualified name, just to make it clear where it belongs. In the examples, though, I will generally prefer to use a more compact notation and only use the ``base name'' of the keys. + +\subsection{Basic styling notions} + +A style is a set of key-value pairs (we have seen many already in the previous pages) that define the properties of some graphical object. As an example, |{draw=red, thick}| is a style (we will soon come to the meaning of these properties). + +The simplest way to define a new style is with the |\tikzstyle| command: + +\begin{command}{\tikzstyle\marg{name}=\options} + \index{style!define new} + Here, \marg{name} is just an identifier for your style (such as |my style|, or |very cool|, whatever). \options{} is a sequence of comma separated key-value pairs, e.g.: +\begin{codeexample}[code only] + \tikzstyle{my cool style} = [draw=black, fill=red] +\end{codeexample} +\index{style!update definition} +Once a style is defined, you can ``add'' things to the style in at least two ways: +\begin{itemize} + \item By using the same syntax as before, but adding a |+| between \marg{name} and the |=| sign, e.g.,: +\begin{codeexample}[code only] + % before: my cool style = {draw=black, fill=red} + \tikzstyle{my cool style} += [thick] + % after: my cool style = {draw=black, fill=red, thick} +\end{codeexample} + \item By setting (via |\tikzset|) the special sub-property |.append style| of an already existent style, e.g.: +\begin{codeexample}[code only] + % before: my cool style = {draw=black, fill=red, thick} + \tikzset{my cool style/.append style = {dotted}} + % after: my cool style = {draw=black, fill=red, thick, dotted} +\end{codeexample} +\end{itemize} +\end{command} + +A dependency graph is built using two \tikzname{} primitives: \emph{nodes}\index{node} and \emph{paths}\index{path}. Dependency edges are paths. Edge labels and words in the sentence are nodes containing text. Word groups are also nodes, which are drawn on the layer \emph{underneath} the word nodes. They have no text themselves, as the text that they surround is actually the text of some word node. + +Nodes have an \emph{outline}\index{outline} (i.e., a contour) and an \emph{area}\index{area} (the space inside the contour), and (generally) contain some text. All these properties can be styled independently, and the styling can be done either globally (in a way that affects all the graphics within a given scope) or locally (i.e., for each node individually). The same applies to paths, even though in this case you only have the outline to play with. + +Let's briefly dive through the most relevant key-value pairs that can be used to configure these properties. My purpose here is just to provide a compact reference to understand the examples in the documentation. + +\subsubsection{Outline properties} +These describe the properties of lines. They apply to edges and to the contour of nodes (such as labels and words in the sentence) +\begin{key}{/tikz/draw} + This key tells tikz to actually draw the outline of a shape. If draw is not set, then the outline is not drawn. By default, outlines are not drawn. +\end{key} +\begin{keylist}[/tikz]{circle,ellipse,rectangle} + Selecting one of this properties allows you to use a different shape to draw a node. When |draw| is selected, by default the node will be drawn as a |rectangle|. +\end{keylist} +\begin{key}{/tikz/rounded corners=\meta{length}} + This property allows you to make corners round. The value that you assign to it is the amount of roundness. +\end{key} +\begin{keylist}[/tikz]{very thin,thin,thick,very thick} + Can be used to set the width of a line. |thin| is the default value (corresponding to |0.4pt|). +\end{keylist} +\begin{key}{/tikz/color=\meta{color-spec}} + Sets the color used to draw the line. \meta{color-spec} can be a color name, such as |red|, |green| or |blue|, or a more complicated expression, such as |red!60!black|, which means ``make a new color made of red for 60\% of red, of black for the rest''. Colors can be specified in many other ways, which we won't cover here. +\end{key} +\begin{keylist}[/tikz]{solid,dotted,loosely dotted,densely dotted,dashed,loosely dashed,densely dashed} +Set the kind of line to be used to draw the outline. |solid| is the default (i.e. a continuous line). +\end{keylist} + +\subsubsection{Area properties} +These describe the properties of areas. They apply to the background of nodes (such as labels, words in the sentence and word groups). +\begin{key}{/tikz/fill=\meta{color}} + This key tells tikz to fill the inside of a shape (or a node) with a solid color. Color specification is the same as for |/tikz/draw|. +\end{key} +\begin{key}{/tikz/shade} + Instead of filling the area with a solid color, fill it with a gradient. +\end{key} +\begin{keylist}[/tikz]{top color=\meta{color},bottom color=\meta{color}} + If |shade| is set, you can use these two keys to set up a vertical gradient. +\end{keylist} +\begin{keylist}[/tikz]{left color=\meta{color},right color=\meta{color}} + If |shade| is set, you can use these two keys to set up a horizontal gradient. +\end{keylist} +\begin{key}{/tikz/inner sep=\meta{length}} + This parameter controls the distance between the outline of a node and its contents (e.g., the text inside the node). +\end{key} + +\subsubsection{Text properties} +These describe the properties of text boxes. They apply to the text of the sentence (the rows if the |matrix| wrapped by |deptext|) and to labels. +\begin{key}{/tikz/text=\meta{color}} + This key sets the color to be used to render the text. +\end{key} +\begin{key}{/tikz/font=\meta{fontmacros}} + Set the font size/family/series/shape to be user to render the text. Every combination of these standard \LaTeX{} macros is a valid value for \meta{fontmacros}: + |\normalsize|, + |\small|, + |\footnotesize|, + |\tiny|, + |\large|, + |\huge|, + |\rmfamily|, + |\ttfamily|, + |\sffamily|, + |\mdseries|, + |\bfseries|, + |\upshape|, + |\itshape|, + |\scshape|, + |\slshape|. +\end{key} + +\printindex + +\end{document} |