Debian Codegraph @

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

raw
1 % ==================================================================
2 % callouts.sty
3 % ==================================================================
4 % (c) 2017 Markus Stuetz, [email protected]
5 % This program can be redistributed and/or modified under the terms
6 % of the LaTeX Project Public License Distributed from CTAN
7 % archives in directory macros/latex/base/lppl.txt; either
8 % version 1 of the License, or any later version.
9 % ==================================================================
10
11 \ProvidesPackage{callouts}[2017/07/27 Callouts]
12 \NeedsTeXFormat{LaTeX2e}
13 \RequirePackage{tikz}
14
15 \usetikzlibrary{calc}
16 \RequirePackage{xifthen}
17
18 \newcommand*{\focol}{black}
19 \newcommand*{\bgcol}{none}
20 \newcommand*{\arcol}{black}
21
22 \RequirePackage{kvoptions}
23 \SetupKeyvalOptions {family = callouts,prefix = callouts@}%
24
25 \DeclareDefaultOption{\ClassWarning{callouts}{Unknown color option '\CurrentOptionKey=\CurrentOptionValue'}}%
26
27 \DeclareVoidOption{bwr}{%
28 \renewcommand*{\bgcol}{white}%
29 \renewcommand*{\arcol}{red}%
30 }
31
32 \DeclareVoidOption{wby}{%
33 \renewcommand*{\focol}{white}%
34 \renewcommand*{\bgcol}{black}%
35 \renewcommand*{\arcol}{yellow}%
36 }
37
38 \DeclareVoidOption{bww}{%
39 \renewcommand*{\focol}{black}%
40 \renewcommand*{\bgcol}{white}%
41 \renewcommand*{\arcol}{white}%
42 }
43
44 \define@key{callouts}{text}{%
45 \renewcommand*{\focol}{#1}%
46 }
47 \define@key{callouts}{background}{%
48 \renewcommand*{\bgcol}{#1}%
49 }
50 \define@key{callouts}{arrow}{%
51 \renewcommand*{\arcol}{#1}%
52 }
53
54 \ProcessKeyvalOptions* % terminate option processing
55
56 % ==================================================================
57
58 \newenvironment{annotate}[2]%[num]%
59 { \begin{tikzpicture}[scale=#2]% }%
60 % Annotate
61 \node (pic) at (0,0) {#1};%
62 \newdimen\xtic
63 \newdimen\ytic
64 \pgfextractx\xtic{\pgfpointanchor{pic}{east}}
65 \pgfmathparse{int(\xtic/1cm)}
66 \pgfmathsetmacro\xtic{\pgfmathresult}
67 \pgfextracty\ytic{\pgfpointanchor{pic}{north}}
68 \pgfmathparse{int(\ytic/1cm)}
69 \pgfmathsetmacro\ytic{\pgfmathresult}
70 }%
71 { \end{tikzpicture} }
72
73 % ==================================================================
74
75 \newcommand{\helpgrid}[1][\bgcol]{%
76 \draw[help lines, color=#1] (pic.south west) grid (pic.north east); \fill[#1] (0,0) circle (3pt);%
77 \foreach \i in {-\xtic,...,\xtic} {%
78 \node at (\i+0.2,0.2) {\color{#1} \tiny \i};}
79 \foreach \i in {-\ytic,...,\ytic} {%
80 \node at (0.2,\i+0.2) {\color{#1} \tiny \i};}
81 }
82 \newcommand{\callout}[3]{%
83 \node [fill=\bgcol] (text) at (#1) {\scriptsize\color{\focol} #2};
84 \draw [\arcol,thick,->] (text) -- (#3);
85 }
86 \newcommand{\note}[2]{%
87 \node [fill=\bgcol] at (#1) {\scriptsize\color{\focol} #2};
88 }
89 \newcommand{\arrow}[2]{%
90 \draw [\arcol,thick,->] (#1) -- (#2);
91 }
92
93 \endinput % === EOF ================================================