blob: e0a0751a6e108c582c8285587c9df8156ca82744 (
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
|
%%
%% This is file `poetry.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% poetry.dtx (with options: `package')
%% This is a generated file.
%%
%% This document is copyright 2014 by Donald P. Goodman, and is
%% released publicly under the LaTeX Project Public License. The
%% distribution and modification of this work is constrained by the
%% conditions of that license. See
%% http://www.latex-project.org/lppl.txt
%% for the text of the license. This document is released
%% under version 1.3 of that license, and this work may be distributed
%% or modified under the terms of that license or, at your option, any
%% later version.
%%
%% This work has the LPPL maintenance status 'maintained'.
%%
%% The Current Maintainer of this work is Donald P. Goodman
%% (dgoodmaniii@gmail.com).
%%
%% This work consists of poetry.dtx, poetry.ins, and
%% derived files poetry.sty and poetry.pdf.
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{poetry}[2017/06/19 v1.0 support for typesetting poetry]
\ProvidesPackage{poetry}%
\newcounter{poemline}%
\newcount\poemlineno%
\newcounter{verseline}%
\newcount\vslineno%
\newcounter{abspoemno}%
\newcount\poem@abspoemno%
\newcounter{poemno}%
\newcount\poem@poemno%
\newcounter{poemgroupno}\setcounter{poemgroupno}{0}%
\newcount\poem@groupno\poem@groupno=0%
\newcounter{poemlinenumsevery}\setcounter{poemlinenumsevery}{1}%
\newcount\poem@linenumsevery\poem@linenumsevery=\value{poemlinenumsevery}%
\newlength{\poemindent}\setlength{\poemindent}{0pt}%
\newlength{\poemtopskip}{\setlength{\poemtopskip}{1em}%
\newlength{\poembotskip}{\setlength{\poembotskip}{1em}%
\newdimen\poem@topskip\newdimen\poem@botskip%
\newdimen\poem@defleftskip\poem@defleftskip=\the\poemindent%
\newdimen\poem@maxlinewd%
\newlength{\poemmaxlinewd}\setlength{\poemmaxlinewd}{\textwidth}%
\newdimen\poem@hinwd\poem@hinwd=1em%
\newlength{\poemhinwd}\setlength{\poemhinwd}{1em}%
\newif\ifpoemlinenums\poemlinenumstrue%
\newif\ifpoemlinenumright\poemlinenumrightfalse%
\newdimen\poem@linenumboxwd\poem@linenumboxwd=2em%
\newlength{\poemlinenumboxwd}\setlength{\poemlinenumboxwd}{2em}%
\newdimen\poem@linenumboxgap\poem@linenumboxgap=0pt%
\newlength{\poemlinenumboxgap}\setlength{\poemlinenumboxgap}{0pt}%
\def\poemlinenumstyle{}%
\newdimen\poem@hangindent\poem@hangindent=1em%
\newlength{\poemhangindent}\setlength{\poemhangindent}{1em}%
\newcount\poem@indentevery\poem@indentevery=0%
\newcounter{poemindentevery}\setcounter{poemindentevery}{0}%
\newdimen\poem@verseskip\poem@verseskip=\baselineskip%
\newlength{\poemverseskip}\setlength{\poemverseskip}{\baselineskip}%
\newdimen\poem@buff%
\newcount\poem@tmp%
\def\poem@expandvsloop#1{\poem@xvsloop#1\relax}%
\def\poem@xvsloop#1{%
\ifx\relax#1\else%
\poem@tmp=#1%
\ifnum\poem@tmp=\the\vslineno%
\hin%
\fi%
\expandafter\poem@xvsloop%
\fi%
}%
\newcommand{\poem@ifbang}[1]{\@ifnextchar !{\@firstoftwo{#1}}}
\newcommand{\poem@ifhyph}[1]{\@ifnextchar -{\@firstoftwo{#1}}}
\newcommand{\poem@ifstar}[1]{\@ifnextchar *{\@firstoftwo{#1}}}
\newcommand{\poem@ifques}[1]{\@ifnextchar ?{\@firstoftwo{#1}}}
\newcount\poem@tmpa
\def\modulo#1#2{%
\poem@tmpa=#1%
\divide\poem@tmpa by#2%
\multiply\poem@tmpa by#2%
\multiply\poem@tmpa by-1%
\advance\poem@tmpa by#1\relax%
}%
\def\poemvsindentlines{}%
\def\poemlnindentlines{}%
\def\tlap#1{\vbox to0pt{\vss\hbox{#1}}}%
\def\blap#1{\vbox to0pt{\hbox{#1}\vss}}%
\def\placelineno{%
\setcounter{verseline}{\the\vslineno}%
\setcounter{poemline}{\the\poemlineno}%
\poem@linenumsevery=\value{poemlinenumsevery}%
\poem@linenumboxgap=\the\poemlinenumboxgap%
\poem@linenumboxwd=\the\poemlinenumboxwd%
\modulo{\the\poemlineno}{\the\poem@linenumsevery}%
\ifpoemlinenums%
\ifnum\poem@tmpa=0%
\ifpoemlinenumright%
\hskip0pt\tlap{%
\rlap{%
\hskip\poem@maxlinewd%
\hskip\poem@linenumboxgap%
\hbox to\poem@linenumboxwd{%
\hfil%
\poemlinenumstyle\thepoemline%
}%
}%
}%
\else%
\hskip-\poem@linenumboxgap%
\llap{%
\tlap{%
\hbox to\poem@linenumboxwd{%
\poemlinenumstyle\thepoemline%
\hfil%
}\penalty10000%
}%
}\penalty10000%
\fi%
\else
\hskip-\poem@linenumboxgap%
\llap{\tlap{\hbox to\poem@linenumboxwd{\hfil}}}%
\penalty10000%
\fi%
\else
\hskip-\poem@linenumboxgap%
\llap{\tlap{\hbox to\poem@linenumboxwd{\hfil}}}%
\penalty10000%
\fi%
\par\vskip-\baselineskip%
\poem@indentevery=\value{poemindentevery}%
\ifnum\poem@indentevery=0%
\else%
\modulo{\the\poemlineno}{\the\poem@indentevery}%
\ifnum\poem@tmpa=0%
\hin%
\fi%
\fi%
\expandafter\poem@expandvsloop\expandafter{\poemvsindentlines}%
\def\@currentlabel{\thepoemline}%
\phantomsection%
}%
\def\poem@endline{%
\par%
\advance\poemlineno by1%
\advance\vslineno by1%
\poem@defaultpars%
\leftskip=\poem@defleftskip%
\placelineno%
}%
\def\poem@endpart{%
\par%
\advance\poemlineno by1%
\advance\vslineno by1%
\poem@defaultpars%
\leftskip=\poem@defleftskip%
}%
\def\poem@resume{%
\placelineno%
}%
\def\*{%
\poem@resume%
}%
\def\poem@endverse{%
\par%
\vslineno=1%
\advance\poemlineno by1%
\poem@verseskip=\the\poemverseskip%
\vskip\poem@verseskip%
\leftskip=\poem@defleftskip%
\placelineno%
}
\def\poem@endversepart{%
\par%
\advance\poemlineno by1%
\vslineno=1%
\poem@defaultpars%
\leftskip=\poem@defleftskip%
}
\def\poem@defaultpars{%
\poem@hangindent=\the\poemhangindent%
\everypar={%
\parindent=0pt%
\hangindent=\poem@hangindent%
\hangafter=1%
}%
}%
\def\hin{%
\poem@hinwd=\the\poemhinwd%
\advance\leftskip by\the\poem@hinwd%
\penalty10000%
}%
\def\poemnew{%
\advance\poem@poemno by1\stepcounter{poemno}%
\advance\poem@abspoemno by1\stepcounter{abspoemno}%
}%
\def\poem{%
\widowpenalty=0\clubpenalty=0%
\def\\{%
\poem@ifbang{\poem@endverse}{%
\poem@ifhyph{\par\vskip\poem@botskip\relax}{%
\poem@ifstar{\poem@endpart}{%
\poem@ifques{\poem@endversepart}{\poem@endline}%
}%
}%
}%
}%
\poem@defleftskip=\the\poemindent%
\leftskip=\poem@defleftskip%
\poem@maxlinewd=\the\poemmaxlinewd%
\hsize=\the\poem@defleftskip%
\advance\hsize by\the\poem@maxlinewd%
\poemlineno=1%
\vslineno=1%
\poem@topskip=\the\poemtopskip%
\poem@botskip=\the\poembotskip%
\vskip\poem@topskip%
\poem@defaultpars%
\noindent%
\poem@ifstar{}{\placelineno}%
}%
\def\endpoem{%
}%
\newdimen\poem@centlinewd
\def\centerpoemon#1{%
\settowidth{\poem@centlinewd}{#1}%
\ifdim\poem@centlinewd>\linewidth\poem@defleftskip=0pt%
\else
\poem@buff=\linewidth%
\advance\poem@buff by-\poem@centlinewd%
\divide\poem@buff by2%
\poem@defleftskip=\the\poem@buff%
\poemindent=\the\poem@buff%
\poem@maxlinewd=\the\poem@centlinewd%
\setlength{\poemmaxlinewd}{\poem@maxlinewd}%
\fi
}%
\def\centerpoemoff{%
\poem@defleftskip=0pt\setlength{\poemindent}{0pt}%
\poem@maxlinewd=\the\linewidth%
\setlength{\poemmaxlinewd}{\linewidth}%
}%
\def\thepoemtitle{\poemblanktitle}%
\def\thepoemauthor{\poemblankauthor}%
\def\thepoemlicense{Public Domain}%
\def\poemdefaultlicense{Public Domain}%
\def\thepoempubdate{\today}%
\def\poemblanktitle{Untitled}%
\def\poemblankauthor{Anonymous}%
\def\poemtitlestyle{\LARGE\bfseries}%
\def\poemauthorstyle{\Large}%
\def\poemtitleprehook{%
\begin{center}%
}%
\def\poemtitleposthook{%
\end{center}%
}%
\def\poemauthorprehook{%
\begin{center}%
}%
\def\poemauthorposthook{%
\end{center}%
}%
\def\titlepoem#1{%
\advance\poem@poemno by1\stepcounter{poemno}%
\advance\poem@abspoemno by1\stepcounter{abspoemno}%
\def\thepoemtitle{#1}\def\thepoemauthor{\poemblankauthor}%
\begingroup%
\poemtitleprehook%
\poemtitlestyle #1%
\poemtitleposthook%
\endgroup%
}%
\def\titleauthorpoem#1#2{%
\advance\poem@poemno by1\stepcounter{poemno}%
\advance\poem@abspoemno by1\stepcounter{abspoemno}%
\def\thepoemtitle{#1}\def\thepoemauthor{#2}%
\begingroup%
\poemtitleprehook%
\poemtitlestyle #1%
\poemtitleposthook%
\endgroup%
\begingroup%
\poemauthorprehook%
\poemauthorstyle #2%
\poemauthorposthook%
\endgroup%
}%
\def\poemgroup{%
\advance\poem@groupno by1%
\stepcounter{poemgroupno}%
\poem@poemno=0\setcounter{poemno}{0}%
\def\thepoemgroupname{\poemgroupblankname}%
}%
\def\endpoemgroup{%
}%
\def\poemgrouptitleprehook{}%
\def\poemgrouptitleposthook{}%
\def\poemgroupotherprehook{}%
\def\poemgroupotherposthook{}%
\def\poemgrouptitlestyle{\Huge}%
\def\poemgroupotherstyle{\LARGE}%
\def\poemgroupblankname{Untitled Group}%
\def\poemgroupname{\poemgroupblankname}%
\def\poemgroupheading#1#2{%
\def\thepoemgroupname{#1}%
\begingroup%
\poemgrouptitleprehook%
\poemgrouptitlestyle #1%
\poemgrouptitleposthook%
\endgroup%
\begingroup%
\poemgroupotherprehook%
\poemgroupotherstyle #2%
\poemgroupotherposthook%
\endgroup%
}%
\def\poemlopformat{%
\@dottedtocline{1}{0em}{2.3em}%
}%
\def\l@poem{\poemlopformat}%
\def\addtolop#1{%
\addcontentsline{lop}{poem}{#1}%
}%
\def\addgrouptolop#1{%
\addcontentsline{lop}{poemgroup}{#1}%
}%
\def\lopname{List of Poems}%
\def\listofpoems{%
\@starttoc{lop}%
}%
\def\poemgrouplopformat#1#2{%
\ifnum \c@tocdepth >\m@ne
\addpenalty{-\@highpenalty}%
\vskip 1.0em \@plus\p@
\setlength\@tempdima{1.5em}%
\begingroup
\parindent \z@ \rightskip \@pnumwidth
\parfillskip -\@pnumwidth
\leavevmode \bfseries
\advance\leftskip\@tempdima
\hskip -\leftskip
#1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
\penalty\@highpenalty
\endgroup
\fi%
}%
\def\l@poemgroup{\poemgrouplopformat}%
\RequirePackage{imakeidx}
\makeindex[intoc,columns=1,name={\jobname-iofl},title={\poemioflname}]
\def\poemioflname{Index of First Lines}%
\def\poemfirstline#1{%
\index[\jobname-iofl]{#1}%
}%
\def\iofl#1{%
\index[\jobname-iofl]{#1}%
#1%
}%
\def\printiofl{%
\printindex[\jobname-iofl]%
}%
\endinput
%%
%% End of file `poetry.sty'.
|