| 1 |
% This is file comes from the documentation of the PGF package by Till Tantau. |
| 2 |
% I have only commented out some code that is unnecessary for my purpose here (I just want to use the |
| 3 |
% codeexample environment) I hope that I do not break PGF license by releasing the file like this. William Blum |
| 4 |
|
| 5 |
|
| 6 |
% Copyright 2006 by Till Tantau |
| 7 |
% |
| 8 |
% This file may be distributed and/or modified |
| 9 |
% |
| 10 |
% 1. under the LaTeX Project Public License and/or |
| 11 |
% 2. under the GNU Free Documentation License. |
| 12 |
% |
| 13 |
% See the file doc/generic/pgf/licenses/LICENSE for more details. |
| 14 |
|
| 15 |
% $Header: /cvsroot/pgf/pgf/doc/generic/pgf/macros/pgfmanual-en-macros.tex,v 1.8 2006/10/11 15:00:27 tantau Exp $ |
| 16 |
|
| 17 |
\providecommand\href[2]{\texttt{#1}} |
| 18 |
|
| 19 |
\colorlet{examplefill}{yellow!80!black} |
| 20 |
\definecolor{graphicbackground}{rgb}{0.96,0.96,0.8} |
| 21 |
\definecolor{codebackground}{rgb}{0.8,0.8,1} |
| 22 |
|
| 23 |
\newenvironment{pgfmanualentry}{\list{}{\leftmargin=2em\itemindent-\leftmargin\def\makelabel##1{\hss##1}}}{\endlist} |
| 24 |
\newcommand\pgfmanualentryheadline[1]{\itemsep=0pt\parskip=0pt\item\strut#1\par\topsep=0pt} |
| 25 |
\newcommand\pgfmanualbody{\parskip3pt} |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
\newenvironment{pgflayout}[1]{ |
| 30 |
\begin{pgfmanualentry} |
| 31 |
\pgfmanualentryheadline{\texttt{\string\pgfpagesuselayout\char`\{\declare{#1}\char`\}}\oarg{options}} |
| 32 |
\index{#1@\protect\texttt{#1} layout}% |
| 33 |
\index{Page layouts!#1@\protect\texttt{#1}}% |
| 34 |
\pgfmanualbody |
| 35 |
} |
| 36 |
{ |
| 37 |
\end{pgfmanualentry} |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
\newenvironment{command}[1]{ |
| 42 |
\begin{pgfmanualentry} |
| 43 |
\extractcommand#1\@@ |
| 44 |
\pgfmanualbody |
| 45 |
} |
| 46 |
{ |
| 47 |
\end{pgfmanualentry} |
| 48 |
} |
| 49 |
|
| 50 |
\def\extractcommand#1#2\@@{% |
| 51 |
\pgfmanualentryheadline{\declare{\texttt{\string#1}}#2}% |
| 52 |
\removeats{#1}% |
| 53 |
\index{\strippedat @\protect\myprintocmmand{\strippedat}}} |
| 54 |
|
| 55 |
|
| 56 |
\newenvironment{environment}[1]{ |
| 57 |
\begin{pgfmanualentry} |
| 58 |
\extractenvironement#1\@@ |
| 59 |
\pgfmanualbody |
| 60 |
} |
| 61 |
{ |
| 62 |
\end{pgfmanualentry} |
| 63 |
} |
| 64 |
|
| 65 |
\def\extractenvironement#1#2\@@{% |
| 66 |
\pgfmanualentryheadline{{\ttfamily\char`\\begin\char`\{\declare{#1}\char`\}}#2}% |
| 67 |
\pgfmanualentryheadline{{\ttfamily\ \ }\meta{environment contents}}% |
| 68 |
\pgfmanualentryheadline{{\ttfamily\char`\\end\char`\{\declare{#1}\char`\}}}% |
| 69 |
\index{#1@\protect\texttt{#1} environment}% |
| 70 |
\index{Environments!#1@\protect\texttt{#1}}} |
| 71 |
|
| 72 |
|
| 73 |
\newenvironment{plainenvironment}[1]{ |
| 74 |
\begin{pgfmanualentry} |
| 75 |
\extractplainenvironement#1\@@ |
| 76 |
\pgfmanualbody |
| 77 |
} |
| 78 |
{ |
| 79 |
\end{pgfmanualentry} |
| 80 |
} |
| 81 |
|
| 82 |
\def\extractplainenvironement#1#2\@@{% |
| 83 |
\pgfmanualentryheadline{{\ttfamily\declare{\char`\\#1}}#2}% |
| 84 |
\pgfmanualentryheadline{{\ttfamily\ \ }\meta{environment contents}}% |
| 85 |
\pgfmanualentryheadline{{\ttfamily\declare{\char`\\end#1}}}% |
| 86 |
\index{#1@\protect\texttt{#1} environment}% |
| 87 |
\index{Environments!#1@\protect\texttt{#1}}} |
| 88 |
|
| 89 |
|
| 90 |
\newenvironment{contextenvironment}[1]{ |
| 91 |
\begin{pgfmanualentry} |
| 92 |
\extractcontextenvironement#1\@@ |
| 93 |
\pgfmanualbody |
| 94 |
} |
| 95 |
{ |
| 96 |
\end{pgfmanualentry} |
| 97 |
} |
| 98 |
|
| 99 |
\def\extractcontextenvironement#1#2\@@{% |
| 100 |
\pgfmanualentryheadline{{\ttfamily\declare{\char`\\start#1}}#2}% |
| 101 |
\pgfmanualentryheadline{{\ttfamily\ \ }\meta{environment contents}}% |
| 102 |
\pgfmanualentryheadline{{\ttfamily\declare{\char`\\stop#1}}}% |
| 103 |
\index{#1@\protect\texttt{#1} environment}% |
| 104 |
\index{Environments!#1@\protect\texttt{#1}}} |
| 105 |
|
| 106 |
|
| 107 |
\newenvironment{shape}[1]{ |
| 108 |
\begin{pgfmanualentry} |
| 109 |
\pgfmanualentryheadline{Shape {\ttfamily\declare{#1}}}% |
| 110 |
\index{#1@\protect\texttt{#1} shape}% |
| 111 |
\index{Shapes!#1@\protect\texttt{#1}} |
| 112 |
\pgfmanualbody |
| 113 |
} |
| 114 |
{ |
| 115 |
\end{pgfmanualentry} |
| 116 |
} |
| 117 |
|
| 118 |
\newenvironment{predefinednode}[1]{ |
| 119 |
\begin{pgfmanualentry} |
| 120 |
\pgfmanualentryheadline{Predefined node {\ttfamily\declare{#1}}}% |
| 121 |
\index{#1@\protect\texttt{#1} node}% |
| 122 |
\index{Predefined node!#1@\protect\texttt{#1}} |
| 123 |
\pgfmanualbody |
| 124 |
} |
| 125 |
{ |
| 126 |
\end{pgfmanualentry} |
| 127 |
} |
| 128 |
|
| 129 |
\newenvironment{coordinatesystem}[1]{ |
| 130 |
\begin{pgfmanualentry} |
| 131 |
\pgfmanualentryheadline{Coordinate system {\ttfamily\declare{#1}}}% |
| 132 |
\index{#1@\protect\texttt{#1} coordinate system}% |
| 133 |
\index{Coordinate systems!#1@\protect\texttt{#1}} |
| 134 |
\pgfmanualbody |
| 135 |
} |
| 136 |
{ |
| 137 |
\end{pgfmanualentry} |
| 138 |
} |
| 139 |
|
| 140 |
\newenvironment{snake}[1]{ |
| 141 |
\begin{pgfmanualentry} |
| 142 |
\pgfmanualentryheadline{Snake {\ttfamily\declare{#1}}}% |
| 143 |
\index{#1@\protect\texttt{#1} snake}% |
| 144 |
\index{Snakes!#1@\protect\texttt{#1}} |
| 145 |
\pgfmanualbody |
| 146 |
} |
| 147 |
{ |
| 148 |
\end{pgfmanualentry} |
| 149 |
} |
| 150 |
|
| 151 |
\def\pgfmanualbar{\char`\|} |
| 152 |
\makeatletter |
| 153 |
\newenvironment{pathoperation}[3][]{ |
| 154 |
\begin{pgfmanualentry} |
| 155 |
\pgfmanualentryheadline{\textcolor{gray}{{\ttfamily\char`\\path}\ |
| 156 |
\ \dots} |
| 157 |
\declare{\texttt{#2}}#3\ \textcolor{gray}{\dots\texttt{;}}}% |
| 158 |
\def\pgfmanualtest{#1}% |
| 159 |
\ifx\pgfmanualtest\@empty% |
| 160 |
\index{#2@\protect\texttt{#2} path operation}% |
| 161 |
\index{Path operations!#2@\protect\texttt{#2}}% |
| 162 |
\fi% |
| 163 |
\pgfmanualbody |
| 164 |
} |
| 165 |
{ |
| 166 |
\end{pgfmanualentry} |
| 167 |
} |
| 168 |
\makeatother |
| 169 |
|
| 170 |
\def\extractcommand#1#2\@@{% |
| 171 |
\pgfmanualentryheadline{\declare{\texttt{\string#1}}#2}% |
| 172 |
\removeats{#1}% |
| 173 |
\index{\strippedat @\protect\myprintocmmand{\strippedat}}} |
| 174 |
|
| 175 |
|
| 176 |
\newenvironment{package}[1]{ |
| 177 |
\begin{pgfmanualentry} |
| 178 |
\pgfmanualentryheadline{{\ttfamily\char`\\usepackage\char`\{\declare{#1}\char`\}\space\space \char`\%\space\space \LaTeX}} |
| 179 |
\index{#1@\protect\texttt{#1} package}% |
| 180 |
\index{Packages and files!#1@\protect\texttt{#1}}% |
| 181 |
\pgfmanualentryheadline{{\ttfamily\char`\\input \declare{#1}.tex\space\space\space \char`\%\space\space plain \TeX}} |
| 182 |
\pgfmanualentryheadline{{\ttfamily\char`\\usemodule[\declare{#1}]\space\space \char`\%\space\space Con\TeX t}} |
| 183 |
\pgfmanualbody |
| 184 |
} |
| 185 |
{ |
| 186 |
\end{pgfmanualentry} |
| 187 |
} |
| 188 |
|
| 189 |
|
| 190 |
\newenvironment{pgflibrary}[1]{ |
| 191 |
\begin{pgfmanualentry} |
| 192 |
\pgfmanualentryheadline{{\ttfamily\char`\\usepgflibrary\char`\{\declare{#1}\char`\}\space\space\space |
| 193 |
\char`\%\space\space \LaTeX\space and plain \TeX\space and pure pgf}} |
| 194 |
\index{#1@\protect\texttt{#1} library}% |
| 195 |
\index{Libraries!#1@\protect\texttt{#1}}% |
| 196 |
\pgfmanualentryheadline{{\ttfamily\char`\\usepgflibrary[\declare{#1}]\space\space \char`\%\space\space Con\TeX t\space and pure pgf}} |
| 197 |
\pgfmanualentryheadline{{\ttfamily\char`\\usetikzlibrary\char`\{\declare{#1}\char`\}\space\space |
| 198 |
\char`\%\space\space \LaTeX\space and plain \TeX\space when using \tikzname}} |
| 199 |
\pgfmanualentryheadline{{\ttfamily\char`\\usetikzlibrary[\declare{#1}]\space |
| 200 |
\char`\%\space\space Con\TeX t\space when using \tikzname}} |
| 201 |
\pgfmanualbody |
| 202 |
} |
| 203 |
{ |
| 204 |
\end{pgfmanualentry} |
| 205 |
} |
| 206 |
|
| 207 |
\newenvironment{tikzlibrary}[1]{ |
| 208 |
\begin{pgfmanualentry} |
| 209 |
\pgfmanualentryheadline{{\ttfamily\char`\\usetikzlibrary\char`\{\declare{#1}\char`\}\space\space \char`\%\space\space \LaTeX\space and plain \TeX}} |
| 210 |
\index{#1@\protect\texttt{#1} library}% |
| 211 |
\index{Libraries!#1@\protect\texttt{#1}}% |
| 212 |
\pgfmanualentryheadline{{\ttfamily\char`\\usetikzlibrary[\declare{#1}]\space \char`\%\space\space Con\TeX t}} |
| 213 |
\pgfmanualbody |
| 214 |
} |
| 215 |
{ |
| 216 |
\end{pgfmanualentry} |
| 217 |
} |
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
\newenvironment{filedescription}[1]{ |
| 222 |
\begin{pgfmanualentry} |
| 223 |
\pgfmanualentryheadline{File {\ttfamily\declare{#1}}}% |
| 224 |
\index{#1@\protect\texttt{#1} file}% |
| 225 |
\index{Packages and files!#1@\protect\texttt{#1}}% |
| 226 |
\pgfmanualbody |
| 227 |
} |
| 228 |
{ |
| 229 |
\end{pgfmanualentry} |
| 230 |
} |
| 231 |
|
| 232 |
|
| 233 |
\newenvironment{packageoption}[1]{ |
| 234 |
\begin{pgfmanualentry} |
| 235 |
\pgfmanualentryheadline{{\ttfamily\char`\\usepackage[\declare{#1}]\char`\{pgf\char`\}}} |
| 236 |
\index{#1@\protect\texttt{#1} package option}% |
| 237 |
\index{Package options for \textsc{pgf}!#1@\protect\texttt{#1}}% |
| 238 |
\pgfmanualbody |
| 239 |
} |
| 240 |
{ |
| 241 |
\end{pgfmanualentry} |
| 242 |
} |
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
\newcommand\opt[1]{{\color{black!50!green}#1}} |
| 247 |
\newcommand\ooarg[1]{{\ttfamily[}\meta{#1}{\ttfamily]}} |
| 248 |
|
| 249 |
\def\opt{\afterassignment\pgfmanualopt\let\next=} |
| 250 |
\def\pgfmanualopt{\ifx\next\bgroup\bgroup\color{black!50!green}\else{\color{black!50!green}\next}\fi} |
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
\def\beamer{\textsc{beamer}} |
| 255 |
\def\pdf{\textsc{pdf}} |
| 256 |
\def\pgfname{\textsc{pgf}} |
| 257 |
\def\tikzname{Ti\emph{k}Z} |
| 258 |
\def\pstricks{\textsc{pstricks}} |
| 259 |
\def\prosper{\textsc{prosper}} |
| 260 |
\def\seminar{\textsc{seminar}} |
| 261 |
\def\texpower{\textsc{texpower}} |
| 262 |
\def\foils{\textsc{foils}} |
| 263 |
|
| 264 |
{ |
| 265 |
\makeatletter |
| 266 |
\global\let\myempty=\@empty |
| 267 |
\global\let\mygobble=\@gobble |
| 268 |
\catcode`\@=12 |
| 269 |
\gdef\getridofats#1@#2\relax{% |
| 270 |
\def\getridtest{#2}% |
| 271 |
\ifx\getridtest\myempty% |
| 272 |
\expandafter\def\expandafter\strippedat\expandafter{\strippedat#1} |
| 273 |
\else% |
| 274 |
\expandafter\def\expandafter\strippedat\expandafter{\strippedat#1\protect\printanat} |
| 275 |
\getridofats#2\relax% |
| 276 |
\fi% |
| 277 |
} |
| 278 |
|
| 279 |
\gdef\removeats#1{% |
| 280 |
\let\strippedat\myempty% |
| 281 |
\edef\strippedtext{\stripcommand#1}% |
| 282 |
\expandafter\getridofats\strippedtext @\relax% |
| 283 |
} |
| 284 |
|
| 285 |
\gdef\stripcommand#1{\expandafter\mygobble\string#1} |
| 286 |
} |
| 287 |
|
| 288 |
\def\printanat{\char`\@} |
| 289 |
|
| 290 |
\def\declare{\afterassignment\pgfmanualdeclare\let\next=} |
| 291 |
\def\pgfmanualdeclare{\ifx\next\bgroup\bgroup\color{red!75!black}\else{\color{red!75!black}\next}\fi} |
| 292 |
|
| 293 |
|
| 294 |
\let\textoken=\command |
| 295 |
\let\endtextoken=\endcommand |
| 296 |
|
| 297 |
\def\myprintocmmand#1{\texttt{\char`\\#1}} |
| 298 |
|
| 299 |
\def\example{\par\smallskip\noindent\textit{Example: }} |
| 300 |
\def\themeauthor{\par\smallskip\noindent\textit{Theme author: }} |
| 301 |
|
| 302 |
\def\itemoption#1{\item \declare{\texttt{#1}}% |
| 303 |
\indexoption{#1}% |
| 304 |
} |
| 305 |
|
| 306 |
\def\indexoption#1{% |
| 307 |
\index{#1@\protect\texttt{#1} option}% |
| 308 |
\index{Graphic options!#1@\protect\texttt{#1}}% |
| 309 |
} |
| 310 |
|
| 311 |
\def\itemstyle#1{\item \texttt{style=}\declare{\texttt{#1}}% |
| 312 |
\index{#1@\protect\texttt{#1} style}% |
| 313 |
\index{Styles!#1@\protect\texttt{#1}}% |
| 314 |
} |
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
\def\class#1{\list{}{\leftmargin=2em\itemindent-\leftmargin\def\makelabel##1{\hss##1}}% |
| 319 |
\extractclass#1@\par\topsep=0pt} |
| 320 |
\def\endclass{\endlist} |
| 321 |
\def\extractclass#1#2@{% |
| 322 |
\item{{{\ttfamily\char`\\documentclass}#2{\ttfamily\char`\{\declare{#1}\char`\}}}}% |
| 323 |
\index{#1@\protect\texttt{#1} class}% |
| 324 |
\index{Classes!#1@\protect\texttt{#1}}} |
| 325 |
|
| 326 |
\def\partname{Part} |
| 327 |
|
| 328 |
\makeatletter |
| 329 |
%\def\index@prologue{\section*{Index}\addcontentsline{toc}{section}{Index} |
| 330 |
% This index only contains automatically generated entries. A good |
| 331 |
% index should also contain carefully selected keywords. This index is |
| 332 |
% not a good index. |
| 333 |
% \bigskip |
| 334 |
%} |
| 335 |
%\c@IndexColumns=2 |
| 336 |
% \def\theindex{\@restonecoltrue |
| 337 |
% \columnseprule \z@ \columnsep 35\p@ |
| 338 |
% \twocolumn[\index@prologue]% |
| 339 |
% \parindent -30pt |
| 340 |
% \columnsep 15pt |
| 341 |
% \parskip 0pt plus 1pt |
| 342 |
% \leftskip 30pt |
| 343 |
% \rightskip 0pt plus 2cm |
| 344 |
% \small |
| 345 |
% \def\@idxitem{\par}% |
| 346 |
% \let\item\@idxitem \ignorespaces} |
| 347 |
% \def\endtheindex{\onecolumn} |
| 348 |
%\def\noindexing{\let\index=\@gobble} |
| 349 |
|
| 350 |
|
| 351 |
%\newcommand\patternindex[1]{ |
| 352 |
% \index{#1@\protect\texttt{#1} pattern}% |
| 353 |
% \index{Patterns!#1@\protect\texttt{#1}} |
| 354 |
% \texttt{#1}& |
| 355 |
% \begin{tikzpicture} |
| 356 |
% \path[draw=black!50,very thin,pattern=#1,rounded corners] |
| 357 |
% (0pt,0pt) rectangle (1cm,1.5em); |
| 358 |
% \end{tikzpicture} |
| 359 |
%} |
| 360 |
% |
| 361 |
% |
| 362 |
%\newcommand\symarrow[1]{ |
| 363 |
% \index{#1@\protect\texttt{#1} arrow tip}% |
| 364 |
% \index{Arrow tips!#1@\protect\texttt{#1}} |
| 365 |
% \texttt{#1}& yields thick |
| 366 |
% \begin{tikzpicture}[arrows={#1-#1},thick,baseline] |
| 367 |
% \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); |
| 368 |
% \draw (0pt,.5ex) -- (1cm,.5ex); |
| 369 |
% \end{tikzpicture} and thin |
| 370 |
% \begin{tikzpicture}[arrows={#1-#1},thin,baseline] |
| 371 |
% \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); |
| 372 |
% \draw (0pt,.5ex) -- (1cm,.5ex); |
| 373 |
% \end{tikzpicture} |
| 374 |
%} |
| 375 |
% |
| 376 |
%\newcommand\sarrow[2]{ |
| 377 |
% \index{#1@\protect\texttt{#1} arrow tip}% |
| 378 |
% \index{Arrow tips!#1@\protect\texttt{#1}} |
| 379 |
% \index{#2@\protect\texttt{#2} arrow tip}% |
| 380 |
% \index{Arrow tips!#2@\protect\texttt{#2}} |
| 381 |
% \texttt{#1-#2}& yields thick |
| 382 |
% \begin{tikzpicture}[arrows={#1-#2},thick,baseline] |
| 383 |
% \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); |
| 384 |
% \draw (0pt,.5ex) -- (1cm,.5ex); |
| 385 |
% \end{tikzpicture} and thin |
| 386 |
% \begin{tikzpicture}[arrows={#1-#2},thin,baseline] |
| 387 |
% \useasboundingbox (0pt,-0.5ex) rectangle (1cm,2ex); |
| 388 |
% \draw (0pt,.5ex) -- (1cm,.5ex); |
| 389 |
% \end{tikzpicture} |
| 390 |
%} |
| 391 |
% |
| 392 |
%\newcommand\carrow[1]{ |
| 393 |
% \index{#1@\protect\texttt{#1} arrow tip}% |
| 394 |
% \index{Arrow tips!#1@\protect\texttt{#1}} |
| 395 |
% \texttt{#1}& yields for line width 1ex |
| 396 |
% \begin{tikzpicture}[arrows={#1-#1},line width=1ex,baseline] |
| 397 |
% \useasboundingbox (0pt,-0.5ex) rectangle (1.5cm,2ex); |
| 398 |
% \draw (0pt,.5ex) -- (1.5cm,.5ex); |
| 399 |
% \end{tikzpicture} |
| 400 |
%} |
| 401 |
%\def\myvbar{\char`\|} |
| 402 |
%\newcommand\plotmarkentry[1]{% |
| 403 |
% \index{#1@\protect\texttt{#1} plot mark}% |
| 404 |
% \index{Plot marks!#1@\protect\texttt{#1}} |
| 405 |
% \texttt{\char`\\pgfuseplotmark\char`\{\declare{#1}\char`\}} & |
| 406 |
% \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)};\\ |
| 407 |
%} |
| 408 |
%\newcommand\plotmarkentrytikz[1]{% |
| 409 |
% \index{#1@\protect\texttt{#1} plot mark}% |
| 410 |
% \index{Plot marks!#1@\protect\texttt{#1}} |
| 411 |
% \texttt{mark=\declare{#1}} & \tikz\draw[color=black!25] |
| 412 |
% plot[mark=#1,mark options={fill=examplefill,draw=black}] |
| 413 |
% coordinates {(0,0) (.5,0.2) (1,0) (1.5,0.2)};\\ |
| 414 |
%} |
| 415 |
% |
| 416 |
|
| 417 |
|
| 418 |
\ifx\scantokens\@undefined |
| 419 |
\PackageError{pgfmanual-macros}{You need to use extended latex |
| 420 |
(elatex) or (pdfelatex) to process this document}{} |
| 421 |
\fi |
| 422 |
|
| 423 |
\begingroup |
| 424 |
\catcode`|=0 |
| 425 |
\catcode`[= 1 |
| 426 |
\catcode`]=2 |
| 427 |
\catcode`\{=12 |
| 428 |
\catcode `\}=12 |
| 429 |
\catcode`\\=12 |gdef|find@example#1\end{codeexample}[|endofcodeexample[#1]] |
| 430 |
|endgroup |
| 431 |
|
| 432 |
\begingroup |
| 433 |
\catcode`\^=7 |
| 434 |
\catcode`\^^M=13 |
| 435 |
\catcode`\ =13% |
| 436 |
\gdef\returntospace{\catcode`\ =13\def {\space}\catcode`\^^M=13\def^^M{}}% |
| 437 |
\endgroup |
| 438 |
|
| 439 |
\begingroup |
| 440 |
\catcode`\%=13 |
| 441 |
\catcode`\^^M=13 |
| 442 |
\gdef\commenthandler{\catcode`\%=13\def%{\@gobble@till@return}} |
| 443 |
\gdef\@gobble@till@return#1^^M{} |
| 444 |
\gdef\typesetcomment{\catcode`\%=13\def%{\@typeset@till@return}} |
| 445 |
\gdef\@typeset@till@return#1^^M{{\def%{\char`\%}\textsl{\char`\%#1}}\par} |
| 446 |
\endgroup |
| 447 |
|
| 448 |
\define@key{codeexample}{width}{\setlength\codeexamplewidth{#1}} |
| 449 |
\define@key{codeexample}{graphic}{\colorlet{graphicbackground}{#1}} |
| 450 |
\define@key{codeexample}{code}{\colorlet{codebackground}{#1}} |
| 451 |
\define@key{codeexample}{execute code}{\csname code@execute#1\endcsname} |
| 452 |
\define@key{codeexample}{code only}[]{\code@executefalse} |
| 453 |
\define@key{codeexample}{pre}{\def\code@pre{#1}} |
| 454 |
\define@key{codeexample}{post}{\def\code@post{#1}} |
| 455 |
|
| 456 |
\def\code@pre{} |
| 457 |
\def\code@post{} |
| 458 |
|
| 459 |
\newdimen\codeexamplewidth |
| 460 |
\newif\ifcode@execute |
| 461 |
\newbox\codeexamplebox |
| 462 |
\def\codeexample[#1]{% |
| 463 |
\code@executetrue |
| 464 |
\setlength\codeexamplewidth{4cm+7pt} |
| 465 |
\setkeys{codeexample}{#1}% |
| 466 |
\parindent0pt |
| 467 |
\begingroup% |
| 468 |
\par% |
| 469 |
\medskip% |
| 470 |
\let\do\@makeother% |
| 471 |
\dospecials% |
| 472 |
\obeylines% |
| 473 |
\@vobeyspaces% |
| 474 |
\catcode`\%=13% |
| 475 |
\catcode`\^^M=13% |
| 476 |
\find@example} |
| 477 |
\def\endofcodeexample#1{% |
| 478 |
\endgroup% |
| 479 |
\ifcode@execute% |
| 480 |
\setbox\codeexamplebox=\hbox{% |
| 481 |
{% |
| 482 |
{% |
| 483 |
\returntospace% |
| 484 |
\commenthandler% |
| 485 |
\xdef\code@temp{#1}% removes returns and comments |
| 486 |
}% |
| 487 |
\colorbox{graphicbackground}{\color{black}\ignorespaces% |
| 488 |
\code@pre\expandafter\scantokens\expandafter{\code@temp\ignorespaces}\code@post\ignorespaces}% |
| 489 |
}% |
| 490 |
}% |
| 491 |
\ifdim\wd\codeexamplebox>\codeexamplewidth% |
| 492 |
\def\code@start{\par}% |
| 493 |
\def\code@flushstart{}\def\code@flushend{}% |
| 494 |
\def\code@mid{\parskip2pt\par\noindent}% |
| 495 |
\def\code@width{\linewidth-6pt}% |
| 496 |
\def\code@end{}% |
| 497 |
\else% |
| 498 |
\def\code@start{% |
| 499 |
\linewidth=\textwidth% |
| 500 |
\parshape \@ne 0pt \linewidth |
| 501 |
\leavevmode% |
| 502 |
\hbox\bgroup}% |
| 503 |
\def\code@flushstart{\hfill}% |
| 504 |
\def\code@flushend{\hbox{}}% |
| 505 |
\def\code@mid{\hskip6pt}% |
| 506 |
\def\code@width{\linewidth-12pt-\codeexamplewidth}% |
| 507 |
\def\code@end{\egroup}% |
| 508 |
\fi% |
| 509 |
\code@start% |
| 510 |
\noindent% |
| 511 |
\begin{minipage}[t]{\codeexamplewidth}\raggedright |
| 512 |
\hrule width0pt% |
| 513 |
\footnotesize\vskip-1em% |
| 514 |
\code@flushstart\box\codeexamplebox\code@flushend% |
| 515 |
\vskip-1ex |
| 516 |
\leavevmode% |
| 517 |
\end{minipage}% |
| 518 |
\else% |
| 519 |
\def\code@mid{\par} |
| 520 |
\def\code@width{\linewidth-6pt} |
| 521 |
\def\code@end{} |
| 522 |
\fi% |
| 523 |
\code@mid% |
| 524 |
\colorbox{codebackground}{% |
| 525 |
\begin{minipage}[t]{\code@width}% |
| 526 |
{% |
| 527 |
\let\do\@makeother |
| 528 |
\dospecials |
| 529 |
\frenchspacing\@vobeyspaces |
| 530 |
\normalfont\ttfamily\footnotesize |
| 531 |
\typesetcomment% |
| 532 |
\@tempswafalse |
| 533 |
\def\par{% |
| 534 |
\if@tempswa |
| 535 |
\leavevmode \null \@@par\penalty\interlinepenalty |
| 536 |
\else |
| 537 |
\@tempswatrue |
| 538 |
\ifhmode\@@par\penalty\interlinepenalty\fi |
| 539 |
\fi}% |
| 540 |
\obeylines |
| 541 |
\everypar \expandafter{\the\everypar \unpenalty}% |
| 542 |
#1} |
| 543 |
\end{minipage}}% |
| 544 |
\code@end% |
| 545 |
\par% |
| 546 |
\medskip |
| 547 |
\end{codeexample} |
| 548 |
} |
| 549 |
|
| 550 |
\def\endcodeexample{} |
| 551 |
|
| 552 |
|
| 553 |
\makeatother |
| 554 |
|
| 555 |
|
| 556 |
%%% Local Variables: |
| 557 |
%%% mode: latex |
| 558 |
%%% TeX-master: "beameruserguide" |
| 559 |
%%% End: |