Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
GuillaumeLaplante-Anfossi
GitHub Repository: GuillaumeLaplante-Anfossi/Poissons
Path: blob/main/Talk GDRIM/hedge.tex
1016 views
1
%% from https://tex.stackexchange.com/questions/356564/macro-for-rounded-polygon-around-some-nodes
2
%% answer of bitt.j
3
%Necessary for the mypoly command%
4
\usepackage{tkz-euclide}
5
\usepackage{xstring}
6
7
%------------------------%
8
%---The mypoly command---%
9
%------------------------%
10
11
%--Getting the last Element of a list--%
12
\def\splicelist#1{
13
\StrCount{#1}{,}[\numofelem]
14
\ifnum\numofelem>0\relax
15
\StrBehind[\numofelem]{#1}{,}[\mylast]%
16
\else
17
\let\mylast#1%
18
\fi
19
}
20
21
%--The mypoly macro--%
22
%How to use:
23
%\myroundpoly[decorative commands]{list of names of nodes}{distance}
24
%list of names has to be given in clockwise order
25
\newcommand{\hedge}[3][thin,color=black]{
26
%Get the last element
27
\splicelist{#2}
28
%Calculate the auxiliary coordinates for the arcs
29
\foreach \vertex [remember=\vertex as \succvertex
30
(initially \mylast)] in {#2}{
31
\coordinate (\succvertex-next) at ($(\succvertex)!#3!90:(\vertex)$);
32
\coordinate (\vertex-previous) at ($(\vertex)!#3!-90:(\succvertex)$);
33
\draw[#1] (\succvertex-next) -- (\vertex-previous);
34
}
35
36
37
%Draw the arcs
38
\foreach \vertex in {#2}{
39
\tkzDrawArc[#1](\vertex,\vertex-next)(\vertex-previous)
40
}
41
}
42
43
44