Skip to content

Instantly share code, notes, and snippets.

@wchargin
Created October 28, 2015 06:24
Show Gist options
  • Save wchargin/364f9abeeb70cf831466 to your computer and use it in GitHub Desktop.
Save wchargin/364f9abeeb70cf831466 to your computer and use it in GitHub Desktop.
paths and polygons on a lattice (or in general, I guess)
\documentclass{article}
\usepackage{wcsetup} % github:wchargin/wclatex
\usepackage{tikz}
\begin{document}
\tikzset{
latticept/.style={
red,
},
latticepath/.style={
blue,
},
}
% usage: \latticepath{(x0, y0){(x1, y1), (x2, y2), ...}
% (the points can actually be any TikZ coordinates)
\newcommand\latticepath[2]{%
\draw[latticepath] #1 \foreach \point in {#2} {-- \point };
\foreach \point in {#1, #2} \filldraw[latticept] \point circle[radius=2pt];
}
% like \latticepath, but will automatically close the path
\newcommand\latticegon[2]{\latticepath{#1}{#2, #1}}
\begin{tikzpicture}
\latticepath{(-1, 0)}{(0, 3), (1, 0), (-1.5, 2), (1.5, 2), (-1, 0)}
%
% works with all your usual commands...
\begin{scope}[
opacity=0.8, transparency group,
xshift=5cm,
latticept/.style={orange,fill=white},
latticepath/.append style={thick,dotted},
]
\latticegon{(-1, 0)}{(0, 3), (1, 0), (-1.5, 2), (1.5, 2)}
\end{scope}
\end{tikzpicture}
\end{document}
@wchargin
Copy link
Author

output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment