%%
%% This is file `contracard.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% contracard.dtx  (with options: `contracard-pkg')
%% 
%%   Copyright 2012 Samuel Whited
%% 
%%   This file may be distributed and/or modified under the
%%   conditions of the LaTeX Project Public License, either
%%   version 1.3c of this license or (at your option) any later
%%   version. The latest version of this license is in:
%% 
%%   http://www.latex-project.org/lppl.txt
%% 
%%   and version 1.3c or later is part of all distributions of
%%   LaTeX version 2008/05/04 or later.
%% 
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{contracard}[2013/02/20]
\RequirePackage{intcalc}
\RequirePackage{ifthen}
\RequirePackage{tocloft}
\newcommand*{\defaultcontraenv}{flushleft}
\newcommand*{\dancetitleenv}{flushleft}
\newcommand*{\dancetitleformat}{\section*}
\newcommand*{\danceauthorformat}{\subsection*}
\newcommand*{\danceformformat}{\hfill}
\newcommand*{\movedelimiter}{,}
\newcommand*{\partdelimiter}{.}
\newcommand*{\midpartdelimiter}{;}
\newlength{\phrasevspace}
\setlength{\phrasevspace}{1em}
\newcommand*{\phraseseparator}{\vspace{\phrasevspace}}
\newcounter{dancecount}
\newcounter{partcount}
\newcounter{phrasecount}
\newcounter{dancepart}
\newcounter{dancephrase}
\newcounter{dancepartlength}
\setcounter{dancepartlength}{16}
\newcounter{dancephraselength}
\setcounter{dancephraselength}{32}
\newcommand*{\resetdancephrase}{%
  \ifthenelse{\value{partcount}=16}{\newline}{}%
  \@ifstar{\@resetdancephraseStar}{\@resetdancephraseNoStar}%
}
\newcommand*{\@resetdancephraseStar}{%
  \setcounter{dancephrase}{1}%
  \setcounter{phrasecount}{0}%
  \resetdancepart*
}
\newcommand*{\@resetdancephraseNoStar}{%
  \ifthenelse{\value{dancephrase}=1}{}{%
    \setcounter{dancephrase}{1}%
    \setcounter{phrasecount}{0}%
    \resetdancepart
  }%
}
\newcommand*{\resetdancepart}{%
  \@ifstar{\@resetdancepartStar}{\@resetdancepartNoStar}%
}
\newcommand*{\@resetdancepartStar}{%
  \setcounter{dancepart}{1}%
  \setcounter{partcount}{0}%
}
\newcommand*{\@resetdancepartNoStar}{%
  \ifthenelse{\value{dancepart}=1}{}{%
    \setcounter{dancepart}{1}%
    \setcounter{partcount}{0}%
  }%
}
\newcommand*{\newdancephrase}{%
  \ifthenelse{\not\value{phrasecount}=0}{\newline}{}%
  \addtocounter{dancephrase}{1}%
  \setcounter{phrasecount}{0}%
  \resetdancepart*
}
\newcommand*{\newdancepart}{%
  \newline
  \addtocounter{dancepart}{1}%
  \setcounter{partcount}{0}%
}
\newenvironment{contra}[4][\defaultcontraenv]{%
  \refstepcounter{dance}
  \addcontentsline{lod}{dance}{\protect\numberline{\thedance}#2}
  \setcounter{dancecount}{0}
  \resetdancepart*
  \resetdancephrase*
  \ifdefined\@ccisclass\clearpage\fi%
  \begin{\dancetitleenv}
    \ifdefined\@ccisclass%
      \pagestyle{myheadings}
      \thispagestyle{myheadings}
      \markboth{}{\danceformformat{#4}}
    \else%
      {\danceformformat{#4}}%
    \fi%
    {\dancetitleformat{#2}}%
    {\danceauthorformat{#3}}%
  \end{\dancetitleenv}
  \newcommand*{\@contraenv}{#1}
  \begin{\@contraenv}
}{%
  \end{\@contraenv}
}
\newcommand*{\move}[2][16]{%
  \ifthenelse{\value{phrasecount}=\value{dancephraselength}}{%
    \newdancephrase%
  }{%
    \ifthenelse{\value{partcount}=\value{dancepartlength}}{%
     \newdancepart%
    }{}%
  }
  \ifthenelse{\intcalcMod{\value{dancecount}}{\value{dancepartlength}}=0}{%
    \Alph{dancephrase}\arabic{dancepart}\partdelimiter\ %
  }{}%
  \addtocounter{dancecount}{#1}%
  \addtocounter{phrasecount}{#1}%
  \addtocounter{partcount}{#1}%
  #2%
  \ifthenelse{\value{phrasecount}=\value{dancephraselength}}{%
    \pagebreak[1]\phraseseparator%
  }{}%
  \ifthenelse{\value{partcount}=\intcalcDiv{\value{dancepartlength}}{2}}{\midpartdelimiter\nopagebreak}{%
    \ifthenelse{\not\value{partcount}=\value{dancepartlength}}{\movedelimiter\nopagebreak\nolinebreak[2]}{}}%
}
\newlistof{dance}{lod}{\lodtitle}
\newcommand*{\listofdances}{\listofdance}
\newcommand*{\lodtitle}{List of Dances}
%% 
%%   ___________
%%   Maintainer: Sam Whited
%%   Website:    https://samwhited.com
%%   Contact:    sam@samwhited.com
%%   Public key: 0xEC2C9934
%% 
%%   This work consists of this file contracard.dtx
%%             and the derived files contracard.sty
%%                               and contracard.cls
%%                               and contracard.pdf
%% 
%%
%% End of file `contracard.sty'.
