Debian Codegraph @

texmf-dist/doc/latex/pdfmarginpar/pgfmanual-en-macros.tex

raw
1 % Copyright 2006 by Till Tantau
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 Free Documentation License.
7 %
8 % See the file doc/generic/pgf/licenses/LICENSE for more details.
9
10 % $Header: /cvsroot/pgfplots/pgfplots/doc/latex/pgfplots/pgfmanual-en-macros.tex,v 1.1 2008/05/24 12:09:27 ludewich Exp $
11
12
13 \providecommand\href[2]{\texttt{#1}}
14
15
16 \colorlet{examplefill}{yellow!80!black}
17 \definecolor{graphicbackground}{rgb}{0.96,0.96,0.8}
18 \definecolor{codebackground}{rgb}{0.8,0.8,1}
19
20 \newenvironment{pgfmanualentry}{\list{}{\leftmargin=2em\itemindent-\leftmargin\def\makelabel##1{\hss##1}}}{\endlist}
21 \newcommand\pgfmanualentryheadline[1]{\itemsep=0pt\parskip=0pt\item\strut{#1}\par\topsep=0pt}
22 \newcommand\pgfmanualbody{\parskip3pt}
23
24
25
26 \newenvironment{pgflayout}[1]{
27 \begin{pgfmanualentry}
28 \pgfmanualentryheadline{\texttt{\string\pgfpagesuselayout\char`\{\declare{#1}\char`\}}\oarg{options}}
29 \index{#1@\protect\texttt{#1} layout}%
30 \index{Page layouts!#1@\protect\texttt{#1}}%
31 \pgfmanualbody
32 }
33 {
34 \end{pgfmanualentry}
35 }
36
37
38 \newenvironment{command}[1]{
39 \begin{pgfmanualentry}
40 \extractcommand#1\@@
41 \pgfmanualbody
42 }
43 {
44 \end{pgfmanualentry}
45 }
46
47 %% MW: START MATH MACROS
48 \def\mvar#1{{\rmfamily\textit{#1}}}
49
50 \makeatletter
51
52 \def\extractmathfunctionname#1{\extractmathfunctionname@#1(,)\tmpa\tmpb}
53 \def\extractmathfunctionname@#1(#2)#3\tmpb{\def\mathname{#1}}
54
55 \def\extractmathoperatorname{\begingroup\def\mvar##1{}\def\ {}\extractmathoperatorname@}
56 \def\extractmathoperatorname@#1{\xdef\mathname{#1}\endgroup}
57
58 \makeatother
59
60 \newenvironment{math-function}[1]{
61 \begin{pgfmanualentry}
62 \extractmathfunctionname{#1}
63 \pgfmanualentryheadline{\texttt{#1}}%
64 \index{\mathname @\protect\texttt{\mathname} math function}%
65 \index{Math functions!\mathname @\protect\texttt{\mathname}}
66 \pgfmanualbody
67 }
68 {
69 \end{pgfmanualentry}
70 }
71
72 \newenvironment{math-operator}[1]{
73 \begin{pgfmanualentry}
74 \extractmathoperatorname{#1}
75 \pgfmanualentryheadline{\texttt{#1}}%
76 \index{\mathname @\protect\texttt{\mathname} math operator}%
77 \index{Math operators!\mathname @\protect\texttt{\mathname}}
78 \pgfmanualbody
79 }
80 {%
81 \end{pgfmanualentry}
82 }
83
84 \newenvironment{math-constant}[1]{
85 \begin{pgfmanualentry}
86 \pgfmanualentryheadline{\texttt{#1}}%
87 \index{#1@\protect\texttt{#1} math constant}%
88 \index{Math constants!#1@\protect\texttt{#1}}
89 \pgfmanualbody
90 }
91 {
92 \end{pgfmanualentry}
93 }
94 \def\calcname{\textsc{calc}}
95 %% MW: END MATH MACROS
96
97
98 \def\extractcommand#1#2\@@{%
99 \pgfmanualentryheadline{\declare{\texttt{\string#1}}#2}%
100 \removeats{#1}%
101 \index{\strippedat @\protect\myprintocmmand{\strippedat}}}
102
103
104 % \begin{environment}{{name}\marg{arguments}}
105 \renewenvironment{environment}[1]{
106 \begin{pgfmanualentry}
107 \extractenvironement#1\@@
108 \pgfmanualbody
109 }
110 {
111 \end{pgfmanualentry}
112 }
113
114 \def\extractenvironement#1#2\@@{%
115 \pgfmanualentryheadline{{\ttfamily\char`\\begin\char`\{\declare{#1}\char`\}}#2}%
116 \pgfmanualentryheadline{{\ttfamily\ \ }\meta{environment contents}}%
117 \pgfmanualentryheadline{{\ttfamily\char`\\end\char`\{\declare{#1}\char`\}}}%
118 \index{#1@\protect\texttt{#1} environment}%
119 \index{Environments!#1@\protect\texttt{#1}}}
120
121
122 \newenvironment{plainenvironment}[1]{
123 \begin{pgfmanualentry}
124 \extractplainenvironement#1\@@
125 \pgfmanualbody
126 }
127 {
128 \end{pgfmanualentry}
129 }
130
131 \def\extractplainenvironement#1#2\@@{%
132 \pgfmanualentryheadline{{\ttfamily\declare{\char`\\#1}}#2}%
133 \pgfmanualentryheadline{{\ttfamily\ \ }\meta{environment contents}}%
134 \pgfmanualentryheadline{{\ttfamily\declare{\char`\\end#1}}}%
135 \index{#1@\protect\texttt{#1} environment}%
136 \index{Environments!#1@\protect\texttt{#1}}}
137
138
139 \newenvironment{contextenvironment}[1]{
140 \begin{pgfmanualentry}
141 \extractcontextenvironement#1\@@
142 \pgfmanualbody
143 }
144 {
145 \end{pgfmanualentry}
146 }
147
148 \def\extractcontextenvironement#1#2\@@{%
149 \pgfmanualentryheadline{{\ttfamily\declare{\char`\\start#1}}#2}%
150 \pgfmanualentryheadline{{\ttfamily\ \ }\meta{environment contents}}%
151 \pgfmanualentryheadline{{\ttfamily\declare{\char`\\stop#1}}}%
152 \index{#1@\protect\texttt{#1} environment}%
153 \index{Environments!#1@\protect\texttt{#1}}}
154
155
156 \newenvironment{shape}[1]{
157 \begin{pgfmanualentry}
158 \pgfmanualentryheadline{Shape {\ttfamily\declare{#1}}}%
159 \index{#1@\protect\texttt{#1} shape}%
160 \index{Shapes!#1@\protect\texttt{#1}}
161 \pgfmanualbody
162 }
163 {
164 \end{pgfmanualentry}
165 }
166
167
168 \newenvironment{handler}[1]{
169 \begin{pgfmanualentry}
170 \extracthandler#1\@nil%
171 \pgfmanualbody
172 }
173 {
174 \end{pgfmanualentry}
175 }
176
177 \def\gobble#1{}
178 \def\extracthandler#1#2\@nil{%
179 \pgfmanualentryheadline{Key handler \meta{key}{\ttfamily/\declare{#1}}#2}%
180 \index{\gobble#1@\protect\texttt{#1} handler}%
181 \index{Key handlers!#1@\protect\texttt{#1}}
182 }
183
184
185 \makeatletter
186
187
188 \newenvironment{stylekey}[1]{
189 \begin{pgfmanualentry}
190 \def\extrakeytext{style, }
191 \extractkey#1\@nil%
192 \pgfmanualbody
193 }
194 {
195 \end{pgfmanualentry}
196 }
197
198
199 % \begin{key}{/path/x=value}
200 % \begin{key}{/path/x=value (initially XXX)}
201 % \begin{key}{/path/x=value (default XXX)}
202 \newenvironment{key}[1]{
203 \begin{pgfmanualentry}
204 \def\extrakeytext{}
205 %\def\altpath{\emph{\color{gray}or}}%
206 \extractkey#1\@nil%
207 \pgfmanualbody
208 }
209 {
210 \end{pgfmanualentry}
211 }
212
213 \def\extractkey#1\@nil{%
214 \pgfutil@in@={#1}%
215 \ifpgfutil@in@%
216 \extractkeyequal#1\@nil
217 \else%
218 \pgfutil@in@{(initial}{#1}%
219 \ifpgfutil@in@%
220 \extractequalinitial#1\@nil%
221 \else
222 \pgfmanualentryheadline{{\ttfamily\declare{#1}}\hfill(\extrakeytext no value)}%
223 \def\mykey{#1}%
224 \def\mypath{}%
225 \def\myname{}%
226 \firsttimetrue%
227 \decompose#1/\nil%
228 \fi
229 \fi%
230 }
231
232 \def\extractkeyequal#1=#2\@nil{%
233 \pgfutil@in@{(default}{#2}%
234 \ifpgfutil@in@%
235 \extractdefault{#1}#2\@nil%
236 \else%
237 \pgfutil@in@{(initial}{#2}%
238 \ifpgfutil@in@%
239 \extractinitial{#1}#2\@nil%
240 \else
241 \pgfmanualentryheadline{{\ttfamily\declare{#1}=}#2\hfill(\extrakeytext no default)}%
242 \fi%
243 \fi%
244 \def\mykey{#1}%
245 \def\mypath{}%
246 \def\myname{}%
247 \firsttimetrue%
248 \decompose#1/\nil%
249 }
250
251 \def\extractdefault#1#2(default #3)\@nil{%
252 \pgfmanualentryheadline{{\ttfamily\declare{#1}\opt{=}}\opt{#2}\hfill (\extrakeytext default {\ttfamily#3})}%
253 }
254
255 \def\extractinitial#1#2(initially #3)\@nil{%
256 \pgfmanualentryheadline{{\ttfamily\declare{#1}=}#2\hfill (\extrakeytext no default, initially {\ttfamily#3})}%
257 }
258
259 \def\extractequalinitial#1 (initially #2)\@nil{%
260 \pgfmanualentryheadline{{\ttfamily\declare{#1}}\hfill (\extrakeytext initially {\ttfamily#2})}%
261 \def\mykey{#1}%
262 \def\mypath{}%
263 \def\myname{}%
264 \firsttimetrue%
265 \decompose#1/\nil%
266 }
267
268 % Introduces a key alias '/#1/<name of current key>'
269 % to be used inside of \begin{key} ... \end{key}
270 \def\keyalias#1{\vspace{-3pt}\item{\small alias {\ttfamily/#1/\myname}}\vspace{-2pt}\par}
271
272 \newif\iffirsttime
273
274 \makeatother
275
276 \def\decompose/#1/#2\nil{%
277 \def\test{#2}%
278 \ifx\test\empty%
279 % aha.
280 \index{#1@\protect\texttt{#1} key}%
281 \index{\mypath#1@\protect\texttt{#1}}%
282 \def\myname{#1}%
283 \else%
284 \iffirsttime
285 \def\mypath{#1@\protect\texttt{/#1/}!}%
286 \firsttimefalse
287 \else
288 \expandafter\def\expandafter\mypath\expandafter{\mypath#1@\protect\texttt{#1/}!}%
289 \fi
290 \def\firsttime{}
291 \decompose/#2\nil%
292 \fi%
293 }
294
295 \newenvironment{predefinedmethod}[1]{
296 \begin{pgfmanualentry}
297 \extractpredefinedmethod#1\@nil
298 \pgfmanualbody
299 }
300 {
301 \end{pgfmanualentry}
302 }
303 \def\extractpredefinedmethod#1(#2)\@nil{%
304 \pgfmanualentryheadline{Method \declare{\ttfamily #1}\texttt(#2\texttt) \hfill(predefined for all classes)}
305 \index{#1@\protect\texttt{#1} method}%
306 \index{Methods!#1@\protect\texttt{#1}}
307 }
308
309
310 \newenvironment{ooclass}[1]{
311 \begin{pgfmanualentry}
312 \def\currentclass{#1}
313 \pgfmanualentryheadline{Class \declare{\texttt{#1}}}
314 \index{#1@\protect\texttt{#1} class}%
315 \index{Class #1@Class \protect\texttt{#1}}%
316 \index{Classes!#1@\protect\texttt{#1}}
317 \pgfmanualbody
318 }
319 {
320 \end{pgfmanualentry}
321 }
322
323 \newenvironment{method}[1]{
324 \begin{pgfmanualentry}
325 \extractmethod#1\@nil
326 \pgfmanualbody
327 }
328 {
329 \end{pgfmanualentry}
330 }
331 \def\extractmethod#1(#2)\@nil{%
332 \def\test{#1}
333 \ifx\test\currentclass
334 \pgfmanualentryheadline{Constructor \declare{\ttfamily #1}\texttt(#2\texttt)}
335 \else
336 \pgfmanualentryheadline{Method \declare{\ttfamily #1}\texttt(#2\texttt)}
337 \fi
338 \index{#1@\protect\texttt{#1} method}%
339 \index{Methods!#1@\protect\texttt{#1}}
340 \index{Class \currentclass!#1@\protect\texttt{#1}}%
341 }
342
343 \newenvironment{attribute}[1]{
344 \begin{pgfmanualentry}
345 \extractattribute#1\@nil
346 \pgfmanualbody
347 }
348 {
349 \end{pgfmanualentry}
350 }
351 \def\extractattribute#1=#2;\@nil{%
352 \def\test{#2}%
353 \ifx\test\@empty
354 \pgfmanualentryheadline{Private attribute \declare{\ttfamily #1} \hfill (initially empty)}
355 \else
356 \pgfmanualentryheadline{Private attribute \declare{\ttfamily #1} \hfill (initially {\ttfamily #2})}
357 \fi
358 \index{#1@\protect\texttt{#1} attribute}%
359 \index{Attributes!#1@\protect\texttt{#1}}
360 \index{Class \currentclass!#1@\protect\texttt{#1}}%
361 }
362
363
364
365 \newenvironment{predefinednode}[1]{
366 \begin{pgfmanualentry}
367 \pgfmanualentryheadline{Predefined node {\ttfamily\declare{#1}}}%
368 \index{#1@\protect\texttt{#1} node}%
369 \index{Predefined node!#1@\protect\texttt{#1}}
370 \pgfmanualbody
371 }
372 {
373 \end{pgfmanualentry}
374 }
375
376 \newenvironment{coordinatesystem}[1]{
377 \begin{pgfmanualentry}
378 \pgfmanualentryheadline{Coordinate system {\ttfamily\declare{#1}}}%
379 \index{#1@\protect\texttt{#1} coordinate system}%
380 \index{Coordinate systems!#1@\protect\texttt{#1}}
381 \pgfmanualbody
382 }
383 {
384 \end{pgfmanualentry}
385 }
386
387 \newenvironment{snake}[1]{
388 \begin{pgfmanualentry}
389 \pgfmanualentryheadline{Snake {\ttfamily\declare{#1}}}%
390 \index{#1@\protect\texttt{#1} snake}%
391 \index{Snakes!#1@\protect\texttt{#1}}
392 \pgfmanualbody
393 }
394 {
395 \end{pgfmanualentry}
396 }
397
398 \newenvironment{decoration}[1]{
399 \begin{pgfmanualentry}
400 \pgfmanualentryheadline{Decoration {\ttfamily\declare{#1}}}%
401 \index{#1@\protect\texttt{#1} decoration}%
402 \index{Decorations!#1@\protect\texttt{#1}}
403 \pgfmanualbody
404 }
405 {
406 \end{pgfmanualentry}
407 }
408
409
410 \def\pgfmanualbar{\char`\|}
411 \makeatletter
412 \newenvironment{pathoperation}[3][]{
413 \begin{pgfmanualentry}
414 \pgfmanualentryheadline{\textcolor{gray}{{\ttfamily\char`\\path}\
415 \ \dots}
416 \declare{\texttt{#2}}#3\ \textcolor{gray}{\dots\texttt{;}}}%
417 \def\pgfmanualtest{#1}%
418 \ifx\pgfmanualtest\@empty%
419 \index{#2@\protect\texttt{#2} path operation}%
420 \index{Path operations!#2@\protect\texttt{#2}}%
421 \fi%
422 \pgfmanualbody
423 }
424 {
425 \end{pgfmanualentry}
426 }
427 \makeatother
428
429 \def\extractcommand#1#2\@@{%
430 \pgfmanualentryheadline{\declare{\texttt{\string#1}}#2}%
431 \removeats{#1}%
432 \index{\strippedat @\protect\myprintocmmand{\strippedat}}}
433
434 \def\doublebs{\texttt{\char`\\\char`\\}}
435
436
437 \newenvironment{package}[1]{
438 \begin{pgfmanualentry}
439 \pgfmanualentryheadline{{\ttfamily\char`\\usepackage\char`\{\declare{#1}\char`\}\space\space \char`\%\space\space \LaTeX}}
440 \index{#1@\protect\texttt{#1} package}%
441 \index{Packages and files!#1@\protect\texttt{#1}}%
442 \pgfmanualentryheadline{{\ttfamily\char`\\input \declare{#1}.tex\space\space\space \char`\%\space\space plain \TeX}}
443 \pgfmanualentryheadline{{\ttfamily\char`\\usemodule[\declare{#1}]\space\space \char`\%\space\space Con\TeX t}}
444 \pgfmanualbody
445 }
446 {
447 \end{pgfmanualentry}
448 }
449
450
451 \newenvironment{pgfmodule}[1]{
452 \begin{pgfmanualentry}
453 \pgfmanualentryheadline{{\ttfamily\char`\\usepgfmodule\char`\{\declare{#1}\char`\}\space\space\space
454 \char`\%\space\space \LaTeX\space and plain \TeX\space and pure pgf}}
455 \index{#1@\protect\texttt{#1} module}%
456 \index{Modules!#1@\protect\texttt{#1}}%
457 \pgfmanualentryheadline{{\ttfamily\char`\\usepgfmodule[\declare{#1}]\space\space \char`\%\space\space Con\TeX t\space and pure pgf}}
458 \pgfmanualbody
459 }
460 {
461 \end{pgfmanualentry}
462 }
463
464 \newenvironment{pgflibrary}[1]{
465 \begin{pgfmanualentry}
466 \pgfmanualentryheadline{{\ttfamily\char`\\usepgflibrary\char`\{\declare{#1}\char`\}\space\space\space
467 \char`\%\space\space \LaTeX\space and plain \TeX\space and pure pgf}}
468 \index{#1@\protect\texttt{#1} library}%
469 \index{Libraries!#1@\protect\texttt{#1}}%
470 \pgfmanualentryheadline{{\ttfamily\char`\\usepgflibrary[\declare{#1}]\space\space \char`\%\space\space Con\TeX t\space and pure pgf}}
471 \pgfmanualentryheadline{{\ttfamily\char`\\usetikzlibrary\char`\{\declare{#1}\char`\}\space\space
472 \char`\%\space\space \LaTeX\space and plain \TeX\space when using \tikzname}}
473 \pgfmanualentryheadline{{\ttfamily\char`\\usetikzlibrary[\declare{#1}]\space
474 \char`\%\space\space Con\TeX t\space when using \tikzname}}
475 \pgfmanualbody
476 }
477 {
478 \end{pgfmanualentry}
479 }
480
481 \newenvironment{tikzlibrary}[1]{
482 \begin{pgfmanualentry}
483 \pgfmanualentryheadline{{\ttfamily\char`\\usetikzlibrary\char`\{\declare{#1}\char`\}\space\space \char`\%\space\space \LaTeX\space and plain \TeX}}
484 \index{#1@\protect\texttt{#1} library}%
485 \index{Libraries!#1@\protect\texttt{#1}}%
486 \pgfmanualentryheadline{{\ttfamily\char`\\usetikzlibrary[\declare{#1}]\space \char`\%\space\space Con\TeX t}}
487 \pgfmanualbody
488 }
489 {
490 \end{pgfmanualentry}
491 }
492
493
494
495 \newenvironment{filedescription}[1]{
496 \begin{pgfmanualentry}
497 \pgfmanualentryheadline{File {\ttfamily\declare{#1}}}%
498 \index{#1@\protect\texttt{#1} file}%
499 \index{Packages and files!#1@\protect\texttt{#1}}%
500 \pgfmanualbody
501 }
502 {
503 \end{pgfmanualentry}
504 }
505
506
507 \newenvironment{packageoption}[1]{
508 \begin{pgfmanualentry}
509 \pgfmanualentryheadline{{\ttfamily\char`\\usepackage[\declare{#1}]\char`\{pgf\char`\}}}
510 \index{#1@\protect\texttt{#1} package option}%
511 \index{Package options for \textsc{pgf}!#1@\protect\texttt{#1}}%
512 \pgfmanualbody
513 }
514 {
515 \end{pgfmanualentry}
516 }
517
518
519
520 \newcommand\opt[1]{{\color{black!50!green}#1}}
521 \newcommand\ooarg[1]{{\ttfamily[}\meta{#1}{\ttfamily]}}
522
523 \def\opt{\afterassignment\pgfmanualopt\let\next=}
524 \def\pgfmanualopt{\ifx\next\bgroup\bgroup\color{black!50!green}\else{\color{black!50!green}\next}\fi}
525
526
527
528 \def\beamer{\textsc{beamer}}
529 \def\pdf{\textsc{pdf}}
530 \def\pgfname{\textsc{pgf}}
531 \def\tikzname{Ti\emph{k}Z}
532 \def\pstricks{\textsc{pstricks}}
533 \def\prosper{\textsc{prosper}}
534 \def\seminar{\textsc{seminar}}
535 \def\texpower{\textsc{texpower}}
536 \def\foils{\textsc{foils}}
537
538 {
539 \makeatletter
540 \global\let\myempty=\@empty
541 \global\let\mygobble=\@gobble
542 \catcode`\@=12
543 \gdef\getridofats#1@#2\relax{%
544 \def\getridtest{#2}%
545 \ifx\getridtest\myempty%
546 \expandafter\def\expandafter\strippedat\expandafter{\strippedat#1}
547 \else%
548 \expandafter\def\expandafter\strippedat\expandafter{\strippedat#1\protect\printanat}
549 \getridofats#2\relax%
550 \fi%
551 }
552
553 \gdef\removeats#1{%
554 \let\strippedat\myempty%
555 \edef\strippedtext{\stripcommand#1}%
556 \expandafter\getridofats\strippedtext @\relax%
557 }
558
559 \gdef\stripcommand#1{\expandafter\mygobble\string#1}
560 }
561
562 \def\printanat{\char`\@}
563
564 \def\declare{\afterassignment\pgfmanualdeclare\let\next=}
565 \def\pgfmanualdeclare{\ifx\next\bgroup\bgroup\color{red!75!black}\else{\color{red!75!black}\next}\fi}
566
567
568 \let\textoken=\command
569 \let\endtextoken=\endcommand
570
571 \def\myprintocmmand#1{\texttt{\char`\\#1}}
572
573 \def\example{\par\smallskip\noindent\textit{Example: }}
574 \def\themeauthor{\par\smallskip\noindent\textit{Theme author: }}
575
576
577 \def\indexoption#1{%
578 \index{#1@\protect\texttt{#1} option}%
579 \index{Graphic options and styles!#1@\protect\texttt{#1}}%
580 }
581
582 \def\itemcalendaroption#1{\item \declare{\texttt{#1}}%
583 \index{#1@\protect\texttt{#1} date test}%
584 \index{Date tests!#1@\protect\texttt{#1}}%
585 }
586
587
588
589 \def\class#1{\list{}{\leftmargin=2em\itemindent-\leftmargin\def\makelabel##1{\hss##1}}%
590 \extractclass#1@\par\topsep=0pt}
591 \def\endclass{\endlist}
592 \def\extractclass#1#2@{%
593 \item{{{\ttfamily\char`\\documentclass}#2{\ttfamily\char`\{\declare{#1}\char`\}}}}%
594 \index{#1@\protect\texttt{#1} class}%
595 \index{Classes!#1@\protect\texttt{#1}}}
596
597 \def\partname{Part}
598
599 \makeatletter
600 \def\index@prologue{\section*{Index}\addcontentsline{toc}{section}{Index}
601 This index only contains automatically generated entries. A good
602 index should also contain carefully selected keywords. This index is
603 not a good index.
604 \bigskip
605 }
606 \c@IndexColumns=2
607 \def\theindex{\@restonecoltrue
608 \columnseprule \z@ \columnsep 29\p@
609 \twocolumn[\index@prologue]%
610 \parindent -30pt
611 \columnsep 15pt
612 \parskip 0pt plus 1pt
613 \leftskip 30pt
614 \rightskip 0pt plus 2cm
615 \small
616 \def\@idxitem{\par}%
617 \let\item\@idxitem \ignorespaces}
618 \def\endtheindex{\onecolumn}
619 \def\noindexing{\let\index=\@gobble}
620
621
622
623 \newcommand\symarrow[1]{
624 \index{#1@\protect\texttt{#1} arrow tip}%
625 \index{Arrow tips!#1@\protect\texttt{#1}}
626 \texttt{#1}& yields thick
627 \begin{tikzpicture}[arrows={#1-#1},thick,baseline]
628 \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex);
629 \draw (0pt,.5ex) -- (1cm,.5ex);
630 \end{tikzpicture} and thin
631 \begin{tikzpicture}[arrows={#1-#1},thin,baseline]
632 \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex);
633 \draw (0pt,.5ex) -- (1cm,.5ex);
634 \end{tikzpicture}
635 }
636 \newcommand\symarrowdouble[1]{
637 \index{#1@\protect\texttt{#1} arrow tip}%
638 \index{Arrow tips!#1@\protect\texttt{#1}}
639 \texttt{#1}& yields thick
640 \begin{tikzpicture}[arrows={#1-#1},thick,baseline]
641 \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex);
642 \draw (0pt,.5ex) -- (1cm,.5ex);
643 \end{tikzpicture}
644 and thin
645 \begin{tikzpicture}[arrows={#1-#1},thin,baseline]
646 \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex);
647 \draw (0pt,.5ex) -- (1cm,.5ex);
648 \end{tikzpicture}, double
649 \begin{tikzpicture}[arrows={#1-#1},thick,baseline]
650 \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex);
651 \draw[double,double equal sign distance] (0pt,.5ex) -- (1cm,.5ex);
652 \end{tikzpicture} and
653 \begin{tikzpicture}[arrows={#1-#1},thin,baseline]
654 \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex);
655 \draw[double,double equal sign distance] (0pt,.5ex) -- (1cm,.5ex);
656 \end{tikzpicture}
657 }
658
659 \newcommand\sarrow[2]{
660 \index{#1@\protect\texttt{#1} arrow tip}%
661 \index{Arrow tips!#1@\protect\texttt{#1}}
662 \index{#2@\protect\texttt{#2} arrow tip}%
663 \index{Arrow tips!#2@\protect\texttt{#2}}
664 \texttt{#1-#2}& yields thick
665 \begin{tikzpicture}[arrows={#1-#2},thick,baseline]
666 \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex);
667 \draw (0pt,.5ex) -- (1cm,.5ex);
668 \end{tikzpicture} and thin
669 \begin{tikzpicture}[arrows={#1-#2},thin,baseline]
670 \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex);
671 \draw (0pt,.5ex) -- (1cm,.5ex);
672 \end{tikzpicture}
673 }
674
675 \newcommand\sarrowdouble[2]{
676 \index{#1@\protect\texttt{#1} arrow tip}%
677 \index{Arrow tips!#1@\protect\texttt{#1}}
678 \index{#2@\protect\texttt{#2} arrow tip}%
679 \index{Arrow tips!#2@\protect\texttt{#2}}
680 \texttt{#1-#2}& yields thick
681 \begin{tikzpicture}[arrows={#1-#2},thick,baseline]
682 \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex);
683 \draw (0pt,.5ex) -- (1cm,.5ex);
684 \end{tikzpicture} and thin
685 \begin{tikzpicture}[arrows={#1-#2},thin,baseline]
686 \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex);
687 \draw (0pt,.5ex) -- (1cm,.5ex);
688 \end{tikzpicture}, double
689 \begin{tikzpicture}[arrows={#1-#2},thick,baseline]
690 \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex);
691 \draw[double,double equal sign distance] (0pt,.5ex) -- (1cm,.5ex);
692 \end{tikzpicture} and
693 \begin{tikzpicture}[arrows={#1-#2},thin,baseline]
694 \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex);
695 \draw[double,double equal sign distance] (0pt,.5ex) -- (1cm,.5ex);
696 \end{tikzpicture}
697 }
698
699 \newcommand\carrow[1]{
700 \index{#1@\protect\texttt{#1} arrow tip}%
701 \index{Arrow tips!#1@\protect\texttt{#1}}
702 \texttt{#1}& yields for line width 1ex
703 \begin{tikzpicture}[arrows={#1-#1},line width=1ex,baseline]
704 \useasboundingbox (0pt,-0.5ex) rectangle (1.5cm,2ex);
705 \draw (0pt,.5ex) -- (1.5cm,.5ex);
706 \end{tikzpicture}
707 }
708 \def\myvbar{\char`\|}
709 \newcommand\plotmarkentry[1]{%
710 \index{#1@\protect\texttt{#1} plot mark}%
711 \index{Plot marks!#1@\protect\texttt{#1}}
712 \texttt{\char`\\pgfuseplotmark\char`\{\declare{#1}\char`\}} &
713 \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)};\\
714 }
715 \newcommand\plotmarkentrytikz[1]{%
716 \index{#1@\protect\texttt{#1} plot mark}%
717 \index{Plot marks!#1@\protect\texttt{#1}}
718 \texttt{mark=\declare{#1}} & \tikz\draw[color=black!25]
719 plot[mark=#1,mark options={fill=examplefill,draw=black}]
720 coordinates {(0,0) (.5,0.2) (1,0) (1.5,0.2)};\\
721 }
722
723
724
725 \ifx\scantokens\@undefined
726 \PackageError{pgfmanual-macros}{You need to use extended latex
727 (elatex) or (pdfelatex) to process this document}{}
728 \fi
729
730 % Define \find@example such that it doesn't destroy catcodes:
731 \begingroup
732 \catcode`|=0
733 \catcode`[= 1
734 \catcode`]=2
735 \catcode`\{=12
736 \catcode `\}=12
737 \catcode`\\=12 |gdef|find@example#1\end{codeexample}[|endofcodeexample[#1]]
738 |endgroup
739
740 % define \returntospace.
741 %
742 % It should define NEWLINE as {}, spaces and tabs as \space.
743 \begingroup
744 \catcode`\^=7
745 \catcode`\^^M=13
746 \catcode`\^^I=13
747 \catcode`\ =13%
748 \gdef\returntospace{\catcode`\ =13\def {\space}\catcode`\^^I=13\def^^I{\space}\catcode`\^^M=13\def^^M{}}%
749 \endgroup
750
751 \begingroup
752 \catcode`\%=13
753 \catcode`\^^M=13
754 \gdef\commenthandler{\catcode`\%=13\def%{\@gobble@till@return}}
755 \gdef\@gobble@till@return#1^^M{}
756 \gdef\@gobble@till@return@ignore#1^^M{\ignorespaces}
757 \gdef\typesetcomment{\catcode`\%=13\def%{\@typeset@till@return}}
758 \gdef\@typeset@till@return#1^^M{{\def%{\char`\%}\textsl{\char`\%#1}}\par}
759 \endgroup
760
761 % Define tab-implementation functions
762 % \codeexample@tabinit@replacementchars@
763 % and
764 % \codeexample@tabinit@catcode@
765 %
766 % They should ONLY be used in case that tab replacement is active.
767 %
768 % This here is merely a preparation step.
769 %
770 % Idea:
771 % \codeexample@tabinit@catcode@ will make TAB active
772 % and
773 % \codeexample@tabinit@replacementchars@ will insert as many spaces as
774 % /codeexample/tabsize contains.
775 {
776 \catcode`\^^I=13
777 % ATTENTION: do NOT use tabs in these definitions!!
778 \gdef\codeexample@tabinit@replacementchars@{%
779 \begingroup
780 \count0=\pgfkeysvalueof{/codeexample/tabsize}\relax
781 \toks0={}%
782 \loop
783 \ifnum\count0>0
784 \advance\count0 by-1
785 \toks0=\expandafter{\the\toks0\ }%
786 \repeat
787 \xdef\codeexample@tabinit@replacementchars@@{\the\toks0}%
788 \endgroup
789 \let^^I=\codeexample@tabinit@replacementchars@@
790 }%
791 \gdef\codeexample@tabinit@catcode@{\catcode`\^^I=13}%
792 }%
793
794 % Called after any options have been set. It assigns
795 % \codeexample@tabinit@catcode
796 % and
797 % \codeexample@tabinit@replacementchars
798 % which are used inside of
799 %\begin{codeexample}
800 % ...
801 %\end{codeexample}
802 %
803 % \codeexample@tabinit@catcode is either \relax or it makes tab
804 % active.
805 %
806 % \codeexample@tabinit@replacementchars is either \relax or it inserts
807 % a proper replacement sequence for tabs (as many spaces as
808 % configured)
809 \def\codeexample@tabinit{%
810 \ifnum\pgfkeysvalueof{/codeexample/tabsize}=0\relax
811 \let\codeexample@tabinit@replacementchars=\relax
812 \let\codeexample@tabinit@catcode=\relax
813 \else
814 \let\codeexample@tabinit@catcode=\codeexample@tabinit@catcode@
815 \let\codeexample@tabinit@replacementchars=\codeexample@tabinit@replacementchars@
816 \fi
817 }
818
819 \pgfqkeys{/codeexample}{%
820 width/.code= {\setlength\codeexamplewidth{#1}},
821 graphic/.code= {\colorlet{graphicbackground}{#1}},
822 code/.code= {\colorlet{codebackground}{#1}},
823 execute code/.is if=code@execute,
824 code only/.code= {\code@executefalse},
825 pre/.code= {\def\code@pre{#1}},
826 post/.code= {\def\code@post{#1}},
827 vbox/.code= {\def\code@pre{\vbox\bgroup\setlength{\hsize}{\linewidth-6pt}}\def\code@post{\egroup}},
828 ignorespaces/.code= {\let\@gobble@till@return=\@gobble@till@return@ignore},
829 leave comments/.code= {\def\code@catcode@hook{\catcode`\%=12}\let\commenthandler=\relax\let\typesetcomment=\relax},
830 tabsize/.initial=0,
831 every codeexample/.style={width=4cm+7pt},
832 }
833
834 \def\code@pre{}
835 \def\code@post{}
836 \def\code@catcode@hook{}
837
838 \newdimen\codeexamplewidth
839 \newif\ifcode@execute
840 \newbox\codeexamplebox
841 \def\codeexample[#1]{%
842 \begingroup%
843 \code@executetrue
844 \pgfqkeys{/codeexample}{every codeexample,#1}%
845 \codeexample@tabinit% assigns \codeexample@tabinit@[catcode,replacementchars]
846 \parindent0pt
847 \begingroup%
848 \par%
849 \medskip%
850 \let\do\@makeother%
851 \dospecials%
852 \obeylines%
853 \@vobeyspaces%
854 \catcode`\%=13%
855 \catcode`\^^M=13%
856 \code@catcode@hook%
857 \codeexample@tabinit@catcode
858 \relax%
859 \find@example}
860 \def\endofcodeexample#1{%
861 \endgroup%
862 \ifcode@execute%
863 \setbox\codeexamplebox=\hbox{%
864 {%
865 {%
866 \returntospace%
867 \commenthandler%
868 \xdef\code@temp{#1}% removes returns and comments
869 }%
870 \colorbox{graphicbackground}{\color{black}\ignorespaces%
871 \code@pre\expandafter\scantokens\expandafter{\code@temp\ignorespaces}\code@post\ignorespaces}%
872 }%
873 }%
874 \ifdim\wd\codeexamplebox>\codeexamplewidth%
875 \def\code@start{\par}%
876 \def\code@flushstart{}\def\code@flushend{}%
877 \def\code@mid{\parskip2pt\par\noindent}%
878 \def\code@width{\linewidth-6pt}%
879 \def\code@end{}%
880 \else%
881 \def\code@start{%
882 \linewidth=\textwidth%
883 \parshape \@ne 0pt \linewidth
884 \leavevmode%
885 \hbox\bgroup}%
886 \def\code@flushstart{\hfill}%
887 \def\code@flushend{\hbox{}}%
888 \def\code@mid{\hskip6pt}%
889 \def\code@width{\linewidth-12pt-\codeexamplewidth}%
890 \def\code@end{\egroup}%
891 \fi%
892 \code@start%
893 \noindent%
894 \begin{minipage}[t]{\codeexamplewidth}\raggedright
895 \hrule width0pt%
896 \footnotesize\vskip-1em%
897 \code@flushstart\box\codeexamplebox\code@flushend%
898 \vskip-1ex
899 \leavevmode%
900 \end{minipage}%
901 \else%
902 \def\code@mid{\par}
903 \def\code@width{\linewidth-6pt}
904 \def\code@end{}
905 \fi%
906 \code@mid%
907 \colorbox{codebackground}{%
908 \begin{minipage}[t]{\code@width}%
909 {%
910 \let\do\@makeother
911 \dospecials
912 \frenchspacing\@vobeyspaces
913 \normalfont\ttfamily\footnotesize
914 \typesetcomment%
915 \codeexample@tabinit@replacementchars
916 \@tempswafalse
917 \def\par{%
918 \if@tempswa
919 \leavevmode \null \@@par\penalty\interlinepenalty
920 \else
921 \@tempswatrue
922 \ifhmode\@@par\penalty\interlinepenalty\fi
923 \fi}%
924 \obeylines
925 \everypar \expandafter{\the\everypar \unpenalty}%
926 #1}
927 \end{minipage}}%
928 \code@end%
929 \par%
930 \medskip
931 \end{codeexample}
932 }
933
934 \def\endcodeexample{\endgroup}
935
936
937 \makeatother
938
939
940 %%% Local Variables:
941 %%% mode: latex
942 %%% TeX-master: "beameruserguide"
943 %%% End: