Debian Codegraph @

texmf-dist/doc/latex/tkz-orm/pgfmanualstyle.sty

raw
1 %<–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––>
2 %
3 % Copyright 2010 by Jakob Voss
4 %
5 % This file is based on works by Till Tantau. It contains additions and/or
6 % modifications by Jakob Voss and Rouben Rostamian. It may be distributed
7 % and/or modified
8 %
9 % 1. under the LaTeX Project Public License and/or
10 % 2. under the GNU Free Documentation License.
11 %
12 % See the file LICENSE for more details.
13
14 %<–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––>
15 \NeedsTeXFormat{LaTeX2e}
16 \ProvidesPackage{pgfmanualstyle}[2010/01/24 v0.1 pgfmanualstyle]
17 \RequirePackage{tikz}[2009/09/04]
18
19 %<–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––>
20 % code from pgfmanual-en-macros.tex
21 %<–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––>
22 \definecolor{graphicbackground}{rgb}{0.96,0.96,0.8}
23 \definecolor{codebackground}{rgb}{0.8,0.8,1}
24
25 \makeatletter
26
27 \begingroup
28 \catcode`|=0
29 \catcode`[= 1
30 \catcode`]=2
31 \catcode`\{=12
32 \catcode `\}=12
33 \catcode`\\=12 |gdef|find@example#1\end{codeexample}[|endofcodeexample[#1]]
34 |endgroup
35 %
36 \begingroup
37 \catcode`\^=7
38 \catcode`\^^M=13
39 \catcode`\ =13%
40 \gdef\returntospace{\catcode`\ =13\def {\space}\catcode`\^^M=13\def^^M{}}%
41 \endgroup
42 %
43 \begingroup
44 \catcode`\%=13
45 \catcode`\^^M=13
46 \gdef\commenthandler{\catcode`\%=13\def%{\@gobble@till@return}}
47 \gdef\@gobble@till@return#1^^M{}
48 \gdef\typesetcomment{\catcode`\%=13\def%{\@typeset@till@return}}
49 \gdef\@typeset@till@return#1^^M{{\def%{\char`\%}\textsl{\char`\%#1}}\par}
50 \endgroup
51 %
52 \define@key{codeexample}{width}{\setlength\codeexamplewidth{#1}}
53 \define@key{codeexample}{graphic}{\colorlet{graphicbackground}{#1}}
54 \define@key{codeexample}{code}{\colorlet{codebackground}{#1}}
55 \define@key{codeexample}{execute code}{\csname code@execute#1\endcsname}
56 \define@key{codeexample}{code only}[]{\code@executefalse}
57 \define@key{codeexample}{pre}{\def\code@pre{#1}}
58 \define@key{codeexample}{post}{\def\code@post{#1}}
59 %
60 \def\code@pre{}
61 \def\code@post{}
62 %
63 \newdimen\finalcodeexamplewidth % XXX
64 \newdimen\codeexamplewidth
65 \newif\ifcode@execute
66 \newbox\codeexamplebox
67 \def\codeexample[#1]{%
68 \code@executetrue
69 \setlength\codeexamplewidth{4cm}%
70 \addtolength\codeexamplewidth{7pt}%
71 \setkeys{codeexample}{#1}%
72 \parindent0pt
73 \begingroup%
74 \par%
75 \medskip%
76 \let\do\@makeother%
77 \dospecials%
78 \obeylines%
79 \@vobeyspaces%
80 \catcode`\%=13%
81 \catcode`\^^M=13%
82 \find@example}
83 \def\endofcodeexample#1{%
84 \endgroup%
85 \ifcode@execute%
86 \setbox\codeexamplebox=\hbox{%
87 {%
88 {%
89 \returntospace%
90 \commenthandler%
91 \xdef\code@temp{#1}% removes returns and comments
92 }%
93 \colorbox{graphicbackground}{\color{black}\ignorespaces%
94 \code@pre\expandafter\scantokens\expandafter{\code@temp\ignorespaces}\code@post\ignorespaces}%
95 }%
96 }%
97 \ifdim\wd\codeexamplebox>\codeexamplewidth%
98 \def\code@start{\par}%
99 \def\code@flushstart{}\def\code@flushend{}%
100 \def\code@mid{\parskip2pt\par\noindent}%
101 %\def\code@width{\linewidth-6pt}% XXX
102 \setlength\finalcodeexamplewidth{\linewidth} % XXX
103 \addtolength\finalcodeexamplewidth{-6pt} % XXX
104 \def\code@end{}%
105 \else%
106 \def\code@start{%
107 \linewidth=\textwidth%
108 \parshape \@ne 0pt \linewidth
109 \leavevmode%
110 \hbox\bgroup}%
111 \def\code@flushstart{\hfill}%
112 \def\code@flushend{\hbox{}}%
113 \def\code@mid{\hskip6pt}%
114 %\def\code@width{\linewidth-12pt-\codeexamplewidth}% XXX
115 \setlength\finalcodeexamplewidth{\linewidth} % XXX
116 \addtolength\finalcodeexamplewidth{-12pt} % XXX
117 \addtolength\finalcodeexamplewidth{-\codeexamplewidth} % XXX
118 \def\code@end{\egroup}%
119 \fi%
120 \code@start%
121 \noindent%
122 \begin{minipage}[t]{\codeexamplewidth}\raggedright
123 \hrule width0pt%
124 \footnotesize\vskip-1em%
125 \code@flushstart\box\codeexamplebox\code@flushend%
126 \vskip-1ex
127 \leavevmode%
128 \end{minipage}%
129 \else%
130 \def\code@mid{\par}
131 %\def\code@width{\linewidth-6pt}% XXX
132 \setlength\finalcodeexamplewidth{\linewidth} % XXX
133 \addtolength\finalcodeexamplewidth{-6pt} % XXX
134 \def\code@end{}
135 \fi%
136 \code@mid%
137 \colorbox{codebackground}{%
138 % \begin{minipage}[t]{\code@width}% XXX
139 \begin{minipage}[t]{\the\finalcodeexamplewidth}%
140 {%
141 \let\do\@makeother
142 \dospecials
143 \frenchspacing\@vobeyspaces
144 \normalfont\ttfamily\footnotesize
145 \typesetcomment%
146 \@tempswafalse
147 \def\par{%
148 \if@tempswa
149 \leavevmode \null \@@par\penalty\interlinepenalty
150 \else
151 \@tempswatrue
152 \ifhmode\@@par\penalty\interlinepenalty\fi
153 \fi}%
154 \obeylines
155 \everypar \expandafter{\the\everypar \unpenalty}%
156 #1}
157 \end{minipage}}%
158 \code@end%
159 \par%
160 \medskip
161 \end{codeexample}
162 }
163
164 \def\endcodeexample{}
165
166
167 %<–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––>
168 % code from various pgf/tikz source files and own modifications or additions
169 %<–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––>
170
171 \newenvironment{pgfmanualentry}{\list{}{\leftmargin=2em\itemindent-\leftmargin\def\makelabel##1{\hss##1}}}{\endlist}
172 \newcommand\pgfmanualentryheadline[1]{\itemsep=0pt\parskip=0pt\item\strut{#1}\par\topsep=0pt}
173 \newcommand\pgfmanualbody{\parskip3pt}
174
175 \definecolor{darkred}{rgb}{0.75,0,0}
176 \definecolor{green}{rgb}{0,.75,0}
177
178 \def\bschar{{\char`\\}}
179
180 \newcommand{\stylekeyheadline}[2][\pgfutil@empty]{%
181 \pgfmanualentryheadline{\texttt{\color{darkred}/tikz/#2}%
182 \def\pgf@test{#1}%
183 \ifx\pgf@test\pgfutil@empty%
184 \else%
185 \texttt{=}#1%
186 \fi%
187 \index{#2@\texttt{#2} key}}%
188 }
189
190 \newenvironment{stylekey}[2][]{
191 \begin{pgfmanualentry}
192 \stylekeyheadline[#1]{#2}
193 \pgfmanualbody
194 }{
195 \end{pgfmanualentry}
196 }
197 \newcommand{\commandentry}[2][]{%
198 \texttt{\color{darkred}\textbackslash #2}#1%
199 \index{#2@\texttt{\textbackslash #2}}
200 }
201 \newenvironment{command}[2][]{
202 \begin{pgfmanualentry}
203 \pgfmanualentryheadline{\commandentry{#2}{#1}}
204 \pgfmanualbody
205 }{
206 \end{pgfmanualentry}
207 }
208 \newcommand\arrowtip[1]{
209 \texttt{#1}\index{Arrow tips!mandatory@\protect\texttt{mandatory}}%
210 }
211
212 \newcommand{\opt}[1]{\color{green}#1}
213 \newcommand{\meta}[1]{$\langle$\textit{#1}$\rangle$}
214 \newcommand{\marg}[1]{\texttt{\textbraceleft}\meta{#1}\texttt{\textbraceright}}
215 \newcommand{\oarg}[1]{\texttt{\textbraceleft} \texttt{\textbraceright}}
216
217 % Global styles:
218 \tikzset{
219 shape example/.style={
220 color=black!30,
221 draw,
222 fill=yellow!30,
223 line width=.25cm, % .5
224 inner xsep=1.25cm, % 2.5
225 inner ysep=0.25cm} % 0.5
226 }
227
228 \def\tikzname{Ti\emph{k}Z}
229
230 \makeatother
231
232 %%% Enable '|' to type verbatim
233
234 \usepackage{fancyvrb}
235 \DefineShortVerb{\|}
236
237 %<–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––>
238 \endinput