-
Notifications
You must be signed in to change notification settings - Fork 3
/
tikz-setup.tex
126 lines (114 loc) · 3.66 KB
/
tikz-setup.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
%!TEX root = tikz-figures.tex
\usetikzlibrary{
external, % Externalise tikzfigures to speed up compile. Needs %!TEX options = -shell-escape
cd,
positioning,
arrows,
graphs,
arrows.meta,
calc,
math,
patterns,
patterns.meta,
decorations.pathreplacing,
decorations.markings,
calligraphy
}
% PGF backwards compatability mode
\pgfplotsset{compat=1.16}
% \usegdlibrary{trees}
% Set up externalisation
% \tikzexternalize[prefix=figures/]
% Turn off externalisation for Tikz cd figures (because it doesn't work)
% https://tex.stackexchange.com/a/172432
\AtBeginEnvironment{tikzcd}{\tikzexternaldisable}
\AtEndEnvironment{tikzcd}{\tikzexternalenable}
% Wong colourblind pallet
\definecolor{pallette_orange}{RGB}{230, 159, 0}
\definecolor{pallette_skyblue}{RGB}{86, 180, 233}
\definecolor{pallette_bluishgreen}{RGB}{0, 158, 115}
\definecolor{pallette_yellow}{RGB}{240, 228, 66}
\definecolor{pallette_blue}{RGB}{0, 114, 178}
\definecolor{pallette_vermillion}{RGB}{213, 94, 0}
\definecolor{pallette_reddishpurple}{RGB}{204, 121, 167}
% Wong colourblind pallet using numbers instead of names
\definecolor{pallette0}{RGB}{0, 0, 0}
\definecolor{pallette1}{RGB}{230, 159, 0}
\definecolor{pallette2}{RGB}{86, 180, 233}
\definecolor{pallette3}{RGB}{0, 158, 115}
\definecolor{pallette4}{RGB}{240, 228, 66}
\definecolor{pallette5}{RGB}{0, 114, 178}
\definecolor{pallette6}{RGB}{213, 94, 0}
\definecolor{pallette7}{RGB}{204, 121, 167}
% Tikz styles
\tikzset{
world/.style={draw,circle,outer sep=0pt,inner sep=0,minimum size=15},
point/.style={draw=black,fill=black,opacity=1,circle,outer sep=0pt,inner sep=0,minimum size=2},
facefill/.style={fill=blue!20,fill opacity=0.4},
dot/.style={draw=black,fill=black,opacity=0,circle,outer sep=0pt,inner sep=0}
}
\tikzgraphsset{
poset/.style={grow up=#1, branch right=#1, empty nodes, simple, nodes=point},
poset/.default=1cm
}
\tikzset{negated/.style={
decoration={markings,
mark= at position 0.5 with {
\node[transform shape] (tempnode) {$\backslash$};
}
},
postaction={decorate}
}
}
\tikzset{
brace/.style={decoration={calligraphic brace,amplitude=5pt}, decorate, line width=1.25pt}
}
\tikzset{
->-/.style={
decoration={
markings,
mark=at position .5 with {\arrow{>}}
},
postaction={decorate}
}
}
% Distance between points
\makeatletter
\newcommand{\Distance}[3]{% % from https://tex.stackexchange.com/q/56353/121799
\tikz@scan@one@point\pgfutil@firstofone($#1-#2$)\relax
\pgfmathsetmacro{#3}{round(0.99626*veclen(\the\pgf@x,\the\pgf@y)/0.0283465)/1000}
}% Explanation: the calc library allows us, among other things, to add and
% subtract points, so ($#1-#2$) is simply the difference between the points
% #1 and #2. The combination \tikz@scan@one@point\pgfutil@firstofone extracts
% the coordinates of the new point and stores them in \pgf@x and \pgf@y.
% They get fed in veclen, and \pgfmathsetmacro stores the result in #3.
% EDIT: included fudge factor, see https://tex.stackexchange.com/a/22702/121799
\makeatother
% Barycentre of points
% Modified from the tikz source tikz.code.tex
\makeatletter
\tikzdeclarecoordinatesystem{bc}
{%
{%
\pgf@xa=0pt% point
\pgf@ya=0pt%
\pgf@xb=0pt% sum
\tikz@bc@dolist#1,,%
\pgfmathparse{1/\the\pgf@xb}%
\global\pgf@x=\pgfmathresult\pgf@xa%
\global\pgf@y=\pgfmathresult\pgf@ya%
}%
}%
\def\tikz@bc@dolist#1,{%
\def\tikz@temp{#1}%
\ifx\tikz@temp\pgfutil@empty%
\else
\pgf@process{\pgfpointanchor{#1}{center}}%
\pgfmathparse{1}%
\advance\pgf@xa by\pgfmathresult\pgf@x%
\advance\pgf@ya by\pgfmathresult\pgf@y%
\advance\pgf@xb by\pgfmathresult pt%
\expandafter\tikz@bc@dolist%
\fi%
}
\makeatother