diff options
author | Robert Alessi <alessi@robertalessi.net> | 2021-03-21 08:34:36 +0100 |
---|---|---|
committer | Robert Alessi <alessi@robertalessi.net> | 2021-03-21 08:34:36 +0100 |
commit | 2a1051c7367679a3a8ecd4681db4de3c7a5d6cb0 (patch) | |
tree | 2088af037adfd443524b8cf86fb25bbe547096b5 /ekdosis.dtx | |
parent | 6efb1bccc1c98f55af0d2579dae22e643e80e1c1 (diff) | |
download | ekdosis-2a1051c7367679a3a8ecd4681db4de3c7a5d6cb0.tar.gz |
added vlineation and continuousvnum
Diffstat (limited to 'ekdosis.dtx')
-rw-r--r-- | ekdosis.dtx | 147 |
1 files changed, 128 insertions, 19 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx index bb02250..c27eab2 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx | |||
@@ -1138,13 +1138,14 @@ along with this program. If not, see | |||
1138 | % \vskip\baselineskip | 1138 | % \vskip\baselineskip |
1139 | % | 1139 | % |
1140 | % \DescribeOption{poetry}\label{ref:poetry-opt} | 1140 | % \DescribeOption{poetry}\label{ref:poetry-opt} |
1141 | % \newfeature[v1.2] | ||
1141 | % |poetry|$=$\verb+verse+ | 1142 | % |poetry|$=$\verb+verse+ |
1142 | % \hfill\tcboxverb{Default: not set}\\ | 1143 | % \hfill\tcboxverb{Default: not set}\\ |
1143 | % |poetry=verse| instructs \pkg{ekdosis} to load and use the facilites | 1144 | % |poetry=verse| instructs \pkg{ekdosis} to load and use the facilites |
1144 | % supplied by the \pkg{verse} package for typesetting lines of | 1145 | % supplied by the \pkg{verse} package for typesetting lines of |
1145 | % poetry. The \env{ekdverse} environment must then be used instead of | 1146 | % poetry. The \env{ekdverse} environment must then be used instead of |
1146 | % the \env{verse} environment that is provided by the \pkg{verse} | 1147 | % the \env{verse} environment that is provided by the \pkg{verse} |
1147 | % package as described below in \vref{sec:poetry}. | 1148 | % package as described below in \vref{sec:verse-package}. |
1148 | % | 1149 | % |
1149 | % \DescribeOption{parnotes}\label{ref:parnotes-opt} | 1150 | % \DescribeOption{parnotes}\label{ref:parnotes-opt} |
1150 | % |parnotes|$=$\verb+true|false|roman+% | 1151 | % |parnotes|$=$\verb+true|false|roman+% |
@@ -3657,19 +3658,31 @@ argument of the | |||
3657 | % | 3658 | % |
3658 | % \section{Poetry} | 3659 | % \section{Poetry} |
3659 | % \label{sec:poetry} | 3660 | % \label{sec:poetry} |
3661 | % \subsection[The Standard \textsf{verse} Environment]{The Standard | ||
3662 | % \env{verse} Environment} | ||
3663 | % \label{sec:stand-verse-env} | ||
3664 | % | ||
3660 | % For typesetting verse texts or poems, \LaTeX\ provides the standard | 3665 | % For typesetting verse texts or poems, \LaTeX\ provides the standard |
3661 | % \env{verse} environment. Usually, within this environment, |\\| is | 3666 | % \env{verse} environment. Within this environment, |\\| is normally |
3662 | % used to end lines, with the exception of the last line. Likewise, | 3667 | % used to end lines, with the exception of the last line. As a result, |
3663 | % stanzas are separated from one another by a blank line. However, | 3668 | % stanzas are separated from one another by a blank line. |
3664 | % \pkg{ekdosis} deviates a little from this usage for it needs all | 3669 | % |
3665 | % lines of poetry to be ended by |\\| as a distinct marker, like | 3670 | % \pkg{ekdosis} provides \env{ekdverse} which is recommended for use |
3666 | % so:--- | 3671 | % in place of the standard \env{verse} environment. By default, |
3672 | % \env{ekdverse} produces the same result as \env{verse}. However, | ||
3673 | % \pkg{ekdosis} deviates a little from the standard usage for it needs | ||
3674 | % all lines of poetry to be ended by |\\| as a distinct marker. In the | ||
3675 | % following listing, stanzas are visually separated from one another | ||
3676 | % by an additional vertical space of \unit[2]{ex} (l.~5). Between | ||
3677 | % stanzas, |%| is used to prevent \TeX\ from | ||
3678 | % introducing a blank line. But a blank line\===or even no blank | ||
3679 | % line\===would produce the exact same result:--- | ||
3667 | % | 3680 | % |
3668 | % \iffalse | 3681 | % \iffalse |
3669 | %<*example> | 3682 | %<*example> |
3670 | % \fi | 3683 | % \fi |
3671 | \begin{minted}{latex} | 3684 | \begin{minted}{latex} |
3672 | \begin{verse} | 3685 | \begin{ekdverse} |
3673 | It is an ancient Mariner,\\ | 3686 | It is an ancient Mariner,\\ |
3674 | And he stoppeth one of three.\\ | 3687 | And he stoppeth one of three.\\ |
3675 | ‘By thy long grey beard and glittering eye,\\ | 3688 | ‘By thy long grey beard and glittering eye,\\ |
@@ -3678,16 +3691,68 @@ argument of the | |||
3678 | The Bridegroom's doors are opened wide,\\ | 3691 | The Bridegroom's doors are opened wide,\\ |
3679 | And I am next of kin;\\ | 3692 | And I am next of kin;\\ |
3680 | The guests are met, the feast is set:\\ | 3693 | The guests are met, the feast is set:\\ |
3681 | May'st hear the merry din.’ | 3694 | May'st hear the merry din.’\\ |
3682 | \end{verse} | 3695 | \end{ekdverse} |
3683 | \end{minted} | 3696 | \end{minted} |
3684 | % \iffalse | 3697 | % \iffalse |
3685 | %</example> | 3698 | %</example> |
3686 | % \fi | 3699 | % \fi |
3687 | % | 3700 | % |
3688 | % As can be seen, stanzas are visually separated from one another by | 3701 | % PDF output:--- |
3689 | % an additional vertical space of \unit[2]{ex} (l.~5), while the | 3702 | % \medskip |
3690 | % subsequent line is rendered inert. | 3703 | % \begingroup |
3704 | % \needspace{7\baselineskip} | ||
3705 | % \resetlinenumber\resetvlinenumber | ||
3706 | % \poemlines{0} | ||
3707 | % \begin{alignment}[flush,tcols=1,texts=coleridge,apparatus=coleridge] | ||
3708 | % \begin{coleridge} | ||
3709 | % \begin{verse} | ||
3710 | % It is an ancient Mariner,\\ | ||
3711 | % And he stoppeth one of three.\\ | ||
3712 | % ‘By thy long grey beard and glittering eye,\\ | ||
3713 | % Now wherefore stopp'st thou me?\\[2ex] | ||
3714 | % | ||
3715 | % The Bridegroom's doors are opened wide,\\ | ||
3716 | % And I am next of kin;\\ | ||
3717 | % The guests are met, the feast is set:\\ | ||
3718 | % May'st hear the merry din.’\\ | ||
3719 | % \end{verse} | ||
3720 | % \end{coleridge} | ||
3721 | % \end{alignment} | ||
3722 | % \endgroup | ||
3723 | % \medskip | ||
3724 | % | ||
3725 | % \indent\texttt{TEI xml} output:--- | ||
3726 | % | ||
3727 | % \iffalse | ||
3728 | %<*example> | ||
3729 | % \fi | ||
3730 | \begin{minted}[linenos=false]{xml} | ||
3731 | <lg> | ||
3732 | <l>It is an ancient Mariner,</l> | ||
3733 | <l>And he stoppeth one of three.</l> | ||
3734 | <l>‘By thy long grey beard and glittering eye,</l> | ||
3735 | <l>Now wherefore stopp'st thou me?</l> | ||
3736 | <l>The Bridegroom's doors are opened wide,</l> | ||
3737 | <l>And I am next of kin;</l> | ||
3738 | <l>The guests are met, the feast is set:</l> | ||
3739 | <l>May'st hear the merry din.’</l> | ||
3740 | </lg> | ||
3741 | \end{minted} | ||
3742 | % \iffalse | ||
3743 | %</example> | ||
3744 | % \fi | ||
3745 | % | ||
3746 | % One would have expected here the |<lg>| element to be used as | ||
3747 | % delimiter to encode the stanzaic verse forms. But as can be seen, | ||
3748 | % only the outermost level of line group has been converted into | ||
3749 | % \texttt{TEI xml}, let alone the vertical spacing between stanzas | ||
3750 | % which has been ignored. This is because it is about as much as the | ||
3751 | % standard \env{verse} environment provides. | ||
3752 | % | ||
3753 | % \subsection[The \textsf{verse} Package]{The \pkg{verse} Package} | ||
3754 | % \label{sec:verse-package} | ||
3755 | % | ||
3691 | % | 3756 | % |
3692 | % \begingroup | 3757 | % \begingroup |
3693 | % \setcolumnwidth{0.6\textwidth} | 3758 | % \setcolumnwidth{0.6\textwidth} |
@@ -7224,6 +7289,7 @@ Sample text with a \textcolor{red}{word} in red. | |||
7224 | % numbering should start afresh at the top of each page. | 7289 | % numbering should start afresh at the top of each page. |
7225 | % \begin{macrocode} | 7290 | % \begin{macrocode} |
7226 | \newif\ifekd@pagelineation | 7291 | \newif\ifekd@pagelineation |
7292 | \newif\ifekd@pagevlineation | ||
7227 | \NewDocumentCommand{\ekdatbegshihook}{}{% | 7293 | \NewDocumentCommand{\ekdatbegshihook}{}{% |
7228 | \ifekd@pagelineation\resetlinenumber\fi | 7294 | \ifekd@pagelineation\resetlinenumber\fi |
7229 | } | 7295 | } |
@@ -7234,6 +7300,10 @@ Sample text with a \textcolor{red}{word} in red. | |||
7234 | document = \ekd@pagelineationfalse}, | 7300 | document = \ekd@pagelineationfalse}, |
7235 | unknown-choice lineation = \PackageError{ekdosis}{unknown | 7301 | unknown-choice lineation = \PackageError{ekdosis}{unknown |
7236 | lineation=#1}{`lineation' must be either `page' or `document'.}, | 7302 | lineation=#1}{`lineation' must be either `page' or `document'.}, |
7303 | choice vlineation = {page = \ekd@pagevlineationtrue, | ||
7304 | document = \ekd@pagevlineationfalse}, | ||
7305 | unknown-choice vlineation = \PackageError{ekdosis}{unknown | ||
7306 | vlineation=#1}{`vlineation' must be either `page' or `document'.}, | ||
7237 | code modulonum = \chardef\c@linenumbermodulo#1\relax, | 7307 | code modulonum = \chardef\c@linenumbermodulo#1\relax, |
7238 | noval modulo = \modulolinenumbers, | 7308 | noval modulo = \modulolinenumbers, |
7239 | code vmodulo = \if@pkg@poetry@verse\poemlines{#1}\fi, | 7309 | code vmodulo = \if@pkg@poetry@verse\poemlines{#1}\fi, |
@@ -8256,13 +8326,46 @@ Sample text with a \textcolor{red}{word} in red. | |||
8256 | } | 8326 | } |
8257 | % \end{macrocode} | 8327 | % \end{macrocode} |
8258 | % \end{macro} | 8328 | % \end{macro} |
8329 | % \paragraph{Poetry Settings} | ||
8259 | % \begin{environment}{ekdverse} | 8330 | % \begin{environment}{ekdverse} |
8260 | % \env{ekdverse} provides an implementation of poetry lines. It is | 8331 | % \env{ekdverse} provides an implementation of poetry lines. It is |
8261 | % set to use either the \pkg{lineno} or the \pkg{verse} package | 8332 | % set to use either the \pkg{lineno} or the \pkg{verse} package |
8262 | % depending on the value that is passed to the global option | 8333 | % depending on the value that is passed to the global option |
8263 | % |verse|:--- | 8334 | % |poetry|. |
8335 | % \begin{macro}{\test@vpnum} | ||
8336 | % \cs{test@vpnum} is used internally when |ekdosis| needs to know | ||
8337 | % whether two subsequent lines are printed on the same page or not. | ||
8338 | % \begin{macrocode} | ||
8339 | \newif\ifekd@test@vpnum | ||
8340 | \newcounter{ekd@vpnum} | ||
8341 | \globalcounter{ekd@vpnum} | ||
8342 | \NewDocumentCommand{\test@vpnum}{}{% | ||
8343 | \ifekd@test@vpnum | ||
8344 | \edef\@tempa{\theekd@vpnum}% | ||
8345 | \stepcounter{ekd@vpnum}% | ||
8346 | \label{vpnum:\theekd@vpnum}% | ||
8347 | \ifnum | ||
8348 | \pdf@strcmp{\getpagerefnumber{vpnum:\@tempa}}% | ||
8349 | {\getpagerefnumber{vpnum:\theekd@vpnum}} | ||
8350 | = 0 | ||
8351 | \else | ||
8352 | \resetvlinenumber | ||
8353 | \fi | ||
8354 | \else | ||
8355 | \label{vpnum:\theekd@vpnum}% | ||
8356 | \global\ekd@test@vpnumtrue | ||
8357 | \fi | ||
8358 | } | ||
8359 | % \end{macrocode} | ||
8360 | % \end{macro} | ||
8361 | % A small patch is applied to the \pkg{verse} package, then | ||
8362 | % \env{ekdverse} is defined:--- | ||
8264 | % \begin{macrocode} | 8363 | % \begin{macrocode} |
8265 | \if@pkg@poetry@verse | 8364 | \if@pkg@poetry@verse |
8365 | \patchcmd{\start@vsline}{% | ||
8366 | \ifaltindent}{% | ||
8367 | \ifekd@pagevlineation\test@vpnum\fi | ||
8368 | \ifaltindent}{}{} | ||
8266 | \ekvdefinekeys{ekd@verse}{ | 8369 | \ekvdefinekeys{ekd@verse}{ |
8267 | dimen width = \vwidth@val, | 8370 | dimen width = \vwidth@val, |
8268 | initial width = \linewidth, | 8371 | initial width = \linewidth, |
@@ -8295,10 +8398,13 @@ Sample text with a \textcolor{red}{word} in red. | |||
8295 | \rightmargin \leftmargin | 8398 | \rightmargin \leftmargin |
8296 | \fi | 8399 | \fi |
8297 | \addtolength{\leftmargin}{\vindent}}% | 8400 | \addtolength{\leftmargin}{\vindent}}% |
8298 | \item[]% | 8401 | \item[]\ifekd@pagevlineation\test@vpnum\fi% |
8299 | } | 8402 | } |
8300 | {\endlist | 8403 | {\endlist |
8301 | \if@continuous@vnum\resetlinenumber[\thepoemline]\fi} | 8404 | \if@continuous@vnum\resetlinenumber[\thepoemline]\fi} |
8405 | % \end{macrocode} | ||
8406 | % Finally, this is the standard \env{verse} environment:--- | ||
8407 | % \begin{macrocode} | ||
8302 | \else | 8408 | \else |
8303 | \newlength{\ekdverseindentlength} | 8409 | \newlength{\ekdverseindentlength} |
8304 | \setlength{\ekdverseindentlength}{\parindent} | 8410 | \setlength{\ekdverseindentlength}{\parindent} |
@@ -8317,8 +8423,8 @@ Sample text with a \textcolor{red}{word} in red. | |||
8317 | % \begin{macro}{\resetvlinenumber} | 8423 | % \begin{macro}{\resetvlinenumber} |
8318 | % \changes{v1.2}{2021/03/06}{resets line numbers in poetry environments} | 8424 | % \changes{v1.2}{2021/03/06}{resets line numbers in poetry environments} |
8319 | % This command is the equivalent of \cs{resetlinenumber} for lines of | 8425 | % This command is the equivalent of \cs{resetlinenumber} for lines of |
8320 | % poetry. It takes an integer (which is |1| by default) as optional | 8426 | % poetry. It takes an integer as optional argument, which is |1| by |
8321 | % argument. | 8427 | % default. |
8322 | % \begin{macrocode} | 8428 | % \begin{macrocode} |
8323 | \NewDocumentCommand{\resetvlinenumber}{O{1}}{% | 8429 | \NewDocumentCommand{\resetvlinenumber}{O{1}}{% |
8324 | \if@pkg@poetry@verse | 8430 | \if@pkg@poetry@verse |
@@ -8329,6 +8435,9 @@ Sample text with a \textcolor{red}{word} in red. | |||
8329 | % \end{macro} | 8435 | % \end{macro} |
8330 | % \begin{environment}{ekdstanza} | 8436 | % \begin{environment}{ekdstanza} |
8331 | % \changes{v1.2}{2021/03/08}{new environment for stanzas} | 8437 | % \changes{v1.2}{2021/03/08}{new environment for stanzas} |
8438 | % \env{ekdstanza} is needed when lines are grouped into stanzas, | ||
8439 | % which can be further named by means of the |type| optional | ||
8440 | % argument:--- | ||
8332 | % \begin{macrocode} | 8441 | % \begin{macrocode} |
8333 | \ekvdefinekeys{ekd@stanza}{ | 8442 | \ekvdefinekeys{ekd@stanza}{ |
8334 | code type = \def\type@value{#1} | 8443 | code type = \def\type@value{#1} |
@@ -8994,7 +9103,7 @@ local function linestotei(str) | |||
8994 | str = "\n<l>"..str | 9103 | str = "\n<l>"..str |
8995 | end | 9104 | end |
8996 | str = gsub(str, poemline * spcenc^0 * bclinegroup, "</l>\n%2") | 9105 | str = gsub(str, poemline * spcenc^0 * bclinegroup, "</l>\n%2") |
8997 | str = gsub(str, linegroup * -(spcenc^0 * bclinegroup), "%1\n<l>a") | 9106 | str = gsub(str, linegroup * -(spcenc^0 * bclinegroup), "%1\n<l>") |
8998 | str = gsub(str, lpeg.Cs("</lg>") * -(spcenc^0 * (bclinegroup + -1)), "%1\n<l>") | 9107 | str = gsub(str, lpeg.Cs("</lg>") * -(spcenc^0 * (bclinegroup + -1)), "%1\n<l>") |
8999 | -- str = gsub(str, poemline * spcenc^-1 * -1, "</l>\n") | 9108 | -- str = gsub(str, poemline * spcenc^-1 * -1, "</l>\n") |
9000 | str = gsub(str, poemlinebreak, "<lb/> ") | 9109 | str = gsub(str, poemlinebreak, "<lb/> ") |