summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/contracard/contracard.dtx
blob: 2c5088ec48e2361b237ddb2cc6488ab85b20df36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
% \iffalse
%<*internal>
\begingroup
\input docstrip.tex
\keepsilent
\usedir{tex/latex/contracard}
\preamble

  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.

\endpreamble
\postamble

  ___________
  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.cls
                              and contracard.pdf

\endpostamble
\askforoverwritefalse

\generate{\file{contracard.cls}{\from{contracard.dtx}{contracard}}}
\generate{\file{contracard-style.sty}{\from{contracard.dtx}{doc-style}}}

\obeyspaces
\Msg{****************************************************}
\Msg{*                                                  *}
\Msg{* To finish the installation you have to move the  *}
\Msg{* following file into a directory searched by TeX: *}
\Msg{*                                                  *}
\Msg{* contracard.cls                                   *}
\Msg{*                                                  *}
\Msg{****************************************************}

\endgroup
%</internal>
%
%<*driver>
\ProvidesFile{contracard.dtx}
%</driver>
%
%<*contracard>
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{contracard}[2013/02/17]
\AtEndOfClass{\LoadClass{article}}
%</contracard>%
%
%<*driver>
\documentclass[a4paper]{ltxdoc}
\usepackage{contracard-style}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
%
% \fi
%
% \GetFileInfo{contracard.dtx}
% \makeatletter
% \errorcontextlines=999
%
% \title{The \textsf{contracard} class}
% \author{
%   \name{Sam Whited}\\
%   \texttt{sam@samwhited.com}
% }
% \date{\today\\\gittag}
%
% \maketitle
% \tableofcontents
%
% \section{Introduction}
%
% The \pkg{contracard} class is designed to aid in the formatting and
% typesetting of caller cards for traditional square and line dances.
%
% \subsection{Rationale}
%
% There is little to no purpose for this class. I was tired of seeing caller
% cards that were written in difficult to read shorthand, or, when they were
% presented in a digital format, using some ugly 90s-looking HTML or MS Word
% template. This is my attempt to make calling cards more beautiful.
%
% \subsection{License / about the source}
%
% This project 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 opinion) any later version. The latest version of this license is in:
%
% \url{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.
%
% Contributions are welcome, and the latest development version of the project
% can always be found at \url{https://github.com/samwhited/contracard}.
%
% \StopEventually{}
% \changes{0.1}{2013/02/09}{Created boilerplate for class}
% \section{Package building and loading}
%
%    \begin{macrocode}
%<*contracard>
%    \end{macrocode}
%
% \paragraph{Building}
%
% Before building \pkg{contracard} you should verify that the following
% dependencies are installed:
%
%    \begin{macrocode}
\AtEndOfClass{\RequirePackage{intcalc}}
\AtEndOfClass{\RequirePackage{hyperref}}
\AtEndOfClass{\RequirePackage{ifthen}}
\AtEndOfClass{\RequirePackage{geometry}}
\AtEndOfClass{\RequirePackage{fancyhdr}}
\AtEndOfClass{\RequirePackage[compact]{titlesec}}
%    \end{macrocode}
% Once you have all the required packages, building \pkg{contracard} from source
% can be accomplished in multiple ways. If the Makefile is present running
% \code{make help} will tell you everything you need to know. To manually
% extract the files and generate the documentation simply run \code{pdflatex}
% against \fname{contracard.dtx} with the \code{-{}-shell-escape} option:
%
% \begin{Verbatim}
%   $ pdflatex --shell-escape contracard.dtx
% \end{Verbatim}
%
% \paragraph{Options}
%
% \hypertarget{CONTRACARD:OPTIONS}{}
% \begin{macro}{small}
% \begin{macro}{medium}
% \begin{macro}{large}
% \begin{macro}{a7paper}
% The class can also be loaded with any of the following options:
%    \begin{macrocode}
\DeclareOption{small}{%
  \AtBeginDocument{%
    \titleformat{\section}{\normalsize\bfseries}{\thesection}{1em}{}%
  }
  \PassOptionsToPackage{%
    margin=0.25in,top=0.75in,paperwidth=5in,paperheight=3in%
  }{geometry}%
}
\DeclareOption{medium}{%
  \AtBeginDocument{\large}
  \PassOptionsToPackage{%
    margin=0.5in,top=0.75in,paperwidth=6in,paperheight=4in%
  }{geometry}%
}
\DeclareOption{large}{%
  \AtBeginDocument{\Large}
  \PassOptionsToPackage{%
    margin=0.75in,top=1in,paperwidth=8in,paperheight=5in%
  }{geometry}%
}
\DeclareOption{a7paper}{%
  \AtBeginDocument{%
    \titleformat{\section}{\normalsize\bfseries}{\thesection}{1em}{}%
  }
  \PassOptionsToPackage{%
    margin=5mm,top=15mm,paperwidth=105mm,paperheight=74mm%
  }{geometry}%
}
\DeclareOption*{%
  \PassOptionsToClass{\CurrentOption}{article}%
}
%    \end{macrocode}
% The \code{small} option creates a 127.0 by 76.2 mm (5 by 3 in) card.
% The \code{medium} option creates a 152.4 by 101.6 mm (6 by 4 in) card.
% The \code{large} option creates a 203.2 by 27.0 mm (8 by 5 in) card.
% The \code{a7paper} option creates a 105 by 74 mm (4.1 by 2.9 in) card.
% Any unrecognized options are passed to the \pkg{article} class.
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \section{Environment setup}
%
% First let's set up the basic environment. We'll start by turning off headers,
% and removing the header rule inserted by \pkg{fancyhdr} on pages that will
% have headers later:
%
%    \begin{macrocode}
\AtBeginDocument{\renewcommand{\headrulewidth}{0pt}}
\AtBeginDocument{\pagestyle{empty}}
%    \end{macrocode}
%
% \begin{macro}{dancecount}
% \begin{macro}{partcount}
% \changes{0.2}{2013/02/15}{Create a counter for the current musical part}
% \begin{macro}{phrasecount}
% \changes{0.2}{2013/02/15}{Create a counter for the current musical phrase}
% Next, we'll create some counters that will help us keep track the counts (or
% `steps') in the dance. The \code{dancecount} is reset at the start of each new
% dance, the \code{partcount} is reset at the begining of each part (eg. \code{%
% A1} or \code{B1}), and the \code{phrasecount} is reset every time the part
% changes (eg. from \code{A} to \code{B}).
%    \begin{macrocode}
\newcounter{dancecount}
\newcounter{partcount}
\newcounter{phrasecount}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\progressed}
% \changes{0.2}{2013/02/15}{Allow the user to reset the phrase}
% The phrase will continue to increment (\code{A}, \code{B}, \code{C}) unless
% the user resets it by calling \code{\textbackslash progressed}. This does not
% strictly indicate progression, but it will be intuitive for most callers.
%    \begin{macrocode}
\newcommand*{\progressed}{\setcounter{phrasecount}{1}}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Formatting}
%
% There are also some options to determine how the environment will be
% formatted.
%
% \begin{macro}{\defaultcontraenv}
% \changes{0.1}{2013/02/14}{Allow user to format moves}
% By default, all contra moves are wrapped in the \code{flushleft} environment.
% To change this you can renew \code{\textbackslash defaultcontraenv}.
%    \begin{macrocode}
\newcommand*{\defaultcontraenv}{flushleft}
%    \end{macrocode}
% \end{macro}
%
% \section{The Meat}
%
% Next we'll define the meat of the \pkg{contracard} package: The \code{contra}
% environment and the \code{\textbackslash move} command.
%
% \subsection{The \code{contra} environment}
%
% \begin{macro}{contra}
% \changes{0.1}{2013/02/14}{Create contra environment}
% The contra environment is pretty simple. It clears the page, resets the
% various counters, and displays some information about the dance.
%    \begin{macrocode}
\newenvironment{contra}[4][\defaultcontraenv]{%
  \clearpage
  \setcounter{dancecount}{0}
  \setcounter{partcount}{1}
  \setcounter{phrasecount}{1}
  \thispagestyle{fancy}
  \rhead{#4}
  \section*{#2}
  {#3}
  \newcommand*{\@contraenv}{#1}
  \begin{\@contraenv}
}{%
  \end{\@contraenv}
}
%    \end{macrocode}
% \end{macro}
%
% \subsection{The \code{\textbackslash move} command}
%
% \begin{macro}{\move}
% \changes{0.1}{2013/02/14}{Add move command}
% The next thing we need to define is the \code{\textbackslash move} command.
% This command takes in a move to display, and (optionally) the number of counts
% the move takes. If the count is not specified, 16 is used as the default.
%    \begin{macrocode}
\newcommand*{\move}[2][16]{%
  \ifthenelse{\intcalcMod{\value{dancecount}}{16}=0}{%
    \Alph{phrasecount}\arabic{partcount}.\ %
  }{}%
  \addtocounter{dancecount}{#1}%
  #2%
  \ifthenelse{\intcalcMod{\value{dancecount}}{8}=0
    \and\not\intcalcMod{\value{dancecount}}{16}=0}{;}{\nopagebreak}%
  \ifthenelse{\not\intcalcMod{\value{dancecount}}{8}=0}{,}{\nopagebreak}%
  \ifthenelse{\intcalcMod{\value{dancecount}}{32}=0}{%
    \addtocounter{phrasecount}{1}\setcounter{partcount}{0}\pagebreak[1]%
    \vspace{1em}}{}%
  \ifthenelse{\intcalcMod{\value{dancecount}}{16}=0}{%
    \addtocounter{partcount}{1}\newline}{}%
}
%    \end{macrocode}
% \end{macro}
%
% \section{Examples}
%
% A few examples are contained below:
%
% \subsection{Code's Compiling by Sam Whited}
%
% \begin{Verbatim}
% \begin{contra}{Code's Compiling}{Sam Whited}{Duple becket}
%   \move[8]{Neighbor dosido}
%   \move[8]{Partner see saw}
%   \move{Shadow swing}
%   \move[8]{Balance and petronella}
%   \move[8]{Balance and petronella}
%   \move[8]{Partner swing}
%   \move[8]{Left diagonal: Right and left through}
% \end{contra}
% \end{Verbatim}
%
% \subsection{Cherokee Shuffle by David Kaynor}
%
% \begin{Verbatim}
% \begin{contra}{Cherokee Shuffle}{David Kaynor}{Duple improper}
%   \move[8]{Circle left}
%   \move[8]{Neighbor dosido}
%   \move{Neighbor balance and swing}
%   \move[4]{Men allemande left \textonehalf}
%   \move[4]{Balance in a wave}
%   \move[8]{Partner swing}
%   \move[8]{Circle left \textthreequarters}
%   \move[4]{Balance the ring}
%   \move[4]{Partner california twirl}
% \end{contra}
% \end{Verbatim}
%
% Now that everything is defined we can process any
% \hyperlink{CONTRACARD:OPTIONS}{options} that were passed in by the user:
%    \begin{macrocode}
\ProcessOptions\relax
%</contracard>
%    \end{macrocode}
%
% \clearpage
% \setcounter{IndexColumns}{2}
% \phantomsection
% \addcontentsline{toc}{section}{Index}
% \PrintIndex
%
% \makeatletter
%   \renewenvironment{theglossary}{%
%   \glossary@prologue
%   \setlength\emergencystretch{5em}
%   \GlossaryParms \let\item\@idxitem \ignorespaces}{}
% \makeatother
% \clearpage
% \phantomsection
% \addcontentsline{toc}{section}{Change History}
% \PrintChanges
% \Finale
%
% \iffalse
%<*doc-style>
%    \begin{macrocode}
\ProvidesPackage{contracard-style}
\usepackage{fancyvrb,hologo,framed,multicol,url}
\usepackage[pdfborder=0, bookmarks, colorlinks=false, hidelinks]{hyperref}
\usepackage[parfill]{parskip}

\fvset{gobble=2}

\newcommand*{\gittag}{%
  \immediate\write18{%
    rm gittag.tex 2> /dev/null; (git describe --tags --dirty || echo "v0.0") 2> /dev/null > gittag.tex
  }%
  \InputIfFileExists{gittag.tex}{}{}\unskip%
  \immediate\write18{%
    rm gittag.tex 2> /dev/null
  }%
}

\newcommand*\name[1]{\textsc{#1}}
\newcommand*\fname[1]{\textsf{#1}}
\newcommand*\pkg[1]{\textsf{#1}}
\newcommand*\code[1]{\texttt{#1}}
%    \end{macrocode}
%</doc-style>
%\fi
\endinput