Skip to content

Commit a31bcbc

Browse files
committed
Version 1.2: Updated color option blue. Updated event label positioning. Added options to modify the tips of links. Added option that automatically breaks a link when it crosses over an event in the command \causet. Added spatial links to the command \rcauset.
1 parent cf7bd9b commit a31bcbc

File tree

7 files changed

+409
-182
lines changed

7 files changed

+409
-182
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66
*.log
77
*.aux
88
causets_development.sty
9+
/causets.out
10+
/causets.pdf

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Bug reports can be send to the maintainer:
3636

3737
Information on Distribution
3838
===========================
39-
Copyright 2020 by C. Minz
39+
Copyright 2020-2022 by C. Minz
4040

4141
This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3 of this license or (at your option) any later version.
4242
The latest version of this license is in
@@ -47,7 +47,7 @@ This work has the LPPL maintenance status "maintained".
4747
The current maintainer of this work is C. Minz.
4848
https://github.com/c-minz
4949

50-
Current version: 1.1
50+
Current version: 1.2
5151

5252
CTAN location: /graphics/pgf/contrib/causets/
5353

causets.pdf

21 KB
Binary file not shown.

causets.sty

Lines changed: 135 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
\NeedsTeXFormat{LaTeX2e}
2-
\ProvidesPackage{causets}[2020/12/13 v1.1 Package to draw causal set diagrams]
3-
%% Copyright 2020 by C. Minz
2+
\ProvidesPackage{causets}[2022/02/07 v1.2 Package to draw causal set diagrams]
3+
%% Copyright 2020-2022 by C. Minz
44
%
55
% This work may be distributed and/or modified under the
66
% conditions of the LaTeX Project Public License, either version 1.3
@@ -10,7 +10,7 @@
1010
%
1111
% This work has the LPPL maintenance status "maintained".
1212
%
13-
% The current version of this package is 1.1.
13+
% The current version of this package is 1.2.
1414
%
1515
% The current maintainer of this work is C. Minz.
1616
% https://github.com/c-minz
@@ -20,6 +20,7 @@
2020
% causet_tikz_example2.tex, causet_tikz_example2.pdf
2121

2222
\RequirePackage{tikz}
23+
\usepgflibrary{arrows.meta}
2324

2425
%% PGF keys:
2526
\def\tikzcausetsset#1{\pgfqkeys{/tikz/causets}{#1}}
@@ -36,6 +37,8 @@
3637
event size/.value required,
3738
link width/.store in=\causetLinkWidth,
3839
link width/.value required,
40+
broken link gap/.store in=\causetBrokenLinkGap,
41+
broken link gap/.value required,
3942
text scale/.store in=\causetTextScale,
4043
text scale/.value required,
4144
tiny/.value forbidden,
@@ -49,34 +52,39 @@
4952
grid line width=0.01ex,
5053
event size=0.16ex,
5154
link width=0.05ex,
55+
broken link gap=0.15ex,
5256
text scale=0.16},
5357
small/.style={%
5458
tile size=0.60ex,
5559
region line width=0.04ex,
5660
grid line width=0.02ex,
5761
event size=0.32ex,
5862
link width=0.10ex,
63+
broken link gap=0.30ex,
5964
text scale=0.32},
6065
normal/.style={%
6166
tile size=0.90ex,
6267
region line width=0.06ex,
6368
grid line width=0.03ex,
6469
event size=0.48ex,
6570
link width=0.15ex,
71+
broken link gap=0.45ex,
6672
text scale=0.48},
6773
large/.style={%
6874
tile size=1.35ex,
6975
region line width=0.09ex,
7076
grid line width=0.05ex,
7177
event size=0.75ex,
7278
link width=0.20ex,
79+
broken link gap=0.60ex,
7380
text scale=0.75},
7481
huge/.style={%
7582
tile size=1.80ex,
7683
region line width=0.12ex,
7784
grid line width=0.07ex,
7885
event size=1.00ex,
7986
link width=0.25ex,
87+
broken link gap=0.75ex,
8088
text scale=1.00}
8189
}
8290
% color options:
@@ -113,11 +121,11 @@
113121
blue colors/.style={%
114122
region color=black!75,
115123
grid color=black!25,
116-
tile color=yellow!75!black!50!white,
124+
tile color=cyan!25!black!25!white,
117125
event color=blue!50!black,
118126
label color=blue!50!black,
119127
link color=cyan!75!black,
120-
spatial link color=red!65!black,
128+
spatial link color=blue!75!white,
121129
ulabel color=black!50,
122130
vlabel color=black!50},
123131
neon colors/.style={%
@@ -134,20 +142,24 @@
134142
% styles:
135143
\newif\ifcausetsDrawPermutation
136144
\newif\ifcausetsDrawLinks
145+
\newif\ifcausetsBreakLinks
137146
\newif\ifcausetsDrawSpatialLinks
138147
\newif\ifcausetsDrawLabels
139148
\newif\ifcausetsDrawULabels
140149
\newif\ifcausetsDrawVLabels
141150
\tikzcausetsset{%
142151
show permutation/.is if=causetsDrawPermutation,
143152
show links/.is if=causetsDrawLinks,
153+
break links/.is if=causetsBreakLinks,
144154
show spatial links/.is if=causetsDrawSpatialLinks,
145155
show labels/.is if=causetsDrawLabels,
146156
show ulabels/.is if=causetsDrawULabels,
147157
show vlabels/.is if=causetsDrawVLabels,
148158
permutation/.code={\causetsDrawPermutationtrue},
149159
linked/.code={\causetsDrawLinkstrue},
150160
unlinked/.code={\causetsDrawLinksfalse},
161+
brokenly linked/.code={\causetsBreakLinkstrue},
162+
continuously linked/.code={\causetsBreakLinksfalse},
151163
spatially linked/.code={\causetsDrawSpatialLinkstrue},
152164
spatially unlinked/.code={\causetsDrawSpatialLinksfalse},
153165
labeled/.code={\causetsDrawLabelstrue},
@@ -159,31 +171,58 @@
159171
every region/.value forbidden,
160172
every region/.style={color=\pgfkeysvalueof{/tikz/causets/region color}, line width=\causetRegionLine},
161173
region/.style={show permutation, every region/.append style={#1}},
174+
every grid/.value forbidden,
162175
every grid/.style={color=\pgfkeysvalueof{/tikz/causets/grid color}, line width=\causetGridLine, step=\causetTileSize},
163176
grid/.style={show permutation, every grid/.append style={#1}},
177+
every tile/.value forbidden,
164178
every tile/.style={color=\pgfkeysvalueof{/tikz/causets/tile color}, line width=\causetGridLine, fill},
165179
tiles/.style={show permutation, every tile/.append style={#1}},
180+
every event/.value forbidden,
166181
every event/.style={color=\pgfkeysvalueof{/tikz/causets/event color}, circle, fill, inner sep=0pt, minimum size=\causetEventSize},
167182
events/.value required,
168183
events/.style={every event/.append style={#1}},
169-
every link/.style={color=\pgfkeysvalueof{/tikz/causets/link color}, line width=\causetLinkWidth, arrows=-},
184+
Link Start/.tip={},
185+
Link Pause/.tip={Triangle Cap[] . Fast Triangle[] . Fast Triangle[]},
186+
Link Resume/.tip={Triangle Cap[reversed] . Fast Triangle[reversed] . Fast Triangle[reversed]},
187+
Link End/.tip={},
188+
every link/.value forbidden,
189+
every link/.style={color=\pgfkeysvalueof{/tikz/causets/link color}, line width=\causetLinkWidth, {Link Start[]}-{Link End[]}},
170190
links/.style={show links, every link/.append style={#1}},
191+
link starts/.value required,
192+
link starts/.style={Link Start/.tip={#1}},
193+
link pauses/.value required,
194+
link pauses/.style={Link Pause/.tip={#1}},
195+
link resumes/.value required,
196+
link resumes/.style={Link Resume/.tip={#1}},
197+
link ends/.value required,
198+
link ends/.style={Link End/.tip={#1}},
199+
cap links/.value forbidden,
200+
cap links/.style={link starts={Triangle Cap[reversed]}, link ends={Triangle Cap[]}},
201+
arrow links/.value forbidden,
202+
arrow links/.style={link ends={Stealth[round, open, length=4*\causetLinkWidth, line width=\causetLinkWidth/3]}},
203+
every spatial link/.value forbidden,
171204
every spatial link/.style={every link, color=\pgfkeysvalueof{/tikz/causets/spatial link color}, dashed},
172205
spatial links/.style={show spatial links, every spatial link/.append style={#1}},
206+
every label base/.value forbidden,
173207
every label base/.style={text opacity=1.0, scale=\causetTextScale, inner sep=0.5*\causetTextScale ex},
174208
all labels/.style={every label base/.append style={#1}},
175-
every label/.style={every label base, color=\pgfkeysvalueof{/tikz/causets/label color}, below left, inner sep=0pt},
209+
every label/.value forbidden,
210+
every label/.style={every label base, color=\pgfkeysvalueof{/tikz/causets/label color}, below left},
176211
labels/.style={show labels, every label/.append style={#1}},
212+
every ulabel/.value forbidden,
177213
every ulabel/.style={every label base, color=\pgfkeysvalueof{/tikz/causets/ulabel color}, right, rotate=-45, align=left},
178214
ulabels/.style={show ulabels, every ulabel/.append style={#1}},
215+
every vlabel/.value forbidden,
179216
every vlabel/.style={every label base, color=\pgfkeysvalueof{/tikz/causets/vlabel color}, left, rotate=45, align=right},
180217
vlabels/.style={show vlabels, every vlabel/.append style={#1}},
218+
every causet/.value forbidden,
181219
every causet/.style={baseline=-0.707*\causetTileSize}
182220
}
183221

184222
%% delare and execute options:
185223
\tikzcausetsset{normal}
186224
\causetsDrawLinkstrue
225+
\causetsBreakLinkstrue
187226
\causetsDrawULabelstrue
188227
\causetsDrawVLabelstrue
189228
\DeclareOption{tiny}{\tikzcausetsset{tiny}}
@@ -200,6 +239,10 @@
200239
\DeclareOption{neon colors}{\tikzcausetsset{neon colors}}
201240
\DeclareOption{linked}{\causetsDrawLinkstrue}
202241
\DeclareOption{unlinked}{\causetsDrawLinksfalse}
242+
\DeclareOption{cap linked}{\tikzcausetsset{cap links}}
243+
\DeclareOption{arrow linked}{\tikzcausetsset{arrow links}}
244+
\DeclareOption{brokenly linked}{\causetsBreakLinkstrue}
245+
\DeclareOption{continuously linked}{\causetsBreakLinksfalse}
203246
\DeclareOption{spatially linked}{\causetsDrawSpatialLinkstrue}
204247
\DeclareOption{spatially unlinked}{\causetsDrawSpatialLinksfalse}
205248
\DeclareOption{permutation}{\causetsDrawPermutationtrue}
@@ -270,12 +313,35 @@
270313
\fi
271314
}
272315

316+
% draw the spatial links from the permutation:
317+
\newcommand*{\causets@drawSpatialLinks}[1]{%
318+
\ifcausetsDrawSpatialLinks
319+
\setcounter{causet@i}{0}
320+
\foreach \causet@p in {#1}{%
321+
\stepcounter{causet@i}
322+
\edef\causet@qBound{0}
323+
\setcounter{causet@j}{0}
324+
\foreach \causet@q in {#1}{%
325+
\stepcounter{causet@j}
326+
\ifnum\value{causet@j}>\value{causet@i}
327+
\ifnum\causet@q>\causet@qBound
328+
\ifnum\causet@p>\causet@q
329+
\draw[causets/.cd, every spatial link] (E\causet@q) -- (E\causet@p);
330+
\xdef\causet@qBound{\causet@q}
331+
\fi
332+
\fi
333+
\fi
334+
}
335+
}
336+
\fi
337+
}
338+
273339
% draw event labels:
274340
\newcommand*{\causets@drawEventLabels}[1]{%
275341
\ifcausetsDrawLabels
276342
\foreach \causet@p in {#1}{%
277343
\node[causets/.cd, every label] (EL\causet@p)
278-
at (E\causet@p.south west) {\causet@p};
344+
at (E\causet@p) {\causet@p};
279345
}
280346
\fi
281347
}
@@ -307,25 +373,7 @@
307373
}
308374
}
309375
\fi
310-
\ifcausetsDrawSpatialLinks
311-
\setcounter{causet@i}{0}
312-
\foreach \causet@p in {#1}{%
313-
\stepcounter{causet@i}
314-
\edef\causet@qBound{0}
315-
\setcounter{causet@j}{0}
316-
\foreach \causet@q in {#1}{%
317-
\stepcounter{causet@j}
318-
\ifnum\value{causet@j}>\value{causet@i}
319-
\ifnum\causet@q>\causet@qBound
320-
\ifnum\causet@p>\causet@q
321-
\draw[causets/.cd, every spatial link] (E\causet@q) -- (E\causet@p);
322-
\xdef\causet@qBound{\causet@q}
323-
\fi
324-
\fi
325-
\fi
326-
}
327-
}
328-
\fi
376+
\causets@drawSpatialLinks{#1}
329377
\causets@drawEventLabels{#1}
330378
\end{scope}
331379
\end{scope}
@@ -340,9 +388,59 @@
340388
\causets@drawEvents{#1}
341389
\causets@drawPermutation{#1}
342390
\ifcausetsDrawLinks
343-
\foreach \causet@From/\causet@To in {#2}{%
344-
\draw[causets/.cd, every link] (E\causet@From) -- (E\causet@To);
345-
}
391+
\ifcausetsBreakLinks
392+
\foreach \causet@From/\causet@To in {#2}{%
393+
\pgfmathsetmacro\causet@dU{int(\causet@To) - int(\causet@From)}
394+
\setcounter{causet@i}{0}
395+
\foreach \causet@p in {#1}{%
396+
\ifnum\causet@p=\causet@To
397+
\pgfmathparse{int(\value{causet@i})}
398+
\xdef\causet@dV{\pgfmathresult}
399+
\fi
400+
\ifnum\value{causet@i}>0
401+
\stepcounter{causet@i}
402+
\fi
403+
\ifnum\causet@p=\causet@From
404+
\stepcounter{causet@i}
405+
\fi
406+
}
407+
\def\causet@LastBreak{0}
408+
\setcounter{causet@i}{0}
409+
\foreach \causet@p in {#1}{%
410+
\ifnum\causet@p=\causet@To
411+
\setcounter{causet@i}{0}
412+
\fi
413+
\pgfmathparse{and(\value{causet@i} > 0, int((\causet@p - \causet@From) * \causet@dV) == int(\causet@dU * \value{causet@i}))}
414+
\ifnum\pgfmathresult=1
415+
\ifnum\causet@LastBreak=0
416+
\draw[causets/.cd, every link, {Link Start}-{Link Pause}, shorten >=\causetBrokenLinkGap]
417+
(E\causet@From) -- (E\causet@p);
418+
\else
419+
\draw[causets/.cd, every link, {Link Resume}-{Link Pause}, shorten <=\causetBrokenLinkGap, shorten >=\causetBrokenLinkGap]
420+
(E\causet@LastBreak) -- (E\causet@p);
421+
\fi
422+
\xdef\causet@LastBreak{\causet@p}
423+
\fi
424+
\ifnum\value{causet@i}>0
425+
\stepcounter{causet@i}
426+
\fi
427+
\ifnum\causet@p=\causet@From
428+
\setcounter{causet@i}{1}
429+
\fi
430+
}
431+
\ifnum\causet@LastBreak>0
432+
\draw[causets/.cd, every link, {Link Resume}-{Link End}, shorten <=\causetBrokenLinkGap]
433+
(E\causet@LastBreak) -- (E\causet@To);
434+
\else
435+
\draw[causets/.cd, every link]
436+
(E\causet@From) -- (E\causet@To);
437+
\fi
438+
}
439+
\else
440+
\foreach \causet@From/\causet@To in {#2}{%
441+
\draw[causets/.cd, every link] (E\causet@From) -- (E\causet@To);
442+
}
443+
\fi
346444
\fi
347445
\causets@drawEventLabels{#1}
348446
\end{scope}
@@ -370,7 +468,7 @@
370468
\ifnum\causet@p<\causet@q
371469
\global\causet@ItemFoundInListfalse
372470
\foreach \causet@From/\causet@To in {#2}{%
373-
\pgfmathparse{and( equal( int(\causet@From), int(\causet@p) ), equal( int(\causet@To), int(\causet@q) ) )}
471+
\pgfmathparse{and(int(\causet@From) == int(\causet@p), int(\causet@To) == int(\causet@q))}
374472
\ifnum\pgfmathresult=1
375473
\global\causet@ItemFoundInListtrue
376474
\fi
@@ -387,6 +485,12 @@
387485
}
388486
}
389487
\fi
488+
\causets@drawSpatialLinks{#1}
489+
\ifcausetsDrawSpatialLinks
490+
\foreach \causet@From/\causet@To in {#2}{%
491+
\draw[causets/.cd, every spatial link] (E\causet@From) -- (E\causet@To);
492+
}
493+
\fi
390494
\causets@drawEventLabels{#1}
391495
\end{scope}
392496
\end{scope}

0 commit comments

Comments
 (0)