Debian Codegraph @

texmf-dist/doc/latex/tikz-inet/tikz-inet-doc.tex

raw
1 % Copyright 2008 by Marc de Falco
2 %
3 % This file may be distributed and/or modified
4 %
5 % 1. under the LaTeX Project Public License and/or
6 % 2. under the GNU Public License.
7 %
8 \documentclass[10pt,a4paper]{article}
9 \usepackage[fancy,color=orange]{tikz-inet}
10 \usetikzlibrary{calc}
11 \usepackage{ifthen}
12
13 \usepackage{fancyvrb}
14 \usepackage{a4wide}
15 \usepackage{pgffor}
16
17 \newenvironment{outputverbat}{%
18 \VerbatimEnvironment\begin{VerbatimOut}{\jobname.tmp}}
19 {\end{VerbatimOut}}
20 \newcommand{\code}[1][0.5]{
21 \fbox{
22 \begin{minipage}{#1\textwidth}
23 \VerbatimInput[gobble=4,fontsize=\footnotesize]{\jobname.tmp}
24 \end{minipage}
25 }
26 }
27 \newcommand{\picturefancy}
28 {\begin{tikzpicture}\input{\jobname.tmp}\end{tikzpicture}}
29 \newcommand{\picturenofancy}
30 {\begin{tikzpicture}\inetnofancy\input{\jobname.tmp}%
31 \inetfancy\end{tikzpicture}}
32 \newenvironment{exampleH}{\VerbatimEnvironment\begin{outputverbat}}
33 {\end{outputverbat}
34 \begin{center}
35 \begin{tabular}{c|cc}\picturefancy & \picturenofancy & \code\end{tabular}
36 \end{center}}
37 \newenvironment{exampleHv}{\VerbatimEnvironment\begin{outputverbat}}
38 {\end{outputverbat}
39 \begin{center}
40 \begin{tabular}{c}
41 \begin{tabular}{r|l}
42 \picturefancy & \picturenofancy
43 \end{tabular}
44 \\ \hline \\ \code[1]\end{tabular}
45 \end{center}}
46 \newenvironment{exampleVv}{\VerbatimEnvironment\begin{outputverbat}}
47 {\end{outputverbat}
48 \begin{center}
49 \begin{tabular}{rl}
50 \begin{tabular}{c}
51 \picturefancy \\ \hline \\ \picturenofancy
52 \end{tabular}
53 & \code
54 \end{tabular}
55 \end{center}}
56
57 \begin{document}
58
59 \title{The package \textsf{tikz-inet}}
60 \author{Marc de Falco}
61 \maketitle
62
63 \begin{abstract}
64 The purpose of this package is to extend tikz
65 with some simple macros in order to draw interaction
66 nets.
67 \end{abstract}
68
69 \section*{Changelog}
70 \newcommand{\changeitem}[2]{\item \textbf{#1} \textit{#2}}
71 \begin{itemize}
72 \changeitem{0.1}{initial release}
73 \end{itemize}
74
75 \section*{TODO}
76 \begin{itemize}
77 \item add support for proofnets
78 \end{itemize}
79
80 \section{Installation}
81 Install this package in your ressource directory or the root of your
82 document directory.
83
84 This package obviously needs tikz and pgf, but \textbf{this package needs
85 the version, at least, 2.0 of them}.
86
87 \section{Usage}
88 \subsection{Loading the package}
89 The command to load the package is the usual
90
91 \verb+\usepackage[<+\emph{options}\verb+>]{tikz-inet}+
92
93 where \emph{options} are a comma separated list of keys ranging in
94
95 \begin{description}
96 \item[fancy] Select a fancier style suitable for talks but
97 likely to frighten referees
98 \item[color=] The global color used by the fancy style, must
99 be xcolor compliant color
100 \item[angle=] The default orientation of cells, in degrees (default to $0$, that is a cell pointing downward)
101 \end{description}
102
103 \subsection{Cell nodes}
104 The cells are displayed using the internal node system of tikz.
105 A special shape \emph{cellule} is inherited from the tikz shape
106 isosceles triangle, thus sharing the original anchors.
107
108 A macro is defined to encapsulate the node creation.
109
110 \verb+\inetcell[+\emph{tikz display keys}\verb+](+\emph{node name}%
111 \verb+){+\emph{symbol}\verb+}[+\emph{angle}\verb+]+
112
113 Every parameter is optional but the symbol.
114
115 \begin{description}
116 \item[symbol] The symbol of the cell, that is the text displayed
117 in the center of the cell. This text is not assumed to be
118 in math mode.
119 \item[node name] This is the name of the node that will be
120 used for referencing it or connecting wires. This name
121 default to the symbol, which is a convenient way to make simple
122 drawings, this can lead to some error as soon as the symbol
123 is not simple, like a math text.
124 \item[angle] The angle of the principal port of the cell,
125 defaults to $0$ which means that the cell has a downward
126 orientation with the principal port on the right.
127
128 Special values $U,D,L$ and $R$ are defined for up, down, left and right
129 orientation of the cell.
130 \item[tikz display keys] This additional display keys are
131 appended to the one used by the package and given to the
132 node construction. As it is appended after, it can be used to
133 redefine all display options.
134
135 A special key \verb+arity+ allows to define arity based anchors
136 for ports. This is not really useful in most cases as the
137 three predefined anchors are more likely to suit your need.
138 \end{description}
139
140 When using this macro a lot of parameters are given to tikz, one of
141 them is the current cell display style. More on this can be found later.
142
143 \subsubsection{Ports}
144 Some anchors are named in order to reflect ports of the cell:
145 \begin{description}
146 \item[pal] the apex of the triangle, where lies the principal port
147 \item[middle pax] an auxiliary port aligned with the principal port
148 \item[left pax, right pax] auxiliaries ports on each side of the opposite
149 edge of the apex
150 \item[pax $n$, $1 \le n \le arity$] numbered auxiliary ports associated
151 with the arity key.
152 \end{description}
153
154 Each anchor has a sibling a bit off the cell, it allows nice curving when
155 branching wires. To get this special anchor, just add \verb+above+ to the
156 other ones: e.g. \verb+above middle pax+
157
158 \begin{center}
159 \begin{tikzpicture}
160 \LARGE
161 \inetcell(c){Cell symbol}[90]
162 \fill (c.pal) circle (2pt)
163 node[above]{\footnotesize pal};
164 \fill (c.above pal) circle (2pt)
165 node[right]{\footnotesize above pal};
166 \fill (c.left pax) circle (2pt)
167 node[above left]{\footnotesize left pax};
168 \fill (c.above left pax) circle (2pt)
169 node[below left]{\footnotesize above left pax};
170 \fill (c.middle pax) circle (2pt)
171 node[above left]{\footnotesize middle pax};
172 \fill (c.above middle pax) circle (2pt)
173 node[below left]{\footnotesize above middle pax};
174 \fill (c.right pax) circle (2pt)
175 node[below left]{\footnotesize right pax};
176 \fill (c.above right pax) circle (2pt)
177 node[above left]{\footnotesize above right pax};
178 \foreach \x in {1,...,4} {
179 \fill (c.pax \x) circle (2pt)
180 node[right]{\footnotesize pax \x};
181 }
182 \end{tikzpicture}
183 \end{center}
184
185 \subsection{Wires}
186 Wires macros help connecting ports by taking into account the current
187 wire display style and dealing implicitly with the \emph{above} anchors.
188 The wires are displayed on a layer below the main one, so cells are always
189 on top of layers. To change this you have to use \verb+\pgfsetlayers+.
190
191 \verb+\inetwire[+\emph{tikz extra display keys}\verb+](cell1.port1)(cell2.port2)+
192
193 The arguments are self-explanatory: this wire will connect the port \verb+port1+
194 of \verb+cell1+ with the port \verb+port2+ of \verb+cell2+. It uses the current
195 wire style.
196
197 \verb+\inetloop[+\emph{tikz extra display keys}\verb+]+
198
199 draws a loop, that is a circle with the current wire style
200
201 \verb+\inetwirecoords[+\emph{tikz extra display keys}\verb+](A)(B)+
202
203 draws a wire from node A to node B with the current wire style. It's useful
204 to add extra wires non linking cell ports while using the current wire style.
205
206 \verb+\inetwirefree[+\emph{tikz extra display keys}\verb+](cell.port)+
207
208 draws a wire from \verb+port+ of \verb+cell+ to \verb+above port+
209 of the same cell, with
210 the current wire style. It allows fast declaration of free ports.
211
212 \subsection{Boxes}
213 Boxes uses the current box style when being displayed, they lie on a
214 layer below the wire layer.
215
216 \verb+\inetbox[+\emph{tikz extra display keys}\verb+]{+\emph{space
217 separated list of cells in the box}\verb+}(+\emph{box node name}+\verb+)+
218 display a box containing the given cells
219
220 \verb+\inetprombox[+\emph{tikz extra display keys}\verb+]{+\emph{space
221 separated list of cells in the box}\verb+}(+\emph{promotion cell
222 node name}+\verb+)+: display a box and add a promotion cell below it,
223 the name of the box is \verb+bname+ where \verb+name+ is the name
224 of the promotion cell.
225
226
227
228 \subsection{Other macros}
229 \verb+\inetnofancy+, \verb+inetfancy+: hotswap the current display style
230
231 \verb+\inetcellstyle+,\verb+\inetwirestyle+,\verb+\inetboxstyle+: get
232 the currently used style for each type of drawing. \textbf{Don't renew this
233 command to define your own style!}
234
235 \verb+\inetcolor+: the current color for the fancy style, also passed
236 as an argument of the non fancy style.
237
238 If you want to call a style you have to give an argument, unless you have
239 redefined the fancy styles to not use it. For a cell like element you have
240 to give the key \verb+\inetcellstyle=\inetcolor+.
241
242 \subsubsection{Tikz styles}
243 This package define six styles :
244 \begin{itemize}
245 \item \emph{cellstyle} and \emph{fancycellstyle}
246 \item \emph{wirestyle} and \emph{fancywirestyle}
247 \item \emph{boxstyle} and \emph{fancyboxstyle}
248 \end{itemize}
249 You can redefine this styles as for any other tikz styles with the
250 command:
251
252 \verb+\tikzset{+\emph{the style name}\verb+/.style={+\emph{tikz display keys}\verb+}}+
253
254 \section{Examples}
255 \subsection{Basic}
256 All examples are shown with the \textsf{fancy} key on the left.
257
258 \begin{exampleH}
259 \inetcell{A}
260 \end{exampleH}
261
262 \begin{exampleVv}
263 \matrix[row sep=0.5cm]{
264 \inetcell{A} & & \inetcell{B} \\
265 & \inetcell{C} & \\
266 };
267 \inetwirefree(A.middle pax)
268 \inetwirefree(B.middle pax)
269 \inetwirefree(C.pal)
270 \inetwire(A.pal)(C.right pax)
271 \inetwire(B.pal)(C.left pax)
272 \inetbox{(A) (B)}(b)
273 \end{exampleVv}
274
275 \subsection{Style variations}
276
277 \begin{exampleVv}
278 \matrix{
279 \inetcell{A} &
280 \inetcell[fancycellstyle=green]{B} \\
281 \inetcell[bottom color=green]{C} &
282 \inetcell[draw=black]{D} \\
283 \inetcell[very thick]{E} &
284 \inetnofancy \inetcell{F} \inetfancy \\
285 };
286 \end{exampleVv}
287
288 \subsection{Special cases}
289 \begin{exampleVv}
290 \inetcell{A}
291 \inetprombox{(A)}(pa)
292 \inetcell[at=(bpa.east),right=5pt]{B}
293 \inetwire(B.middle pax)(A.middle pax)
294 \inetprombox{(bpa)(pa)(B)}(p)
295 \inetwire(A.pal)(pa.middle pax)
296 \inetwirefree(pa.pal)
297 \inetwirefree(p.pal)
298 \inetwire(B.pal)(p.middle pax)
299 \end{exampleVv}
300
301 \begin{exampleVv}
302 \newcount\angle
303 \foreach \x in {1,...,12} {
304 \pgfmathsetcount{\angle}{360*\x/12+90}
305 \inetcell[\inetcellstyle=green!\x0,
306 at=(\the\angle-90:1.5cm)]
307 (c\x){A}[\angle]
308 }
309 \end{exampleVv}
310
311 \begin{exampleHv}
312 \newcount\angle
313 \newcount\order
314 \order=10
315 \newcount\arity
316 \pgfmathsetcount{\arity}{\order-1}
317 \foreach \x in {1,...,\order} {
318 \foreach \y/\symbol in {0/!,1/?} {
319 \pgfmathsetcount{\angle}
320 {(180*(2*\x+\y))/\order+90}
321 \inetcell[at=(\the\angle-90:\the\order*1.8ex),
322 arity=\order-1](c\y\x){\symbol}[\angle]
323 \inetwirefree(c\y\x.pal)
324 }
325 }
326
327 \newcount\nextcell
328 \newcount\nextport
329 \newcount\depth
330 \foreach \x in {1,...,\order} {
331 \foreach \y in {1,...,\arity} {
332 \pgfmathsetcount{\nextcell}
333 {mod(\x+\y-1,\order)+1}
334 \pgfmathsetcount{\nextport}
335 {\arity-\y+1}
336 \pgfmathsetcount{\depth}{(\x-1)*100/\order}
337 \inetwire[\inetwirestyle=\inetcolor!\the\depth!black]%
338 (c0\x.pax \y)(c1\the\nextcell.pax \the\nextport)
339 }
340 }
341 \end{exampleHv}
342
343 \end{document}