From 6219ac62c9c11fa4bf11a78c8a27d7b23045bf0c Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Sat, 24 Apr 2021 16:50:54 +0200 Subject: better handling of line numbers of nested apps (2/2). added 'num' and 'nonum' optional arguments to \lem and \note --- ekdosis.dtx | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 85 insertions(+), 15 deletions(-) diff --git a/ekdosis.dtx b/ekdosis.dtx index c2e8e42..513483e 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx @@ -1761,6 +1761,19 @@ yesterday. % orthographical and the like may apply. Obviously, |type=emendation| % should be restricted to lemma texts and |type=conjecture| to variant % readings recorded by means of \cs{rdg} described below. +% +% \needspace{2\baselineskip} +% \noindent +% \DescribeOption{num} (no-value +% argument)\phts\label{ref:lem-num}\newfeature[v1.3]\\ +% |num| takes no value. If used, this argument instructs to print any +% line number that \pkg{ekdosis} may have decided not to print in the +% apparatus criticus before the lemma text.\\ +% \DescribeOption{nonum} (no-value +% argument)\phts\label{ref:lem-nonum}\newfeature[v1.3]\\ +% Compared to |num|, |nonum| does the opposite. If used, any number +% that \pkg{ekdosis} may have decided to print before the lemma text +% is suppressed. % % \needspace{11\baselineskip} % Finally, four named arguments can be used to insert words at the @@ -2052,6 +2065,19 @@ friend % % \fi % +% \danger It must be noted that from a technical standpoint, albeit +% the nested lemmas are printed \emph{before} their parents in the +% apparatus criticus, they are seen by \pkg{ekdosis} \emph{after} the +% latter as the source file is compiled. As a result, notably when the +% whole nested group of lemmas fall on the same line without being +% preceded by an apparatus entry on this line, it may be needed to +% suppress redundant numbers that \pkg{ekdosis} may have decided to +% print in the appartus criticus. Conversely, it may be needed to +% print numbers that \pkg{ekdosis} may have decided not to print. To +% both ends, the |num| and |nonum| optional arguments of the \cs{lem} +% command can be used as described above +% \vpagerefrange{ref:lem-num}{ref:lem-nonum}. +% % \subsubsection{Explicit Grouping} % \label{sec:explicit-grouping} % \DescribeMacro{\rdgGrp} \cs{rdgGrp}\oarg{options}\marg{lemma text @@ -2459,11 +2485,11 @@ friend % \iffalse % % \fi -% +% +% \needspace{11\baselineskip} % PDF output:--- % \medskip % -% \needspace{7\baselineskip} % \resetlinenumber % \begin{alignment}[flush,tcols=1,texts=specimen,apparatus=specimen] % \begin{specimen} @@ -3548,6 +3574,14 @@ Some \app[type=rec2]{ % \DescribeOption{lem} |lem|$=$\meta{lemma text}\\ % |lem| is the span of text the note is about. It may consist of one % or more words, or of an abridged lemma text.\\ +% \DescribeOption{num} (no-value argument)\newfeature[v1.3]\\ +% |num| takes no value. If used, this argument instructs to print any +% line number that \pkg{ekdosis} may have decided not to print in the +% apparatus criticus before the note.\\ +% \DescribeOption{nonum} (no-value argument)\\ +% Compared to |num|, |nonum| does the opposite. If used, any number +% that \pkg{ekdosis} may have decided to print before the note +% is suppressed.\\ % \DescribeOption{labelb} |labelb|$=$\meta{label} % \hfill\tcboxverb{Mandatory}\\ % |labelb| is the unique label to serve as a reference for the point @@ -5880,7 +5914,7 @@ many mathematical writings and to the sense of % \danger If the entire string to be captured be enclosed in square or % curly brackets, it is advisable to use |@b|\texttt{\emph{n}} (for % curly brackets) or |@s|\texttt{\emph{n}} (for square brackets) -% instead of |#|\texttt{\emph{n}}, where \texttt{\emph{n}} is the the +% instead of |#|\texttt{\emph{n}}, where \texttt{\emph{n}} is the % number that is expected in the sequence. This will prevent any % brackets that may be found in the captured string from being % interpreted. @@ -8174,6 +8208,9 @@ Sample text with a \textcolor{red}{word} in red. \LRnum{\getpagerefnumber{#2}}.% \LRnum{\getrefnumber{#2}}\unexpanded\expandafter{\ekd@postrefnum}% issue pg and ln nos \fi% + \ifekdn@forcenum + \LRnum{\getrefnumber{#1}}\unexpanded\expandafter{\ekd@postrefnum}% force the no + \fi }% } % \end{macrocode} @@ -8210,14 +8247,21 @@ Sample text with a \textcolor{red}{word} in red. = 0 \ifekd@appinapp + \ifnum% + \pdf@strcmp{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}% + {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevprevlnlab())}-b}} + = + 0 + \else \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}% - \unexpanded\expandafter{\ekd@postrefnum}% issue the no + \unexpanded\expandafter{\ekd@postrefnum}% issue the no + \fi \fi \else \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}% - \unexpanded\expandafter{\ekd@postrefnum}% issue the no + \unexpanded\expandafter{\ekd@postrefnum}% issue the no \fi - %%%end + %%% end \else \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}% \unexpanded\expandafter{\ekd@postrefnum}% issue the no @@ -8239,14 +8283,21 @@ Sample text with a \textcolor{red}{word} in red. = 0 \ifekd@appinapp + \ifnum% + \pdf@strcmp{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}% + {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevprevlnlab())}-b}} + = + 0 + \else \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}% - \unexpanded\expandafter{\ekd@postrefnum}% issue the no + \unexpanded\expandafter{\ekd@postrefnum}% issue the no + \fi \fi \else \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}% - \unexpanded\expandafter{\ekd@postrefnum}% issue the no + \unexpanded\expandafter{\ekd@postrefnum}% issue the no \fi - %%%end + %%% end \else \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}% \unexpanded\expandafter{\ekd@postrefnum}% issue the no @@ -8276,12 +8327,18 @@ Sample text with a \textcolor{red}{word} in red. \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}% \unexpanded\expandafter{\ekd@postrefnum}% issue pg and ln nos \fi% + \ifekdl@forcenum + \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}% + \unexpanded\expandafter{\ekd@postrefnum}% force the no + \fi }% } % \end{macrocode} % Define keys to be used by the optional arguments of \cs{lem} and % \cs{rdg}:--- % \begin{macrocode} +\newif\ifekdl@forcenum +\newif\ifekdl@nonum \ekvdefinekeys{lem}{ code wit = \def\ekdlr@wit{#1}, code source = \def\ekdlr@source{#1}, @@ -8293,6 +8350,8 @@ Sample text with a \textcolor{red}{word} in red. code postwit = \def\ekdlr@postwit{#1}, store type = \ekdlr@type, store sep = \ekdl@sep, + noval nonum = \ekdl@nonumtrue, + noval num = \ekdl@forcenumtrue, bool nolem = \ifekdl@nolem, bool nosep = \ifekdl@nosep, initial sep = \ekdsep @@ -8358,6 +8417,8 @@ Sample text with a \textcolor{red}{word} in red. \luadirect{ekdosis.dolnlab(\luastringN{#2})}% \null \bgroup% + \ekdl@forcenumfalse + \ekdl@nonumfalse \ekvset{lem}{#1}% \ekd@test@lang \ifekd@mapps% @@ -8379,7 +8440,7 @@ Sample text with a \textcolor{red}{word} in red. \else% \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi% \fi% - \current@ref}%\hskip .25em}% + \unless\ifekdl@nonum\current@ref\fi}%\hskip .25em}% \else% \ifbool{al@rlmode}{% \edef\lem@app{% @@ -8390,7 +8451,7 @@ Sample text with a \textcolor{red}{word} in red. \else% \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi% \fi% - \current@ref%\hskip .25em + \unless\ifekdl@nonum\current@ref\fi%\hskip .25em \ifdefined\ekdlr@alt% \ifdefined\ekdlr@post% \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi @@ -8425,7 +8486,7 @@ Sample text with a \textcolor{red}{word} in red. \else% \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi% \fi% - \current@ref%\hskip .25em + \unless\ifekdl@nonum\current@ref\fi%\hskip .25em \ifdefined\ekdlr@alt% \ifdefined\ekdlr@pre% \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi @@ -8561,6 +8622,7 @@ Sample text with a \textcolor{red}{word} in red. % Define keys to be used by the optional argument of \cs{note} when % this command is found outside \cs{app}:--- % \begin{macrocode} +\newif\ifekdn@forcenum \ekvdefinekeys{note}{ store type = \ekdan@type, store lem = \ekdn@lem, @@ -8569,7 +8631,9 @@ Sample text with a \textcolor{red}{word} in red. store sep = \ekdn@sep, bool nosep = \ifekdn@nosep, initial type = default, - initial sep = \ekdsep + initial sep = \ekdsep, + bool nonum = \ifekdn@nonum, + noval num = \ekdn@forcenumtrue } % \end{macrocode} % \cs{note@noapp} is used internally when a \cs{note} command is found @@ -8615,7 +8679,7 @@ Sample text with a \textcolor{red}{word} in red. \else% \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi% \fi% - \current@ref@arg{\ekdn@labelb}{\ekdn@labele}%\hskip .25em + \unless\ifekdn@nonum\current@ref@arg{\ekdn@labelb}{\ekdn@labele}\fi%\hskip .25em \ifdefined\ekdn@lem% {\textdir TRT\unexpanded\expandafter{\ekd@lemmastyle}% \unexpanded\expandafter{\ekdn@lem}}% @@ -8631,7 +8695,7 @@ Sample text with a \textcolor{red}{word} in red. \else% \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi% \fi% - \current@ref@arg{\ekdn@labelb}{\ekdn@labele}%\hskip .25em + \unless\ifekdn@nonum\current@ref@arg{\ekdn@labelb}{\ekdn@labele}\fi%\hskip .25em \ifdefined\ekdn@lem \ifbool{ekd@lang@pkg}% {{\unexpanded\expandafter{\ekd@lemmastyle}% @@ -11455,6 +11519,7 @@ local lnlabs = {} local lnlab_salt = 0 local current_lnlab = nil local prev_lnlab = nil +local prev_prev_lnlab = nil local notelabs = {} local current_notelab = nil local prev_notelab = nil @@ -11469,6 +11534,7 @@ local function mdvisintable(table, value) end function ekdosis.dolnlab(str) + if prev_lnlab ~= nil then prev_prev_lnlab = prev_lnlab end prev_lnlab = current_lnlab current_lemma = str i = md5.sumhexa(str) @@ -11491,6 +11557,10 @@ function ekdosis.getprevlnlab() return prev_lnlab end +function ekdosis.getprevprevlnlab() + return prev_prev_lnlab +end + function ekdosis.setnotelab(str) current_notelab = str if isfound(notelabs, current_notelab) -- cgit v1.2.3