%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Simpler Wick Contractions
% Copyright (C) 2014 Joshua Ellis
%
% An simpler implementation of the Wick contractions.
%
%
% 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.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Joshua Ellis.
%
% This program is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
% FOR A PARTICULAR PURPOSE. See the LaTeX Project Public License for more
% details.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ProvidesPackage{simpler-wick}[2015/12/11 Simpler Wick contractions]
\RequirePackage{tikz}
\RequirePackage{pgfopts}
\usetikzlibrary{calc}
\usetikzlibrary{external}
\pgfkeys{
/simplerwick/.is family,
/simplerwick,
sep/.store in=\swick@sep,
sep=3pt,
offset/.store in=\swick@offset,
offset=1em}
\ProcessPgfOptions{/simplerwick}
% Works just like \@ifnextchar[, except for digits [1-9]
\def\swick@ifnextdigit#1#2{
\@ifnextchar 1{#1}{
\@ifnextchar 2{#1}{
\@ifnextchar 3{#1}{
\@ifnextchar 4{#1}{
\@ifnextchar 5{#1}{
\@ifnextchar 6{#1}{
\@ifnextchar 7{#1}{
\@ifnextchar 8{#1}{
\@ifnextchar 9{#1}{#2}}}}}}}}}}
% A count to keep track of how many contraction are currently open.
\countdef\swick@count=0
% Convert the digit to its representation as a word
\def\swick@translate#1{%
\ifcase#1\or
one\or
two\or
three\or
four\or
five\or
six\or
seven\or
eight\or
nine\fi
}
% Keeping track of which contraction is open or closed.
\newif\ifswick@if@one@
\newif\ifswick@if@two@
\newif\ifswick@if@three@
\newif\ifswick@if@four@
\newif\ifswick@if@five@
\newif\ifswick@if@six@
\newif\ifswick@if@seven@
\newif\ifswick@if@eight@
\newif\ifswick@if@nine@
% Shortcut to the ith 'if' variable
\def\swick@settrue@#1{
\csname swick@if@\swick@translate{#1}@true\endcsname}
\def\swick@setfalse@#1{
\csname swick@if@\swick@translate{#1}@false\endcsname}
% Returns true or false based on whether the ith. Use as:
%
% \if\swick@cond@4
%
% \else
%