| 1 |
% \iffalse |
| 2 |
%<*internal> |
| 3 |
\begingroup |
| 4 |
\input docstrip.tex |
| 5 |
\keepsilent |
| 6 |
\usedir{tex/latex/poetrytex} |
| 7 |
\preamble |
| 8 |
|
| 9 |
Copyright 2012 Samuel Whited |
| 10 |
|
| 11 |
This file may be distributed and/or modified under the |
| 12 |
conditions of the LaTeX Project Public License, either |
| 13 |
version 1.3c of this license or (at your option) any later |
| 14 |
version. The latest version of this license is in: |
| 15 |
|
| 16 |
http://www.latex-project.org/lppl.txt |
| 17 |
|
| 18 |
and version 1.3c or later is part of all distributions of |
| 19 |
LaTeX version 2008/05/04 or later. |
| 20 |
|
| 21 |
\endpreamble |
| 22 |
\postamble |
| 23 |
|
| 24 |
___________ |
| 25 |
Maintainer: Sam Whited |
| 26 |
Website: https://blog.samwhited.com |
| 27 |
Contact: [email protected] |
| 28 |
Public key: 0x54083AE104EA7AD3 |
| 29 |
|
| 30 |
This work consists of this file poetrytex.dtx |
| 31 |
and the derived files poetrytex.sty |
| 32 |
and poetrytex.pdf |
| 33 |
|
| 34 |
\endpostamble |
| 35 |
\askforoverwritefalse |
| 36 |
|
| 37 |
\generate{\file{poetrytex.sty}{\from{poetrytex.dtx}{poetrytex}}} |
| 38 |
|
| 39 |
\obeyspaces |
| 40 |
\Msg{****************************************************} |
| 41 |
\Msg{* *} |
| 42 |
\Msg{* To finish the installation you have to move the *} |
| 43 |
\Msg{* following file into a directory searched by TeX: *} |
| 44 |
\Msg{* *} |
| 45 |
\Msg{* poetrytex.sty *} |
| 46 |
\Msg{* *} |
| 47 |
\Msg{****************************************************} |
| 48 |
|
| 49 |
\endgroup |
| 50 |
%</internal> |
| 51 |
% |
| 52 |
%<*driver> |
| 53 |
\ProvidesFile{poetrytex.dtx} |
| 54 |
%</driver> |
| 55 |
% |
| 56 |
%<*poetrytex> |
| 57 |
\NeedsTeXFormat{LaTeX2e}[1994/06/01] |
| 58 |
\ProvidesPackage{poetrytex}[2014/12/12] |
| 59 |
%</poetrytex>% |
| 60 |
% |
| 61 |
%<*driver> |
| 62 |
\documentclass[a4paper]{ltxdoc} |
| 63 |
\usepackage[pdfborder=0, bookmarks, colorlinks=false, hidelinks]{hyperref} |
| 64 |
\usepackage{fancyvrb,hologo,framed,multicol,tipa,url,textcomp,poetrytex} |
| 65 |
\usepackage[parfill]{parskip} |
| 66 |
|
| 67 |
\fvset{gobble=2} |
| 68 |
|
| 69 |
\newenvironment{Example}{% |
| 70 |
\begingroup\setlength{\columnseprule}{.4pt} |
| 71 |
\begin{minipage}{\textwidth} |
| 72 |
\begin{multicols}{2} |
| 73 |
}{ |
| 74 |
\end{multicols} |
| 75 |
\end{minipage} |
| 76 |
\endgroup |
| 77 |
} |
| 78 |
|
| 79 |
\newcommand*{\gitdescribe}{% |
| 80 |
\immediate\write18{% |
| 81 |
rm -f gitdescribe.tex 2> /dev/null; (git describe --tags --dirty ||% |
| 82 |
echo "v0.0.0") 2> /dev/null > gitdescribe.tex |
| 83 |
}% |
| 84 |
\InputIfFileExists{gitdescribe.tex}{}{}\unskip% |
| 85 |
\immediate\write18{% |
| 86 |
rm -f gitdescribe.tex 2> /dev/null |
| 87 |
}% |
| 88 |
} |
| 89 |
|
| 90 |
\newcommand\XeLaTeX{\hologo{XeLaTeX}} |
| 91 |
|
| 92 |
\newcommand*\name[1]{\textsc{#1}} |
| 93 |
\newcommand*\fname[1]{\textsf{#1}} |
| 94 |
\newcommand*\pkg[1]{\textsf{#1}} |
| 95 |
\newcommand*\code[1]{\texttt{#1}} |
| 96 |
|
| 97 |
\renewcommand\partname{Part} |
| 98 |
\EnableCrossrefs |
| 99 |
\CodelineIndex |
| 100 |
\RecordChanges |
| 101 |
\begin{document} |
| 102 |
\DocInput{\jobname.dtx} |
| 103 |
\end{document} |
| 104 |
%</driver> |
| 105 |
% |
| 106 |
% \fi |
| 107 |
% |
| 108 |
% \GetFileInfo{\jobname.dtx} |
| 109 |
% \makeatletter |
| 110 |
% \errorcontextlines=999 |
| 111 |
% |
| 112 |
% \title{The \textsf{\jobname} package} |
| 113 |
% \author{ |
| 114 |
% \name{Sam Whited}\\* |
| 115 |
% \texttt{[email protected]} |
| 116 |
% } |
| 117 |
% \date{\today\\*\gitdescribe} |
| 118 |
% |
| 119 |
% \maketitle |
| 120 |
% \maketoc |
| 121 |
% |
| 122 |
% \section{Introduction} |
| 123 |
% |
| 124 |
% The \pkg{poetrytex} package is designed to aid in the formatting and |
| 125 |
% typesetting of anthologies of poetry. |
| 126 |
% |
| 127 |
% \subsection{History} |
| 128 |
% |
| 129 |
% The package started out as a collection of macros for automating simple tasks |
| 130 |
% that I often had to perform while working on a collection of poetry and prose. |
| 131 |
% After a time, I decided to turn it into an STY file which would be geared |
| 132 |
% more towards the idea of an anthology or a collection of works and less about |
| 133 |
% typesetting the verse itself (for which there were already several good |
| 134 |
% packages on CTAN). While the file was small this worked well---Learning to |
| 135 |
% use the package was easily accomplished by reading the annotated source code |
| 136 |
% (generated via a modified version of Jeremy Ashkenas' literate programming |
| 137 |
% tool `docco'). However, as the source and scope of the project grew I decided |
| 138 |
% to move away from docco and start working on a proper package that would use |
| 139 |
% more traditional \TeX-style docs. As of version 2.0.0, I began using |
| 140 |
% \href{https://semver.org}{semantic versioning} to track releases. |
| 141 |
% |
| 142 |
% \subsection{License / about the source} |
| 143 |
% |
| 144 |
% This project may be distributed and/or modified under the conditions of the |
| 145 |
% \LaTeX\ Project Public License, either version 1.3c of this license or (at |
| 146 |
% your opinion) any later version. The latest version of this license is in: |
| 147 |
% |
| 148 |
% \url{http://www.latex-project.org/lppl.txt} |
| 149 |
% |
| 150 |
% and version 1.3c or later is part of all distributions of \LaTeX\ version |
| 151 |
% 2008/05/04 or later. |
| 152 |
% |
| 153 |
% Contributions are welcome, and the latest development version of the project |
| 154 |
% can always be found at \url{https://bitbucket.org/SamWhited/poetrytex}. |
| 155 |
% |
| 156 |
% \subsection{Acknowledgements} |
| 157 |
% |
| 158 |
% A special thanks is in order for Brittany Taylor. Though she probably has no |
| 159 |
% idea what \TeX\ is, or that this project even exists, it is due mostly to her |
| 160 |
% influence that it ever got off the ground. Secondly: to Sarah Snyder, who |
| 161 |
% helped me to start writing again after many wasted years, and is always |
| 162 |
% obliging when I want to lose at Scrabble. |
| 163 |
% |
| 164 |
% \StopEventually{} |
| 165 |
% \changes{1.0}{2012/07/18}{Converted package to dtx} |
| 166 |
% \changes{2.1.0}{2013/09/04}{Removed \fname{poetrytex-style.sty} (documentation |
| 167 |
% style)} |
| 168 |
% |
| 169 |
% \section{Package building and loading} |
| 170 |
% |
| 171 |
% \begin{macrocode} |
| 172 |
%<*poetrytex> |
| 173 |
% \end{macrocode} |
| 174 |
% |
| 175 |
% \paragraph{Building} |
| 176 |
% |
| 177 |
% Before building \pkg{poetrytex} you should verify that the following |
| 178 |
% dependencies are installed (note that you do not need to include these lines |
| 179 |
% in your project; just install the packages mentioned): |
| 180 |
% \changes{1.0}{2012/07/18}{Removed \pkg{fontspec} / \pkg{xelatex} dependency} |
| 181 |
% \changes{1.2}{2012/10/03}{Removed \pkg{parskip} dependency} |
| 182 |
% \changes{1.2}{2012/10/03}{Removed default \pkg{hyperref} options} |
| 183 |
% \changes{1.3}{2012/10/03}{Load \pkg{hyperref} at end of package} |
| 184 |
% \changes{2.0.0}{2013/02/23}{Require \pkg{tcloft} package} |
| 185 |
% \changes{2.0.0}{2013/08/17}{Begin using semantic versioning (semver.org)} |
| 186 |
% \changes{3.0.0}{2014/12/12}{Don't load hyperref by default} |
| 187 |
% \begin{macrocode} |
| 188 |
\RequirePackage{expl3} |
| 189 |
\RequirePackage{tocloft} |
| 190 |
% \end{macrocode} |
| 191 |
% Once you have all the required packages, building \pkg{poetrytex} from source |
| 192 |
% can be accomplished in multiple ways. If the Makefile is present running |
| 193 |
% \code{make help} will tell you everything you need to know. To manually |
| 194 |
% extract the files and generate the documentation simply run \code{pdflatex} |
| 195 |
% or \XeLaTeX\ against \fname{poetrytex.dtx}: |
| 196 |
% |
| 197 |
% \begin{Verbatim} |
| 198 |
% pdflatex poetrytex.dtx |
| 199 |
% \end{Verbatim} |
| 200 |
% |
| 201 |
% You can also use the \code{-{}-shell-escape} option to generate documentation |
| 202 |
% which includes the current git commit short-hash in the version number: |
| 203 |
% |
| 204 |
% \begin{Verbatim} |
| 205 |
% pdflatex --shell-escape poetrytex.dtx |
| 206 |
% \end{Verbatim} |
| 207 |
% |
| 208 |
% It should be noted that this option is extremely unsafe and you should only |
| 209 |
% use it if you understand the risks. |
| 210 |
% |
| 211 |
% \paragraph{Loading} |
| 212 |
% |
| 213 |
% Using \pkg{poetrytex} in your project works exactly as you'd expect: |
| 214 |
% |
| 215 |
% \begin{Verbatim} |
| 216 |
% \usepackage{poetrytex} |
| 217 |
% \end{Verbatim} |
| 218 |
% |
| 219 |
% \hypertarget{POETRYTEX:OPTIONS}{} |
| 220 |
% \changes{1.2}{2012/10/03}{Added various package options} |
| 221 |
% \changes{3.0.0}{2014/12/11}{Remove the redundant `clearpageafterpoems' option} |
| 222 |
% \changes{3.0.0}{2014/12/12}{Don't pass unrecognized options to hyperref} |
| 223 |
% \begin{macro}{poemsintoc} |
| 224 |
% \changes{2.0.0}{2012/08/17}{Add option to insert poems in the ToC} |
| 225 |
% \begin{macro}{numbertop} |
| 226 |
% \begin{macro}{numbertoc} |
| 227 |
% \changes{2.0.0}{2012/08/17}{Add option to number poems in the ToC} |
| 228 |
% \begin{macro}{numberpoems} |
| 229 |
% \begin{macro}{usedefaulttitles} |
| 230 |
% \changes{1.4}{2012/02/13}{Add package option to use default titles} |
| 231 |
% \begin{macro}{useincipits} |
| 232 |
% \changes{2.0.0}{2012/03/06}{Add package option to use incipits} |
| 233 |
% \begin{macro}{clearpageafterpoem} |
| 234 |
% \begin{macro}{clearpageafterannotation} |
| 235 |
% \changes{3.0.0}{2014/12/11}{Add an option to clear the page after annotations} |
| 236 |
% The package can also be loaded with any of the following options. If you're |
| 237 |
% unsure what an option does, check the documentation for the macro that is |
| 238 |
% associated with it in the code below: |
| 239 |
% \begin{macrocode} |
| 240 |
\DeclareOption{poemsintoc}{\listpoemsintoc} |
| 241 |
\DeclareOption{numbertop}{\numbertop} |
| 242 |
\DeclareOption{numbertoc}{\numbertoc} |
| 243 |
\DeclareOption{numberpoems}{\numberpoems} |
| 244 |
\DeclareOption{usedefaulttitles}{\usedefaulttitles} |
| 245 |
\DeclareOption{useincipits}{\useincipits} |
| 246 |
\DeclareOption{clearpageafterpoem}{\clearpageafterpoem} |
| 247 |
\DeclareOption{clearpageafterannotation}{\clearpageafterannotation} |
| 248 |
% \end{macrocode} |
| 249 |
% \end{macro} |
| 250 |
% \end{macro} |
| 251 |
% \end{macro} |
| 252 |
% \end{macro} |
| 253 |
% \end{macro} |
| 254 |
% \end{macro} |
| 255 |
% \end{macro} |
| 256 |
% \end{macro} |
| 257 |
% |
| 258 |
% For instance: |
| 259 |
% |
| 260 |
% \begin{Verbatim} |
| 261 |
% \usepackage[numberpoems,clearpageafterpoem]{poetrytex} |
| 262 |
% \end{Verbatim} |
| 263 |
% |
| 264 |
% \part{Document setup and structure} |
| 265 |
% |
| 266 |
% The \pkg{poetrytex} package is fairly simple as far as \TeX\ packages go, so |
| 267 |
% it's worth taking a look at how it works internally. |
| 268 |
% |
| 269 |
% \section{Environment setup and defaults} |
| 270 |
% |
| 271 |
% First we setup our environment, define some useful properties, and choose some |
| 272 |
% default values for those properties. |
| 273 |
% |
| 274 |
% \subsection{Title page} |
| 275 |
% |
| 276 |
% We'll start with the title page: |
| 277 |
% |
| 278 |
% \begin{macro}{\pttitle} |
| 279 |
% \begin{macro}{\ptsubtitle} |
| 280 |
% \begin{macro}{\ptauthor} |
| 281 |
% \begin{macro}{\ptdate} |
| 282 |
% These properties will affect the appearance of \code{\textbackslash% |
| 283 |
% maketitle}: |
| 284 |
% \begin{macrocode} |
| 285 |
\newcommand*{\pttitle}{Title} |
| 286 |
\newcommand*{\ptsubtitle}{Subtitle} |
| 287 |
\newcommand*{\ptauthor}{Author} |
| 288 |
\newcommand*{\ptdate}{\today} |
| 289 |
% \end{macrocode} |
| 290 |
% \end{macro} |
| 291 |
% \end{macro} |
| 292 |
% \end{macro} |
| 293 |
% \end{macro} |
| 294 |
% |
| 295 |
% Since we define them as commands, you can change the appearance of your |
| 296 |
% title page by redefining them in your preamble like so: |
| 297 |
% |
| 298 |
% \begin{Verbatim} |
| 299 |
% \renewcommand*{\pttitle}{My Title} |
| 300 |
% \renewcommand*{\ptauthor}{The Author} |
| 301 |
% \end{Verbatim} |
| 302 |
% |
| 303 |
% We then use these properties to set the document title, author, and date: |
| 304 |
% \begin{macrocode} |
| 305 |
\title{% |
| 306 |
\beforetitle\pttitle\aftertitle% |
| 307 |
\ifx\ptsubtitle\@ptundefined% |
| 308 |
\relax% |
| 309 |
\else% |
| 310 |
\\*\beforesubtitle\ptsubtitle\aftersubtitle% |
| 311 |
\fi% |
| 312 |
} |
| 313 |
\author{\beforeauthor\ptauthor\afterauthor} |
| 314 |
\date{\beforedate\ptdate\afterdate} |
| 315 |
% \end{macrocode} |
| 316 |
% Since \code{\textbackslash maketitle} clears the internal title, author, and |
| 317 |
% date we use the \code{\textbackslash pt} equivalents so that we can refer to |
| 318 |
% them again later, or redefine them throughout the document---in anthologies |
| 319 |
% with works by multiple authors, for instance. |
| 320 |
% |
| 321 |
% \subsection{Poem config} |
| 322 |
% |
| 323 |
% \begin{macro}{\@ptpoemlabeltext} |
| 324 |
% Each time you create a poem in your document we automatically assign it a |
| 325 |
% special label that can be used to link to it later. This label is prefixed |
| 326 |
% with \code{\textbackslash @ptpoemlabeltext} to prevent it from conflicting |
| 327 |
% with user defined labels, or labels defined in other packages. |
| 328 |
% \begin{macrocode} |
| 329 |
\newcommand*{\@ptpoemlabeltext}{poetrytexpoem:} |
| 330 |
% \end{macrocode} |
| 331 |
% \end{macro} |
| 332 |
% |
| 333 |
% Chances are you'll never need to touch this. |
| 334 |
% |
| 335 |
% \begin{macro}{poemnum} |
| 336 |
% \begin{macro}{absolutepoemnum} |
| 337 |
% \begin{macro}{untitledpoemnum} |
| 338 |
% \changes{1.4}{2013/02/12}{Create a new counter to track untitled poems} |
| 339 |
% \begin{macro}{absoluteuntitledpoemnum} |
| 340 |
% \changes{1.4}{2013/02/12}{Create a new counter to track of untitled poems} |
| 341 |
% \begin{macro}{titledpoemnum} |
| 342 |
% \changes{2.1.0}{2013/09/01}{Create a new counter to track titled poems} |
| 343 |
% \begin{macro}{absolutetitledpoemnum} |
| 344 |
% \changes{2.1.0}{2013/09/01}{Create a new counter to track titled poems} |
| 345 |
% \begin{macro}{poemgroupnum} |
| 346 |
% \changes{2.0.0}{2013/02/23}{Create a new counter to track poem groups} |
| 347 |
% The \code{poemnum} and \code{absolutepoemnum} counters will be incremented |
| 348 |
% every time we include a poem in our document and can be used later to number |
| 349 |
% the poems. The \code{absolutepoemnum} counter will never be reset by \pkg{% |
| 350 |
% poetrytex} while \code{poemnum} will be be reset to 0 at the beginning of a |
| 351 |
% new \code{poemgroup}. The \code{untitledpoemnum} and |
| 352 |
% \code{absoluteuntitledpoemnum} are similar except that they are only |
| 353 |
% incremented when the poem does not have a title. |
| 354 |
% \begin{macrocode} |
| 355 |
\newcounter{poemnum} |
| 356 |
\newcounter{absolutepoemnum} |
| 357 |
\newcounter{untitledpoemnum} |
| 358 |
\newcounter{absoluteuntitledpoemnum} |
| 359 |
\newcounter{titledpoemnum} |
| 360 |
\newcounter{absolutetitledpoemnum} |
| 361 |
\newcounter{poemgroupnum} |
| 362 |
% \end{macrocode} |
| 363 |
% \end{macro} |
| 364 |
% \end{macro} |
| 365 |
% \end{macro} |
| 366 |
% \end{macro} |
| 367 |
% \end{macro} |
| 368 |
% \end{macro} |
| 369 |
% \end{macro} |
| 370 |
% |
| 371 |
% \begin{macro}{\poemvspace} |
| 372 |
% \changes{1.4}{2013/02/11}{Allow whitespace before every poem} |
| 373 |
% Sometimes you might want to insert a certain amount of vertical space before |
| 374 |
% every poem. For instance, maybe you have several poems without titles and you |
| 375 |
% need a visual cue to let your readers know that a new poem is starting. This |
| 376 |
% can be acomplished by setting \code{\textbackslash poemvspace}: |
| 377 |
% |
| 378 |
% \begin{macrocode} |
| 379 |
\newlength{\poemvspace} |
| 380 |
\setlength{\poemvspace}{0em} |
| 381 |
% \end{macrocode} |
| 382 |
% \end{macro} |
| 383 |
% |
| 384 |
% \begin{macro}{\pttitleleftspace} |
| 385 |
% \changes{1.4}{2013/02/14}{Add macro to define poem title left hspace} |
| 386 |
% \begin{macro}{\pttitlerightspace} |
| 387 |
% \changes{1.4}{2013/02/14}{Add macro to define poem title right hspace} |
| 388 |
% \begin{macro}{\ptsubtitleleftspace} |
| 389 |
% \changes{1.4}{2013/02/14}{Add macro to define poem subtitle left hspace} |
| 390 |
% \begin{macro}{\ptsubtitlerightspace} |
| 391 |
% \changes{1.4}{2013/02/14}{Add macro to define poem subtitle right hspace} |
| 392 |
% To indent the poems title or subtitle to the left or the right, set the length |
| 393 |
% of \code{\textbackslash pttitleleftspace} and \code{\textbackslash% |
| 394 |
% pttitlerightspace}. |
| 395 |
% |
| 396 |
% \begin{macrocode} |
| 397 |
\newlength{\pttitleleftspace} |
| 398 |
\setlength{\pttitleleftspace}{0em} |
| 399 |
\newlength{\pttitlerightspace} |
| 400 |
\setlength{\pttitlerightspace}{0em} |
| 401 |
\newlength{\ptsubtitleleftspace} |
| 402 |
\setlength{\ptsubtitleleftspace}{0em} |
| 403 |
\newlength{\ptsubtitlerightspace} |
| 404 |
\setlength{\ptsubtitlerightspace}{0em} |
| 405 |
% \end{macrocode} |
| 406 |
% \end{macro} |
| 407 |
% \end{macro} |
| 408 |
% \end{macro} |
| 409 |
% \end{macro} |
| 410 |
% |
| 411 |
% \begin{macro}{\usedefaulttitles} |
| 412 |
% \changes{3.0.0}{2014/12/12}{Change name of \code{\textbackslash ptusedefaulttitles} to \code{\textbackslash usedefaulttitles}} |
| 413 |
% \begin{macro}{\nousedefaulttitles} |
| 414 |
% \changes{3.0.0}{2014/12/12}{Add macro to stop using default titles} |
| 415 |
% \begin{macro}{\ptdefaulttitle} |
| 416 |
% \changes{1.4}{2013/02/12}{Add a default poem title} |
| 417 |
% \begin{macro}{\useincipits} |
| 418 |
% \changes{2.0.0}{2013/03/06}{Add option for using incipits in the ToP} |
| 419 |
% \changes{3.0.0}{2014/12/12}{Change name of \code{\textbackslash ptuseincipits} to \code{\textbackslash useincipits}} |
| 420 |
% \begin{macro}{\nouseincipits} |
| 421 |
% \changes{3.0.0}{2014/12/12}{Add macro to stop using incipits} |
| 422 |
% The default title for poems that don't include one. If |
| 423 |
% \code{\textbackslash usedefaulttitles} is called the default title will be |
| 424 |
% displayed above the poem itself as well as in the table of contents. Otherwise |
| 425 |
% the title is left blank. We can also use incipits in the ToP by calling |
| 426 |
% \code{\textbackslash ptuseincipits}. This will override the default title in |
| 427 |
% the ToP, but will not be displayed atop the poem itself. |
| 428 |
% |
| 429 |
% \begin{macrocode} |
| 430 |
\newcommand*{\usedefaulttitles}{\newcommand*{\@ptusedefaulttitles}{}} |
| 431 |
\newcommand*{\nousedefaulttitles}{\let\@ptusedefaulttitles\@ptundefined} |
| 432 |
\newcommand*{\ptdefaulttitle}{% |
| 433 |
Untitled No. \arabic{absoluteuntitledpoemnum}% |
| 434 |
} |
| 435 |
\newcommand*{\useincipits}{\newcommand*{\@ptuseincipits}{}} |
| 436 |
\newcommand*{\nouseincipits}{\let\@ptuseincipits\@ptundefined} |
| 437 |
% \end{macrocode} |
| 438 |
% \end{macro} |
| 439 |
% \end{macro} |
| 440 |
% \end{macro} |
| 441 |
% \end{macro} |
| 442 |
% \end{macro} |
| 443 |
% |
| 444 |
% \begin{macro}{\ptdefaultenv} |
| 445 |
% \changes{1.2}{2012/09/20}{Added an option to change the default environment} |
| 446 |
% \begin{macro}{\pttitleenv} |
| 447 |
% \changes{1.4}{2013/02/13}{Allow changing of the poem title environment} |
| 448 |
% These macros contain the names of the default environments in which we should |
| 449 |
% wrap poems and poem titles. |
| 450 |
% \begin{macrocode} |
| 451 |
\newcommand*{\ptdefaultenv}{verse} |
| 452 |
\newcommand*{\pttitleenv}{center} |
| 453 |
% \end{macrocode} |
| 454 |
% \end{macro} |
| 455 |
% \end{macro} |
| 456 |
% |
| 457 |
% \begin{macro}{\ptdefaultgroupenv} |
| 458 |
% \changes{2.0.0}{2013/03/09}{Allow changing of the default group environment} |
| 459 |
% \begin{macro}{\grouppagestyle} |
| 460 |
% \changes{2.0.0}{2013/03/09}{Allow changing of group page style} |
| 461 |
% \begin{macro}{\pregroupvspace} |
| 462 |
% \changes{2.0.0}{2013/03/09}{Allow change in vspace before group} |
| 463 |
% \begin{macro}{\postgroupvspace} |
| 464 |
% \changes{2.0.0}{2013/03/09}{Allow change in vspace after group} |
| 465 |
% The following macros can be used to configure how the poem group page looks. |
| 466 |
% \begin{macrocode} |
| 467 |
\newcommand*{\ptdefaultgroupenv}{center} |
| 468 |
\newcommand*{\grouppagestyle}{empty} |
| 469 |
\newlength{\pregroupvspace} |
| 470 |
\newlength{\postgroupvspace} |
| 471 |
\setlength{\pregroupvspace}{\fill} |
| 472 |
\setlength{\postgroupvspace}{\fill} |
| 473 |
% \end{macrocode} |
| 474 |
% \end{macro} |
| 475 |
% \end{macro} |
| 476 |
% \end{macro} |
| 477 |
% \end{macro} |
| 478 |
% |
| 479 |
% \subsection{Annotation config} |
| 480 |
% |
| 481 |
% \begin{macro}{annotationnum} |
| 482 |
% \changes{2.1.0}{2013/09/04}{Create a new counter to track annotations} |
| 483 |
% \begin{macro}{absoluteannotationnum} |
| 484 |
% \changes{2.1.0}{2013/09/04}{Create a new counter to track annotations} |
| 485 |
% Like their poem counterparts, these counters are incremented each time an |
| 486 |
% annotation is created and the non-absolute version may be reset when the poem |
| 487 |
% group changes. |
| 488 |
% \begin{macrocode} |
| 489 |
\newcounter{annotationnum} |
| 490 |
\newcounter{absoluteannotationnum} |
| 491 |
% \end{macrocode} |
| 492 |
% \end{macro} |
| 493 |
% \end{macro} |
| 494 |
% |
| 495 |
% \begin{macro}{\ptannotationenv} |
| 496 |
% \changes{1.3}{2012/10/30}{Added an option to change the default annotation |
| 497 |
% environment} |
| 498 |
% This contains the name of the default environment in which we should wrap |
| 499 |
% annotations. |
| 500 |
% \begin{macrocode} |
| 501 |
\newcommand*{\ptannotationenv}{flushleft} |
| 502 |
% \end{macrocode} |
| 503 |
% \end{macro} |
| 504 |
% |
| 505 |
% \subsection{Dedication} |
| 506 |
% |
| 507 |
% After your title page you might want to add a dedication page. |
| 508 |
% |
| 509 |
% \begin{macro}{\ptdedication} |
| 510 |
% \begin{macro}{\makededication} |
| 511 |
% \changes{1.1}{2012/07/21}{Added optional `environment' argument} |
| 512 |
% As with the \code{\textbackslash pttitle} and author commands you can simply |
| 513 |
% redefine \code{\textbackslash ptdedication} to change the dedication text. |
| 514 |
% |
| 515 |
% To create a dedication page, the \code{\textbackslash makededication} command |
| 516 |
% can be called. By default, this command aligns everything to the right using |
| 517 |
% the \textsf{flushright} environment, however, by adding an optional argument |
| 518 |
% you can specify another environment to wrap the dedication in. |
| 519 |
% \begin{macrocode} |
| 520 |
\newcommand*{\ptdedication}{Renew \textsf{\textbackslash ptdedication}} |
| 521 |
\newcommand*{\makededication}[1][flushright]{% |
| 522 |
\thispagestyle{empty} |
| 523 |
\vspace*{\prededicationvspace} |
| 524 |
\begin{#1} |
| 525 |
\beforededication{\dedicationformat\ptdedication}\afterdedication |
| 526 |
\end{#1} |
| 527 |
\vspace*{\postdedicationvspace} |
| 528 |
} |
| 529 |
% \end{macrocode} |
| 530 |
% For example, you might do something like the following: |
| 531 |
% |
| 532 |
% \begin{Example} |
| 533 |
% \begin{Verbatim} |
| 534 |
% \renewcommand*{\ptdedication}{% |
| 535 |
% Frontmatter haiku:\\* |
| 536 |
% This is dedicated to\\* |
| 537 |
% Someone else, not you. |
| 538 |
% } |
| 539 |
% \makededication[center] |
| 540 |
% \end{Verbatim} |
| 541 |
% \columnbreak |
| 542 |
% \renewcommand*{\ptdedication}{% |
| 543 |
% Frontmatter haiku:\\* |
| 544 |
% This is dedicated to\\* |
| 545 |
% Someone else, not you. |
| 546 |
% } |
| 547 |
% \makededication[center] |
| 548 |
% \end{Example} |
| 549 |
% \end{macro} |
| 550 |
% \end{macro} |
| 551 |
% |
| 552 |
% \subsection{Tables and links} |
| 553 |
% |
| 554 |
% Next we setup the table of contents and list of poems: |
| 555 |
% |
| 556 |
% \begin{macro}{\listofpoems} |
| 557 |
% \changes{2.0.0}{2013/02/23}{Use custom table for list of poems} |
| 558 |
% \begin{macro}{\resetnumon} |
| 559 |
% \changes{2.0.0}{2013/02/23}{Allow user to reset poem nums on counter change} |
| 560 |
% The \code{\textbackslash listofpoems} command is nothing more than a |
| 561 |
% convenient alias for \code{\textbackslash listofpoem} as defined by the |
| 562 |
% \pkg{tocloft} package. We can reset poem numbering at a given point by |
| 563 |
% redefining the \code{\textbackslash resetnumon} macro. |
| 564 |
% \begin{macrocode} |
| 565 |
\newcommand*{\resetnumon}{} |
| 566 |
\newlistof[\resetnumon]{poem}{top}{\topname} |
| 567 |
\newcommand*{\listofpoems}{\listofpoem} |
| 568 |
% \end{macrocode} |
| 569 |
% \end{macro} |
| 570 |
% \end{macro} |
| 571 |
% |
| 572 |
% \begin{macro}{\topname} |
| 573 |
% \changes{2.0.0}{2013/03/16}{Rename from \code{\textbackslash toptitle}} |
| 574 |
% \begin{macro}{\topentrytype} |
| 575 |
% \begin{macro}{\toptocentrytype} |
| 576 |
% \changes{2.0.0}{2013/03/07}{Add hook to change ToP entry type in ToC} |
| 577 |
% The value of \code{\textbackslash topname} will be rendered atop the Table of |
| 578 |
% Poems, and \code{\textbackslash topentrytype} will set the default entry type |
| 579 |
% for poems in the ToP. \code{\textbackslash toptocentrytype} sets the default |
| 580 |
% entry type for the ToP in the ToC. |
| 581 |
% \begin{macrocode} |
| 582 |
\newcommand*{\topname}{List of Poems} |
| 583 |
\newcommand*{\topentrytype}{subsection} |
| 584 |
\newcommand*{\toptocentrytype}{section} |
| 585 |
% \end{macrocode} |
| 586 |
% \end{macro} |
| 587 |
% \end{macro} |
| 588 |
% \end{macro} |
| 589 |
% |
| 590 |
% \begin{macro}{\listpoemsintoc} |
| 591 |
% \changes{2.0.0}{2013/08/17}{List poems in the table of contents} |
| 592 |
% \begin{macro}{\nolistpoemsintoc} |
| 593 |
% \changes{3.0.0}{2014/12/12}{Add macro to stop poems being listed in the ToC} |
| 594 |
% \begin{macro}{\tocentrytype} |
| 595 |
% \changes{2.0.0}{2013/08/17}{Sets the entry type for poems in the ToC} |
| 596 |
% Using these commands you can cause poems to be listed in the ToC and set the |
| 597 |
% entry type just like the ToP. By default, the ToC entry type is set to |
| 598 |
% \code{\textbackslash topentrytype}. |
| 599 |
% \begin{macrocode} |
| 600 |
\newcommand*{\listpoemsintoc}{\newcommand*{\@ptlistpoemsintoc}{}} |
| 601 |
\newcommand*{\nolistpoemsintoc}{\let\@ptlistpoemsintoc\@ptundefined} |
| 602 |
\newcommand*{\tocentrytype}{\topentrytype} |
| 603 |
% \end{macrocode} |
| 604 |
% \end{macro} |
| 605 |
% \end{macro} |
| 606 |
% \end{macro} |
| 607 |
% |
| 608 |
% We then set the \code{secnumdepth} and \code{tocdepth} counters to disable |
| 609 |
% chapter, section, and subsection numbering, and to limit the maximum depth of |
| 610 |
% entries in the ToC. |
| 611 |
% |
| 612 |
% \begin{macrocode} |
| 613 |
\setcounter{secnumdepth}{-1} |
| 614 |
\setcounter{tocdepth}{2} |
| 615 |
\renewcommand*{\listtablename}{\topname} |
| 616 |
% \end{macrocode} |
| 617 |
% |
| 618 |
% \begin{macro}{\maketoc} |
| 619 |
% \begin{macro}{\maketop} |
| 620 |
% \begin{macro}{\maketop*} |
| 621 |
% Once you've configured the ToC and ToP you probably want to insert them into |
| 622 |
% your document somewhere. While you could just use the \LaTeX\ command |
| 623 |
% \code{\textbackslash tableofcontents} for the ToC, we provide an alternative |
| 624 |
% that adds a bit of formatting and clears the page. By default the ToP creates |
| 625 |
% a listing for itself in the ToC---using the star modifier prevents this. An |
| 626 |
% example table of poems can be found at the end of this document. |
| 627 |
% \begin{macrocode} |
| 628 |
\newcommand*{\maketoc}{% |
| 629 |
\beforetoc |
| 630 |
\tableofcontents |
| 631 |
\pagestyle{plain} |
| 632 |
\aftertoc |
| 633 |
\clearpage |
| 634 |
\thispagestyle{empty} |
| 635 |
} |
| 636 |
\newcommand*{\maketop}{\@ifstar{\@ptmaketopStar}{\@ptmaketopNoStar}} |
| 637 |
\newcommand*{\@ptmaketopStar}{% |
| 638 |
\cleardoublepage |
| 639 |
\beforetop |
| 640 |
\listofpoems |
| 641 |
\pagestyle{plain} |
| 642 |
\aftertop |
| 643 |
\clearpage |
| 644 |
} |
| 645 |
\newcommand*{\@ptmaketopNoStar}{% |
| 646 |
\cleardoublepage |
| 647 |
\beforetop |
| 648 |
\phantomsection |
| 649 |
\addcontentsline{toc}{\toptocentrytype}{\topname} |
| 650 |
\listofpoems |
| 651 |
\pagestyle{plain} |
| 652 |
\aftertop |
| 653 |
\clearpage |
| 654 |
} |
| 655 |
% \end{macrocode} |
| 656 |
% \end{macro} |
| 657 |
% \end{macro} |
| 658 |
% \end{macro} |
| 659 |
% |
| 660 |
% \begin{macro}{\numbertop} |
| 661 |
% \begin{macro}{\numbertoc} |
| 662 |
% \changes{2.0.0}{2012/08/17}{Number poems in the table of contents} |
| 663 |
% \begin{macro}{\nonumbertop} |
| 664 |
% \changes{3.0.0}{2014/12/11}{Add command to stop numbering the ToP} |
| 665 |
% \begin{macro}{\nonumbertoc} |
| 666 |
% \changes{3.0.0}{2014/12/11}{Add command to stop numbering the ToC} |
| 667 |
% Placing one of these commands in your document preamble will cause the table |
| 668 |
% of poems or table of contents to be numbered (or stop them from being |
| 669 |
% numbered). |
| 670 |
% \begin{macrocode} |
| 671 |
\newcommand*{\numbertop}{\newcommand*{\@ptnumbertop}{}} |
| 672 |
\newcommand*{\numbertoc}{\newcommand*{\@ptnumbertoc}{}} |
| 673 |
\newcommand*{\nonumbertop}{\let\@ptnumbertop\@ptundefined} |
| 674 |
\newcommand*{\nonumbertoc}{\let\@ptnumbertoc\@ptundefined} |
| 675 |
% \end{macrocode} |
| 676 |
% \end{macro} |
| 677 |
% \end{macro} |
| 678 |
% \end{macro} |
| 679 |
% \end{macro} |
| 680 |
% |
| 681 |
% \section{Hooks and formatting} |
| 682 |
% \changes{2.0.0}{2013/03/08}{Refactor hooks into new section} |
| 683 |
% A great many commands are provided to act as hooks into various parts of |
| 684 |
% \pkg{poetrytex}. These commands don't do anything initially, but can be |
| 685 |
% redefined to customize the way \pkg{poetrytex} behaves. |
| 686 |
% |
| 687 |
% \subsection{Title page} |
| 688 |
% |
| 689 |
% \begin{macro}{\beforetitle} |
| 690 |
% \changes{2.0.0}{2013/03/08}{Add hook before title} |
| 691 |
% \begin{macro}{\aftertitle} |
| 692 |
% \changes{2.0.0}{2013/03/08}{Add hook after title} |
| 693 |
% \begin{macro}{\beforesubtitle} |
| 694 |
% \changes{2.0.0}{2013/03/08}{Add hook before subtitle} |
| 695 |
% \begin{macro}{\aftersubtitle} |
| 696 |
% \changes{2.0.0}{2013/03/08}{Add hook after subtitle} |
| 697 |
% \begin{macro}{\beforeauthor} |
| 698 |
% \changes{2.0.0}{2013/03/08}{Add hook before author} |
| 699 |
% \begin{macro}{\afterauthor} |
| 700 |
% \changes{2.0.0}{2013/03/08}{Add hook after author} |
| 701 |
% \begin{macro}{\beforedate} |
| 702 |
% \changes{2.0.0}{2013/03/08}{Add hook before date} |
| 703 |
% \begin{macro}{\afterdate} |
| 704 |
% \changes{2.0.0}{2013/03/08}{Add hook after date} |
| 705 |
% These hooks get inserted before or after elements on the title page or |
| 706 |
% dedication. If the element has formatting, they will be inserted outside of |
| 707 |
% the formatted block, but inside of any enclosing environments. |
| 708 |
% \begin{macrocode} |
| 709 |
\newcommand*{\beforetitle}{} |
| 710 |
\newcommand*{\aftertitle}{} |
| 711 |
\newcommand*{\beforesubtitle}{} |
| 712 |
\newcommand*{\aftersubtitle}{} |
| 713 |
\newcommand*{\beforeauthor}{} |
| 714 |
\newcommand*{\afterauthor}{} |
| 715 |
\newcommand*{\beforedate}{} |
| 716 |
\newcommand*{\afterdate}{} |
| 717 |
% \end{macrocode} |
| 718 |
% \end{macro} |
| 719 |
% \end{macro} |
| 720 |
% \end{macro} |
| 721 |
% \end{macro} |
| 722 |
% \end{macro} |
| 723 |
% \end{macro} |
| 724 |
% \end{macro} |
| 725 |
% \end{macro} |
| 726 |
% |
| 727 |
% \subsection{Dedication} |
| 728 |
% |
| 729 |
% \begin{macro}{\dedicationformat} |
| 730 |
% \changes{2.0.0}{2013/03/08}{Allow customization of dedication format} |
| 731 |
% \begin{macro}{\prededicationvspace} |
| 732 |
% \changes{2.0.0}{2013/03/08}{Add length for setting the pre-dedication vspace} |
| 733 |
% \begin{macro}{\postdedicationvspace} |
| 734 |
% \changes{2.0.0}{2013/03/08}{Add length for setting the post-dedication vspace} |
| 735 |
% \begin{macro}{\beforededication} |
| 736 |
% \changes{2.0.0}{2013/03/08}{Add hook before dedication} |
| 737 |
% \begin{macro}{\afterdedication} |
| 738 |
% \changes{2.0.0}{2013/03/08}{Add hook after dedication} |
| 739 |
% Redefine \code{\textbackslash dedicationformat} to change how the dedication |
| 740 |
% text is formatted. You can change the length of the vspace around the |
| 741 |
% dedication by redefining \code{\textbackslash prededicationvspace} and |
| 742 |
% \code{\textbackslash postdedicationvspace} or redefine the |
| 743 |
% \code{beforededication} and \code{afterdedication} hooks to insert content |
| 744 |
% around the dedication text. |
| 745 |
% \begin{macrocode} |
| 746 |
\newcommand*{\dedicationformat}{\normalfont\itshape} |
| 747 |
\newlength{\prededicationvspace} |
| 748 |
\newlength{\postdedicationvspace} |
| 749 |
\setlength{\prededicationvspace}{\fill} |
| 750 |
\setlength{\postdedicationvspace}{\fill} |
| 751 |
\newcommand*{\beforededication}{} |
| 752 |
\newcommand*{\afterdedication}{} |
| 753 |
% \end{macrocode} |
| 754 |
% \end{macro} |
| 755 |
% \end{macro} |
| 756 |
% \end{macro} |
| 757 |
% \end{macro} |
| 758 |
% \end{macro} |
| 759 |
% |
| 760 |
% \subsection{Tables and links} |
| 761 |
% |
| 762 |
% \begin{macro}{\beforetoc} |
| 763 |
% \changes{1.4}{2012/02/18}{Add hook before table of contents} |
| 764 |
% \begin{macro}{\aftertoc} |
| 765 |
% \changes{1.4}{2012/02/18}{Add hook after table of contents} |
| 766 |
% \begin{macro}{\beforetop} |
| 767 |
% \changes{1.4}{2012/02/18}{Add hook before table of poems} |
| 768 |
% \begin{macro}{\aftertop} |
| 769 |
% \changes{1.4}{2012/02/18}{Add hook after table of poems} |
| 770 |
% Several hooks are provided which allow you to insert content before or after |
| 771 |
% the tables: |
| 772 |
% \begin{macrocode} |
| 773 |
\newcommand{\beforetoc}{} |
| 774 |
\newcommand{\aftertoc}{} |
| 775 |
\newcommand{\beforetop}{} |
| 776 |
\newcommand{\aftertop}{} |
| 777 |
% \end{macrocode} |
| 778 |
% \end{macro} |
| 779 |
% \end{macro} |
| 780 |
% \end{macro} |
| 781 |
% \end{macro} |
| 782 |
% |
| 783 |
% \subsection{Poem group} |
| 784 |
% |
| 785 |
% \begin{macro}{\beforepoemgroup} |
| 786 |
% \changes{2.0.0}{2013/03/09}{Add hook before group} |
| 787 |
% \begin{macro}{\afterpoemgroup} |
| 788 |
% \changes{2.0.0}{2013/03/09}{Add hook after group} |
| 789 |
% The following hooks occur before and after a new poem group. |
| 790 |
% \begin{macrocode} |
| 791 |
\newcommand*{\beforepoemgroup}{\cleardoublepage} |
| 792 |
\newcommand*{\afterpoemgroup}{\clearpage} |
| 793 |
% \end{macrocode} |
| 794 |
% \end{macro} |
| 795 |
% \end{macro} |
| 796 |
% |
| 797 |
% \part{Poems and annotations} |
| 798 |
% |
| 799 |
% Now that we've got all the boilerplate, configuration, titles, tables, and |
| 800 |
% properties out of the way, it's time to move on to the core functionality of |
| 801 |
% \pkg{poetrytex}: displaying and organizing poems! |
| 802 |
% |
| 803 |
% \section{The \code{poem} environment} |
| 804 |
% |
| 805 |
% \begin{environment}{poem} |
| 806 |
% \changes{1.2}{2012/09/20}{Use \code{hypertarget} instead of \code{label}} |
| 807 |
% \changes{2.0.0}{2013/08/15}{Prevent orphan / widow lines in stanzas (\href{https://github.com/SamWhited/poetrytex/issues/7}{Issue \#7)}} |
| 808 |
% Inserting a poem or other writing into your anthology is accomplished by |
| 809 |
% wrapping it in the \code{poem} environment. This environment takes in two |
| 810 |
% arguments, the title and subtitle (or author, date, etc.) of the poem. |
| 811 |
% \begin{macrocode} |
| 812 |
\newenvironment{poem}[3][\ptdefaultenv]{% |
| 813 |
% \end{macrocode} |
| 814 |
% |
| 815 |
% \begin{macro}{\@ptwrapenvironment} |
| 816 |
% By default \code{poem} re-wraps your text in the \code{verse} environment. |
| 817 |
% However, this can be changed by passing in an optional argument with the name |
| 818 |
% of another environment to wrap it in (eg. \code{center}) or, for all poems, by |
| 819 |
% redefining \code{ptdefaultenv}. |
| 820 |
% \begin{macrocode} |
| 821 |
\newcommand*{\@ptwrapenvironment}{#1} |
| 822 |
% \end{macrocode} |
| 823 |
% \end{macro} |
| 824 |
% |
| 825 |
% For example, a poem wrapped in the \code{center} environment might look like |
| 826 |
% this: |
| 827 |
% |
| 828 |
% \begin{Example} |
| 829 |
% \begin{Verbatim} |
| 830 |
% \begin{poem}[center] |
| 831 |
% {The Sea Bell}{J.R.R. Tolkien} |
| 832 |
% I walked by the sea, |
| 833 |
% and there came to me,\\ |
| 834 |
% as a star-beam on the wet sand,\\ |
| 835 |
% a white shell like a sea-bell;\\ |
| 836 |
% trembling it lay |
| 837 |
% in my wet hand.\\ |
| 838 |
% In my fingers shaken |
| 839 |
% I heard waken\\ |
| 840 |
% a ding within, by a harbour bar\\ |
| 841 |
% a buoy swinging, a call ringing\\ |
| 842 |
% over endless seas, |
| 843 |
% faint now and far\ldots |
| 844 |
% \end{poem} |
| 845 |
% \end{Verbatim} |
| 846 |
% \columnbreak |
| 847 |
% \begin{poem}[center] |
| 848 |
% {The Sea Bell} |
| 849 |
% {J.R.R. Tolkien} |
| 850 |
% I walked by the sea, |
| 851 |
% and there came to me,\\ |
| 852 |
% as a star-beam on the wet sand,\\ |
| 853 |
% a white shell like a sea-bell;\\ |
| 854 |
% trembling it lay in my wet hand.\\ |
| 855 |
% In my fingers shaken I heard waken\\ |
| 856 |
% a ding within, by a harbour bar\\ |
| 857 |
% a buoy swinging, a call ringing\\ |
| 858 |
% over endless seas, |
| 859 |
% faint now and far\ldots |
| 860 |
% \end{poem} |
| 861 |
% \end{Example} |
| 862 |
% |
| 863 |
% \begin{macro}{\incipit} |
| 864 |
% \changes{2.0.0}{2013/03/06}{Allow the user to declare an incipit} |
| 865 |
% \begin{macro}{\incipit*} |
| 866 |
% \changes{2.2.0}{2014/08/21}{Add non-printing incipit command} |
| 867 |
% An incipit can be declared within the poem environment using the |
| 868 |
% \code{\textbackslash incipit} command. This will reprint the first argument |
| 869 |
% so you don't have to write your first line twice. This is useful for |
| 870 |
% untitled poems as you can put their incipit in the ToP in place of a default |
| 871 |
% title. \code{\textbackslash incipit*} will declare an incipit but will not |
| 872 |
% reprint its argument, for cases where the incipit differs from the actual |
| 873 |
% line. |
| 874 |
% \begin{macrocode} |
| 875 |
\newcommand*{\incipit}{% |
| 876 |
\@ifstar{% |
| 877 |
\@ptincipitStar |
| 878 |
}{% |
| 879 |
\@ptincipitNoStar |
| 880 |
} |
| 881 |
} |
| 882 |
\newcommand*{\@ptincipitNoStar}[1]{% |
| 883 |
\global\expandafter\def% |
| 884 |
\csname% |
| 885 |
@poem\arabic{absolutepoemnum} incipit% |
| 886 |
\endcsname{##1}% |
| 887 |
##1% |
| 888 |
} |
| 889 |
\newcommand*{\@ptincipitStar}[1]{% |
| 890 |
\global\expandafter\def% |
| 891 |
\csname% |
| 892 |
@poem\arabic{absolutepoemnum} incipit% |
| 893 |
\endcsname{##1}% |
| 894 |
} |
| 895 |
% \end{macrocode} |
| 896 |
% \end{macro} |
| 897 |
% \end{macro} |
| 898 |
|
| 899 |
% \begin{macro}{\theincipit} |
| 900 |
% \changes{2.0.0}{2013/03/06}{Allow the user to insert the incipit} |
| 901 |
% After an incipit has been declared, this will expand to the text of the |
| 902 |
% incipit for the current poem. |
| 903 |
% |
| 904 |
% \begin{macrocode} |
| 905 |
\newcommand*{\theincipit}{% |
| 906 |
\csname @poem\arabic{absolutepoemnum} incipit\endcsname% |
| 907 |
} |
| 908 |
% \end{macrocode} |
| 909 |
% \end{macro} |
| 910 |
% |
| 911 |
% This poem has a (slightly modified) default title and an incipit in the ToP: |
| 912 |
% |
| 913 |
% \begin{Example} |
| 914 |
% \begin{Verbatim} |
| 915 |
% \usedefaulttitles |
| 916 |
% \useincipits |
| 917 |
% \renewcommand*{\ptdefaulttitle}{% |
| 918 |
% Untitled \textnumero\ |
| 919 |
% \arabic{absoluteuntitledpoemnum}% |
| 920 |
% } |
| 921 |
% \begin{poem}{}{Traditional} |
| 922 |
% \incipit{Media vita in morte% |
| 923 |
% sumus};\\* |
| 924 |
% Quem qu\ae rimus adjutorem nisi% |
| 925 |
% te, Domine?\\* |
| 926 |
% Qui pro peccatis nostris juste% |
| 927 |
% irasceris\\* |
| 928 |
% Sancte Deus, Sancte fortis,% |
| 929 |
% Sancte et misericors |
| 930 |
% Salvator,\\* |
| 931 |
% Amar\ae morti ne tradas nos. |
| 932 |
% \end{poem} |
| 933 |
% \end{Verbatim} |
| 934 |
% \columnbreak |
| 935 |
% \usedefaulttitles |
| 936 |
% \useincipits |
| 937 |
% \renewcommand*{\ptdefaulttitle}{% |
| 938 |
% Untitled \textnumero\ |
| 939 |
% \arabic{absoluteuntitledpoemnum}% |
| 940 |
% } |
| 941 |
% \begin{poem}{}{Traditional} |
| 942 |
% \incipit{Media vita in morte% |
| 943 |
% sumus};\\* |
| 944 |
% Quem qu\ae rimus adjutorem nisi% |
| 945 |
% te, Domine?\\* |
| 946 |
% Qui pro peccatis nostris juste% |
| 947 |
% irasceris\\* |
| 948 |
% Sancte Deus, Sancte fortis,% |
| 949 |
% Sancte et misericors% |
| 950 |
% Salvator,\\* |
| 951 |
% Amar\ae morti ne tradas nos. |
| 952 |
% \end{poem} |
| 953 |
% \end{Example} |
| 954 |
% |
| 955 |
% Now we render the page header, title, and the actual poem: |
| 956 |
% \begin{macrocode} |
| 957 |
\addtocounter{poemnum}{1} |
| 958 |
\addtocounter{absolutepoemnum}{1} |
| 959 |
\poetryheadings |
| 960 |
\ifx&% |
| 961 |
\addtocounter{untitledpoemnum}{1} |
| 962 |
\addtocounter{absoluteuntitledpoemnum}{1} |
| 963 |
\else |
| 964 |
\addtocounter{titledpoemnum}{1} |
| 965 |
\addtocounter{absolutetitledpoemnum}{1} |
| 966 |
\fi |
| 967 |
\vspace*{\poemvspace} |
| 968 |
\begin{\pttitleenv} |
| 969 |
\refstepcounter{poem}% |
| 970 |
\phantomsection% |
| 971 |
\addcontentsline{top}{\topentrytype}{% |
| 972 |
\ifx\@ptnumbertop\@ptundefined% |
| 973 |
\relax% |
| 974 |
\else% |
| 975 |
\toppoemnum% |
| 976 |
\fi% |
| 977 |
\ifx&% |
| 978 |
\ifx\@ptuseincipits\@ptundefined% |
| 979 |
\ptdefaulttitle% |
| 980 |
\else% |
| 981 |
{\incipittopformat \theincipit}% |
| 982 |
\fi% |
| 983 |
\else% |
| 984 |
#2% |
| 985 |
\fi% |
| 986 |
}% |
| 987 |
\ifx\@ptlistpoemsintoc\@ptundefined% |
| 988 |
\relax% |
| 989 |
\else% |
| 990 |
\addcontentsline{toc}{\tocentrytype}{% |
| 991 |
\ifx\@ptnumbertoc\@ptundefined% |
| 992 |
\relax% |
| 993 |
\else% |
| 994 |
\tocpoemnum% |
| 995 |
\fi% |
| 996 |
\ifx&% |
| 997 |
\ifx\@ptuseincipits\@ptundefined% |
| 998 |
\ptdefaulttitle% |
| 999 |
\else% |
| 1000 |
{\incipittocformat \theincipit}% |
| 1001 |
\fi% |
| 1002 |
\else% |
| 1003 |
#2% |
| 1004 |
\fi% |
| 1005 |
}% |
| 1006 |
\fi% |
| 1007 |
\ifx\hypertarget\@ptundefined% |
| 1008 |
\relax% |
| 1009 |
\else% |
| 1010 |
\hypertarget{\@ptpoemlabeltext\arabic{absolutepoemnum}}{}% |
| 1011 |
\fi% |
| 1012 |
{\poemtitleformat% |
| 1013 |
\ifx\@ptnumberpoems\@ptundefined |
| 1014 |
\relax |
| 1015 |
\else |
| 1016 |
\titlepoemnum |
| 1017 |
\fi% |
| 1018 |
\ifx&% |
| 1019 |
\ifx\@ptusedefaulttitles\@ptundefined% |
| 1020 |
\relax% |
| 1021 |
\else% |
| 1022 |
\hspace*{\pttitleleftspace}\ptdefaulttitle% |
| 1023 |
\hspace*{\pttitlerightspace}\\*% |
| 1024 |
\fi% |
| 1025 |
\else |
| 1026 |
\hspace*{\pttitleleftspace}#2\hspace*{\pttitlerightspace}\\*% |
| 1027 |
\fi% |
| 1028 |
}% |
| 1029 |
\hspace*{\ptsubtitleleftspace}#3\hspace*{\ptsubtitlerightspace} |
| 1030 |
\end{\pttitleenv} |
| 1031 |
\nopagebreak |
| 1032 |
\begin{\@ptwrapenvironment} |
| 1033 |
\begingroup\setlength{\parskip}{\stanzaparskip}% |
| 1034 |
}{% |
| 1035 |
\endgroup |
| 1036 |
\end{\@ptwrapenvironment}% |
| 1037 |
\ifx\@ptclearpageafterpoem\@ptundefined% |
| 1038 |
\relax% |
| 1039 |
\else% |
| 1040 |
\clearpage% |
| 1041 |
\fi% |
| 1042 |
} |
| 1043 |
% \end{macrocode} |
| 1044 |
% \end{environment} |
| 1045 |
% |
| 1046 |
% \section{Formatting poems} |
| 1047 |
% |
| 1048 |
% The \code{poem} environment provides some reasonable defaults for formatting |
| 1049 |
% your work but chances are you want a little more control. |
| 1050 |
% |
| 1051 |
% \subsection{Headings} |
| 1052 |
% |
| 1053 |
% \begin{macro}{\poetryheadings} |
| 1054 |
% Every time a new \code{poem} environment is created we automatically call |
| 1055 |
% \code{\textbackslash poetryheadings}. By redefining this you can change how |
| 1056 |
% your headings look, use packages like |
| 1057 |
% \pkg{\href{http://ctan.org/pkg/fancyhdr}{fancyhdr}}, or remove headers from |
| 1058 |
% poem pages altogether. |
| 1059 |
% \begin{macrocode} |
| 1060 |
\newcommand*{\poetryheadings}[0]{% |
| 1061 |
\pagestyle{myheadings} |
| 1062 |
\markboth{\ |\ \textsc{\pttitle}\hfill } |
| 1063 |
{\hfill\textsc{\ptgroup}\ |\ } |
| 1064 |
} |
| 1065 |
% \end{macrocode} |
| 1066 |
% \end{macro} |
| 1067 |
% |
| 1068 |
% \subsection{Numbering} |
| 1069 |
% |
| 1070 |
% \begin{macro}{\numberpoems} |
| 1071 |
% \begin{macro}{\nonumberpoems} |
| 1072 |
% \changes{3.0.0}{2014/12/11}{Add command to stop numbering poems} |
| 1073 |
% This command determines if the poems should display their number above the |
| 1074 |
% title. Generally these should be called from the preamble but they can be |
| 1075 |
% defined at any point in your document to change how numbering works, or to |
| 1076 |
% turn on numbering from that point forward. |
| 1077 |
% \begin{macrocode} |
| 1078 |
\newcommand*{\numberpoems}{\newcommand*{\@ptnumberpoems}{}} |
| 1079 |
\newcommand*{\nonumberpoems}{\let\@ptnumberpoems\@ptundefined} |
| 1080 |
% \end{macrocode} |
| 1081 |
% \end{macro} |
| 1082 |
% \end{macro} |
| 1083 |
% Using \code{\textbackslash numberpoems} results in: |
| 1084 |
% |
| 1085 |
% \begin{Example} |
| 1086 |
% \begin{Verbatim} |
| 1087 |
% \numberpoems |
| 1088 |
% \numbertop |
| 1089 |
% |
| 1090 |
% \begin{poem}{The Highwayman} |
| 1091 |
% {Alfred Noyes} |
| 1092 |
% The wind was a torrent of |
| 1093 |
% darkness among the gusty trees,\\ |
| 1094 |
% The moon was a ghostly galleon |
| 1095 |
% tossed upon cloudy seas,\\ |
| 1096 |
% The road was a ribbon of |
| 1097 |
% moonlight over the purple moor% |
| 1098 |
% \ldots |
| 1099 |
% \end{poem} |
| 1100 |
% \end{Verbatim} |
| 1101 |
% \columnbreak |
| 1102 |
% \numberpoems |
| 1103 |
% \numbertop |
| 1104 |
% |
| 1105 |
% \begin{poem}{The Highwayman}{Alfred Noyes} |
| 1106 |
% The wind was a torrent of |
| 1107 |
% darkness among the gusty trees,\\ |
| 1108 |
% The moon was a ghostly galleon |
| 1109 |
% tossed upon cloudy seas,\\ |
| 1110 |
% The road was a ribbon of |
| 1111 |
% moonlight over the purple moor% |
| 1112 |
% \ldots |
| 1113 |
% \end{poem} |
| 1114 |
% \end{Example} |
| 1115 |
% |
| 1116 |
% \begin{macro}{\titlepoemnum} |
| 1117 |
% \changes{1.4}{2012/02/18}{Add hook for poem number formatting} |
| 1118 |
% \changes{3.0.0}{2014/12/10}{Use absolute poem nums by default} |
| 1119 |
% \begin{macro}{\toppoemnum} |
| 1120 |
% \changes{1.4}{2012/02/18}{Add hook for Table of Poems poem number formatting} |
| 1121 |
% \changes{3.0.0}{2014/12/10}{Use absolute poem nums by default} |
| 1122 |
% \begin{macro}{\tocpoemnum} |
| 1123 |
% \changes{2.0.0}{2013/08/17}{Add hook for Table of Contents poem number formatting} |
| 1124 |
% These commands are used to insert the poem number into the poem title, the |
| 1125 |
% table of poems, and the table of contents respectively. By redefining them you |
| 1126 |
% can customize how the numbering looks. |
| 1127 |
% \begin{macrocode} |
| 1128 |
\newcommand*{\titlepoemnum}{\arabic{absolutepoemnum}\\*} |
| 1129 |
\newcommand*{\toppoemnum}{\arabic{absolutepoemnum}.\ } |
| 1130 |
\newcommand*{\tocpoemnum}{\toppoemnum} |
| 1131 |
% \end{macrocode} |
| 1132 |
% \end{macro} |
| 1133 |
% \end{macro} |
| 1134 |
% \end{macro} |
| 1135 |
% |
| 1136 |
% If we want to use uppercase roman numerals on the poems, and lowercase roman |
| 1137 |
% numerals in the \code{\hyperlink{POETRYTEX:TOP}{Table of Poems}}, we could |
| 1138 |
% redefine them like so: |
| 1139 |
% |
| 1140 |
% \begin{Example} |
| 1141 |
% \begin{Verbatim} |
| 1142 |
% \numberpoems |
| 1143 |
% \numbertop |
| 1144 |
% \renewcommand*{\titlepoemnum}{% |
| 1145 |
% \unskip\Roman{poemnum}\\} |
| 1146 |
% \renewcommand*{\toppoemnum}{ |
| 1147 |
% \unskip\roman{poemnum}.\ } |
| 1148 |
% |
| 1149 |
% \begin{poem}% |
| 1150 |
% {The Lady of Shalott}% |
| 1151 |
% {Alfred Tennyson (1842)} |
| 1152 |
% On either side the river lie\\ |
| 1153 |
% Long fields of barley and |
| 1154 |
% of rye,\\ |
| 1155 |
% That clothe the wold and meet |
| 1156 |
% the sky;\\ |
| 1157 |
% And through the field the road |
| 1158 |
% runs by\\ |
| 1159 |
% To many-towered Camelot;\\ |
| 1160 |
% And up and down the people go,\\ |
| 1161 |
% Gazing where the lilies blow\\ |
| 1162 |
% Round an island there below,\\ |
| 1163 |
% The island of Shalott--- |
| 1164 |
% \end{poem} |
| 1165 |
% \end{Verbatim} |
| 1166 |
% \columnbreak |
| 1167 |
% \numberpoems |
| 1168 |
% \numbertop |
| 1169 |
% \renewcommand*{\titlepoemnum}{% |
| 1170 |
% \unskip\Roman{poemnum}\\} |
| 1171 |
% \renewcommand*{\toppoemnum}{ |
| 1172 |
% \unskip\roman{poemnum}.\ } |
| 1173 |
% |
| 1174 |
% \begin{poem}% |
| 1175 |
% {The Lady of Shalott}% |
| 1176 |
% {Alfred Tennyson (1842)} |
| 1177 |
% On either side the river lie\\ |
| 1178 |
% Long fields of barley and |
| 1179 |
% of rye,\\ |
| 1180 |
% That clothe the wold and meet |
| 1181 |
% the sky;\\ |
| 1182 |
% And through the field the road |
| 1183 |
% runs by\\ |
| 1184 |
% To many-towered Camelot;\\ |
| 1185 |
% And up and down the people go,\\ |
| 1186 |
% Gazing where the lilies blow\\ |
| 1187 |
% Round an island there below,\\ |
| 1188 |
% The island of Shalott--- |
| 1189 |
% \end{poem} |
| 1190 |
% \end{Example} |
| 1191 |
% |
| 1192 |
% \subsection{Spacing and indentation} |
| 1193 |
% |
| 1194 |
% \begin{macro}{\stanzaparskip} |
| 1195 |
% This length is used to change the \code{parskip} within a poem environment. |
| 1196 |
% \begin{macrocode} |
| 1197 |
\newlength{\stanzaparskip} |
| 1198 |
\setlength{\stanzaparskip}{0.7em} |
| 1199 |
% \end{macrocode} |
| 1200 |
% \end{macro} |
| 1201 |
% |
| 1202 |
% \begin{macro}{\clearpageafterpoem} |
| 1203 |
% \begin{macro}{\noclearpageafterpoem} |
| 1204 |
% \begin{macro}{\clearpageafterannotation} |
| 1205 |
% \changes{3.0.0}{2014/12/11}{Make clearing the page after an annotation optional behavior} |
| 1206 |
% \begin{macro}{\noclearpageafterannotation} |
| 1207 |
% \changes{3.0.0}{2014/12/11}{Add command to stop page clearing after annotations} |
| 1208 |
% \code{clearpageafterpoem} and \code{clearpageafterannotation} cause the page |
| 1209 |
% to be cleared after every poem environment or annotation environment |
| 1210 |
% respectively. |
| 1211 |
% \begin{macrocode} |
| 1212 |
\newcommand*{\clearpageafterpoem}{\newcommand*{\@ptclearpageafterpoem}{}} |
| 1213 |
\newcommand*{\clearpageafterannotation}{\newcommand*{\@ptclearpageafterannotation}{}} |
| 1214 |
\newcommand*{\noclearpageafterpoem}{\let\@ptclearpageafterpoem\@ptundefined} |
| 1215 |
\newcommand*{\noclearpageafterannotation}{\let\@ptclearpageafterannotation\@ptundefined} |
| 1216 |
% \end{macrocode} |
| 1217 |
% \end{macro} |
| 1218 |
% \end{macro} |
| 1219 |
% \end{macro} |
| 1220 |
% \end{macro} |
| 1221 |
% |
| 1222 |
% \begin{macro}{\ptgap} |
| 1223 |
% \begin{macro}{\ptind} |
| 1224 |
% \begin{macro}{\ptind*} |
| 1225 |
% The \code{\textbackslash ptgap} length and \code{\textbackslash ptind} |
| 1226 |
% command are two of those places where \pkg{poetrytex} strays a bit into the |
| 1227 |
% realm of poetry typesetting. They overlap with the \pkg{verse} package's |
| 1228 |
% \code{\textbackslash vgap} and \code{\textbackslash vin} commands and insert |
| 1229 |
% indentation at at the beginning of a line. This is useful for typesetting |
| 1230 |
% poems consistently when the \pkg{verse} package is not loaded. Redefine |
| 1231 |
% \code{\textbackslash ptgap} to change the length that \code{\textbackslash% |
| 1232 |
% ptind} indents by. The starred version of \code{ptind} uses\code{% |
| 1233 |
% \textbackslash hspace*}. |
| 1234 |
% \begin{macrocode} |
| 1235 |
\newlength{\ptgap} |
| 1236 |
\setlength{\ptgap}{2em} |
| 1237 |
\newcommand*{\ptind}{% |
| 1238 |
\@ifstar{% |
| 1239 |
\@ptindStar |
| 1240 |
}{% |
| 1241 |
\@ptindNoStar |
| 1242 |
} |
| 1243 |
} |
| 1244 |
\newcommand*{\@ptindStar}{\hspace*{\ptgap}} |
| 1245 |
\newcommand*{\@ptindNoStar}{\hspace{\ptgap}} |
| 1246 |
% \end{macrocode} |
| 1247 |
% \end{macro} |
| 1248 |
% \end{macro} |
| 1249 |
% \end{macro} |
| 1250 |
% |
| 1251 |
% Using it works something like this: |
| 1252 |
% |
| 1253 |
% \begin{Example} |
| 1254 |
% \begin{Verbatim} |
| 1255 |
% \setlength{\ptgap}{2em} |
| 1256 |
% \begin{poem}[flushleft]{PoE\TeX} |
| 1257 |
% {An {\tipaencoding |
| 1258 |
% /Ig"zA:mp@l/} poem} |
| 1259 |
% There once was a poem called% |
| 1260 |
% PoE\TeX\\* |
| 1261 |
% That's name sounded somewhat% |
| 1262 |
% {\tipaencoding /p@"TEtEk/}.\\* |
| 1263 |
% \ptind It was really quite% |
| 1264 |
% sad,\\* |
| 1265 |
% \ptind to see pronunciation% |
| 1266 |
% so bad,\\* |
| 1267 |
% And to read such a terrible% |
| 1268 |
% {\tipaencoding /"lIme(@)rEk/}! |
| 1269 |
% \end{poem} |
| 1270 |
% \end{Verbatim} |
| 1271 |
% \columnbreak |
| 1272 |
% \setlength{\ptgap}{2em} |
| 1273 |
% \begin{poem}[flushleft]{PoE\TeX} |
| 1274 |
% {An {\tipaencoding |
| 1275 |
% /Ig"zA:mp@l/} poem} |
| 1276 |
% There once was a poem called% |
| 1277 |
% PoE\TeX\\* |
| 1278 |
% That's name sounded somewhat% |
| 1279 |
% {\tipaencoding /p@"TEtEk/}.\\* |
| 1280 |
% \ptind It was really quite% |
| 1281 |
% sad,\\* |
| 1282 |
% \ptind to see pronunciation% |
| 1283 |
% so bad,\\* |
| 1284 |
% And to read such a terrible% |
| 1285 |
% {\tipaencoding /"lIme(@)rEk/}! |
| 1286 |
% \end{poem} |
| 1287 |
% \end{Example} |
| 1288 |
% |
| 1289 |
% \subsection{Style} |
| 1290 |
% |
| 1291 |
% \begin{macro}{\poemtitleformat} |
| 1292 |
% By redefining \code{\textbackslash poemtitleformat} we can change how the poem |
| 1293 |
% title is rendered. |
| 1294 |
% \begin{macrocode} |
| 1295 |
\newcommand*{\poemtitleformat}{\normalfont\bfseries\large} |
| 1296 |
% \end{macrocode} |
| 1297 |
% |
| 1298 |
% This can be used for everything from changing the font size to adding |
| 1299 |
% interesting effects: |
| 1300 |
% |
| 1301 |
% \begin{Example} |
| 1302 |
% \begin{Verbatim} |
| 1303 |
% \renewcommand*{\poemtitleformat} |
| 1304 |
% {\normalfont\bfseries% |
| 1305 |
% {\rule{5em}{0.2em}}\\*} |
| 1306 |
% \begin{poem}{Excelsior} |
| 1307 |
% {Henry Wadsworth Longfellow\\* |
| 1308 |
% 1841} |
| 1309 |
% The shades of night were falling% |
| 1310 |
% fast,\\* |
| 1311 |
% As through an Alpine village% |
| 1312 |
% passed\\* |
| 1313 |
% A youth, who bore, `mid snow and |
| 1314 |
% ice,\\* |
| 1315 |
% A banner with the strange% |
| 1316 |
% device,\\* |
| 1317 |
% Excelsior! |
| 1318 |
% \end{poem} |
| 1319 |
% \end{Verbatim} |
| 1320 |
% \columnbreak |
| 1321 |
% \renewcommand*{\poemtitleformat} |
| 1322 |
% {\normalfont\bfseries% |
| 1323 |
% {\rule{5em}{0.2em}}\\*} |
| 1324 |
% \begin{poem}{Excelsior} |
| 1325 |
% {Henry Wadsworth Longfellow\\* |
| 1326 |
% 1841} |
| 1327 |
% The shades of night were falling% |
| 1328 |
% fast,\\* |
| 1329 |
% As through an Alpine village% |
| 1330 |
% passed\\* |
| 1331 |
% A youth, who bore, `mid snow and |
| 1332 |
% ice,\\* |
| 1333 |
% A banner with the strange% |
| 1334 |
% device,\\* |
| 1335 |
% Excelsior! |
| 1336 |
% \end{poem} |
| 1337 |
% \end{Example} |
| 1338 |
% \end{macro} |
| 1339 |
% |
| 1340 |
% \begin{macro}{\incipittopformat} |
| 1341 |
% \changes{2.0.0}{2013/02/23}{Add hook for incipit formatting in the ToP} |
| 1342 |
% \begin{macro}{\incipittocformat} |
| 1343 |
% \changes{2.0.0}{2013/08/17}{Add hook for incipit formatting in the ToC} |
| 1344 |
% Similarly we can change how the incipit is rendered in the Table of Poems or |
| 1345 |
% Table of Contents: |
| 1346 |
% \begin{macrocode} |
| 1347 |
\newcommand*{\incipittopformat}{\itshape} |
| 1348 |
\newcommand*{\incipittocformat}{\incipittopformat} |
| 1349 |
% \end{macrocode} |
| 1350 |
% \end{macro} |
| 1351 |
% \end{macro} |
| 1352 |
% |
| 1353 |
% If you want a stylistic marker between two poems, or between sections |
| 1354 |
% or stanzas within a poem, the following commands are your friend. |
| 1355 |
% |
| 1356 |
% \begin{macro}{\ptspacergap} |
| 1357 |
% \begin{macro}{\ptspacerchar} |
| 1358 |
% \begin{macro}{ptspacernum} |
| 1359 |
% \changes{3.0.0}{2014/12/10}{Change ptspacernum into a counter} |
| 1360 |
% The \code{ptspacergap} length is the indentation of the spacer, and\code{% |
| 1361 |
% \textbackslash ptspacerchar} is the actual character that will be printed |
| 1362 |
% \code{ptspacernum} times. |
| 1363 |
% \begin{macrocode} |
| 1364 |
\newlength{\ptspacergap} |
| 1365 |
\setlength{\ptspacergap}{4em} |
| 1366 |
\newcommand*{\ptspacerchar}{\S} |
| 1367 |
\newcounter{ptspacernum} |
| 1368 |
% \end{macrocode} |
| 1369 |
% \end{macro} |
| 1370 |
% \end{macro} |
| 1371 |
% \end{macro} |
| 1372 |
% |
| 1373 |
% \begin{macro}{\ptspacer} |
| 1374 |
% \changes{1.0}{2012/07/17}{Repeat \code{\textbackslash ptspacernum} times} |
| 1375 |
% \begin{macro}{\ptspacer*} |
| 1376 |
% The starred version of the \code{ptspacer} command uses \code{\textbackslash% |
| 1377 |
% hspace*} for indention. |
| 1378 |
% \begin{macrocode} |
| 1379 |
\newcommand*{\ptspacer}{% |
| 1380 |
\@ifstar{% |
| 1381 |
\@ptspacerStar |
| 1382 |
}{% |
| 1383 |
\@ptspacerNoStar |
| 1384 |
} |
| 1385 |
} |
| 1386 |
\newcommand*{\@ptspacerStar}{% |
| 1387 |
\hspace*{\ptspacergap}% |
| 1388 |
\@ptrepeat{\value{ptspacernum}}{\ptspacerchar}% |
| 1389 |
} |
| 1390 |
\newcommand*{\@ptspacerNoStar}{% |
| 1391 |
\hspace{\ptspacergap}% |
| 1392 |
\@ptrepeat{\value{ptspacernum}}{\ptspacerchar}% |
| 1393 |
} |
| 1394 |
\ExplSyntaxOn |
| 1395 |
\cs_new_eq:NN \@ptrepeat \prg_replicate:nn |
| 1396 |
\ExplSyntaxOff |
| 1397 |
% \end{macrocode} |
| 1398 |
% \end{macro} |
| 1399 |
% \end{macro} |
| 1400 |
% |
| 1401 |
% For example: |
| 1402 |
% |
| 1403 |
% \begin{Example} |
| 1404 |
% \begin{Verbatim} |
| 1405 |
% \renewcommand{\ptspacerchar}{\o} |
| 1406 |
% \setcounter{ptspacernum}{2} |
| 1407 |
% \begin{poem}{The Love Song% |
| 1408 |
% of J. Alfred Prufrock} |
| 1409 |
% {T.S. Eliot} |
| 1410 |
% \ldots I should have been a pair% |
| 1411 |
% of ragged claws\\ |
| 1412 |
% Scuttling across the floors of% |
| 1413 |
% silent seas. |
| 1414 |
% |
| 1415 |
% \ptspacer |
| 1416 |
% |
| 1417 |
% And the afternoon, the evening, |
| 1418 |
% sleeps so peacefully!\\ |
| 1419 |
% Smoothed by long fingers,\\ |
| 1420 |
% Asleep\ldots\ tired\ldots\ or% |
| 1421 |
% it malingers,\\ |
| 1422 |
% Stretched on the floor, here% |
| 1423 |
% beside you and me\ldots |
| 1424 |
% \end{poem} |
| 1425 |
% \end{Verbatim} |
| 1426 |
% \columnbreak |
| 1427 |
% \renewcommand{\ptspacerchar}{\o} |
| 1428 |
% \setcounter{ptspacernum}{2} |
| 1429 |
% \begin{poem}{The Love Song% |
| 1430 |
% of J. Alfred Prufrock} |
| 1431 |
% {T.S. Eliot} |
| 1432 |
% \ldots I should have been a pair% |
| 1433 |
% of ragged claws\\ |
| 1434 |
% Scuttling across the floors of% |
| 1435 |
% silent seas. |
| 1436 |
% |
| 1437 |
% \ptspacer |
| 1438 |
% |
| 1439 |
% And the afternoon, the evening, |
| 1440 |
% sleeps so peacefully!\\ |
| 1441 |
% Smoothed by long fingers,\\ |
| 1442 |
% Asleep\ldots\ tired\ldots\ or% |
| 1443 |
% it malingers,\\ |
| 1444 |
% Stretched on the floor, here% |
| 1445 |
% beside you and me\ldots |
| 1446 |
% \end{poem} |
| 1447 |
% \end{Example} |
| 1448 |
% |
| 1449 |
% \subsection{Groups and linking} |
| 1450 |
% |
| 1451 |
% When putting together a large collection of poetry and prose you most likely |
| 1452 |
% need a way to organize your works and find them quickly. While the table of |
| 1453 |
% poems helps we might also want to link directly to poems, or further subdivide |
| 1454 |
% the collection into groups of related works (by year written, or subject |
| 1455 |
% matter for instance). |
| 1456 |
% |
| 1457 |
% \begin{macro}{\linktopoem} |
| 1458 |
% \changes{1.1}{2012/07/24}{Fix spacing and multiple use issues} |
| 1459 |
% \changes{1.2}{2012/09/20}{Use \code{hyperlink} when linking to a poem} |
| 1460 |
% \changes{3.0.0}{2014/12/12}{Don't create links unless \pkg{hyperref} is loaded} |
| 1461 |
% We can \emph{\linktopoem[1]{link}} \emph{\linktopoem[2]{to}}% |
| 1462 |
% \emph{\linktopoem[3]{poems}} easily enough by providing \code{linktopoem} with |
| 1463 |
% the text for the link and, optionally, the number of the poem to link to. If |
| 1464 |
% only one argument is given it is used as both the link destination and text. |
| 1465 |
% This macro only works if the \pkg{hyperref} package is loaded; otherwise, text |
| 1466 |
% is just passed through. |
| 1467 |
% \begin{macrocode} |
| 1468 |
\newcommand*{\linktopoem}[2][ptnull]{% |
| 1469 |
\ifx\hyperlink\@ptundefined |
| 1470 |
#2\relax% |
| 1471 |
\else |
| 1472 |
\ifx{#1}{ptnull} |
| 1473 |
\hyperlink{\@ptpoemlabeltext#2}{#2}\relax |
| 1474 |
\else |
| 1475 |
\hyperlink{\@ptpoemlabeltext#1}{#2}\relax |
| 1476 |
\fi |
| 1477 |
\fi |
| 1478 |
} |
| 1479 |
% \end{macrocode} |
| 1480 |
% \end{macro} |
| 1481 |
% |
| 1482 |
% \changes{3.0.0}{2014/12/10}{Always reset \code{poemnum} on group change} |
| 1483 |
% \begin{macro}{\ptgroup} |
| 1484 |
% \begin{macro}{\poemgroup} |
| 1485 |
% \begin{macro}{\poemgroup*} |
| 1486 |
% \begin{macro}{\setpoemgroup} |
| 1487 |
% \changes{3.0.0}{2014/12/12}{Add macro to change group without creating a titlepage} |
| 1488 |
% \begin{macro}{\setpoemgroup*} |
| 1489 |
% \changes{3.0.0}{2014/12/12}{Add macro to change group without creating a titlepage or adding group to the ToC/ToP} |
| 1490 |
% Dividing poems up into groups can be accomplished with the \code{% |
| 1491 |
% \textbackslash poemgroup} command. The command creates a title-page for the |
| 1492 |
% group at the current location and adds entries to the ToP and ToC unless the |
| 1493 |
% starred version of the command is used. The \code{\textbackslash ptgroup} |
| 1494 |
% command will always contain a reference to the current group in case you need |
| 1495 |
% to refer to it later. If you want to change the group, but don't want to |
| 1496 |
% create a title page, use the \code{\textbackslash setpoemgroup} command. The |
| 1497 |
% starred version also doesn't add an entry in the ToP and ToC. |
| 1498 |
% \begin{macrocode} |
| 1499 |
\newcommand*{\ptgroup}{} |
| 1500 |
\newcommand*{\poemgroup}[1]{% |
| 1501 |
\addtocounter{poemgroupnum}{1} |
| 1502 |
\setcounter{poemnum}{0} |
| 1503 |
\setcounter{untitledpoemnum}{0} |
| 1504 |
\setcounter{titledpoemnum}{0} |
| 1505 |
\setcounter{annotationnum}{0} |
| 1506 |
\beforepoemgroup |
| 1507 |
\vspace*{\pregroupvspace} |
| 1508 |
\renewcommand*{\ptgroup}{#1} |
| 1509 |
\pagestyle{\grouppagestyle} |
| 1510 |
\begin{\ptdefaultgroupenv} |
| 1511 |
\@ifstar{% |
| 1512 |
\@ptpoemgroupStar{#1} |
| 1513 |
}{% |
| 1514 |
\@ptpoemgroupNoStar{#1} |
| 1515 |
} |
| 1516 |
\end{\ptdefaultgroupenv} |
| 1517 |
\vspace*{\postgroupvspace} |
| 1518 |
\afterpoemgroup |
| 1519 |
} |
| 1520 |
\newcommand*{\@ptpoemgroupStar}[1]{% |
| 1521 |
\section*{#1} |
| 1522 |
} |
| 1523 |
\newcommand*{\@ptpoemgroupNoStar}[1]{% |
| 1524 |
\section{#1} |
| 1525 |
\addcontentsline{top}{section}{#1} |
| 1526 |
} |
| 1527 |
\newcommand*{\setpoemgroup}[1]{% |
| 1528 |
\addtocounter{poemgroupnum}{1} |
| 1529 |
\setcounter{poemnum}{0} |
| 1530 |
\setcounter{untitledpoemnum}{0} |
| 1531 |
\setcounter{titledpoemnum}{0} |
| 1532 |
\setcounter{annotationnum}{0} |
| 1533 |
\renewcommand*{\ptgroup}{#1} |
| 1534 |
\@ifstar{% |
| 1535 |
\relax% |
| 1536 |
}{% |
| 1537 |
\@ptsetpoemgroupNoStar{#1} |
| 1538 |
} |
| 1539 |
} |
| 1540 |
\newcommand*{\@ptsetpoemgroupNoStar}[1]{% |
| 1541 |
\addcontentsline{top}{section}{#1} |
| 1542 |
\addcontentsline{toc}{section}{#1} |
| 1543 |
} |
| 1544 |
% \end{macrocode} |
| 1545 |
% \end{macro} |
| 1546 |
% \end{macro} |
| 1547 |
% \end{macro} |
| 1548 |
% \end{macro} |
| 1549 |
% \end{macro} |
| 1550 |
% |
| 1551 |
% \section{The \code{annotation} environment} |
| 1552 |
% |
| 1553 |
% \begin{environment}{annotation} |
| 1554 |
% \changes{1.1}{2012/07/20}{Added optional `environment' argument} |
| 1555 |
% Annotations allow you to insert prose that relates to a specific poem into |
| 1556 |
% your document. It uses \code{\textbackslash annotationheadings} (see below), |
| 1557 |
% clears the page twice, and adds itself to the ToC (but not the ToP). The page |
| 1558 |
% is also cleared again after the annotation. |
| 1559 |
% |
| 1560 |
% Like the \code{poetry} environment, an optional first argument can be used to |
| 1561 |
% specify the environment in which the annotation will be wrapped. The default |
| 1562 |
% is \code{flushleft} and can be changed by redefining \code{\textbackslash |
| 1563 |
% ptannotationenv}. |
| 1564 |
% \begin{macrocode} |
| 1565 |
\newenvironment{annotation}[2][\ptannotationenv]{% |
| 1566 |
\newcommand*{\@ptwrapenvironment}{#1} |
| 1567 |
\cleardoublepage |
| 1568 |
\addtocounter{annotationnum}{1} |
| 1569 |
\addtocounter{absoluteannotationnum}{1} |
| 1570 |
\annotationheadings |
| 1571 |
\begin{\@ptwrapenvironment} |
| 1572 |
\subsection{#2} |
| 1573 |
\nopagebreak |
| 1574 |
}{% |
| 1575 |
\end{\@ptwrapenvironment}% |
| 1576 |
\ifx\@ptclearpageafterannotation\@ptundefined% |
| 1577 |
\relax% |
| 1578 |
\else% |
| 1579 |
\clearpage% |
| 1580 |
\fi% |
| 1581 |
} |
| 1582 |
% \end{macrocode} |
| 1583 |
% \end{environment} |
| 1584 |
% |
| 1585 |
% |
| 1586 |
% \section{Formatting annotations} |
| 1587 |
% |
| 1588 |
% \subsection{Headings} |
| 1589 |
% |
| 1590 |
% \begin{macro}{\annotationheadings} |
| 1591 |
% \changes{2.1.0}{2013/08/29}{Allow separate headings on annotation pages} |
| 1592 |
% The \code{\textbackslash annotationheadings} macro is automatically called |
| 1593 |
% every time a new \code{annotation} environment is created. By default, it |
| 1594 |
% simply calls \code{\textbackslash poetryheadings}, but it can be redefined to |
| 1595 |
% give your annotation pages a different heading style than your poem pages. |
| 1596 |
% \begin{macrocode} |
| 1597 |
\newcommand*{\annotationheadings}[0]{\poetryheadings} |
| 1598 |
% \end{macrocode} |
| 1599 |
% \end{macro} |
| 1600 |
% |
| 1601 |
% |
| 1602 |
% |
| 1603 |
% Now that everything is defined we can process any |
| 1604 |
% \hyperlink{POETRYTEX:OPTIONS}{options} that were passed in by the user: |
| 1605 |
% \begin{macrocode} |
| 1606 |
\ProcessOptions\relax |
| 1607 |
%</poetrytex> |
| 1608 |
% \end{macrocode} |
| 1609 |
% |
| 1610 |
% \clearpage |
| 1611 |
% \setcounter{IndexColumns}{2} |
| 1612 |
% \phantomsection |
| 1613 |
% \addcontentsline{toc}{part}{Index} |
| 1614 |
% \PrintIndex |
| 1615 |
% |
| 1616 |
% \makeatletter |
| 1617 |
% \renewenvironment{theglossary}{% |
| 1618 |
% \glossary@prologue |
| 1619 |
% \setlength\emergencystretch{5em} |
| 1620 |
% \GlossaryParms \let\item\@idxitem \ignorespaces}{} |
| 1621 |
% \makeatother |
| 1622 |
% \clearpage |
| 1623 |
% \phantomsection |
| 1624 |
% \addcontentsline{toc}{part}{Change History} |
| 1625 |
% \PrintChanges |
| 1626 |
% \changes{1.1}{2012/07/19}{Added an example table of poems} |
| 1627 |
% \renewcommand*{\toptocentrytype}{part} |
| 1628 |
% \renewcommand*{\beforetop}{\hypertarget{POETRYTEX:TOP}{}} |
| 1629 |
% \maketop |
| 1630 |
% \Finale |
| 1631 |
% |
| 1632 |
% \iffalse |
| 1633 |
%\fi |
| 1634 |
\endinput |