From 34786688b350598f9da6641a1a45d9d747c17536 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Sun, 19 Jul 2020 12:23:57 +0200 Subject: added \null at the beginning of \lem and \note. elide digits of end-range line numbers --- ekdosis.dtx | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 87 insertions(+), 6 deletions(-) diff --git a/ekdosis.dtx b/ekdosis.dtx index 2cc2ead..f2bae26 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx @@ -1757,8 +1757,39 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+ % \section{Laying Out the Apparatus Criticus } % \label{sec:apparatus-layout} % Single-layer apparatus criticus can be laid out in a variety of -% ways. +% ways with the following specialized commands, all of which can be +% used in the preamble or at any point of the document. % +% \DescribeMacro{\SetLTRapp} +% \DescribeMacro{\SetRTLapp} +% \cs{SetLTRapp} and \cs{SetRTLapp} are two argument-less commands to +% set the direction of the apparatus criticus, either left-to-right or +% right-to-left. +% +% \DescribeMacro{\SetSeparator} \cs{SetSeparator}\marg{separator} is +% used to change the separator between lemma texts and variants +% readings. By default, the separator is a closing square bracket +% followed by a space (\verb*+] +). +% +% \DescribeMacro{\SetBeginApparatus} +% \cs{SetBeginApparatus}\marg{characters/commands} can be used to +% append \meta{characters} or \meta{commands} at the beginning of the +% apparatus block. By default, nothing is appended. For instance, +% \mintinline{latex}|\SetBeginApparatus{\textbf{Apparatus:}}| will +% append \enquote{\textbf{Apparatus:}} at the beginning of the +% apparatus block, while % +% \mintinline{latex}|\SetBeginApparatus{\hskip 1em}| will set an +% indentation of one em. +% +% \DescribeMacro{\SetEndApparatus} +% \cs{SetEndApparatus}\marg{characters} can be used to append +% \meta{characters} at the end of the apparatus block. By default, +% nothing is appended. As an example of use, +% \mintinline{latex}|\SetEndApparatus{.}| will have a period printed +% at the end of the apparatus as it is customary in some editions. +% +% \DescribeMacro{\SetUnitDelimiter} +% \cs{SetUnitDelimiter} % % \section{To Be Continued...} % v1.0 of \pkg{ekdosis}, which should be available by the end of July @@ -2780,7 +2811,7 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+ % \end{macro} % \begin{macro}{\SetEndApparatus} % \cs{SetEndApparatus}\marg{characters} can be used to append -% characters at the end of the apparatus block\---such as a full stop, +% characters at the end of the apparatus block\---such as a period, % as it is customary in some editions. By default, nothing is % appended:--- % \begin{macrocode} @@ -2998,8 +3029,10 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+ \fi % \else - \LRnum{\getrefnumber{#1}}--% - \LRnum{\getrefnumber{#2}}% issue the nos + \luadirect{tex.sprint(ekdosis.numrange(\luastring{\getrefnumber{#1}}, + \luastring{\getrefnumber{#2}}))} + % \LRnum{\getrefnumber{#1}}--% + % \LRnum{\getrefnumber{#2}}% issue the nos \fi% \else \LRnum{\getrefnumber{#1}}--% @@ -3051,8 +3084,11 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+ \fi % \else - \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}--% - \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}% issue the nos + \luadirect{tex.sprint(ekdosis.numrange( + \luastring{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}, + \luastring{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}))}% issue the nos + % \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}--% + % \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}% issue the nos \fi% \else \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}--% @@ -3099,6 +3135,7 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+ \NewDocumentCommand{\lem}{O{} m}{% \ekd@isinlemtrue% \luadirect{ekdosis.dolnlab(\luastringN{#2})}% + \null \bgroup% \ekvset{lem}{#1}% \ifekd@mapps% @@ -3300,6 +3337,7 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+ % specified; otherwise \pkg{ekdosis} will issue an error message. % \begin{macrocode} \NewDocumentCommand{\note@noapp}{O{} +m}{% + \null \bgroup% \ekvset{note}{#1}% \stepcounter{ekd@lab}% @@ -5360,6 +5398,49 @@ function ekdosis.testapparatus() end end +local function get_ln_prefix(x, y) + for index = 1, string.len(x) + do + if string.sub(x, index, index) ~= string.sub(y, index, index) + then + return string.sub(x, 1, index - 1) + end + end +end + +function ekdosis.numrange(x, y) + xstr = tostring(x) + ystr = tostring(y) + if x == y -- which will never apply + then + return "\\LRnum{" .. xstr .. "}" + elseif string.len(xstr) ~= string.len(ystr) + then + return "\\LRnum{" .. xstr .. "}--\\LRnum{" .. ystr .. "}" + else + common = get_ln_prefix(xstr, ystr) + if string.len(common) == 0 + then + return "\\LRnum{" .. xstr .. "}--\\LRnum{" .. ystr .. "}" + elseif string.sub(xstr, -2, -2) == "1" + then + return "\\LRnum{" + .. string.sub(common, 1, -2) + .. string.sub(xstr, string.len(common), -1) + .. "}--\\LRnum{" + .. string.sub(ystr, string.len(common), -1) + .. "}" + else + return "\\LRnum{" + .. string.sub(common, 1, -1) + .. string.sub(xstr, string.len(common) + 1, -1) + .. "}--\\LRnum{" + .. string.sub(ystr, string.len(common) + 1, -1) + .. "}" + end + end +end + local lnlabs = {} local lnlab_salt = 0 local current_lnlab = nil -- cgit v1.2.3