From bd7687e8abb5975905db822498e640ca7e2e1b2c Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 13 May 2014 22:12:56 +0000 Subject: verse (11may14) git-svn-id: svn://tug.org/texlive/trunk@34017 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/source/latex/verse/verse.dtx | 552 +++++++++++++------------ 1 file changed, 297 insertions(+), 255 deletions(-) (limited to 'Master/texmf-dist/source/latex/verse') diff --git a/Master/texmf-dist/source/latex/verse/verse.dtx b/Master/texmf-dist/source/latex/verse/verse.dtx index 63768253ddf..cd5d4299ff7 100644 --- a/Master/texmf-dist/source/latex/verse/verse.dtx +++ b/Master/texmf-dist/source/latex/verse/verse.dtx @@ -20,12 +20,28 @@ \documentclass[twoside]{ltxdoc} \usepackage{alltt} \usepackage{verse} +\usepackage{xcolor} \usepackage[draft=false, plainpages=false, pdfpagelabels, bookmarksnumbered, hyperindex=false ]{hyperref} +\usepackage{listings} +\lstset{ + basicstyle=\small\ttfamily, + columns=fullflexible, + backgroundcolor=\color[rgb]{0.97,0.97,1}, + gobble=2, +} +\newsavebox\ltxbox +\newenvironment{ltxoutput*} + {\fboxsep=0pt\noindent\begin{lrbox}{\ltxbox}\begin{minipage}{\textwidth}} + {\end{minipage}\end{lrbox}\begin{center}\colorbox[rgb]{0.97,1,0.97}{\usebox\ltxbox\par}\end{center}} +\newenvironment{ltxoutput} + {\par\begin{ltxoutput*}} + {\end{ltxoutput*}} + \providecommand{\phantomsection} \show\makeatletter \makeatletter @@ -44,7 +60,7 @@ % % \fi % -% \CheckSum{555} +% \CheckSum{551} % % \DoNotIndex{\',\.,\@M,\@@input,\@addtoreset,\@arabic,\@badmath} % \DoNotIndex{\@centercr,\@cite} @@ -98,6 +114,7 @@ % \changes{v2.3}{2006/01/14}{Added switch for linenumber side} % \changes{v2.4}{2007/01/10}{Added code to start numbering at a given line} % \changes{v2.4a}{2009/09/04}{New maintainer (Will Robertson)} +% \changes{v2.4b}{2014/05/10}{Documentation updates} % % \def\dtxfile{verse.dtx} % ^^A \def\fileversion{v1.0} @@ -115,6 +132,7 @@ % \def\fileversion{v2.3} \def\filedate{2006/01/14} % \def\fileversion{v2.4} \def\filedate{2007/01/10} % \def\fileversion{v2.4a} \def\filedate{2009/09/04} +% \def\fileversion{v2.4b} \def\filedate{2014/05/10} % \newcommand*{\Lpack}[1]{\textsf {#1}} ^^A typeset a package % \newcommand*{\Lopt}[1]{\textsf {#1}} ^^A typeset an option % \newcommand*{\file}[1]{\texttt {#1}} ^^A typeset a file @@ -123,16 +141,15 @@ % \newcommand*{\Lenv}[1]{\texttt {#1}} ^^A typeset an environment % \newcommand*{\ablankline}{\vspace{\baselineskip}} % -% \title{Typesetting simple verse with LaTeX\thanks{This -% file (\texttt{\dtxfile}) has version number \fileversion, last revised -% \filedate.}} +% \title{Typesetting simple verse with \LaTeX} % % \author{ % Author: Peter Wilson, Herries Press \\ % Maintainer: Will Robertson \\ -% \texttt{will dot robertson at latex-project dot org} +% \large +% \texttt{http://github.com/wspr/herries-press/} % } -% \date{\filedate} +% \date{\fileversion\qquad\filedate} % \maketitle % \begin{abstract} % The \Lpack{verse} package provides some aids for the typesetting @@ -158,22 +175,25 @@ % Section~\ref{sec:usc} describes the usage of the \Lpack{verse} % package and % commented source code is in Section~\ref{sec:code}. +% Colour is used to indicate input and output material; a \colorbox[rgb]{0.97,0.97,1}{blue} background indicates \LaTeX\ input source, and a \colorbox[rgb]{0.97,1,0.97}{green} background shows the corresponding output one should expect. % % The doggerel used as illustrative material has been taken % from~\cite{RUMOUR}. % +% \section{Verses in \LaTeX\ \emph{without} this package} +% % LaTeX provides the |verse| environment which is defined as a particular % kind of list. Within the environment you use |\\| to end a line % and a blank line will end a stanza. For example, here is a single % stanza poem: -% \begin{verbatim} +% \begin{lstlisting} % \newcommand{\garden}{ -% I used to love my garden \\ -% But now my love is dead \\ -% For I found a bachelor's button \\ -% In black-eyed Susan's bed. +% I used to love my garden \\ +% But now my love is dead \\ +% For I found a bachelor's button \\ +% In black-eyed Susan's bed. % } -% \end{verbatim} +% \end{lstlisting} % \newcommand{\garden}{ % I used to love my garden \\ % But now my love is dead \\ @@ -181,41 +201,38 @@ % In black-eyed Susan's bed. % } % When this is typeset as a normal LaTeX paragraph (with no paragraph -% indentation) it looks like: \\[\baselineskip] +% indentation) it looks like: +% \begin{ltxoutput} % \garden{} -% -% \ablankline -% -% Typesetting it within the |verse| environment produces: \\[\baselineskip] +% \end{ltxoutput} +% Typesetting it within \LaTeX's |verse| environment produces: +% \begin{ltxoutput} % \begin{verse} % \garden % \end{verse} -% -% \ablankline -% +% \end{ltxoutput} % The stanza could also be typeset within the |alltt| environment, defined % in the standard \Lpack{alltt} package, using a normal font and no |\\| % line endings. -% \begin{verbatim} +% \begin{lstlisting} % \begin{alltt}\normalfont % I used to love my garden % But now my love is dead % For I found a bachelor's button % In black-eyed Susan's bed. -% \end{alltt} -% \end{verbatim} +% \end{alltt}\end{lstlisting} % which produces: -% \begin{alltt} -% \normalfont -% I used to love my garden -% But now my love is dead -% For I found a bachelor's button -% In black-eyed Susan's bed. +% \begin{ltxoutput} +% \begin{alltt}\catcode\%=9 +%\normalfont +%I used to love my garden +%But now my love is dead +%For I found a bachelor's button +%In black-eyed Susan's bed. % \end{alltt} +% \end{ltxoutput} % The |alltt| environment is like the |verbatim| environment except that -% you can use LaTeX macros inside it. Note that the \% characters are -% an artifact of an interaction between this document's class and -% the |alltt| environment that I have not been able to eliminate. +% you can use LaTeX macros inside it. % % In the |verse| environment long lines will be wrapped and indented % but in the |alltt| environment there is no indentation. @@ -223,7 +240,7 @@ % Some stanzas have certain lines indented, often alternate ones. To % typeset stanzas like this you have to add your own spacing. For % instance: -% \begin{verbatim} +% \begin{lstlisting} % \begin{verse} % There was an old party of Lyme \\ % Who married three wives at one time. \\ @@ -231,8 +248,9 @@ % \hspace{2em} He replied: `One's absurd, \\ % And bigamy, sir, is a crime.' % \end{verse} -% \end{verbatim} +% \end{lstlisting} % will be typeset in a verse environment as: +% \begin{ltxoutput} % \begin{verse} % There was an old party of Lyme \\ % Who married three wives at one time. \\ @@ -240,12 +258,10 @@ % \hspace{2em} He replied: `One's absurd, \\ % And bigamy, sir, is a crime.' % \end{verse} -% -% \ablankline -% +% \end{ltxoutput} % Using the |alltt| environment you can put in the spacing via ordinary % spaces. That is, this -% \begin{verbatim} +% \begin{lstlisting} % \begin{alltt}\normalfont % There was an old party of Lyme % Who married three wives at one time. @@ -253,19 +269,20 @@ % He replied: `One's absurd, % And bigamy, sir, is a crime.' % \end{alltt} -% \end{verbatim} +% \end{lstlisting} % is typeset as -% \begin{alltt} -% \normalfont -% There was an old party of Lyme -% Who married three wives at one time. -% When asked: `Why the third?' -% He replied: `One's absurd, -% And bigamy, sir, is a crime.' +% \begin{ltxoutput} +% \begin{alltt}\catcode\%=9\normalfont +%There was an old party of Lyme +%Who married three wives at one time. +% When asked: `Why the third?' +% He replied: `One's absurd, +%And bigamy, sir, is a crime.' % \end{alltt} +% \end{ltxoutput} % % More exotically you could use the TeX |\parshape| command: -% \begin{verbatim} +% \begin{lstlisting} % \parshape = 5 0pt \linewidth 0pt \linewidth % 2em \linewidth 2em \linewidth 0pt \linewidth % \noindent There was an old party of Lyme \\ @@ -273,11 +290,9 @@ % When asked: `Why the third?' \\ % He replied: `One's absurd, \\ % And bigamy, sir, is a crime.' \par -% \end{verbatim} +% \end{lstlisting} % which will be typeset as: -% -% \ablankline -% +% \begin{ltxoutput*} % \parshape = 5 0pt \linewidth 0pt \linewidth % 2em \linewidth 2em \linewidth 0pt \linewidth % \noindent There was an old party of Lyme \\ @@ -285,10 +300,8 @@ % When asked: `Why the third?' \\ % He replied: `One's absurd, \\ % And bigamy, sir, is a crime.' \par -% -% \ablankline -% -% This is about as much assistance as standard (La)TeX provides. +% \end{ltxoutput*} +% All of this is about as much assistance as standard (La)TeX provides. % % % \clearpage @@ -299,6 +312,25 @@ % provide a comprehensive solution to all the requirements that % will arise. % +% A brief introduction is included to get started quickly; see the examples in Section~\ref{sec:ex} for more context. +% +% \subsection{Brief introduction} +% +% The \Lpack{verse} package provides the |verse| environment for typesetting verses, overwriting \LaTeX's original definition. +% Every line in a verse environment must end with |\\|, and every stanza within a verse should end with |\\!| (an empty line afterwards is optional for readability). +% These requirements allow line numbering to work correctly in all cases. +% Use the \cs{poemlines}\marg{N} command to number every \meta{N}th line of a poem. +% +% Use the \cs{poemtitle}\marg{title} command (just before the |verse| environment) to give each poem a title; commands are provided to adjust the formatting and include the poem into the standard table of contents. +% +% Each stanza within a verse may optionally be surrounded by either an |altverse| or |patverse| environment to effect specific typesetting; |altverse| indents every second line of a stanza, and |patverse| allows arbitrary indentation based on the \meta{pattern} given by \cs{indentpattern}\marg{pattern}. +% The command \cs{flagverse}, placed at the very beginning of a stanza places a `title'; e.g., for numbering and otherwise labelling stanzas. +% +% +% \subsection{Comprehensive documentation} +% +% \subsubsection{Main verse environments} +% % \DescribeEnv{verse} % The |verse| environment provided by the package is an extension % of the usual LaTeX environment. The environment takes one optional @@ -314,13 +346,13 @@ % The length |\versewidth| is provided as a convenience. It may be used, % for example, to calculate the length of a line of text for use % as the optional argument to the |verse| environment: -% \begin{verbatim} +% \begin{lstlisting} % \settowidth{\versewidth}{This is the average line,} % \begin{verse}[\versewidth] -% \end{verbatim} +% \end{lstlisting} % % \DescribeEnv{altverse} -% Within the |verse| environment verses are seperated by a blank line +% Within the |verse| environment verses are separated by a blank line % in the input. Individual verses within |verse| may, however, % be enclosed in the |altverse| environment. This has the effect of % indenting the 2nd, 4th, etc., lines of the verse by the length |\vgap|. @@ -343,6 +375,36 @@ % shorter than the number of lines in a verse, the trailing lines will % not be indented. % +% \subsubsection{Other verse commands} +% +% \DescribeMacro{\\} +% Within the |verse| environment, the macro |\\| must be used at the +% end of each line of a verse, except for the last line in each stanza. +% If the lines in a poem are to be numbered then +% \DescribeMacro{\\!} +% |\\!| must be used at the +% end of the last line in each stanza (the |\\| macro increments the line +% numbers). +% +% \DescribeMacro{\\*} +% The starred version, |\\*|, prohibits a page break after the +% line. +% \DescribeMacro{\\>} +% The |\\>| version causes a linebreak within a verse line. +% +% The |\\| macro in its various forms can also take an optional length +% argument, like |\\[30pt]| +% which will insert |30pt| of vertical space; in the case of |\\>[30pt]| +% an additional 30pt of horizontal space will be inserted after the +% linebreak (effectively |\\>| is shorthand for |\verselinebreak|). +% +% The allowable forms of the +% macro are: +% \begin{center} +% |\\|, |\\*|. |\\!|, |\\>|, |\\[...]|, |\\*[...]|, |\\![...]|, +% and |\\>[...]|. +% \end{center} +% % \DescribeMacro{\vin} % \DescribeMacro{\vgap} % The command |\vin| is shorthand for |\hspace{\vgap}| for use @@ -354,22 +416,6 @@ % wrapped onto the next line with a space, given by the value of the % length \cs{vindent}. % -% \DescribeMacro{\leftmargini} -% All verse lines have a minimum indent given by the length \cs{leftmargini} -% which also applies to any list environment. To change the minimum -% indent for verses do something along the lines: -% \begin{verbatim} -% \newlength{\saveleftmargini} -% \setlength{\saveleftmargini}{\leftmargini} -% \setlength{\leftmargini}{-1em}% for example to outdent verse -% % verses -% \setlength{\leftmargini}{\saveleftmargini}% restore original value -% \end{verbatim} -% -% \DescribeMacro{\stanzaskip} -% The length |\stanzaskip| controls the spacing between stanzas. -% It may be changed like any other length. -% % \DescribeMacro{\verselinebreak} % Using the command |\verselinebreak[|\meta{length}|]| will cause % later text in the @@ -386,6 +432,27 @@ % of verse will typeset \meta{flag} towards the left margin, ending % a distance |\vleftskip| before the verse line. % +% \subsubsection{Generic verse formatting} +% +% \DescribeMacro{\stanzaskip} +% The length |\stanzaskip| controls the spacing between stanzas. +% It may be changed like any other length. +% +% \DescribeMacro{\leftmargini} +% All verse lines have a minimum indent given by the length \cs{leftmargini} +% which also applies to any list environment. To change the minimum +% indent for verses do something along the lines: +% \begin{lstlisting} +% \newlength{\saveleftmargini} +% \setlength{\saveleftmargini}{\leftmargini} +% \setlength{\leftmargini}{-1em}% for example to outdent verse +% % verses +% \setlength{\leftmargini}{\saveleftmargini}% restore original value +% \end{lstlisting} +% +% +% \subsubsection{Line numbering} +% % \DescribeMacro{\poemlines} % The declaration |\poemlines{|\meta{nth}|}| will cause every \meta{nth} % lines of succeeding verses to be numbered. For example, |\poemlines{5}| @@ -405,9 +472,8 @@ % or if it was line 115 that was first numbered: \\ % \verb?\setverselinenums{112}{115}? % -% Note that the numbers must be such that the relationship \\ -% \verb?firstlinenum <= startnumsat < firstlinenum + poemlines? \\ -% holds. +% Note that the numbers must be such that the following relationship holds: \\ +% \verb?firstlinenum <= startnumsat < firstlinenum + poemlines? % % % \DescribeMacro{\thepoemline} @@ -415,8 +481,8 @@ % Lines are numbered via \cs{thepoemline} which defaults to typesetting % arabic numerals via: \\ % \verb?\renewcommand*{\thepoemline}{\arabic{poemline}}? \\ -% The particular font is defined by \cs{verselinenumfont}\marg{font-spec}. -% The default is: \\ +% The particular font is defined by \cs{verselinenumfont}\marg{font-spec}, +% with default: \\ % \verb?\verselinenumfont{\rmfamily}? \\ % % \DescribeMacro{\vrightskip} @@ -428,22 +494,6 @@ % declaration. To revert to the default use \cs{verselinenumbersright}. % % -% \DescribeMacro{\\} -% Within the |verse| environment, the macro |\\| must be used at the -% end of each line of a verse, except for the last line in each stanza. -% If the lines in a poem are to be numbered then |\\!| must be used at the -% end of the last line in each stanza (the |\\| macro increments the line -% numbers). The starred version, |\\*|, prohibits a page break after the -% line. The |\\>| version causes a linebreak within a verse line. -% The |\\| macro in its various forms can also take an optional length -% argument, like |\\[30pt]| -% which will insert |30pt| of vertical space; in the case of |\\>[30pt]| -% an additional 30pt of horizontal space will be inserted after the -% linebreak (effectively |\\>| is shorthand for |\verselinebreak|). -% The allowable forms of the -% macro are: |\\|, |\\*|. |\\!|, |\\>|, |\\[...]|, |\\*[...]|, |\\![...]|, -% and |\\>[...]|. -% % \DescribeMacro{\label} % \DescribeMacro{\ref} % The standard |\label{|meta{key}|}| command @@ -452,6 +502,8 @@ % what the setting of |\poemlines|. Elsewhere the standard % |\ref{|\meta{key}|}| command can be used to refer to the line number. % +% \subsubsection{Titles} +% % \DescribeMacro{\poemtitle} % |\poemtitle[|\meta{short}|}{|\meta{long}|}| typesets the title % of a poem and makes an entry into the ToC. There is a starred version @@ -528,16 +580,16 @@ % |\arraytostring{MyArray}{\MyString}|. % % \DescribeMacro{\checkifinteger} -% |\checkifinteger{|\meta{num}|}| ckecks if \meta{num} is an integer (not less +% |\checkifinteger{|\meta{num}|}| checks if \meta{num} is an integer (not less % than zero). If it is then |\ifinteger| is set TRUE, otherwise it is set % FALSE. % -% \clearpage % \subsection{Examples} +% \label{sec:ex} % % Here are some sample verses using the package facilities. % First our old Limerick friend, but titled and centered: -% \begin{verbatim} +% \begin{lstlisting} % \renewcommand{\poemtoc}{subsection} % \poemtitle{A Limerick} % \settowidth{\versewidth}{There was an old party of Lyme} @@ -546,13 +598,13 @@ % Who married three wives at one time. \\ % \vin When asked: `Why the third?' \\ % \vin He replied: `One's absurd, \\ -% And bigamy, sir, is a crime.' +% And bigamy, sir, is a crime.' \\ % \end{verse} -% \end{verbatim} +% \end{lstlisting} % which gets typeset as below. The default |\poemtoc| is redefined % to |subsection| so the % title is entered into the ToC as an unnumbered |\subsection|. -% +% \begin{ltxoutput} % \renewcommand{\poemtoc}{subsection} % \poemtitle{A Limerick} % \settowidth{\versewidth}{There was an old party of Lyme} @@ -561,14 +613,15 @@ % Who married three wives at one time. \\ % \vin When asked: `Why the third?' \\ % \vin He replied: `One's absurd, \\ -% And bigamy, sir, is a crime.' +% And bigamy, sir, is a crime.' \\ % \end{verse} +% \end{ltxoutput} % % \ablankline % % Next is the Garden verse within the |altverse| environment. It % is titled and centered. -% \begin{verbatim} +% \begin{lstlisting} % \settowidth{\versewidth}{But now my love is dead} % \poemtitle{Love's lost} % \begin{verse}[\versewidth] @@ -576,8 +629,9 @@ % \garden % \end{altverse} % \end{verse} -% \end{verbatim} +% \end{lstlisting} % which produces: +% \begin{ltxoutput} % \settowidth{\versewidth}{But now my love is dead} % \poemtitle{Love's lost} % \begin{verse}[\versewidth] @@ -585,77 +639,81 @@ % \garden % \end{altverse} % \end{verse} +% \end{ltxoutput} % % \ablankline % % It is left up to you how you might want to add information about % the author of a poem. Here is one example of a macro for this: -% \begin{verbatim} +% \begin{lstlisting} % \newcommand{\attrib}[1]{% % \nopagebreak{\raggedleft\footnotesize #1\par}} -% \end{verbatim} +% \end{lstlisting} % \newcommand{\attrib}[1]{% % \nopagebreak{\raggedleft\footnotesize #1\par}} % -% This can be used as in the next bit of doggeral. -% \begin{verbatim} +% This can be used as in the next bit of doggerel. +% \begin{lstlisting} % \poemtitle{Fleas} % \settowidth{\versewidth}{What a funny thing is a flea} % \begin{verse}[\versewidth] % What a funny thing is a flea. \\ % You can't tell a he from a she. \\ % But he can. And she can. \\ -% Whoopee! +% Whoopee! \\ % \end{verse} % \attrib{Anonymous} -% \end{verbatim} +% \end{lstlisting} % +% \begin{ltxoutput} % \poemtitle{Fleas} % \settowidth{\versewidth}{What a funny thing is a flea} % \begin{verse}[\versewidth] % What a funny thing is a flea. \\ % You can't tell a he from a she. \\ % But he can. And she can. \\ -% Whoopee! +% Whoopee! \\ % \end{verse} % \attrib{Anonymous} +% \end{ltxoutput} % % \ablankline % % Here is an example of line wrapping. -% \begin{verbatim} +% \begin{lstlisting} % \poemtitle{In the beginning} % \settowidth{\versewidth}{And objects at rest tended to remain at rest} % \begin{verse}[\versewidth] -% Then God created Newton, \\* -% And objects at rest tended to remain at rest, \\* -% And objects in motion tended to remain in motion, \\* +% Then God created Newton, \\ +% And objects at rest tended to remain at rest, \\ +% And objects in motion tended to remain in motion, \\ % And energy was conserved % and momentum was conserved -% and matter was conserved \\* -% And God saw that it was conservative. +% and matter was conserved \\ +% And God saw that it was conservative. \\ % \end{verse} % \attrib{Possibly from \textit{Analog}, circa 1950} -% \end{verbatim} +% \end{lstlisting} % -% \clearpage +% \begin{ltxoutput} % \poemtitle{In the beginning} % \settowidth{\versewidth}{And objects at rest tended to remain at rest} % \begin{verse}[\versewidth] -% Then God created Newton, \\* -% And objects at rest tended to remain at rest, \\* -% And objects in motion tended to remain in motion, \\* +% Then God created Newton, \\ +% And objects at rest tended to remain at rest, \\ +% And objects in motion tended to remain in motion, \\ % And energy was conserved % and momentum was conserved -% and matter was conserved \\* -% And God saw that it was conservative. +% and matter was conserved \\ +% And God saw that it was conservative. \\ % \end{verse} % \attrib{Possibly from \textit{Analog}, circa 1950} +% \end{ltxoutput} % % \ablankline % % Here is one with a forced line break and a slightly different title style. -% \begin{verbatim} +% \begin{lstlisting} % \renewcommand{\poemtitlefont}{\normalfont\large\itshape\centering} % \poemtitle{Mathematics} % \settowidth{\versewidth}{Than Tycho Brahe, or Erra Pater:} @@ -667,11 +725,12 @@ % Resolve, by sines \\>[\versewidth] and tangents straight, \\ % If bread or butter wanted weight; \\ % And wisely tell what hour o' the day \\ -% The clock does strike, by Algebra. +% The clock does strike, by Algebra. \\ % \end{verse} % \attrib{Samuel Butler (1612--1680)} -% \end{verbatim} +% \end{lstlisting} % +% \begin{ltxoutput} % \renewcommand{\poemtitlefont}{\normalfont\large\itshape\centering} % \poemtitle{Mathematics} % \settowidth{\versewidth}{Than Tycho Brahe, or Erra Pater:} @@ -683,16 +742,16 @@ % Resolve, by sines \\>[\versewidth] and tangents straight, \\ % If bread or butter wanted weight; \\ % And wisely tell what hour o' the day \\ -% The clock does strike, by Algebra. +% The clock does strike, by Algebra. \\ % \end{verse} % \attrib{Samuel Butler (1612--1680)} +% \end{ltxoutput} % % \ablankline -% \clearpage % % Another limerick, but this time taking advantage of the |patverse| % environment and numbering every third line. -% \begin{verbatim} +% \begin{lstlisting} % \settowidth{\versewidth}{There was a young lady of Ryde} % \poemtitle{The Young Lady of Ryde} % \begin{verse}[\versewidth] @@ -703,12 +762,13 @@ % Who ate some apples and died. \\ % The apples fermented \\ % Inside the lamented \\ -% And made cider inside her inside. +% And made cider inside her inside. \\ % \end{patverse} % \poemlines{0} % \end{verse} -% \end{verbatim} +% \end{lstlisting} % +% \begin{ltxoutput} % \settowidth{\versewidth}{There was a young lady of Ryde} % \poemtitle{The Young Lady of Ryde} % \begin{verse}[\versewidth] @@ -719,17 +779,18 @@ % Who ate some apples and died. \\ % The apples fermented \\ % Inside the lamented \\ -% And made cider inside her inside. +% And made cider inside her inside. \\ % \end{patverse} % \poemlines{0} % \end{verse} +% \end{ltxoutput} % % \ablankline % % The next example is a song you may have heard of. The `forty-niner' in % line \ref{vs:49} refers to the gold rush of 1849. % -% \begin{verbatim} +% \begin{lstlisting} % \settowidth{\versewidth}{In a cavern, in a canyon,} % \poemtitle{Clementine} % \begin{verse}[\versewidth] @@ -745,13 +806,14 @@ % \flagverse{\textsc{chorus}} Oh my darling, Oh my darling, \\ % Oh my darling Clementine. \\ % Thou art lost and gone forever, \\ -% Oh my darling Clementine +% Oh my darling Clementine \\! % \end{altverse} % \poemlines{0} % \end{verse} -% \end{verbatim} +% \end{lstlisting} % % +% \begin{ltxoutput} % \settowidth{\versewidth}{In a cavern, in a canyon,} % \poemtitle{Clementine} % \begin{verse}[\versewidth] @@ -767,10 +829,11 @@ % \flagverse{\textsc{chorus}} Oh my darling, Oh my darling, \\ % Oh my darling Clementine. \\ % Thou art lost and gone forever, \\ -% Oh my darling Clementine +% Oh my darling Clementine \\! % \end{altverse} % \poemlines{0} % \end{verse} +% \end{ltxoutput} % % % The last example is a much more ambitious use of |\indentpattern|. In @@ -780,6 +843,7 @@ % % % \clearpage +% \begin{ltxoutput} % \poemtitle{Mouse's Tale} % \settowidth{\versewidth}{a mouse that morning} % \indentpattern{0135554322112346898779775545653222345544456688778899} @@ -840,7 +904,7 @@ % \end{patverse} % \end{verse} % \attrib{Lewis Carrol, \textit{Alice's Adventures in Wonderland}, 1865} -% +% \end{ltxoutput} % % % \StopEventually{ @@ -872,12 +936,11 @@ %<*usc> \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{verse}[2009/09/04 v2.4a verse typesetting] - % \end{macrocode} % % For reference, here is the original definition of the |verse| environment % from \file{classes.dtx}, based on |\let|ting |\\| equal |\@centercr|. -% \begin{verbatim} +% \begin{lstlisting} % \newenvironment{verse} % {\let\\\@centercr % \list{}{\itemsep \z@ @@ -887,7 +950,7 @@ % \advance\leftmargin 1.5em}% % \item\relax} % {\endlist} -% \end{verbatim} +% \end{lstlisting} % % \subsection{Verse code} % @@ -913,7 +976,6 @@ \newcounter{modulo@vs} \newcounter{verse@envctr}\setcounter{verse@envctr}{0} \newcommand*{\theHpoemline}{\arabic{verse@envctr}.\arabic{poemline}} - % \end{macrocode} % \end{macro} % \end{macro} @@ -929,13 +991,12 @@ % \begin{macrocode} \newcommand{\poemlines}[1]{% \ifnum#1>\z@ - \setcounter{modulo@vs}{#1} + \setcounter{modulo@vs}{#1}% \else - \setcounter{modulo@vs}{0} + \setcounter{modulo@vs}{0}% \fi } \poemlines{0} - % \end{macrocode} % \end{macro} % @@ -946,7 +1007,6 @@ % \begin{macrocode} \newcommand*{\verselinenumfont}[1]{\def\vlnumfont{#1}} \verselinenumfont{\rmfamily} - % \end{macrocode} % \end{macro} % \end{macro} @@ -974,8 +1034,8 @@ \multiply\@tempcnta\c@modulo@vs \c@fvsline #2\relax \advance\c@fvsline-\@tempcnta - \fi} - + \fi +} % \end{macrocode} % \end{macro} % @@ -986,9 +1046,9 @@ % of line numbers} % \begin{macrocode} \newcommand{\getmodulo@vs}{\bgroup - \ifnum\c@modulo@vs<\@ne% no line numbers + \ifnum\c@modulo@vs<\@ne % no line numbers \else - \ifnum\c@modulo@vs<\tw@% every line numbered + \ifnum\c@modulo@vs<\tw@ % every line numbered \vlnumfont\thepoemline \else \@tempcnta\c@poemline @@ -1000,7 +1060,6 @@ \fi \fi \egroup} - % \end{macrocode} % \end{macro} % @@ -1008,7 +1067,6 @@ % This should be set TRUE for indenting alternate lines. % \begin{macrocode} \newif\ifaltindent - \altindentfalse % \end{macrocode} % \end{macro} % @@ -1016,7 +1074,6 @@ % This should be set TRUE for indenting lines according to a pattern. % \begin{macrocode} \newif\ifpattern - \patternfalse % \end{macrocode} % \end{macro} % @@ -1026,8 +1083,6 @@ % \changes{v2.1}{2002/03/8}{Added \cs{ifstarpattern}} % \begin{macrocode} \newif\ifstarpattern - \starpatternfalse - % \end{macrocode} % \end{macro} % @@ -1035,7 +1090,6 @@ % |\versewidth| is a convenience length for the user. % \begin{macrocode} \newlength{\versewidth} - % \end{macrocode} % \end{macro} % @@ -1049,11 +1103,13 @@ % between stanzas. % \changes{v2.2}{2002/07/18}{Added \cs{stanzaskip}} % \begin{macrocode} -\newlength{\vgap} \setlength{\vgap}{1.5em} +\newlength{\vgap} +\setlength{\vgap}{1.5em} \newcommand{\vin}{\hspace*{\vgap}} -\newlength{\vindent} \setlength{\vindent}{2\vgap} -\newlength{\stanzaskip} \setlength{\stanzaskip}{0.75\baselineskip} - +\newlength{\vindent} +\setlength{\vindent}{2\vgap} +\newlength{\stanzaskip} +\setlength{\stanzaskip}{0.75\baselineskip} % \end{macrocode} % \end{macro} % \end{macro} @@ -1066,10 +1122,9 @@ % \changes{v2.0}{2002/03/24}{Added \cs{vleftksip} and \cs{vrightskip}} % \begin{macrocode} \newlength{\vleftskip} - \setlength{\vleftskip}{30pt} +\setlength{\vleftskip}{30pt} \newlength{\vrightskip} - \setlength{\vrightskip}{10pt} - +\setlength{\vrightskip}{10pt} % \end{macrocode} % \end{macro} % \end{macro} @@ -1078,8 +1133,10 @@ % |\flagverse{|\meta{flag}|}| inserts \meta{flag} at the left (of a line). % \changes{v2.0}{2002/03/24}{Added \cs{flagverse}} % \begin{macrocode} -\newcommand{\flagverse}[1]{\hskip-\vleftskip\llap{#1}\hskip\vleftskip\ignorespaces} - +\newcommand{\flagverse}[1]{% + \hskip-\vleftskip\llap{#1}\hskip\vleftskip + \ignorespaces +} % \end{macrocode} % \end{macro} % @@ -1091,7 +1148,10 @@ % \changes{v2.1}{2002/03/28}{Modified \cs{verselinebreak}} % \changes{v2.3}{2006/01/14}{Added \cs{ignorespaces} to \cs{verselinebreak}} % \begin{macrocode} -\newcommand*{\verselinebreak}[1][\z@]{\newline\hspace*{#1}\ignorespaces} +\newcommand*{\verselinebreak}[1][\z@]{% + \newline\hspace*{#1}% + \ignorespaces +} % \end{macrocode} % \end{macro} % @@ -1101,8 +1161,8 @@ % \begin{macrocode} \newcommand{\incr@vsline}{% \refstepcounter{poemline}% - \stepcounter{vslineno}} - + \stepcounter{vslineno}% +} % \end{macrocode} % \end{macro} % @@ -1119,7 +1179,6 @@ % \changes{v2.1}{2002/03/28}{Added \cs{@vsifgt}} % \begin{macrocode} \newcommand{\@vsifgt}[1]{\@ifnextchar >{\@firstoftwo{#1}}} - % \end{macrocode} % \end{macro} % @@ -1127,19 +1186,20 @@ % \begin{macro}{\@vstypelinenumleft} % \begin{macro}{\verselinenumbersright} % \begin{macro}{\verselinenumbersleft} -% These control the typesetting of verse linenumbers to the +% These control the typesetting of verse line numbers to the % right and to the left of the verse. Default is to set them at % the right. % \changes{v2.3}{2006/01/14}{Added left/right switching line numbers} % \begin{macrocode} \newcommand*{\@vstypelinenumright}{% - \hfill\rlap{\kern\vrightskip\kern\rightmargin\getmodulo@vs}} + \hfill\rlap{\kern\vrightskip\kern\rightmargin\getmodulo@vs}% +} \newcommand*{\@vstypelinenumleft}{% - \hfill\rlap{\kern-\textwidth\kern-\vrightskip\getmodulo@vs}} + \hfill\rlap{\kern-\textwidth\kern-\vrightskip\getmodulo@vs}% +} \newcommand*{\verselinenumbersright}{\def\@vstypelinenum{\@vstypelinenumright}} -\newcommand*{\verselinenumbersleft}{\def\@vstypelinenum{\@vstypelinenumleft}} +\newcommand*{\verselinenumbersleft} {\def\@vstypelinenum{\@vstypelinenumleft}} \verselinenumbersright - % \end{macrocode} % \end{macro} % \end{macro} @@ -1160,23 +1220,24 @@ % \begin{macrocode} \newcommand{\@vscentercr}{% \ifhmode \unskip\else \@nolnerr\fi - \@vstypelinenum% + \@vstypelinenum %%%% \hfill\rlap{\kern\vrightskip\kern\rightmargin\getmodulo@vs}% % \end{macrocode} % For |>| call |\verselinebreak| to process it. % \begin{macrocode} \@vsifgt{\verselinebreak}{% - \incr@vsline + \incr@vsline % \end{macrocode} % If the call is |\\*...| call |\@vsxcentercr| to handle the |*...|. % If the call is |\\!|, do nothing. % If the call is |\\![...]|, call |\@vsicentercr| to handle the |[...]|. % Otherwise, call |\@vsxcentercr|. % \begin{macrocode} - \par\@ifstar{\nobreak\@vsxcentercr}{% -% \end{macrocode} -% \begin{macrocode} - \@vsifbang{\@ifnextchar[ {\@vsicentercr}{}}{\@vsxcentercr}}}} + \par\@ifstar{\nobreak\@vsxcentercr}{% + \@vsifbang{\@ifnextchar[ {\@vsicentercr}{}}{\@vsxcentercr}% + }% + }% +} % \end{macrocode} % \end{macro} % @@ -1185,8 +1246,10 @@ % or |\start@vsline|. % \changes{v2.0}{2002/03/24}{Added \cs{@vsxcentercr}} % \begin{macrocode} -\newcommand{\@vsxcentercr}{\addvspace{-\parskip}% - \@ifnextchar[ {\@vsicentercr}{\start@vsline}} +\newcommand{\@vsxcentercr}{% + \addvspace{-\parskip}% + \@ifnextchar[ {\@vsicentercr}{\start@vsline}% +} % \end{macrocode} % \end{macro} % @@ -1208,8 +1271,8 @@ \newcommand{\start@vsline}{% \ifaltindent\ifodd\c@vslineno\else\vin\fi\fi% \ifpattern\get@vsindent\fi% - \ifstarpattern\getstar@vsindent\fi} - + \ifstarpattern\getstar@vsindent\fi +} % \end{macrocode} % \end{macro} % @@ -1226,7 +1289,7 @@ % \changes{v2.2}{2002/07/18}{Added \cs{stanzaskip} to the verse environment} % \changes{v2.22}{2005/08/22}{Added verse@envctr to the verse environment} % \begin{macrocode} -\renewenvironment{verse}[1][\linewidth]{ +\renewenvironment{verse}[1][\linewidth]{% \stepcounter{verse@envctr}% \setcounter{poemline}{0}\refstepcounter{poemline}% \setcounter{vslineno}{1}% @@ -1243,9 +1306,10 @@ \else \rightmargin \leftmargin \fi - \addtolength{\leftmargin}{\vindent}} - \item[]}{\endlist} - + \addtolength{\leftmargin}{\vindent}}% + \item[]% +} +{\endlist} % \end{macrocode} % \end{environment} % @@ -1256,7 +1320,6 @@ \newenvironment{altverse}% {\starpatternfalse\patternfalse\altindenttrue\setcounter{vslineno}{1}}% {\altindentfalse} - % \end{macrocode} % \end{environment} % @@ -1267,12 +1330,12 @@ % digit at a particular position in the array. % \changes{v1.1}{2001/08/03}{Added all the pattern code} % -% \begin{macro}{\@nameedef} +% \begin{macro}{\vs@nameedef} % A shorthand for using |\protected@edef|. % \begin{macrocode} -\newcommand{\@nameedef}[1]{ - \expandafter\protected@edef\csname #1\endcsname} - +\newcommand{\vs@nameedef}[1]{% + \expandafter\protected@edef\csname #1\endcsname +} % \end{macrocode} % \end{macro} % @@ -1282,7 +1345,6 @@ % the array limits. % \begin{macrocode} \newif\ifbounderror - \bounderrorfalse % \end{macrocode} % \end{macro} % @@ -1290,7 +1352,6 @@ % A flag to indicate if a `number' is an integer (TRUE) or not (FALSE). % \begin{macrocode} \newif\ifinteger - % \end{macrocode} % \end{macro} % @@ -1298,7 +1359,6 @@ % A counter for the number of characters. % \begin{macrocode} \newcounter{chrsinstr} % CHARactersINSTRing - % \end{macrocode} % \end{macro} % @@ -1306,16 +1366,15 @@ % \begin{macro}{\newarray} % |\newarray{|\meta{arrayname}|}{|\meta{low}|}{|\meta{high}|}| defines % an array called \meta{arrayname} (no backslash e.g. |MyArray|), -% with low and high limts \meta{low} and \meta{high}. +% with low and high limits \meta{low} and \meta{high}. % \begin{macrocode} \newcommand{\newarray}[3]{% - \@nameedef{#1-low}{#2}% - \@nameedef{#1-high}{#3}% + \vs@nameedef{#1-low}{#2}% + \vs@nameedef{#1-high}{#3}% \ifnum #3<#2 \PackageError{verse}{Limits for array #1 are in reverse order}{\@ehc}% \fi } - % \end{macrocode} % \end{macro} % @@ -1332,13 +1391,12 @@ \newarray{\@vsarrayname}{1}{1}% \@ifmtarg{#2}{% \c@chrsinstr \z@ - \@namedef{\@vsarrayname-1}{} + \@namedef{\@vsarrayname-1}{}% }{% \c@chrsinstr \@ne \expandafter\@vsstringtoarray \the@vsstring\@vsend - } + }% } - % \end{macrocode} % \end{macro} % @@ -1348,8 +1406,8 @@ % the array's high limit. % \begin{macrocode} \def\@vsstringtoarray #1#2\@vsend{% - \@namedef{\@vsarrayname-\the\c@chrsinstr}{#1} - \@nameedef{\@vsarrayname-high}{\the\c@chrsinstr} + \@namedef{\@vsarrayname-\the\c@chrsinstr}{#1}% + \vs@nameedef{\@vsarrayname-high}{\the\c@chrsinstr}% \@ifmtarg{#2}{% \def\@vsinext{}% }{% @@ -1357,10 +1415,9 @@ \def\@vsinext{% \@vsstringtoarray #2\@vsend% }% - } + }% \@vsinext } - % \end{macrocode} % \end{macro} % @@ -1371,9 +1428,8 @@ % \begin{macrocode} \newcommand{\setarrayelement}[3]{% \checkarrayindex{#1}{#2}% - \@nameedef{#1-#2}{#3}% + \vs@nameedef{#1-#2}{#3}% } - % \end{macrocode} % \end{macro} % @@ -1387,7 +1443,6 @@ \checkarrayindex{#1}{#2}% \protected@edef#3{\@nameuse{#1-#2}}% } - % \end{macrocode} % \end{macro} % @@ -1399,26 +1454,25 @@ % \begin{macrocode} \newcommand{\checkarrayindex}[2]{% \bounderrorfalse - \expandafter\ifx\csname #1-low\endcsname\relax% + \expandafter\ifx\csname #1-low\endcsname\relax \ifpattern\else \PackageError{verse}{No array called #1}{\@ehc}% \fi \bounderrortrue \fi - \ifnum #2<\@nameuse{#1-low}\relax% + \ifnum #2<\@nameuse{#1-low}\relax \ifpattern\else \PackageError{verse}{Index #2 outside limits for array #1}{\@ehc}% \fi \bounderrortrue \fi - \ifnum #2>\@nameuse{#1-high}\relax% + \ifnum #2>\@nameuse{#1-high}\relax \ifpattern\else \PackageError{verse}{Index #2 outside limits for array #1}{\@ehc}% \fi \bounderrortrue \fi } - % \end{macrocode} % \end{macro} % @@ -1435,7 +1489,6 @@ \long\gdef\@xifmtarg#1#2Q#3#4#5\@nil{#4} \long\gdef\@ifnotmtarg#1{\@xifmtarg#1QQ\@firstofone\@gobble\@nil} \endgroup - % \end{macrocode} % \end{macro} % @@ -1450,7 +1503,6 @@ \c@chrsinstr = \@nameuse{#1-low}% \@vsarraytostring{#1}{#2}% } - % \end{macrocode} % \end{macro} % @@ -1466,7 +1518,6 @@ \@vsarraytostring{#1}{#2}% \fi% } - % \end{macrocode} % \end{macro} % @@ -1479,10 +1530,10 @@ \newcommand{\checkifinteger}[1]{% \protected@edef\@vsa{#1}% \ifcat _\ifnum9<1\gobm{#1} _\else A\fi - \integertrue% + \integertrue \else - \integerfalse% - \fi% + \integerfalse + \fi } % \end{macrocode} % \end{macro} @@ -1496,7 +1547,6 @@ % (Code from a posting to CTT by Donald Arseneau on 1997/07/21). % \begin{macrocode} \newcommand{\gobm}[1]{#1} - % \end{macrocode} % \end{macro} % @@ -1505,8 +1555,8 @@ % a verse indentation pattern. % \begin{macrocode} \newcommand{\indentpattern}[1]{% - \stringtoarray{Array@vs}{#1}} - + \stringtoarray{Array@vs}{#1}% +} % \end{macrocode} % \end{macro} % @@ -1533,7 +1583,8 @@ \def\@vspat{0}% \fi \fi - \ifcase\@vspat\else\hspace*{\@vspat\vgap}\fi} + \ifcase\@vspat\else\hspace*{\@vspat\vgap}\fi +} % \end{macrocode} % \end{macro} % @@ -1546,14 +1597,14 @@ % \begin{macrocode} \newcommand{\getstar@vsindent}{% \expandafter\ifx\csname Array@vs-high\endcsname\relax - \PackageError{verse}{A pattern has not been specified}{\@ehc} + \PackageError{verse}{A pattern has not been specified}{\@ehc}% \else \ifnum\c@vslineno>\@nameuse{Array@vs-high}% \setcounter{vslineno}{1}% \fi \get@vsindent - \fi} - + \fi +} % \end{macrocode} % \end{macro} % @@ -1564,10 +1615,9 @@ % and initialises the line number. It ends by setting |\ifpattern| FALSE. % \changes{v2.1}{2002/03/28}{Added \cs{starpatternfalse} to patverse} % \begin{macrocode} -\newenvironment{patverse}% - {\starpatternfalse\patterntrue\altindentfalse\setcounter{vslineno}{1}}% +\newenvironment{patverse} + {\starpatternfalse\patterntrue\altindentfalse\setcounter{vslineno}{1}} {\patternfalse} - % \end{macrocode} % \end{environment} % @@ -1578,10 +1628,9 @@ % and initialises the line number. It ends by setting |\ifstarpattern| FALSE. % \changes{v2.1}{2002/03/28}{Added patverse* environment} % \begin{macrocode} -\newenvironment{patverse*}% - {\starpatterntrue\patternfalse\altindentfalse\setcounter{vslineno}{1}}% +\newenvironment{patverse*} + {\starpatterntrue\patternfalse\altindentfalse\setcounter{vslineno}{1}} {\starpatternfalse} - % \end{macrocode} % \end{environment} % @@ -1591,8 +1640,10 @@ % Typeset a poem title (like |\section| or other). The actual work % is done by |\@vsptitle| (plain) or |\@vssptitle| (starred). % \begin{macrocode} -\newcommand{\poemtitle}{\par% - \secdef\@vsptitle\@vssptitle} +\newcommand{\poemtitle}{% + \par + \secdef\@vsptitle\@vssptitle +} % \end{macrocode} % \end{macro} % @@ -1600,7 +1651,6 @@ % The kind of entry |\poemtitle| is to make in the ToC. % \begin{macrocode} \newcommand{\poemtoc}{section} - % \end{macrocode} % \end{macro} % @@ -1610,11 +1660,11 @@ % \begin{macrocode} \def\@vsptitle[#1]#2{% \@nameuse{phantomsection}% - \addcontentsline{toc}{\poemtoc}{#1} + \addcontentsline{toc}{\poemtoc}{#1}% \poemtitlemark{#1}% - \@vstypeptitle{#2} - \@afterheading} - + \@vstypeptitle{#2}% + \@afterheading +} % \end{macrocode} % \end{macro} % @@ -1623,8 +1673,8 @@ % \begin{macrocode} \def\@vssptitle#1{% \@vstypeptitle{#1} - \@afterheading} - + \@afterheading +} % \end{macrocode} % \end{macro} % @@ -1632,11 +1682,10 @@ % This \emph{really} typesets the title. % \begin{macrocode} \newcommand{\@vstypeptitle}[1]{% - \vspace{\beforepoemtitleskip} - {\poemtitlefont #1\par} - \vspace{\afterpoemtitleskip} + \vspace{\beforepoemtitleskip}% + {\poemtitlefont #1\par}% + \vspace{\afterpoemtitleskip}% } - % \end{macrocode} % \end{macro} % @@ -1646,7 +1695,6 @@ % \begin{macrocode} \newcommand{\poemtitlefont}{\normalfont\large\bfseries\centering} \newcommand{\poemtitlemark}[1]{} - % \end{macrocode} % \end{macro} % \end{macro} @@ -1656,28 +1704,22 @@ % Lengths before and after a poem title, using the |\section| values. % \begin{macrocode} \newlength{\beforepoemtitleskip} - \setlength{\beforepoemtitleskip}{3.5ex \@plus 1ex \@minus .2ex} +\setlength{\beforepoemtitleskip}{3.5ex \@plus 1ex \@minus .2ex} \newlength{\afterpoemtitleskip} - \setlength{\afterpoemtitleskip}{2.3ex \@plus.2ex} - +\setlength{\afterpoemtitleskip}{2.3ex \@plus.2ex} % \end{macrocode} % \end{macro} % \end{macro} % -% % The end of this package. % \begin{macrocode} % % \end{macrocode} % -% -% -% % \Finale % \PrintIndex % \endinput - %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z -- cgit v1.2.3