Debian Codegraph @

texmf-dist/tex/latex/esk/esk.sty

raw
1 %%
2 %% This is file `esk.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% esk.dtx (with options: `style')
8 %%
9 %% Copyright (C) 2010 Tom Kazimiers (tom AT voodoo-arts.net)
10 %% Based on the Makefile of emp latex package by Thorsten Ohl
11 %% ([email protected])
12 %%
13 %% This file is NOT the source for esk, because almost all comments
14 %% have been stripped from it. It is NOT the preferred form of esk
15 %% for making modifications to it.
16 %%
17 %% Therefore you can NOT redistribute and/or modify THIS file. You can
18 %% however redistribute the complete source (esk.dtx and esk.ins)
19 %% and/or modify it under the terms of the GNU General Public License as
20 %% published by the Free Software Foundation; either version 2, or (at
21 %% your option) any later version.
22 %%
23 %% As a special exception, you can redistribute parts of this file for
24 %% the electronic distribution of scientific papers, provided that you
25 %% include a short note pointing to the complete source.
26 %%
27 %% Esk is distributed in the hope that it will be useful, but
28 %% WITHOUT ANY WARRANTY; without even the implied warranty of
29 %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 %% GNU General Public License for more details.
31 %%
32 %% You should have received a copy of the GNU General Public License
33 %% along with this program; if not, write to the Free Software
34 %% Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
35 %%
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37 %%
38 %% \CheckSum{397}
39 %% \CharacterTable
40 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
41 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
42 %% Digits \0\1\2\3\4\5\6\7\8\9
43 %% Exclamation \! Double quote \" Hash (number) \#
44 %% Dollar \$ Percent \% Ampersand \&
45 %% Acute accent \' Left paren \( Right paren \)
46 %% Asterisk \* Plus \+ Comma \,
47 %% Minus \- Point \. Solidus \/
48 %% Colon \: Semicolon \; Less than \<
49 %% Equals \= Greater than \> Question mark \?
50 %% Commercial at \@ Left bracket \[ Backslash \\
51 %% Right bracket \] Circumflex \^ Underscore \_
52 %% Grave accent \` Left brace \{ Vertical bar \|
53 %% Right brace \} Tilde \~}
54 %%
55 %%
56 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 %% TeX hints:
58 %% - @ is considered a normal letter in packages and classes
59 %% - There are 256 32Bit \count<num> registers (i.e. \count0=42),
60 %% can be expanded with \the<register> (i.e. \the\count0)
61 %% - \relax ends scanning for tokens
62 %% (i.e. \count0=\macro 42 <> \count0=\macro\relax 42)
63 %% - A macro defined with can has a maximum of 9 arguments
64 %% - \gdef is shortcut for \global\def
65 %% \xdef is shortcut for \global\edef
66 %% - \string<\macro> returns the "macro" (the name of a macro)
67 %% Doc hints:
68 %% - There must be _exactly_ four spaces between the "%" and the
69 %% "\begin{macrocode}" or "\end{macrocode}. Otherwise, Doc
70 %% won't detect the end of the code fragment.
71 %% - The lines of code withen \begin{macrocode}...\end{macrocode}
72 %% get written exactly as is to the .ins file, with no %-stripping.
73 \def\fileversion{v1.0}
74 {\def\RCS#1#2\endRCS{%
75 % is the first parameter a "$%?
76 \ifx$#1%
77 \@RCS $#2 \endRCS
78 \else
79 \@RCS $*: #1#2$ \endRCS
80 \fi}%
81 \def\@RCS $#1: #2,v #3 #4 #5 #6 #7$ \endRCS{%
82 % global defines (independent of current scope) of file attributes
83 \gdef\filename{#2}%
84 \gdef\filerevision{#3}%
85 \gdef\filedate{#4}%
86 \gdef\filemaintainer{#6}}%
87 \RCS $Id: esk.dtx,v 1.0 2010/05/05 01:23:42 kazimiers Exp $ \endRCS}%
88 \NeedsTeXFormat{LaTeX2e}
89 \ProvidesPackage{esk}[\filedate\space\fileversion\space
90 Encapsulated Sketch LaTeX Package (\filemaintainer)]
91 \RequirePackage{verbatim}
92 \RequirePackage{kvsetkeys}[2007/09/29]
93 {\catcode`\%=11\gdef\p@rcent{%}}
94 {\catcode`\>=1 \catcode`\<=2
95 \catcode`\{=11 \catcode`\}=11
96 \gdef\lc@rly>{<
97 \gdef\rc@rly>}<
98 \catcode`\{=1 \catcode`\}=2
99 }
100 \def\eskwrite#1{%
101 \if@eskio
102 \immediate\write\@outesk{#1}%
103 \fi
104 \ignorespaces}
105 \def\eskwritetoken#1{
106 \eskwrite{\the#1}}
107 \newif\if@eskio
108 \@eskiotrue
109 \newwrite\@outesk
110 \newcommand{\eskfile}[1][\jobname]{%
111 \def\theeskfile{#1}%
112 \if@eskio
113 \@ifundefined{ifmeasuring@}%
114 {}%
115 {\def\if@eskio{\ifmeasuring@\else}}%
116 \immediate\openout\@outesk=\theeskfile.sk\relax
117 \eskwrite{\p@rcent\p@rcent\p@rcent\space \theeskfile.sk -- %
118 do not edit, generated automatically by \jobname.tex}%
119 \expandafter\ifx\expandafter*\the\esk@prelude*\else
120 \eskwrite{\the\esk@prelude}%
121 \fi
122 \fi}
123 \let\theeskfile\relax
124 \newcounter{eskfig}
125 \newtoks\esk@prelude
126 \def\eskprelude#1{\esk@prelude={#1}}
127 \def\eskaddtoprelude#1{\esk@prelude=\expandafter{\the\esk@prelude^^J#1}}
128 \newtoks\esk@globals
129 \esk@globals={language tikz}
130 \def\eskglobals#1{\esk@globals={#1}}
131 \def\eskaddtoglobals#1{\esk@globals=\expandafter{\the\esk@globals,#1}}
132 \def\endeskfile{%
133 \expandafter\ifx\expandafter*\the\esk@globals*\else
134 \eskwrite{global \lc@rly\the\esk@globals\rc@rly }%
135 \fi
136 \eskwrite{\p@rcent\p@rcent\p@rcent\space the end.^^J}%
137 \let\theeskfile\relax
138 \if@eskio
139 \immediate\closeout\@outesk
140 \fi}
141 \newcommand{\esk}[1][\jobname]{%
142 \def\esk@@name{#1}%
143 \esk@}
144 \let\leftparanthesis=(
145 \def\esk@{
146 \futurelet\next\esk@impl}
147 \def\esk@impl{%
148 \ifx\next\leftparanthesis
149 \expandafter\esk@impl@Arg
150 \else
151 \expandafter\esk@impl@NoArg
152 \fi}
153 \def\esk@impl@NoArg{\esk@impl@Arg()}
154 \def\esk@impl@Arg(#1){%
155 \esk@start%
156 \esk@includegraphics{\theeskfile}%
157 \comma@parse{#1}{\esk@def@processor}%
158 \esk@cmds{eskwritetoken}}
159 \def\esk@def@processor#1{
160 \esk@use{#1}}
161 \def\esk@start{%
162 \global\expandafter\advance\csname c@eskfig\endcsname \@ne
163 \esk@checkfile
164 \esk@@def{\esk@@name}}
165 \def\esk@checkfile{%
166 \ifx\theeskfile\relax
167 \eskfile[\esk@@name.\arabic{eskfig}]
168 \fi
169 \ifx\theeskfile\relax
170 \errmessage{Could not open file "\esk@@name.\arabic{eskfig}.sk"!}
171 \fi}
172 \def\esk@includegraphics#1{%
173 \leavevmode
174 \IfFileExists{#1.sk.tex}%
175 {\input{#1.sk.tex}}%
176 {\typeout{%
177 esk: File #1.sk.tex\space not found:^^J%
178 esk: Process #1.sk with Sketch (-o #1.sk.tex) and then %
179 reprocess this file.}}}
180 \newcommand{\esk@cmds}[1]{%
181 \begingroup
182 \@bsphack
183 \let\do\@makeother\dospecials
184 \catcode`\^^M\active
185 \def\verbatim@processline{\csname#1\endcsname{\verbatim@line}}%
186 \verbatim@start}%
187 \def\endesk@cmds{%
188 \@esphack
189 \endgroup}
190 \def\endesk{%
191 \endesk@cmds
192 \endeskfile}
193 %% \iffalse TODO: Make it more robust by remembering old name
194 %% and setting it back afterwards (if any), so it can
195 %% be used in esk environments \fi
196 \newcommand{\eskdef}[1]{%
197 %% Define a new name
198 \def\esk@@def@name{esk@def:#1}%
199 \esk@def}
200 \def\esk@def{%
201 \expandafter\ifcsname\esk@@def@name\endcsname
202 \errmessage{"\esk@@def@name" is already defined!}
203 \fi
204 \expandafter\tok@newtoks\csname\esk@@def@name\endcsname
205 \global\edef\esk@@def@reg{\csname\esk@@def@name\endcsname}
206 \esk@cmds{esk@def@verb@proc}}
207 \global\def\esk@@def@reg{}
208 \def\esk@def@verb@proc#1{%
209 \expandafter\let\expandafter\token@reg\esk@@def@reg
210 \expandafter\ifx\expandafter*\the\token@reg*
211 \global\esk@@def@reg=\expandafter{\the#1}
212 \else
213 \global\esk@@def@reg=\expandafter{%
214 \the\expandafter\token@reg\expandafter^^J\the#1}
215 \fi}
216 \def\endeskdef{
217 \endesk@cmds}
218 \def\esk@@def#1{%
219 \global\e@namedef{esk@k:f:#1}{\theeskfile}%
220 \global\e@namedef{esk@k:c:#1}{\theeskfig}}
221 \def\e@namedef#1{%
222 \expandafter\edef\csname #1\endcsname}
223 \def\esk@use#1{%
224 \def\esk@@def@name{esk@def:#1}%
225 \expandafter\ifcsname\esk@@def@name\endcsname
226 \eskwrite{\p@rcent\p@rcent\space included definition: #1}%
227 \expandafter\eskwritetoken\expandafter{%
228 \expandafter\csname\esk@@def@name\endcsname}
229 \eskwrite{^^J}
230 \else
231 \errmessage{esk: "#1" is undefined!}
232 \fi
233 }
234 \def\tok@newtoks{
235 \csname newtoks\endcsname}
236 \def\futurenospacelet#1{\def\cs{#1}%
237 \afterassignment\stepone\let\nexttoken= }
238 \def\\{\let\stoken= } \\
239 \def\stepone{\expandafter\futurelet\cs\steptwo}
240 \def\steptwo{\expandafter\ifx\cs\stoken\let\next=\stepthree
241 \else\let\next=\nexttoken\fi \next}
242 \def\stepthree{\afterassignment\stepone\let\next= }
243
244 \endinput
245 %%
246 %% End of file `esk.sty'.