Ian Jauslin
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jauslin <ian@jauslin.org>2022-06-14 16:32:34 +0200
committerIan Jauslin <ian@jauslin.org>2022-06-14 16:32:34 +0200
commitd254a3e3f495e9cd3110ae48020786466d850d57 (patch)
treec88e465b5bc2aff974daaa3617adf615a0b68880 /figs/lib/graphene.sty
Initial commitv1.0
Diffstat (limited to 'figs/lib/graphene.sty')
-rw-r--r--figs/lib/graphene.sty48
1 files changed, 48 insertions, 0 deletions
diff --git a/figs/lib/graphene.sty b/figs/lib/graphene.sty
new file mode 100644
index 0000000..4f044ae
--- /dev/null
+++ b/figs/lib/graphene.sty
@@ -0,0 +1,48 @@
+% sqrt(3)/2
+\def\sqrtThOT{0.866}
+% sqrt(3)
+\def\sqrtTh{1.732}
+% pi
+\def\pival{3.14159}
+
+% base vectorsj
+\def\Lo{(1.5,\sqrtThOT)}
+\def\Lt{(1.5,-\sqrtThOT)}
+\def\mLo{(-1.5,-\sqrtThOT)}
+\def\mLt{(-1.5,\sqrtThOT)}
+
+% filled square at #1 of side-length #2
+\def\fullsquare#1#2{\fill#1++(-#2,-#2)--++(#2,0)--++(#2,0)--++(0,#2)--++(0,#2)--++(-#2,0)--++(-#2,0)--++(0,-#2)--++(0,-#2);}
+% in color
+\def\fullsquarecolor#1#2#3{\fill[color=#3]#1++(-#2,-#2)--++(#2,0)--++(#2,0)--++(0,#2)--++(0,#2)--++(-#2,0)--++(-#2,0)--++(0,-#2)--++(0,-#2);}
+
+% type-a site at #1
+\def\asite#1{\fill#1circle(.1);}
+% in color
+\def\asitec#1#2{\fill[color=#2]#1circle(.1);}
+% type-b site at #1
+\def\bsite#1{\fullsquare{#1}{.1}}
+% in color
+\def\bsitec#1#2{\fullsquarecolor{#1}{.1}{#2}}
+
+% base cell with a site at #1
+\def\cell#1{
+ \draw#1--++(0:1);
+ \draw#1--++(120:1);
+ \draw#1--++(240:1);
+ \asite{#1}
+ \draw#1++(1,0)--++(0:-1);
+ \draw#1++(1,0)--++(120:-1);
+ \draw#1++(1,0)--++(240:-1);
+ \bsite{#1++(1,0)}
+}
+
+% grpahene grid at #1 of width #2 and height #3
+\def\graphene#1#2#3{
+ \foreach \i in {0,...,#2}{
+ \foreach \j in {0,...,#3}{
+ \cell{#1++(\i*3,-2*\j*\sqrtThOT)}
+ \cell{#1++(\i*3+1.5,\sqrtThOT-2*\j*\sqrtThOT)}
+ }
+ }
+}