%%
%% Macros to draw graphene lattices
%%

% numerical values
% sqrt(3)/2
\def\sqrttt{0.866}
% sqrt(3)
\def\sqrtt {1.732}

%l1
\def\lo{(1.5,\sqrttt)}
%l2
\def\lt{(1.5,-\sqrttt)}
%-l1
\def\mlo{(-1.5,-\sqrttt)}
%-l2
\def\mlt{(-1.5,\sqrttt)}

% shapes
\def\square#1#2#3{\draw[#3]#1++(-#2,-#2)--++(#2,0)--++(#2,0)--++(0,#2)--++(0,#2)--++(-#2,0)--++(-#2,0)--++(0,-#2)--++(0,-#2);}
\def\fullsquare#1#2#3{\fill[#3]#1++(-#2,-#2)--++(#2,0)--++(#2,0)--++(0,#2)--++(0,#2)--++(-#2,0)--++(-#2,0)--++(0,-#2)--++(0,-#2);}

% atoms
\def\a#1#2{\fill[#2]#1circle(.1);}
\def\b#1#2{\fullsquare{#1}{.1}{#2}}
\def\at#1#2{\fill[color=white]#1circle(.1);\draw[#2]#1circle(.1);}
\def\bt#1#2{\fullsquare{#1}{.17}{color=white}\square{#1}{.17}{#2}}


% draw a hexagon
\def\hexagon#1#2{
  % draw the lines one at a time (so that dashes overlap if the line is dashed)
  \draw[#2]#1++(1,0)--++(120:1);
  \draw[#2]#1++(-120:1)--++(120:1);
  \draw[#2]#1++(60:1)--++(-1,0);
  \draw[#2]#1++(-60:1)--++(-1,0);
  \draw[#2]#1++(120:1)--++(-120:1);
  \draw[#2]#1++(1,0)--++(-120:1);
}

% draw the atoms around a hexagon
\def\as#1#2{
  \a{#1++(1,0)}{#2}
  \a{#1++(120:1)}{#2}
  \a{#1++(-120:1)}{#2}
}
\def\ats#1#2{
  \at{#1++(1,0)}{#2}
  \at{#1++(120:1)}{#2}
  \at{#1++(-120:1)}{#2}
}
\def\bs#1#2{
  \b{#1++(-1,0)}{#2}
  \b{#1++(60:1)}{#2}
  \b{#1++(-60:1)}{#2}
}
\def\bts#1#2{
  \bt{#1++(-1,0)}{#2}
  \bt{#1++(60:1)}{#2}
  \bt{#1++(-60:1)}{#2}
}

% base lattice
\def\graphene#1#2{
  \hexagon{#1}{#2}
  \hexagon{#1++\lo}{#2}
  \hexagon{#1++\lt}{#2}
  \hexagon{#1++\mlo}{#2}
  \hexagon{#1++\mlt}{#2}
  \hexagon{#1++\lo++\mlt}{#2}
  \hexagon{#1++\lo++\mlt++\lo}{#2}
  \hexagon{#1++\lo++\mlt++\mlt}{#2}
}

% base lattice of sites
\def\sitelattice#1#2#3{
  \csname #1s\endcsname{#2}{#3}
  \csname #1s\endcsname{#2++\lo}{#3}
  \csname #1s\endcsname{#2++\lt}{#3}
  \csname #1s\endcsname{#2++\mlo}{#3}
  \csname #1s\endcsname{#2++\mlt}{#3}
  \csname #1s\endcsname{#2++\lo++\mlt}{#3}
  \csname #1s\endcsname{#2++\lo++\mlt++\lo}{#3}
  \csname #1s\endcsname{#2++\lo++\mlt++\mlt}{#3}
}
