From 3296aeaae9cb2b4dce92b573ee2745aa03a3c3a3 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Thu, 25 Mar 2021 10:53:27 +0100 Subject: poetry: added compatibility with the memoir class --- ekdosis.dtx | 214 +++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 189 insertions(+), 25 deletions(-) diff --git a/ekdosis.dtx b/ekdosis.dtx index c27eab2..c7f6592 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx @@ -365,7 +365,7 @@ along with this program. If not, see @Software{verse, title = {The Verse package}, - subtitle = {Aids for typesetting simple verse}, + titleaddon = {Aids for typesetting simple verse}, author = {Wilson, Peter R. and Robertson, Will}, url = {http://www.ctan.org/pkg/verse}, date = {2014-05-10}, @@ -1233,9 +1233,9 @@ along with this program. If not, see % comma-separated list of the following \enquote{name=value} arguments % that are used to collect items of information to be found within % the || element in the \texttt{TEI} -% header:---\footnote{See +% header:\footnote{See % \url{https://tei-c.org/release/doc/tei-p5-doc/en/html/MS.html\#msid} -% for detailed information on these elements.}\\ +% for detailed information on these elements.}---\\ % \DescribeOption{settlement} |settlement|$=$\meta{name}: The name of % a city or administrative unit.\\ % \DescribeOption{institution} |institution|$=$\meta{name}: The name @@ -1460,8 +1460,8 @@ along with this program. If not, see % and N, and β, which includes mss.\ T, f, U and l. Therefore, % provided that all these witnesses have been already declared, here % is how the two families α and β could be -% declared:---\footnote{These witnesses are used in the example -% provided below in \vref{lst:caesar-bg}.} +% declared:\footnote{These witnesses are used in the example +% provided below in \vref{lst:caesar-bg}.}--- % \label{ref:caesar-bg-sigla} % \iffalse %<*example> @@ -2675,6 +2675,7 @@ friend % \end{remarks} % % Finally, the corresponding \texttt{TEI xml} output follows:--- +% % \iffalse %<*example> % \fi @@ -3662,10 +3663,10 @@ argument of the % \env{verse} Environment} % \label{sec:stand-verse-env} % -% For typesetting verse texts or poems, \LaTeX\ provides the standard -% \env{verse} environment. Within this environment, |\\| is normally -% used to end lines, with the exception of the last line. As a result, -% stanzas are separated from one another by a blank line. +% In order to typeset verse texts or poems, \LaTeX\ provides the +% standard \env{verse} environment. Within this environment, |\\| is +% normally used to end lines, with the exception of the last line. As +% a result, stanzas are separated from one another by a blank line. % % \pkg{ekdosis} provides \env{ekdverse} which is recommended for use % in place of the standard \env{verse} environment. By default, @@ -3700,10 +3701,10 @@ argument of the % % PDF output:--- % \medskip +% \SetLineation{vmodulo=0} % \begingroup % \needspace{7\baselineskip} % \resetlinenumber\resetvlinenumber -% \poemlines{0} % \begin{alignment}[flush,tcols=1,texts=coleridge,apparatus=coleridge] % \begin{coleridge} % \begin{verse} @@ -3720,6 +3721,7 @@ argument of the % \end{coleridge} % \end{alignment} % \endgroup +% \SetLineation{vmodulo=1} % \medskip % % \indent\texttt{TEI xml} output:--- @@ -3752,8 +3754,118 @@ argument of the % % \subsection[The \textsf{verse} Package]{The \pkg{verse} Package} % \label{sec:verse-package} +% \pkg{ekdosis} can use the facilities offered by the excellent +% \pkg{verse} package\footcite{verse} to which it adds a specific +% environment for the encoding of line groups such as +% stanzas. Furthermore, as the \pkg{verse} package provides its own +% numbering mechanism, the lines can be numbered independently of +% prose text. +% +% \danger For what is described in this section to operate, +% \pkg{ekdosis} must be loaded with the global option |poetry=verse| +% as explained above \vpageref{ref:poetry-opt}. Simply loading the +% \pkg{verse} package by means of \cs{usepackage} will have no effect. +% +% \paragraph{Compatible Verse Commands} +% The reader is invited to refer to the documentation of the +% \env{verse} package for detailed information. Within the +% \env{ekdverse} environment, |\\| \emph{must be used} at the end of +% each line, as follows:--- +% \begin{enumerate} +% \item |\\| is the standard command to be used at the end of each +% line. +% \item |\\!| must be used at the end of stanzas or line groups +% instead of |\\|. +% \item |\\*| does the same as |\\| except that it prohibits a page +% break after the line. +% \item |\\>| is for line breaks within a verse line. +% \end{enumerate} +% +% All of these commands can take a dimension as optional argument, +% like so: |\\[30pt]|, |\\![30pt]|, |\\*[30pt]| or |\\>[30pt]|. If +% |\\|, |\\!| or |\\*| be used, a vertical space of the dimension +% specified is added between lines, whereas |\\>[...]| adds an +% horizontal space after the line break. +% +% \DescribeMacro{\vin} \cs{vin} indents a verse line by a length which +% is by default \unit[1.5]{em}. This length is stored as \cs{vgap} and +% can be changed by \cs{setlength} or \cs{addtolength}. +% +% \paragraph{The \env{ekdverse} Environment} +% \DescribeEnv{ekdverse} \cs{begin}|{ekdverse}|\oarg{options} \dots\ +% \cs{end}|{ekdverse}|\label{ref:ekdverse-syntax}\newfeature[v1.2]\\ +% This environment is used to hold verse lines as described above and +% may receive an optional argument in which the following +% \enquote{name$=$value} arguments are accepted:---\\ +% \DescribeOption{width} |width|$=$\meta{length} +% \hfill\tcboxverb{Default: \linewidth}\\ +% If |width| be supplied, it is taken as a length in relation to which +% the entire contents of the environment is to be horizontally +% centered. If given, this dimension may correspond to an average line +% or to the longest line of the line group. To this end, the standard +% \LaTeX\ command \cs{settowidth} can be used, like so:--- % +% \iffalse +%<*example> +% \fi +\begin{minted}[linenos=false]{latex} +\settowidth{\versewidth}{This is the average line,} +\begin{ekdverse}[width=\versewidth] +... +\end{ekdverse} +\end{minted} +% \iffalse +% +% \fi % +% \begin{remarks} +% \item[\textsc{Rem.}] \cs{versewidth} is provided by the \env{verse} +% package as a convenience and can be used by \env{ekdosis}. +% \end{remarks} +% \DescribeOption{type} |width|$=$\meta{type} +% \hfill\tcboxverb{Default: not set}\\ +% This named argument is used in the \texttt{TEI xml} output to +% name the type of unit encoded within the || element, viz.\ +% \enquote{sonnet}, \enquote{quatrain}, \enquote{couplet} and the +% like. +% +% As an example, the first five lines of Homer's \emph{Odyssey} could +% be encoded like so:\footcite{HomerMurray}--- % +% \iffalse +%<*example> +% \fi +\begin{minted}[linenos=false]{latex} +\begin{alignment}[tcols=2, + lcols=2, + texts=homer[xml:lang="grc"];murray[xml:lang="en"], + apparatus=homer] + \begin{homer} + \begin{ekdverse} + Ἄνδρα μοι ἔννεπε, Μοῦσα, πολύτροπον, ὃς μάλα πολλὰ \\ + πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν· \\ + πολλῶν δ' ἀνθρώπων ἴδεν ἄστεα καὶ + \app{\lem{νόον} + \rdg[resp=Zen]{νόμον} + \note{Cf. Schol.}} ἔγνω, \\ + πολλὰ δ' ὅ γ' ἐν πόντῳ πάθεν ἄλγεα ὃν κατὰ θυμόν, \\ + ἀρνύμενος ἥν τε ψυχὴν καὶ νόστον ἑταίρων. \\ + \end{ekdverse} + \end{homer} + \begin{murray} + Tell me, O Muse, of the man of many devices, who wandered full + many ways after he had sacked the sacred citadel of Troy. Many + were the men whose cities he saw and whose mind he learned, aye, + and many the woes he suffered in his heart upon the sea, seeking + to win his own life and the return of his + comrades. + \end{murray} +\end{alignment} +\end{minted} +% \iffalse +% +% \fi % +% PDF output:--- +% \medskip % \begingroup % \setcolumnwidth{0.6\textwidth} % \setlength{\leftmargini}{0em} @@ -3761,7 +3873,7 @@ argument of the % \resetlinenumber\resetvlinenumber % \begin{alignment}[flush, % lcols=2, -% texts=homer[xml:lang="grc"];murray, +% texts=homer[xml:lang="grc"];murray[xml:lang="en"], % apparatus=homer] % \AtBeginEnvironment{homer}{\selectlanguage{greek}} % \setlength{\vrightskip}{0.25em} @@ -3782,11 +3894,44 @@ argument of the % many ways after he had sacked the sacred citadel of Troy. Many % were the men whose cities he saw and whose mind he learned, aye, % and many the woes he suffered in his heart upon the sea, seeking -% to win his own life and the return of his -% comrades.\footcite{HomerMurray} +% to win his own life and the return of his comrades. % \end{murray} % \end{alignment} % \endgroup +% \medskip +% +% \texttt{TEI xml} output:--- +% +% \iffalse +%<*example> +% \fi +\begin{minted}[linenos=false]{xml} +
+ + Ἄνδρα μοι ἔννεπε, Μοῦσα, πολύτροπον, ὃς μάλα πολλὰ + πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν· + πολλῶν δ' ἀνθρώπων ἴδεν ἄστεα καὶ + + νόον + νόμον + Cf. Schol. + ἔγνω, + πολλὰ δ' ὅ γ' ἐν πόντῳ πάθεν ἄλγεα ὃν κατὰ θυμόν, + ἀρνύμενος ἥν τε ψυχὴν καὶ νόστον ἑταίρων. + +
+
+

Tell me, O Muse, of the man of many devices, who + wandered full many ways after he had sacked the sacred + citadel of Troy. Many were the men whose cities he saw and + whose mind he learned, aye, and many the woes he suffered + in his heart upon the sea, seeking to win his own life and + the return of his comrades.

+
+\end{minted} +% \iffalse +% +% \fi % % \begingroup % \junicode @@ -3862,12 +4007,15 @@ argument of the % Pitty the world,or else this glutton be,\\ % To eate the worlds due,\app{ % \lem{by the} -% \rdg[resp=shStee, postwit=conj., type=conjecture]{be thy} -% \rdg[resp=shGod, postwit=conj., type=conjecture]{by thy} +% \rdg[resp=shStee, type=conjecture]{be thy} +% \note{conj.} +% \rdg[resp=shGod, type=conjecture]{by thy} +% \note{conj.} % } graue % \app{ % \lem{and} -% \rdg[resp=shGod, postwit=conj., type=conjecture]{as} +% \rdg[resp=shGod, type=conjecture]{as} +% \note{conj.} % } thee.\\! % \end{ekdstanza} % \end{patverse} @@ -3876,6 +4024,8 @@ argument of the % \end{alignment} % \endgroup % +% \url{https://www.bl.uk/collection-items/first-edition-of-shakespeares-sonnets-1609} +% % \section{Lineation Settings} % \label{sec:lineation} % \danger \pkg{ekdosis} uses \pkg{lineno} internally for line @@ -4960,14 +5110,15 @@ subtype="arabtex">'inna 'abI kAna mina % of options} can be used in the preamble or at any point of the % document, except inside environments set to receive an apparatus % criticus, namely the \env{ekdosis} environment or any other similar -% environment declared by means of \cs{DeclareApparatus}.\footnote{See -% above \vref{sec:declaring-layers}.} At the time of writing, there is +% environment declared by means of the \env{alignment} environment or +% \cs{SetAlignment}.\footnote{See above +% \vref{sec:multiple-alignment}.} At the time of writing, there is % only one option, as follows:---\\ % \DescribeOption{autopar} |autopar|$=$\verb+true|false+ % \hfill\tcboxverb{Default: true}\\ % The algorithm described above applies for edition texts composed in -% running paragraphs or in lines of poetry, but it may fail to produce -% a valid \texttt{TEI xml} output with other arrangements, such as +% running paragraphs or lines of poetry, but it may fail to produce a +% valid \texttt{TEI xml} output with other arrangements, such as % performance texts or transcriptions of speech for which the % \texttt{TEI} Guidelines define specific rules. |autopar=false| % instructs \pkg{ekdosis} to ignore blank lines in the |.tex| source @@ -6528,6 +6679,9 @@ Sample text with a \textcolor{red}{word} in red. `tidy'.} } \ekvoProcessLocalOptions{ekdosis} +\newif\ifekd@memoir@loaded +\@ifclassloaded{memoir}{% + \ekd@memoir@loadedtrue\@pkg@poetry@versetrue}{} % \end{macrocode} % \paragraph{Required Packages} \label{ref:ekdrequirements} In % addition to \pkg{iftex}, \pkg{expkv-opt} and \pkg{expkv-def}, a list @@ -7306,7 +7460,8 @@ Sample text with a \textcolor{red}{word} in red. vlineation=#1}{`vlineation' must be either `page' or `document'.}, code modulonum = \chardef\c@linenumbermodulo#1\relax, noval modulo = \modulolinenumbers, - code vmodulo = \if@pkg@poetry@verse\poemlines{#1}\fi, + code vmodulo = \ifekd@memoir@loaded\linenumberfrequency{#1} + \else\if@pkg@poetry@verse\poemlines{#1}\fi\fi, initial vmodulo = 1, default vmodulo = 5, bool continuousvnum = \if@continuous@vnum, @@ -8371,14 +8526,22 @@ Sample text with a \textcolor{red}{word} in red. initial width = \linewidth, code type = \def\type@value{#1}, } -\verselinenumfont{\normalfont\footnotesize} +\ifekd@memoir@loaded + \linenumberfont{\normalfont\footnotesize} +\else + \verselinenumfont{\normalfont\footnotesize} +\fi \setcounter{poemline}{1} \NewDocumentEnvironment{ekdverse}{!O{}}{% \ekvset{ekd@verse}{#1}% \if@continuous@vnum\setverselinenums{\thelinenumber}{0}\fi \nolinenumbers \let\linelabel\label - \stepcounter{verse@envctr}% + \ifekd@memoir@loaded + \refstepcounter{verse}% + \else + \stepcounter{verse@envctr}% + \fi \addtocounter{poemline}{-1}\refstepcounter{poemline}% \setcounter{vslineno}{1}% \let\\=\@vscentercr @@ -8508,8 +8671,8 @@ local sections = lpeg.Cs(lpeg.P("book") + lpeg.P("part") + lpeg.P("chapter") + lpeg.P("section") + lpeg.P("subsection") + lpeg.P("subsubsection")) local par = lpeg.P(lpeg.P("\\par") * spce^0) -local parb = lpeg.P(lpeg.Cs("\\p@rb") * spce^0) -local para = lpeg.P(lpeg.Cs("\\p@ra") * spce^0) +local parb = lpeg.P(lpeg.P("\\p@rb") * spce^0) +local para = lpeg.P(lpeg.P("\\p@ra") * spce^0) local labelrefcmds = lpeg.Cs(lpeg.P("label") + lpeg.P("linelabel") + lpeg.P("lineref") @@ -8856,6 +9019,7 @@ local texpatttotags = { {a="\\resetlinenumber%s+%[(.-)%]", b=""}, {a="\\resetlinenumber%s+", b=""}, {a="\\indentpattern%s+{(.-)}", b=""}, + {a="\\settowidth%s+{(.-)}{(.-)}", b=""}, {a="\\poemlines%s+{(.-)}", b=""}, {a="\\pagebreak%s+%[[1-4]%]", b=""}, {a="\\pagebreak%s+", b=""}, -- cgit v1.2.3