Debian Codegraph @

texmf-dist/doc/latex/msc/manual-macros.tex

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