aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2022-05-09 16:49:52 +0200
committerRobert Alessi <alessi@robertalessi.net>2022-05-09 16:49:52 +0200
commit01d8585248fb7b51e069b5bf70d2afdaaf57ab5d (patch)
tree0a7da1d852228b057e8b3e9e94d7ddea62769f27
parent722dc38d4a161da24e36c43293003f687a81ea3b (diff)
downloadekdosis-01d8585248fb7b51e069b5bf70d2afdaaf57ab5d.tar.gz
new option to set 'maxentries' globally in \SetHooks
-rw-r--r--ekdosis.dtx134
-rw-r--r--ekdosis.el2
2 files changed, 106 insertions, 30 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index 1b794b6..e285197 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -61,7 +61,7 @@ along with this program. If not, see
61%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] 61%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
62%<package>\ProvidesPackage{ekdosis} 62%<package>\ProvidesPackage{ekdosis}
63%<*package> 63%<*package>
64 [2022/05/04 v1.5-dev Typesetting TEI xml-compliant critical editions] 64 [2022/05/09 v1.5-dev Typesetting TEI xml-compliant critical editions]
65%</package> 65%</package>
66%<*driver> 66%<*driver>
67\begin{filecontents}[noheader,overwrite]{bibdata.xml} 67\begin{filecontents}[noheader,overwrite]{bibdata.xml}
@@ -638,7 +638,7 @@ along with this program. If not, see
638\babeltags{ancientgreek = greek} 638\babeltags{ancientgreek = greek}
639\def\sg#1{\textancientgreek{#1}} 639\def\sg#1{\textancientgreek{#1}}
640\usepackage[biblatex=true]{embrac} 640\usepackage[biblatex=true]{embrac}
641\usepackage[nospace,american]{varioref} 641\usepackage[nospace,american,draft]{varioref}
642\usepackage{addlines} 642\usepackage{addlines}
643\newcommand\phts{\phantomsection} 643\newcommand\phts{\phantomsection}
644\usepackage{chifoot} 644\usepackage{chifoot}
@@ -1327,8 +1327,9 @@ along with this program. If not, see
1327% characters is reduced to allow for additional entries. As a 1327% characters is reduced to allow for additional entries. As a
1328% consequence of this rationale, the total number of entries on a 1328% consequence of this rationale, the total number of entries on a
1329% given page must not be too high. It is therefore advisable to use 1329% given page must not be too high. It is therefore advisable to use
1330% |layout=fitapp| conjointly with |maxentries| as described below 1330% |layout=fitapp| conjointly with |maxentries| as described below on
1331% \vpageref{ref:maxentries} and in \vref{sec:oscillating-problem}. % 1331% pages~\pageref{ref:glimit} and~\pageref{ref:maxentries} and in
1332% \vref{sec:oscillating-problem}.
1332% \danger If used appropriately, this mechanism gives excellent 1333% \danger If used appropriately, this mechanism gives excellent
1333% typographical results, notably with complex edition texts of which 1334% typographical results, notably with complex edition texts of which
1334% the entries in the associated apparatus can be quite abundant in 1335% the entries in the associated apparatus can be quite abundant in
@@ -3647,6 +3648,29 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+
3647% An example of the way these hooks may be used is provided below in 3648% An example of the way these hooks may be used is provided below in
3648% \vref{lst:shak-sonnet1}. 3649% \vref{lst:shak-sonnet1}.
3649% 3650%
3651% \medskip\noindent\textbf{Limiting the Number of Entries per Page}
3652% \phts\label{ref:glimit}\\
3653% \DescribeOption{maxentries} |maxentries|=\meta{n} (where
3654% $n \geq 10$) \hfill\tcboxverb{Default: not set}\\
3655% \newfeature[v1.5] This option may be used to set a limit to the
3656% number of entries per page that \emph{all layers of critical notes
3657% taken together} may accept, notably when entries are so abundant in
3658% number that \pkg{ekdosis} may oscillate indefinitely between
3659% different sets of page decisions without being able to settle down.
3660% \danger It is also possible to restrict this option to a given layer
3661% of the apparatus criticus as described below
3662% \vpageref{ref:maxentries}. If |maxentries| be set both globally in
3663% \cs{SetHooks} and in \cs{DeclareApparatus} for specific layers, then
3664% the page will break when \emph{any} of the values defined as
3665% |maxentries| has been reached.
3666%
3667% If |maxentries|$=$\meta{n} be set, then \pkg{ekdosis} will issue
3668% \cs{pagebreak} (namely \cs{penalty}|-10000|) just after the
3669% \emph{n\textsuperscript{th}} entry has been inserted in whichever
3670% layer of the apparatus criticus. As a result, the page will actually
3671% break at the end of the current line. The particulars of this
3672% technique will be discussed below in \vref{sec:oscillating-problem}.
3673%
3650% \medskip 3674% \medskip
3651% \noindent\textbf{Option Specific to the |layout=keyfloat| Global 3675% \noindent\textbf{Option Specific to the |layout=keyfloat| Global
3652% Setting}\footnote{See above \vref{ref:keyfloat-opt}.}\\ 3676% Setting}\footnote{See above \vref{ref:keyfloat-opt}.}\\
@@ -3991,14 +4015,24 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+
3991% may oscillate indefinitely between different sets of page decisions 4015% may oscillate indefinitely between different sets of page decisions
3992% without being able to settle down.\\ 4016% without being able to settle down.\\
3993% \DescribeOption{maxentries} |maxentries|=\meta{n} (where $n \geq 4017% \DescribeOption{maxentries} |maxentries|=\meta{n} (where $n \geq
3994% 10$) \hfill\tcboxverb{Default: not set}\\ 4018% 10$) \hfill\tcboxverb{Default: not set}
4019% \danger It is also possible to set a maximum number of entries for
4020% all layers of critical notes taken together as described above
4021% \vpageref{ref:glimit}. If |maxentries| be set both globally in
4022% \cs{SetHooks} and in \cs{DeclareApparatus} for specific layers, then
4023% the page will break when \emph{any} of the values defined as
4024% |maxentries| has been reached.
4025%
3995% If |maxentries|$=$\meta{n} be set, then \pkg{ekdosis} will issue 4026% If |maxentries|$=$\meta{n} be set, then \pkg{ekdosis} will issue
3996% \cs{pagebreak} (namely \cs{penalty}|-10000|) just after the 4027% \cs{pagebreak} (namely \cs{penalty}|-10000|) just after the
3997% \emph{n\textsuperscript{th}} entry has been inserted in the layer of 4028% \emph{n\textsuperscript{th}} entry has been inserted in the layer of
3998% the apparatus criticus this option is related to. As a result, the 4029% the apparatus criticus this option is related to. As a result, the
3999% page will actually break at the end of the current line. The 4030% page will actually break at the end of the current line. The
4000% particulars of this technique will be discussed below in 4031% particulars of this technique will be discussed below in
4001% \vref{sec:oscillating-problem}. 4032% \vref{sec:oscillating-problem}.\\
4033% \DescribeOption{nomaxentries}\hfill\tcboxverb{Default: not set}\\
4034% |nomaxentries| does not accept any value and is equivalent to
4035% |maxentries=none|.\\
4002% 4036%
4003% \section{Inserting Notes in Multiple-Layer Apparatus} 4037% \section{Inserting Notes in Multiple-Layer Apparatus}
4004% \label{sec:notes-in-multilayer-app} 4038% \label{sec:notes-in-multilayer-app}
@@ -6145,11 +6179,13 @@ subtype="arabtex">'inna 'abI kAna mina
6145% 6179%
6146% \paragraph{Using \texttt{maxentries}} 6180% \paragraph{Using \texttt{maxentries}}
6147% Another way\---should the edition text fall into the vicious circle 6181% Another way\---should the edition text fall into the vicious circle
6148% too often\---is to limit the number of entries per page that a given 6182% too often\---is to limit the number of entries per page that all
6149% layer of apparatus criticus may accept as described above 6183% layers of critical notes taken together or a given layer of
6150% \vpageref{ref:maxentries}. As a result, \pkg{ekdosis} will take care 6184% apparatus criticus may accept as described above on
6151% of inserting automatic breakpoints between pages whenever the number 6185% pages~\pageref{ref:glimit} and~\pageref{ref:maxentries}. As a result,
6152% of entries on a given page reaches the value set as |maxentries|. 6186% \pkg{ekdosis} will take care of inserting automatic breakpoints
6187% between pages whenever the number of entries on a given page reaches
6188% the value set as |maxentries|.
6153% 6189%
6154% |maxentries| must not be too small: otherwise offensive to look at 6190% |maxentries| must not be too small: otherwise offensive to look at
6155% vertical spaces may come between the edition text and the apparatus 6191% vertical spaces may come between the edition text and the apparatus
@@ -8200,7 +8236,7 @@ Sample text with a \textcolor{red}{word} in red.
8200\fi 8236\fi
8201\if@pkg@fitapp 8237\if@pkg@fitapp
8202 \RequirePackage{tcolorbox} 8238 \RequirePackage{tcolorbox}
8203 \tcbuselibrary{fitting,skins} 8239 \tcbuselibrary{fitting,skins} %,breakable}
8204\fi 8240\fi
8205\RequirePackage{refcount} 8241\RequirePackage{refcount}
8206\RequirePackage{zref-user} 8242\RequirePackage{zref-user}
@@ -8226,7 +8262,7 @@ Sample text with a \textcolor{red}{word} in red.
8226% \end{macrocode} 8262% \end{macrocode}
8227% \paragraph{\textsf{ekdosis} Symbol} 8263% \paragraph{\textsf{ekdosis} Symbol}
8228% \begin{macro}{\eKd} 8264% \begin{macro}{\eKd}
8229% \changes{v1.5}{2022/05/04}{Prints \textsf{ekdosis} indentifying 8265% \changes{v1.5}{2022/05/09}{Prints \textsf{ekdosis} indentifying
8230% symbol} As of v1.5, \pkg{ekdosis} has its own identifying 8266% symbol} As of v1.5, \pkg{ekdosis} has its own identifying
8231% symbol. It is produced by \cs{eKd} and best printed with the Old 8267% symbol. It is produced by \cs{eKd} and best printed with the Old
8232% Standard Greek font. 8268% Standard Greek font.
@@ -8272,6 +8308,11 @@ Sample text with a \textcolor{red}{word} in red.
8272 code familysep = \luadirect{ekdosis.setfamilysep(\luastringN{#1})}, 8308 code familysep = \luadirect{ekdosis.setfamilysep(\luastringN{#1})},
8273 store lemmastyle = \ekd@lemmastyle, 8309 store lemmastyle = \ekd@lemmastyle,
8274 store readingstyle = \ekd@readingstyle, 8310 store readingstyle = \ekd@readingstyle,
8311 code initialrule = \def\ekd@initial@rule{#1\NLS},
8312 default initialrule = \rule{0.4\columnwidth}{0.4pt},
8313 noval noinitialrule = \undef\ekd@initial@rule,
8314 code maxentries = \luadirect{ekdosis.setglimit(\luastringN{#1})},
8315 nmeta nomaxentries = {maxentries=none},
8275 code keyparopts = \if@pkg@keyfloat\ekd@keyparopts{#1}\fi, 8316 code keyparopts = \if@pkg@keyfloat\ekd@keyparopts{#1}\fi,
8276 dimen appheight = \ekd@app@height, 8317 dimen appheight = \ekd@app@height,
8277 initial appheight = .5\textheight, 8318 initial appheight = .5\textheight,
@@ -8283,9 +8324,6 @@ Sample text with a \textcolor{red}{word} in red.
8283 unknown-choice fitalgorithm = \PackageError{ekdosis}{unknown 8324 unknown-choice fitalgorithm = \PackageError{ekdosis}{unknown
8284 fitalgorithm=#1}{`fitalgorithm' must be either `fontsize', 8325 fitalgorithm=#1}{`fitalgorithm' must be either `fontsize',
8285 `hybrid', `areasize' or `squeeze'.}, 8326 `hybrid', `areasize' or `squeeze'.},
8286 code initialrule = \def\ekd@initial@rule{#1\NLS},
8287 default initialrule = \rule{0.4\columnwidth}{0.4pt},
8288 noval noinitialrule = \undef\ekd@initial@rule,
8289 initial appfontsize = \footnotesize, 8327 initial appfontsize = \footnotesize,
8290 initial refnumstyle = \bfseries, 8328 initial refnumstyle = \bfseries,
8291 initial postrefnum = ~, 8329 initial postrefnum = ~,
@@ -8487,7 +8525,7 @@ Sample text with a \textcolor{red}{word} in red.
8487% \begin{macro}{\teidirectE} 8525% \begin{macro}{\teidirectE}
8488% \changes{v1.3}{2021/08/18}{direct insertion of elements in the 8526% \changes{v1.3}{2021/08/18}{direct insertion of elements in the
8489% \texttt{TEI xml} file} 8527% \texttt{TEI xml} file}
8490% \changes{v1.5}{2022/05/04}{direct insertion of empty elements in the 8528% \changes{v1.5}{2022/05/09}{direct insertion of empty elements in the
8491% \texttt{TEI xml} file} 8529% \texttt{TEI xml} file}
8492% \cs{teidirect}\oarg{xml attributes}\marg{xml element}\marg{code} 8530% \cs{teidirect}\oarg{xml attributes}\marg{xml element}\marg{code}
8493% does nothing in \LaTeX. It is only used to insert elements in the 8531% does nothing in \LaTeX. It is only used to insert elements in the
@@ -8502,7 +8540,7 @@ Sample text with a \textcolor{red}{word} in red.
8502% \end{macro} 8540% \end{macro}
8503% \end{macro} 8541% \end{macro}
8504% \begin{macro}{\getTEIxmlid} 8542% \begin{macro}{\getTEIxmlid}
8505% \changes{v1.5}{2022/05/04}{returns \texttt{TEI xml:ids} from a 8543% \changes{v1.5}{2022/05/09}{returns \texttt{TEI xml:ids} from a
8506% csv-list of ids} This command returns from a csv-list of unique 8544% csv-list of ids} This command returns from a csv-list of unique
8507% identifiers declared in commands such as \cs{DeclareWitness} and the 8545% identifiers declared in commands such as \cs{DeclareWitness} and the
8508% like a space-separated list of their corresponding |xml:id|s, each 8546% like a space-separated list of their corresponding |xml:id|s, each
@@ -8975,6 +9013,7 @@ Sample text with a \textcolor{red}{word} in red.
8975\if@pkg@fitapp 9013\if@pkg@fitapp
8976 \newtcboxfit{\ekd@fitapp}{% 9014 \newtcboxfit{\ekd@fitapp}{%
8977 blankest, 9015 blankest,
9016 % breakable,
8978 fit basedim = \f@size pt, 9017 fit basedim = \f@size pt,
8979 fit fontsize macros, 9018 fit fontsize macros,
8980 fit height from=0pt to \ekd@app@height, 9019 fit height from=0pt to \ekd@app@height,
@@ -10078,7 +10117,7 @@ Sample text with a \textcolor{red}{word} in red.
10078% \end{macro} 10117% \end{macro}
10079% \paragraph{Lacunae} 10118% \paragraph{Lacunae}
10080% \begin{macro}{\ilabel} 10119% \begin{macro}{\ilabel}
10081% \changes{v1.5}{2022/05/04}{recalls and sets the ending label of 10120% \changes{v1.5}{2022/05/09}{recalls and sets the ending label of
10082% lemmas used to mark lacunae in witnesses} When \cs{lem} has been 10121% lemmas used to mark lacunae in witnesses} When \cs{lem} has been
10083% used with the optional argument |ilabel=<label>|, 10122% used with the optional argument |ilabel=<label>|,
10084% \cs{ilabel}\marg{label} must be used to mark the point where the 10123% \cs{ilabel}\marg{label} must be used to mark the point where the
@@ -10393,7 +10432,7 @@ Sample text with a \textcolor{red}{word} in red.
10393% \end{macrocode} 10432% \end{macrocode}
10394% \end{macro} 10433% \end{macro}
10395% \begin{macro}{\ekdEOprint} 10434% \begin{macro}{\ekdEOprint}
10396% \changes{v1.5}{2022/05/04}{Sets headers and footers on 10435% \changes{v1.5}{2022/05/09}{Sets headers and footers on
10397% \enquote{paired} facing pages} 10436% \enquote{paired} facing pages}
10398% To set headers and footers on \enquote{paired} facing pages, 10437% To set headers and footers on \enquote{paired} facing pages,
10399% \cs{ekdEOprint} accepts two mandatory, self-evident arguments, like 10438% \cs{ekdEOprint} accepts two mandatory, self-evident arguments, like
@@ -10433,7 +10472,7 @@ Sample text with a \textcolor{red}{word} in red.
10433% counter to set the value of the page numbers. This counter should be 10472% counter to set the value of the page numbers. This counter should be
10434% incremented every two pages. 10473% incremented every two pages.
10435% \begin{counter}{pairedpage} 10474% \begin{counter}{pairedpage}
10436% \changes{v1.5}{2022/05/04}{A counter incremented every two pages} 10475% \changes{v1.5}{2022/05/09}{A counter incremented every two pages}
10437% |pairedpage| is first set as a global counter:--- 10476% |pairedpage| is first set as a global counter:---
10438% \begin{macrocode} 10477% \begin{macrocode}
10439\newcounter{pairedpage} 10478\newcounter{pairedpage}
@@ -10441,19 +10480,19 @@ Sample text with a \textcolor{red}{word} in red.
10441% \end{macrocode} 10480% \end{macrocode}
10442% \end{counter} 10481% \end{counter}
10443% \begin{macro}{\setpairedpagenum} 10482% \begin{macro}{\setpairedpagenum}
10444% \changes{v1.5}{2022/05/04}{sets the same page number on paired 10483% \changes{v1.5}{2022/05/09}{sets the same page number on paired
10445% pages} \cs{setpairedpagenum}\marg{number} is used just ahead of 10484% pages} \cs{setpairedpagenum}\marg{number} is used just ahead of
10446% the alignment environment to set the number of the first left-hand 10485% the alignment environment to set the number of the first left-hand
10447% paired page. 10486% paired page.
10448% \begin{macro}{\setpairedpage} 10487% \begin{macro}{\setpairedpage}
10449% \changes{v1.5}{2022/05/04}{sets the page number of the first paired 10488% \changes{v1.5}{2022/05/09}{sets the page number of the first paired
10450% page} \cs{setpairedpage} is an argument-less command meant to be 10489% page} \cs{setpairedpage} is an argument-less command meant to be
10451% issued in commands used to set headers or footers before 10490% issued in commands used to set headers or footers before
10452% \cs{thepage}. This command has the counter |pairedpage| 10491% \cs{thepage}. This command has the counter |pairedpage|
10453% incremented on right-hand pages only, and sets |page| $\leftarrow$ 10492% incremented on right-hand pages only, and sets |page| $\leftarrow$
10454% |pairedpage| on every page. 10493% |pairedpage| on every page.
10455% \begin{macro}{\resetpagenumber} 10494% \begin{macro}{\resetpagenumber}
10456% \changes{v1.5}{2022/05/04}{resets normal running page numbers} 10495% \changes{v1.5}{2022/05/09}{resets normal running page numbers}
10457% \cs{resetpagenumber} must be used right out of \enquote{mirrored} 10496% \cs{resetpagenumber} must be used right out of \enquote{mirrored}
10458% paired pages alignment environments. This argument-less command 10497% paired pages alignment environments. This argument-less command
10459% corrects any numbering error on the page following the edition 10498% corrects any numbering error on the page following the edition
@@ -12785,6 +12824,8 @@ end
12785-- 12824--
12786local apparatuses = {} 12825local apparatuses = {}
12787local bagunits = {} 12826local bagunits = {}
12827local glimit = nil
12828local gunits = 0
12788 12829
12789function ekdosis.newapparatus(teitype, 12830function ekdosis.newapparatus(teitype,
12790 appdir, 12831 appdir,
@@ -12877,28 +12918,61 @@ end
12877 12918
12878function ekdosis.limit_bagunits(teitype) 12919function ekdosis.limit_bagunits(teitype)
12879 local limit = tonumber(getapplimit(teitype)) 12920 local limit = tonumber(getapplimit(teitype))
12880 if limit >= 10 and bagunits[teitype] >= limit 12921 if glimit then
12881 then 12922 glimit = tonumber(glimit)
12882 bagunits[teitype] = 2 12923 gunits = tonumber(gunits)
12883 return "\\pagebreak" 12924 if glimit >= 10 and gunits >= glimit
12925 then
12926 bagunits[teitype] = 2
12927 gunits = 0
12928 return "\\pagebreak"
12929 else
12930 if limit >= 10 and bagunits[teitype] >= limit
12931 then
12932 bagunits[teitype] = 2
12933 gunits = 0
12934 return "\\pagebreak"
12935 else
12936 return ""
12937 end
12938 end
12884 else 12939 else
12885 return "" 12940 if limit >= 10 and bagunits[teitype] >= limit
12941 then
12942 bagunits[teitype] = 2
12943 gunits = 1
12944 return "\\pagebreak"
12945 else
12946 return ""
12947 end
12886 end 12948 end
12887end 12949end
12888 12950
12889function ekdosis.addto_bagunits(teitype, n) 12951function ekdosis.addto_bagunits(teitype, n)
12952 n = tonumber(n)
12953 if glimit then gunits = gunits - n end
12890 if tonumber(getapplimit(teitype)) ~= 0 12954 if tonumber(getapplimit(teitype)) ~= 0
12891 then 12955 then
12892 n = tonumber(n)
12893 bagunits[teitype] = bagunits[teitype] - n 12956 bagunits[teitype] = bagunits[teitype] - n
12894 end 12957 end
12895end 12958end
12896 12959
12897function ekdosis.increment_bagunits(teitype) 12960function ekdosis.increment_bagunits(teitype)
12961 if glimit then gunits = gunits + 1 end
12898 bagunits[teitype] = (bagunits[teitype] or 0) + 1 12962 bagunits[teitype] = (bagunits[teitype] or 0) + 1
12899end 12963end
12900 12964
12965function ekdosis.setglimit(n)
12966 if math.tointeger(n)
12967 then
12968 glimit = math.tointeger(math.abs(n))
12969 else
12970 glimit = nil
12971 end
12972end
12973
12901local function reset_bagunits() 12974local function reset_bagunits()
12975 if glimit then gunits = 0 end
12902 for i = 1,#apparatuses 12976 for i = 1,#apparatuses
12903 do 12977 do
12904 bagunits[apparatuses[i].a] = 1 12978 bagunits[apparatuses[i].a] = 1
diff --git a/ekdosis.el b/ekdosis.el
index 95af33e..322d552 100644
--- a/ekdosis.el
+++ b/ekdosis.el
@@ -157,6 +157,8 @@
157 ("familysep") 157 ("familysep")
158 ("initialrule") 158 ("initialrule")
159 ("noinitialrule") 159 ("noinitialrule")
160 ("maxentries")
161 ("nomaxentries")
160 ("keyparopts") 162 ("keyparopts")
161 ("appheight") 163 ("appheight")
162 ("fitalgorithm" ("fontsize" "hybrid" "areasize" "squeeze"))) 164 ("fitalgorithm" ("fontsize" "hybrid" "areasize" "squeeze")))