Debian Codegraph @

texmf-dist/tex/latex/hf-tikz/hf-tikz.sty

raw
1 %%
2 %% This is file `hf-tikz.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% hf-tikz.dtx (with options: `package')
8 %% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
9 %% * hf-tikz --- A simple way to highlight formulas and formula parts.
10 %% *
11 %% * E-mail: claudio dot fiandrino at gmail dot com
12 %% *
13 %% * Released under the LaTeX Project Public License v1.3c or later
14 %% *
15 %% * See http://www.latex-project.org/lppl.txt
16 %% * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
17 \NeedsTeXFormat{LaTeX2e}
18 \ProvidesPackage{hf-tikz}[2014/07/25 v0.3a A simple way to highlight formulas and formula parts.]
19
20
21
22 \RequirePackage{tikz}
23 \usetikzlibrary{shadings}
24 \RequirePackage{xparse}
25 \RequirePackage{etoolbox}
26 \AtEndDocument{%
27 \let\oldpgfsyspdfmark\pgfsyspdfmark
28 \def\pgfsyspdfmark#1#2#3{%
29 \expandafter\let\expandafter\tmp\csname pgf@sys@pdf@mark@pos@#1\endcsname
30 \oldpgfsyspdfmark{#1}{#2}{#3}%
31 \expandafter\ifx\csname pgf@sys@pdf@mark@pos@#1\endcsname\tmp\else
32 \let\oldsavepointas\savepointas
33 \def\savepointas##1##2{%
34 \immediate\write\@auxout{hf-TikZ Warning: Mark '##1' changed. Rerun to get mark in right position.}%
35 }
36 \fi
37 }}
38 %% Colors
39
40 \definecolor{fancybrown}{RGB}{255,216,197}
41 \definecolor{fancyviolet}{RGB}{197,122,197}
42
43 \newcommand{\fcol}{fancybrown}
44 \newcommand{\bcol}{fancyviolet}
45
46 %% Package option
47
48 \newbool{fill}
49 \booltrue{fill}
50 \DeclareOption{nofill}{\boolfalse{fill}}
51
52 \DeclareOption{customcolors}{
53 \def\hfsetfillcolor#1{\renewcommand{\fcol}{#1}}
54 \def\hfsetbordercolor#1{\renewcommand{\bcol}{#1}}
55 \pgfkeys{/tikz/.cd,
56 set fill color/.code={\renewcommand{\fcol}{#1}},
57 set border color/.code={\renewcommand{\bcol}{#1}}
58 }
59 }
60
61 \newbool{shade}
62 \boolfalse{shade}
63 \DeclareOption{shade}{\booltrue{shade}}
64
65 \newbool{beamer}
66 \boolfalse{beamer}
67 \DeclareOption{beamer}{\booltrue{beamer}}
68
69 \newbool{norndcorners}
70 \boolfalse{norndcorners}
71 \DeclareOption{norndcorners}{\booltrue{norndcorners}}
72
73 \newbool{markings}
74 \boolfalse{markings}
75 \DeclareOption{markings}{\booltrue{markings}}
76
77 \ProcessOptions
78 \pgfkeys{/tikz/.cd,%
79 not use rounded corners/.is choice,%
80 not use rounded corners/true/.style={rounded corners=0pt},%
81 not use rounded corners/false/.style={rounded corners},%
82 }%
83
84 \tikzset{disable rounded corners/.estyle={%
85 not use rounded corners=#1,%
86 },%
87 disable rounded corners/.default=false,%
88 }%
89
90
91 \ifbool{fill}{%
92 \pgfkeys{/tikz/.cd,%
93 left offset/.initial=-0.1,
94 right offset/.initial=0.1,
95 above offset/.initial=0.35,
96 below offset/.initial=-0.18,
97 }
98 }{
99 \pgfkeys{/tikz/.cd,%
100 left offset/.initial=-0.075,
101 right offset/.initial=0.075,
102 above offset/.initial=0.35,
103 below offset/.initial=-0.18,
104 }
105 }
106
107 \pgfkeys{/tikz/.cd,%
108 left offset/.get=\leftoff,
109 left offset/.store in=\leftoff,
110 right offset/.get=\rightoff,
111 right offset/.store in=\rightoff,
112 above offset/.get=\aboveoff,
113 above offset/.store in=\aboveoff,
114 below offset/.get=\belowoff,
115 below offset/.store in=\belowoff,
116 below right offset/.initial={\rightoff,\belowoff},
117 below right offset/.get=\belowrightoff,
118 below right offset/.store in=\belowrightoff,
119 above left offset/.initial={\leftoff,\aboveoff},
120 above left offset/.get=\aboveleftoff,
121 above left offset/.store in=\aboveleftoff,
122 }%
123 \ifbool{markings}{
124 \usetikzlibrary{decorations.markings}
125 \newif\ifshowmarkers
126 \pgfkeys{/tikz/show markers/.is if=showmarkers}
127 \pgfkeys{/tikz/show markers=false}
128
129 \pgfkeys{/tikz/.cd,%
130 marker color/.initial=blue,
131 marker color/.get=\colmarker,
132 marker color/.store in=\colmarker,
133 marker size/.initial=1pt,
134 marker size/.get=\sizemarker,
135 marker size/.store in=\sizemarker,
136 }
137
138 \tikzset{
139 mark at/.style={
140 decoration={
141 markings,
142 mark=
143 at position #1
144 with
145 {
146 \coordinate (marker point-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,0pt);
147 \coordinate (marker unit vector-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (1,0pt);
148 \coordinate (marker orthogonal unit vector-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,1);
149 \ifshowmarkers% conditional to make them appear just when invoked
150 \draw[draw=none,fill=\colmarker,radius=\sizemarker] (0,0) circle ;
151 \else
152 \relax
153 \fi
154 }
155 },
156 postaction=decorate
157 },
158 use marker id/.style={
159 shift=(marker point-#1),
160 x=(marker unit vector-#1),
161 y=(marker orthogonal unit vector-#1)
162 },
163 use marker id/.default=1,
164 }
165 }
166 %% Settings
167
168 \ifbool{beamer}{%true
169 \newcounter{jumping}
170 \resetcounteronoverlays{jumping}
171
172 \def\jump@setbb#1#2#3{%
173 \@ifundefined{jump@#1@maxbb}{%
174 \expandafter\gdef\csname jump@#1@maxbb\endcsname{#3}%
175 }{%
176 \csname jump@#1@maxbb\endcsname
177 \pgf@xa=\pgf@x
178 \pgf@ya=\pgf@y
179 #3
180 \pgfmathsetlength\pgf@x{max(\pgf@x,\pgf@xa)}%
181 \pgfmathsetlength\pgf@y{max(\pgf@y,\pgf@ya)}%
182 \expandafter\xdef\csname jump@#1@maxbb\endcsname{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}%
183 }
184 \@ifundefined{jump@#1@minbb}{%
185 \expandafter\gdef\csname jump@#1@minbb\endcsname{#2}%
186 }{%
187 \csname jump@#1@minbb\endcsname
188 \pgf@xa=\pgf@x
189 \pgf@ya=\pgf@y
190 #2
191 \pgfmathsetlength\pgf@x{min(\pgf@x,\pgf@xa)}%
192 \pgfmathsetlength\pgf@y{min(\pgf@y,\pgf@ya)}%
193 \expandafter\xdef\csname jump@#1@minbb\endcsname{\noexpand\pgfpoint{\the\pgf@x}{\the\pgf@y}}%
194 }
195 }
196
197 \tikzset{%
198 remember picture with id/.style={%
199 remember picture,
200 overlay,
201 save picture id=#1,
202 },
203 save picture id/.code={%
204 \edef\pgf@temp{#1}%
205 \immediate\write\pgfutil@auxout{%
206 \noexpand\savepointas{\pgf@temp}{\pgfpictureid}}%
207 },
208 if picture id/.code args={#1#2#3}{%
209 \@ifundefined{save@pt@#1}{%
210 \pgfkeysalso{#3}%
211 }{
212 \pgfkeysalso{#2}%
213 }
214 },
215 onslide/.code args={<#1>#2}{%
216 \only<#1>{\pgfkeysalso{#2}}%
217 },
218 alt/.code args={<#1>#2#3}{%
219 \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}%
220 },
221 stop jumping/.style={
222 execute at end picture={%
223 \stepcounter{jumping}%
224 \immediate\write\pgfutil@auxout{%
225 \noexpand\jump@setbb{\the\value{jumping}}{\noexpand\pgfpoint{\the\pgf@picminx}{\the\pgf@picminy}}{\noexpand\pgfpoint{\the\pgf@picmaxx}{\the\pgf@picmaxy}}
226 },
227 \csname jump@\the\value{jumping}@maxbb\endcsname
228 \path (\the\pgf@x,\the\pgf@y);
229 \csname jump@\the\value{jumping}@minbb\endcsname
230 \path (\the\pgf@x,\the\pgf@y);
231 },
232 }
233 }
234 }{% false
235 \tikzset{%
236 remember picture with id/.style={%
237 remember picture,
238 overlay,
239 save picture id=#1,
240 },
241 save picture id/.code={%
242 \edef\pgf@temp{#1}%
243 \immediate\write\pgfutil@auxout{%
244 \noexpand\savepointas{\pgf@temp}{\pgfpictureid}}%
245 },
246 if picture id/.code args={#1#2#3}{%
247 \@ifundefined{save@pt@#1}{%
248 \pgfkeysalso{#3}%
249 }{
250 \pgfkeysalso{#2}%
251 }
252 }
253 }
254 }
255
256 \def\savepointas#1#2{%
257 \expandafter\gdef\csname save@pt@#1\endcsname{#2}%
258 }
259
260 \def\tmk@labeldef#1,#2\@nil{%
261 \def\tmk@label{#1}%
262 \def\tmk@def{#2}%
263 }
264
265 \tikzdeclarecoordinatesystem{pic}{%
266 \pgfutil@in@,{#1}%
267 \ifpgfutil@in@%
268 \tmk@labeldef#1\@nil
269 \else
270 \tmk@labeldef#1,(0pt,0pt)\@nil
271 \fi
272 \@ifundefined{save@pt@\tmk@label}{%
273 \tikz@scan@one@point\pgfutil@firstofone\tmk@def
274 }{%
275 \pgfsys@getposition{\csname save@pt@\tmk@label\endcsname}\save@orig@pic%
276 \pgfsys@getposition{\pgfpictureid}\save@this@pic%
277 \pgf@process{\pgfpointorigin\save@this@pic}%
278 \pgf@xa=\pgf@x
279 \pgf@ya=\pgf@y
280 \pgf@process{\pgfpointorigin\save@orig@pic}%
281 \advance\pgf@x by -\pgf@xa
282 \advance\pgf@y by -\pgf@ya
283 }%
284 }
285 \ifbool{norndcorners}{%true-norndcorners
286 \ifbool{beamer}{%true-beamer
287 \ifbool{fill}{%true-fill
288 \ifbool{shade}{%true-shade
289 \NewDocumentCommand{\tikzmarkin}{r<> o m D(){\belowrightoff} D(){\aboveleftoff}}{%
290 \IfNoValueTF{#2}{%true-val
291 \only<#1>{\tikz[remember picture,overlay]
292 \draw[line width=1pt,rectangle,fill=\fcol,draw=\bcol]
293 (pic cs:#3) ++(#4) rectangle (#5) node [anchor=base] (#3){}
294 ;}
295 }{%false-val
296 \only<#1>{\tikz[remember picture,overlay]
297 \draw[line width=1pt,rectangle,fill=\fcol,draw=\bcol,#2]
298 (pic cs:#3) ++(#4) rectangle (#5) node [anchor=base] (#3){}
299 ;}}
300 }
301 }{%false-shade
302 \NewDocumentCommand{\tikzmarkin}{r<> o m D(){\belowrightoff} D(){\aboveleftoff}}{%
303 \IfNoValueTF{#2}{%true-val
304 \only<#1>{\tikz[remember picture,overlay]
305 \draw[line width=1pt,rectangle,fill=\fcol,draw=\bcol]
306 (pic cs:#3) ++(#4) rectangle (#5) node [anchor=base] (#3){}
307 ;}
308 }{%false-val
309 \only<#1>{\tikz[remember picture,overlay]
310 \draw[line width=1pt,rectangle,fill=\fcol,draw=\bcol,#2]
311 (pic cs:#3) ++(#4) rectangle (#5) node [anchor=base] (#3){}
312 ;}}
313 }
314 }
315 }{%false-fill
316 \NewDocumentCommand{\tikzmarkin}{r<> o m D(){\belowrightoff} D(){\aboveleftoff}}{%
317 \IfNoValueTF{#2}{%true-val
318 \only<#1>{\tikz[remember picture,overlay]
319 \draw[line width=1pt,rectangle,draw=\bcol]
320 (pic cs:#3) ++(#4) rectangle (#5) node [anchor=base] (#3){}
321 ;}
322 }{%false-val
323 \only<#1>{\tikz[remember picture,overlay]
324 \draw[line width=1pt,rectangle,draw=\bcol,#2]
325 (pic cs:#3) ++(#4) rectangle (#5) node [anchor=base] (#3){}
326 ;}}
327 }
328 }
329 }{%false-beamer
330 \ifbool{fill}{%true-fill
331 \ifbool{shade}{%true-shade
332 \NewDocumentCommand{\tikzmarkin}{o m D(){\belowrightoff} D(){\aboveleftoff}}{%
333 \IfNoValueTF{#1}{%true-val
334 \tikz[remember picture,overlay]
335 \draw[line width=1pt,rectangle,fill=\fcol,draw=\bcol]
336 (pic cs:#2) ++(#3) rectangle (#4) node [anchor=base] (#2){}
337 ;
338 }{%false-val
339 \tikz[remember picture,overlay]
340 \draw[line width=1pt,rectangle,fill=\fcol,draw=\bcol,#1]
341 (pic cs:#2) ++(#3) rectangle (#4) node [anchor=base] (#2){}
342 ;}}
343 }{%false-shade
344 \NewDocumentCommand{\tikzmarkin}{o m D(){\belowrightoff} D(){\aboveleftoff}}{%
345 \IfNoValueTF{#1}{%true-val
346 \tikz[remember picture,overlay]
347 \draw[line width=1pt,rectangle,fill=\fcol,draw=\bcol]
348 (pic cs:#2) ++(#3) rectangle (#4) node [anchor=base] (#2){}
349 ;
350 }{%false-val
351 \tikz[remember picture,overlay]
352 \draw[line width=1pt,rectangle,fill=\fcol,draw=\bcol,#1]
353 (pic cs:#2) ++(#3) rectangle (#4) node [anchor=base] (#2){}
354 ;}}
355 }
356 }{%false-fill
357 \NewDocumentCommand{\tikzmarkin}{o m D(){\belowrightoff} D(){\aboveleftoff}}{%
358 \IfNoValueTF{#1}{%true-val
359 \tikz[remember picture,overlay]
360 \draw[line width=1pt,rectangle,draw=\bcol]
361 (pic cs:#2) ++(#3) rectangle (#4) node [anchor=base] (#2){}
362 ;
363 }{%false-val
364 \tikz[remember picture,overlay]
365 \draw[line width=1pt,rectangle,draw=\bcol,#1]
366 (pic cs:#2) ++(#3) rectangle (#4) node [anchor=base] (#2){}
367 ;}}
368 }
369 }
370 }{%false-norndcorners
371 \ifbool{beamer}{%true-beamer
372 \ifbool{fill}{%true-fill
373 \ifbool{shade}{%true-shade
374 \NewDocumentCommand{\tikzmarkin}{r<> o m D(){\belowrightoff} D(){\aboveleftoff}}{%
375 \IfNoValueTF{#2}{%true-val
376 \only<#1>{\tikz[remember picture,overlay]
377 \draw[line width=1pt,rectangle,disable rounded corners,fill=\fcol,draw=\bcol]
378 (pic cs:#3) ++(#4) rectangle (#5) node [anchor=base] (#3){}
379 ;}
380 }{%false-val
381 \only<#1>{\tikz[remember picture,overlay]
382 \draw[line width=1pt,rectangle,disable rounded corners,fill=\fcol,draw=\bcol,#2]
383 (pic cs:#3) ++(#4) rectangle (#5) node [anchor=base] (#3){}
384 ;}}
385 }
386 }{%false-shade
387 \NewDocumentCommand{\tikzmarkin}{r<> o m D(){\belowrightoff} D(){\aboveleftoff}}{%
388 \IfNoValueTF{#2}{%true-val
389 \only<#1>{\tikz[remember picture,overlay]
390 \draw[line width=1pt,rectangle,disable rounded corners,fill=\fcol,draw=\bcol]
391 (pic cs:#3) ++(#4) rectangle (#5) node [anchor=base] (#3){}
392 ;}
393 }{%false-val
394 \only<#1>{\tikz[remember picture,overlay]
395 \draw[line width=1pt,rectangle,disable rounded corners,fill=\fcol,draw=\bcol,#2]
396 (pic cs:#3) ++(#4) rectangle (#5) node [anchor=base] (#3){}
397 ;}}
398 }
399 }
400 }{%false-fill
401 \NewDocumentCommand{\tikzmarkin}{r<> o m D(){\belowrightoff} D(){\aboveleftoff}}{%
402 \IfNoValueTF{#2}{%true-val
403 \only<#1>{\tikz[remember picture,overlay]
404 \draw[line width=1pt,rectangle,disable rounded corners,draw=\bcol]
405 (pic cs:#3) ++(#4) rectangle (#5) node [anchor=base] (#3){}
406 ;}
407 }{%false-val
408 \only<#1>{\tikz[remember picture,overlay]
409 \draw[line width=1pt,rectangle,disable rounded corners,draw=\bcol,#2]
410 (pic cs:#3) ++(#4) rectangle (#5) node [anchor=base] (#3){}
411 ;}}
412 }
413 }
414 }{%false-beamer
415 \ifbool{fill}{%true-fill
416 \ifbool{shade}{%true-shade
417 \NewDocumentCommand{\tikzmarkin}{o m D(){\belowrightoff} D(){\aboveleftoff}}{%
418 \IfNoValueTF{#1}{%true-val
419 \tikz[remember picture,overlay]
420 \draw[line width=1pt,rectangle,disable rounded corners,fill=\fcol,draw=\bcol]
421 (pic cs:#2) ++(#3) rectangle (#4) node [anchor=base] (#2){}
422 ;
423 }{%false-val
424 \tikz[remember picture,overlay]
425 \draw[line width=1pt,rectangle,disable rounded corners,fill=\fcol,draw=\bcol,#1]
426 (pic cs:#2) ++(#3) rectangle (#4) node [anchor=base] (#2){}
427 ;}}
428 }{%false-shade
429 \NewDocumentCommand{\tikzmarkin}{o m D(){\belowrightoff} D(){\aboveleftoff}}{%
430 \IfNoValueTF{#1}{%true-val
431 \tikz[remember picture,overlay]
432 \draw[line width=1pt,rectangle,disable rounded corners,fill=\fcol,draw=\bcol]
433 (pic cs:#2) ++(#3) rectangle (#4) node [anchor=base] (#2){}
434 ;
435 }{%false-val
436 \tikz[remember picture,overlay]
437 \draw[line width=1pt,rectangle,disable rounded corners,fill=\fcol,draw=\bcol,#1]
438 (pic cs:#2) ++(#3) rectangle (#4) node [anchor=base] (#2){}
439 ;}}
440 }
441 }{%false-fill
442 \NewDocumentCommand{\tikzmarkin}{o m D(){\belowrightoff} D(){\aboveleftoff}}{%
443 \IfNoValueTF{#1}{%true-val
444 \tikz[remember picture,overlay]
445 \draw[line width=1pt,rectangle,disable rounded corners,draw=\bcol]
446 (pic cs:#2) ++(#3) rectangle (#4) node [anchor=base] (#2){}
447 ;
448 }{%false-val
449 \tikz[remember picture,overlay]
450 \draw[line width=1pt,rectangle,disable rounded corners,draw=\bcol,#1]
451 (pic cs:#2) ++(#3) rectangle (#4) node [anchor=base] (#2){}
452 ;}}
453 }
454 }
455 }
456
457 \newcommand\tikzmarkend[2][]{%
458 \tikz[remember picture with id=#2] #1;}
459 %%
460 %% Copyright (C) 2012-2014 by Claudio Fiandrino <[email protected]>
461 %%
462 %% This work may be distributed and/or modified under the
463 %% conditions of the LaTeX Project Public License (LPPL), either
464 %% version 1.3c of this license or (at your option) any later
465 %% version. The latest version of this license is in the file:
466 %%
467 %% http://www.latex-project.org/lppl.txt
468 %%
469 %% This work is "maintained" (as per LPPL maintenance status) by
470 %% Claudio Fiandrino.
471 %%
472 %% This work consists of the file hf-tikz.dtx
473 %% and the derived files hf-tikz.ins and
474 %% hf-tikz.pdf
475 %% hf-tikz.sty.
476 %%
477 %% End of file `hf-tikz.sty'.