texlive[60271] Master/texmf-dist: ekdosis (18aug21)

commits+karl at tug.org commits+karl at tug.org
Wed Aug 18 22:47:26 CEST 2021


Revision: 60271
          http://tug.org/svn/texlive?view=revision&revision=60271
Author:   karl
Date:     2021-08-18 22:47:26 +0200 (Wed, 18 Aug 2021)
Log Message:
-----------
ekdosis (18aug21)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/lualatex/ekdosis/README.md
    trunk/Master/texmf-dist/doc/lualatex/ekdosis/ekdosis.el
    trunk/Master/texmf-dist/doc/lualatex/ekdosis/ekdosis.pdf
    trunk/Master/texmf-dist/doc/lualatex/ekdosis/samples/Caesar_BG-6-13-1.pdf
    trunk/Master/texmf-dist/doc/lualatex/ekdosis/samples/Caesar_BG-6-13-1.tex
    trunk/Master/texmf-dist/source/lualatex/ekdosis/Makefile
    trunk/Master/texmf-dist/source/lualatex/ekdosis/ekdosis.dtx
    trunk/Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.lua
    trunk/Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.sty

Modified: trunk/Master/texmf-dist/doc/lualatex/ekdosis/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/ekdosis/README.md	2021-08-18 20:47:09 UTC (rev 60270)
+++ trunk/Master/texmf-dist/doc/lualatex/ekdosis/README.md	2021-08-18 20:47:26 UTC (rev 60271)
@@ -62,7 +62,7 @@
 
 License Applicable to the Documentation
 ---------------------------------------
-Copyright ⓒ 2020 Robert Alessi
+Copyright ⓒ 2020--2021 Robert Alessi
 
 The documentation file `ekdosis.pdf` that is generated from the
 `ekdosis.dtx` source file is licensed under the GNU Free Documentation

Modified: trunk/Master/texmf-dist/doc/lualatex/ekdosis/ekdosis.el
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/ekdosis/ekdosis.el	2021-08-18 20:47:09 UTC (rev 60270)
+++ trunk/Master/texmf-dist/doc/lualatex/ekdosis/ekdosis.el	2021-08-18 20:47:26 UTC (rev 60271)
@@ -24,7 +24,11 @@
 (defvar LaTeX-ekdosis-preamble-options
   '(("parnotes" ("true" "false" "roman"))
     ("teiexport" ("true" "false" "tidy"))
-    ("layout" ("float" "footins")))
+    ("layout" ("float" "footins" "keyfloat" "fitapp"))
+    ("divs" ("ekdosis" "latex"))
+    ("poetry" ("verse"))
+    ("parnotes" ("true" "false" "roman"))
+    ("teiexport" ("true" "false" "tidy")))
   "Package options for the ekdosis package.")
 
 (defun LaTeX-ekdosis-package-options ()
@@ -42,14 +46,35 @@
      (TeX-read-key-val optional arg)
      optional)))
 
+(defvar LaTeX-ekdosis-ekdsetup-options
+  '(("showpagebreaks" ("true" "false"))
+    ("spbmk")
+    ("hpbmk"))
+  "List of local options for ekdsetup macro.")
+
 (defvar LaTeX-ekdosis-declarewitness-options
   '(("settlement")
+    ("institution")
     ("repository")
+    ("collection")
+    ("idno")
     ("msName")
     ("origDate")
-    ("idno"))
+    ("locus"))
   "List of local options for DeclareWitness macro.")
 
+(defvar LaTeX-ekdosis-declarehand-options
+  '(("note"))
+  "List of local options for DeclareHand macro.")
+
+(defvar LaTeX-ekdosis-declarescholar-options
+  '(("rawname")
+    ("forename")
+    ("surname")
+    ("addname")
+    ("note"))
+  "List of local options for DeclareScholar macro.")
+
 (defvar LaTeX-ekdosis-app-options
   '(("type"))
   "Local option for app|note macro.")
@@ -56,6 +81,8 @@
 
 (defvar LaTeX-ekdosis-lem-options
   '(("wit")
+    ("source")
+    ("resp")
     ("alt")
     ("pre")
     ("post")
@@ -62,6 +89,9 @@
     ("prewit")
     ("postwit")
     ("sep")
+    ("type")
+    ("num")
+    ("nonum")
     ("nolem" ("true" "false"))
     ("nosep" ("true" "false")))
   "Local options for lem macro")
@@ -68,11 +98,14 @@
 
 (defvar LaTeX-ekdosis-rdg-options
   '(("wit")
+    ("source")
+    ("resp")
     ("alt")
     ("pre")
     ("post")
     ("prewit")
     ("postwit")
+    ("type")
     ("nordg" ("true" "false")))
   "Local options for rdg macro.")
 
@@ -82,6 +115,9 @@
     ("labelb")
     ("labele")
     ("sep")
+    ("nosep")
+    ("num")
+    ("nonum")
     ("pre")
     ("post"))
   "Local options for note macro.")
@@ -91,6 +127,93 @@
     ("post"))
   "Local options for note* macro.")
 
+(defvar LaTeX-ekdosis-rdggrp-options
+  '(("type"))
+  "Local options for rdgGrp macro.")
+
+(defvar LaTeX-ekdosis-setcritsymbols-options
+  '(("suppbegin")
+    ("suppend")
+    ("delbegin")
+    ("delend")
+    ("sicbegin")
+    ("sicend")
+    ("gapmark"))
+  "List of local options for setcritsymbols macro.")
+
+(defvar LaTeX-ekdosis-sethooks-options
+  '(("appfontsize")
+    ("refnumstyle")
+    ("postrefnum")
+    ("lemmastyle")
+    ("readingstyle")
+    ("initialrule")
+    ("noinitialrule")
+    ("keyparopts")
+    ("appheight")
+    ("fitalgorithm" ("fontsize" "hybrid" "areasize" "squeeze")))
+  "List of local options for sethooks macro.")
+
+(defvar LaTeX-ekdosis-gap-options
+  '(("reason")
+    ("unit")
+    ("quantity")
+    ("extent"))
+  "List of local options for gap macro.")
+
+(defvar LaTeX-ekdosis-setapparatus-options
+  '(("direction" ("LR" "RL"))
+    ("sep")
+    ("delim")
+    ("bhook")
+    ("ehook")
+    ("rule")
+    ("norule")
+    ("lang")
+    ("notelang"))
+  "List of local options for setapparatus macro.")
+
+(defvar LaTeX-ekdosis-declareapparatus-options
+  '(("direction" ("LR" "RL"))
+    ("sep")
+    ("delim")
+    ("bhook")
+    ("ehook")
+    ("rule")
+    ("norule")
+    ("lang")
+    ("notelang")
+    ("maxentries"))
+  "List of local options for declareapparatus macro.")
+
+(defvar LaTeX-ekdosis-setlineation-options
+  '(("lineation" ("page" "document" "none"))
+    ("sep")
+    ("modulo")
+    ("modulonum")
+    ("margin" ("right" "left" "inner" "outer"))
+    ("numbers" ("elided" "full"))
+    ("vlineation" ("page" "document"))
+    ("vmodulo")
+    ("vmargin" ("right" "left"))
+    ("continuousvnum"))
+  "List of local options for setlineation macro.")
+
+(defvar LaTeX-ekdosis-ekddiv-options
+  '(("type")
+    ("n")
+    ("head")
+    ("barehead")
+    ("depth" ("1" "2" "3" "4" "5" "6" "7" "8" "9"))
+    ("toc" ("book" "part" "chapter" "section" "subsection"
+	    "subsubsection" "paragraph" "subparagraph"))
+    ("mark"))
+  "List of local options for ekddiv macro.")
+
+(defvar LaTeX-ekdosis-setteixmlexport-options
+  '(("autopar" ("true" "false")))
+  "List of local options for SetTEIxmlExport macro.")
+
 (defvar LaTeX-ekdosis-alignment-key-val-options
   '(("tcols")
     ("lcols")
@@ -98,9 +221,18 @@
     ("apparatus")
     ("flush" ("true" "false"))
     ("paired" ("true" "false"))
-    ("pagelineation" ("true" "false")))
+    ("lineation" ("page" "document")))
   "Local options for alignment env.")
 
+(defvar LaTeX-ekdosis-ekdverse-key-val-options
+  '(("width")
+    ("type"))
+  "Local options for ekdverse env.")
+
+(defvar LaTeX-ekdosis-ekdstanza-key-val-options
+  '(("type"))
+  "Local options for ekdstanza env.")
+
 (TeX-add-style-hook
  "ekdosis"
  (lambda ()
@@ -120,12 +252,53 @@
    (add-to-list (make-local-variable 'LaTeX-fold-macro-spec-list)
    		'("[l]" ("linelabel"))
    		t)
+   (add-to-list (make-local-variable 'LaTeX-fold-macro-spec-list)
+   		'("{{1}}" ("surplus"))
+   		t)
+   (add-to-list (make-local-variable 'LaTeX-fold-macro-spec-list)
+   		'("<{1}>" ("supplied"))
+   		t)
+   (add-to-list (make-local-variable 'LaTeX-fold-macro-spec-list)
+   		'("{1}" ("sic"))
+   		t)
+   (add-to-list (make-local-variable 'LaTeX-fold-macro-spec-list)
+   		'("[g]" ("gap"))
+   		t)
+   (add-to-list (make-local-variable 'LaTeX-fold-macro-spec-list)
+   		'("{1}" ("mbox"))
+   		t)
+   (add-to-list (make-local-variable 'LaTeX-fold-macro-spec-list)
+   		'("{1}" ("rdgGrp"))
+   		t)
+   (add-to-list (make-local-variable 'LaTeX-fold-macro-spec-list)
+   		'("[pb]" ("ekdpb"))
+   		t)
+   (add-to-list (make-local-variable 'LaTeX-fold-macro-spec-list)
+   		'("[t]" ("teidirect"))
+   		t)
    ;; This package relies on lualatex, so check for it:
    (TeX-check-engine-add-engines 'luatex)
    (TeX-add-symbols
+    '("ekdsetup" (TeX-arg-key-val LaTeX-ekdosis-ekdsetup-options))
     '("DeclareWitness" "xml:id" "rendition" "description"
       [ LaTeX-ekdosis-long-key-val LaTeX-ekdosis-declarewitness-options ]
       0)
+    '("DeclareHand" "xml:id" "base ms." "rendition"
+      [ LaTeX-ekdosis-long-key-val LaTeX-ekdosis-declarehand-options ]
+      0)
+    '("DeclareSource" "xml:id" "rendition"
+      0)
+    '("DeclareScholar" "xml:id" "rendition"
+      [ LaTeX-ekdosis-long-key-val LaTeX-ekdosis-declarescholar-options ]
+      0)
+    '("DeclareShorthand" "xml:id" "rendition" "csv-list of ids"
+      0)
+    '("getsiglum" "csv-list"
+      0)
+    '("SigLine" "unique id"
+      0)
+    '("linelabel" "label"
+      0)
     '("app" [ TeX-arg-key-val LaTeX-ekdosis-app-options ]
       t)
     '("lem" [ LaTeX-ekdosis-long-key-val LaTeX-ekdosis-lem-options ]
@@ -136,14 +309,90 @@
       t)
     '("note*" [ LaTeX-ekdosis-long-key-val LaTeX-ekdosis-note-star-options ]
       t)
-    '("SetEkdosisAlignment"
+    '("rdgGrp" [ TeX-arg-key-val LaTeX-ekdosis-rdggrp-options ]
+      t)
+    '("SetCritSymbols" (TeX-arg-key-val LaTeX-ekdosis-setcritsymbols-options))
+    '("supplied" "supplied text" 0)
+    '("surplus" "surplus text" 0)
+    '("gap" (TeX-arg-key-val LaTeX-ekdosis-gap-options))
+    '("sic" "sic text" 0)
+    '("SetAlignment"
       (TeX-arg-key-val LaTeX-ekdosis-alignment-key-val-options))
+    '("columnratio" "fraction(s)" [ "fraction(s)" ] )
+    '("setcolumnwidth" "width/gap" [ "width/gap" ] )
+    '("marginparthreshold" "number of columns" [ "number of columns" ] )
+    '("footnotelayout"
+      (TeX-arg-eval completing-read
+                    (TeX-argument-prompt nil nil "Layout")
+                    '("c" "m" "p")))
+    '("SetHooks" (TeX-arg-key-val LaTeX-ekdosis-sethooks-options))
+    '("SetLTRapp" 0)
+    '("SetRTLapp" 0)
+    '("SetSeparator" "separator" 0)
+    '("SetBeginApparatus" "chars|commands" 0)
+    '("SetEndApparatus" "chars" 0)
+    '("SetUnitDelimiter" "delimiter" 0)
+    '("SetDefaultRule" "command" 0)
+    '("SetApparatusLanguage" "lang name" 0)
+    '("SetApparatusNoteLanguage" "lang name" 0)
+    '("SetApparatus" (TeX-arg-key-val LaTeX-ekdosis-setapparatus-options))
+    '("footnoteruletrue" 0)
+    '("footnoterulefalse" 0)
+    '("SetDefaultApparatus" "apparatus name" 0)
+    '("DeclareApparatus" "apparatus name"
+      [ TeX-arg-key-val LaTeX-ekdosis-declareapparatus-options ] 0)
+    '("indentpattern" "pattern" 0)
+    '("vin" 0)
+    '("SetLineation" (TeX-arg-key-val LaTeX-ekdosis-setlineation-options))
+    '("innerlinenumbers" 0)
+    '("outerlinenumbers" 0)
+    '("modulolinenumbers" [ "number" ] )
+    '("resetlinenumber" [ "number" ] )
+    '("resetvlinenumber" [ "number" ] )
+    '("verselinenumfont" "commands" 0)
+    '("SetLR" 0)
+    '("SetRL" 0)
+    '("MkBodyDivs" "div1" "div2" "div3" "div4" "div5" "div6" 0)
+    '("ekddiv" (LaTeX-ekdosis-long-key-val LaTeX-ekdosis-ekddiv-options))
+    '("FormatDiv" "number" "code before" "code after" 0)
+    '("ekdmark" 0)
+    '("endmark" 0)
+    '("ekdprintmark"
+      (TeX-arg-eval completing-read
+                    (TeX-argument-prompt nil nil "selector")
+                    '("HEL" "HEC" "HER" "HOL" "HOC" "HOR"
+		      "FEL" "FEC" "FER" "FOL" "FOC" "FOR"))
+      "signpost" 0 )
+    '("ekdnohfmark" 0)
+    '("ekdresethfmarks" 0)
+    '("ekdpb" [ "page number" ] "line number" 0)
+    '("ekdpb*")
+    '("addentries" [ "layer" ] "number" 0)
+    '("SetTEIFilename" "base name" 0)
+    '("SetTEIxmlExport" (TeX-arg-key-val
+			 LaTeX-ekdosis-setteixmlexport-options))
+    '("TeXtoTEI" "csname" "TEI element" [ "TEI attributes" ] 0)
+    '("EnvtoTEI" "env name" "TEI element" [ "TEI attributes" ] 0)
+    '("EnvtoTEI*" "env name" "TEI element" [ "TEI attributes" ] 0)
+    '("TeXtoTEIPat" "TeX pattern" "TEI pattern" 0)
+    '("teidirect" [ "xml attributes" ] "xml element" "code" 0)
+    '("AddxmlBibResource" "basename or name.xml" 0)
     )
  (LaTeX-add-environments
   "ekdosis"
+  "edition"
+  "translation"
+  "edition*"
+  "translation*"
+  "patverse"
+  "ekdpar"
   '("alignment" LaTeX-env-args
-    [ TeX-arg-key-val LaTeX-ekdosis-alignment-key-val-options ]
-    ))
+    [ TeX-arg-key-val LaTeX-ekdosis-alignment-key-val-options ] )
+  '("ekdverse" LaTeX-env-args
+    [ TeX-arg-key-val LaTeX-ekdosis-ekdverse-key-val-options ] )
+  '("ekdstanza" LaTeX-env-args
+    [ TeX-arg-key-val LaTeX-ekdosis-ekdstanza-key-val-options ] )
+  )
  )
  LaTeX-dialect)
 

Modified: trunk/Master/texmf-dist/doc/lualatex/ekdosis/ekdosis.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/lualatex/ekdosis/samples/Caesar_BG-6-13-1.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/lualatex/ekdosis/samples/Caesar_BG-6-13-1.tex
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/ekdosis/samples/Caesar_BG-6-13-1.tex	2021-08-18 20:47:09 UTC (rev 60270)
+++ trunk/Master/texmf-dist/doc/lualatex/ekdosis/samples/Caesar_BG-6-13-1.tex	2021-08-18 20:47:26 UTC (rev 60271)
@@ -2,8 +2,8 @@
 \usepackage{fontspec}
 \usepackage[latin.classic,french,english]{babel}
 \babelfont{rm}{Old Standard}
-\babelfont{sf}{NewComputerModern Sans}
-\babelfont{tt}{NewComputerModern Mono}
+\babelfont{sf}{NewComputerModernSans10}
+\babelfont{tt}{NewComputerModernMono10}
 
 \usepackage{nextpage}
 \usepackage{xltabular}

Modified: trunk/Master/texmf-dist/source/lualatex/ekdosis/Makefile
===================================================================
--- trunk/Master/texmf-dist/source/lualatex/ekdosis/Makefile	2021-08-18 20:47:09 UTC (rev 60270)
+++ trunk/Master/texmf-dist/source/lualatex/ekdosis/Makefile	2021-08-18 20:47:26 UTC (rev 60271)
@@ -57,6 +57,8 @@
 	rm -rf *
 	cp -p -r .backup/* .
 	rm -rf .backup
+
+pandoc:
 	pandoc -s README.md -o about.html
 
 auctex:
@@ -86,7 +88,19 @@
 	mkdir -p $(UTREE)/{tex,source,doc}/lualatex/$(NAME)
 	cp $(NAME).sty $(UTREE)/tex/lualatex/$(NAME)
 	cp $(NAME).lua $(UTREE)/tex/lualatex/$(NAME)
+	if [ -e "$(NAME).pdf" ]; then cp $(NAME).pdf $(UTREE)/doc/lualatex/$(NAME) &&\
+	cp -r $(SAMPLES)/ $(UTREE)/doc/lualatex/$(NAME); fi
 
+install: all
+	sudo mkdir -p $(LOCAL)/{tex,source,doc}/latex/$(NAME)
+	sudo cp $(NAME).dtx $(LOCAL)/source/latex/$(NAME)
+	sudo cp $(NAME).sty $(LOCAL)/tex/latex/$(NAME)
+	sudo cp $(NAME).pdf $(LOCAL)/doc/latex/$(NAME)
+	cp -r $(SAMPLES)/ $(LOCAL)/doc/latex/$(NAME)
+
+uninstall:
+	rm -rf $(LOCAL)/{tex,source,doc}/latex/$(NAME)
+
 zip: all
 	ln -sf . $(NAME)
 	zip -Drq $(PWD)/$(NAME)-$(VERS).zip $(NAME)/{samples,README.md,$(NAME).{pdf,sty,lua,el}}
@@ -109,4 +123,4 @@
 	rm -rf $(NAME)/
 
 .SILENT: testsamples
-.PHONY: all clean distclean inst local uninst install uninstall zip package samples testsamples
+.PHONY: all clean distclean pandoc inst local uninst install uninstall zip package samples testsamples

Modified: trunk/Master/texmf-dist/source/lualatex/ekdosis/ekdosis.dtx
===================================================================
--- trunk/Master/texmf-dist/source/lualatex/ekdosis/ekdosis.dtx	2021-08-18 20:47:09 UTC (rev 60270)
+++ trunk/Master/texmf-dist/source/lualatex/ekdosis/ekdosis.dtx	2021-08-18 20:47:26 UTC (rev 60271)
@@ -61,7 +61,7 @@
 %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
 %<package>\ProvidesPackage{ekdosis}
 %<*package>
-    [2021/04/02 v1.2 Typesetting TEI xml-compliant critical editions]
+    [2021/08/18 v1.3 Typesetting TEI xml-compliant critical editions]
 %</package>
 %<*driver>
 \begin{filecontents}[noheader,overwrite]{bibdata.xml}
@@ -166,7 +166,7 @@
     <monogr>
       <title level="m">Works of W. Shakespeare</title>
       <editor>
-        <forename>H.N.</forename>
+        <forename>H. N.</forename>
         <surname>Hudson</surname>
       </editor>
       <imprint>
@@ -180,7 +180,7 @@
     <monogr>
       <title level="m">Shakespeare's Complete Sonnets</title>
       <editor>
-        <forename>C.M.</forename>
+        <forename>C. M.</forename>
         <surname>Walsh</surname>
       </editor>
       <imprint>
@@ -246,7 +246,7 @@
   author =	 {{Homer}},
   title =	 {The Odyssey},
   date =	 1919,
-  editor =	 {Murray, A.T\adddot},
+  editor =	 {Murray, A. T.},
   volumes =	 2,
   publisher =	 {Harvard University Press -- William Heinemann},
   location =	 {Cambridge, MA. -- London}
@@ -266,7 +266,7 @@
 }
 
 @Book{ReynoldsWilson1991,
-  author =	 {Reynolds, L. D. and Wilson, N. G},
+  author =	 {Reynolds, L. D. and Wilson, N. G.},
   title =	 {Scribes and Scholars},
   year =	 {1991},
   subtitle =	 {A Guide to the Translation of Greek and Latin
@@ -311,6 +311,15 @@
   url =		 {http://www.teibyexample.org}
 }
 
+ at Software{babel,
+  title =	 {The Babel package},
+  titleaddon =	 {Multilingual support for Plain TeX or LaTeX},
+  author =	 {Bezos López, Javier and Braams, Johannes L.},
+  url =		 {http://www.ctan.org/pkg/babel},
+  date =	 {2020-07-13},
+  version =	 {3.47}
+}
+
 @Software{extdash,
   title =	 {The Extdash package},
   titleaddon =	 {A range of dash commands for compound words},
@@ -329,6 +338,16 @@
   version =	 {1.0}
 }
 
+ at Software{keyfloat,
+  title =	 {The Keyfloat package},
+  subtitle =	 {Provides a key/value interface for generating
+                  floats},
+  author =	 {Dunn, Brian},
+  url =		 {https://ctan.org/pkg/keyfloat},
+  date =	 {2021-06-29},
+  version =	 {2.06},
+}
+
 @Software{lineno,
   title =	 {The Lineno package},
   titleaddon =	 {Line numbers on paragraphs},
@@ -365,15 +384,25 @@
   version =	 {1.49}
 }
 
- at Software{babel,
-  title =	 {The Babel package},
-  titleaddon =	 {Multilingual support for Plain TeX or LaTeX},
-  author =	 {Bezos López, Javier and Braams, Johannes L.},
-  url =		 {http://www.ctan.org/pkg/babel},
-  date =	 {2020-07-13},
-  version =	 {3.47}
+ at Software{tcolorbox,
+  title =	 {The Tcolorbox package},
+  subtitle =	 {Coloured boxes, for LaTeX examples and theorems,
+                  etc},
+  author =	 {Sturm, Thomas F.},
+  url =		 {https://ctan.org/pkg/tcolorbox},
+  date =	 {2021-06-14},
+  version =	 {4.51},
 }
 
+ at Software{titleps,
+  title =	 {The Titleps package},
+  titleaddon =	 {Page style control},
+  author =	 {Bezos López, Javier},
+  url =		 {https://ctan.org/pkg/titleps},
+  date =	 {2019-10-16},
+  version =	 {2.13}
+}
+
 @Software{verse,
   title =	 {The Verse package},
   titleaddon =	 {Aids for typesetting simple verse},
@@ -413,6 +442,7 @@
 \end{filecontents}
 \begin{filecontents}[overwrite]{\jobname-ekd.cfg}
 \footnotelayout{m}
+\SetCritSymbols{suppbegin = 〈,suppend = 〉}
 \EnvtoTEI{ancientgreek}{p}[xml:lang="grc"]
 \DeclareApparatus{fontium}[
         delim=\hskip0.75em,
@@ -423,7 +453,6 @@
         delim=\hskip0.75em]
 \DeclareApparatus{rtl}[
         direction=RL,
-        sep={[ },
         delim=\hskip0.75em]
 \DeclareWitness{M}{M}{\emph{Marcianus Gr.} 269}[
         settlement=Venice,
@@ -475,6 +504,11 @@
 \DeclareHand{hIpc}{hI}{I\textsuperscript{pc}}[Lectio post correctionem]
 \DeclareWitness{hR}{R}{\emph{Vaticanus Gr.} 277}
 \DeclareWitness{hH}{H}{\emph{Parisinus Gr.} 2142}
+\DeclareWitness{hGalE1.Q}{Gal.E1(Q)}{\emph{Parisinus Gr.}
+  2174}[origDate=s. XIV]
+\DeclareWitness{hGalE1.M}{Gal.E1(M)}{\emph{Monacencis Gr.}
+  231}[origDate=s. XVI]
+  \DeclareShorthand{hGalE1.M.Q}{Gal.E1(MQ)}{hGalE1.M,hGalE1.Q}
 \DeclareSource{Lit}{Littré}
 \DeclareSource{Erm}{Ermerins}
 \DeclareSource{Sm}{Smith}
@@ -524,17 +558,18 @@
 \defaultfontfeatures{Renderer=Harfbuzz}
 \usepackage[latin.classic,greek.ancient,american]{babel}
 \babelfont{rm}{Old Standard}
-\babelfont{sf}{NewComputerModern Sans}
-\babelfont{tt}{NewComputerModern Mono}
+\babelfont{sf}{NewComputerModernSans10}
+\babelfont{tt}{NewComputerModernMono10}
 \babelfont[greek]{rm}[
       Script=Greek,
       RawFeature={+ss05;+ss06}
       ]{Old Standard}
-\babelfont[greek]{sf}[Script=Greek]{NewComputerModern Sans}
-\babelfont[greek]{tt}[Script=Greek]{NewComputerModern Mono}
+\babelfont[greek]{sf}[Script=Greek]{NewComputerModernSans10}
+\babelfont[greek]{tt}[Script=Greek]{NewComputerModernMono10}
 \newfontfamily{\junicode}{Junicode}[
                 Ligatures=TeX,
                 RawFeature={+hist}]
+\newfontfamily\missaali{Missaali Regular}
 \babeltags{ancientgreek = greek}
 \def\sg#1{\textancientgreek{#1}}
 \usepackage[Old Standard]{mathfont}
@@ -564,6 +599,8 @@
 \usepackage{manfnt}
 \usepackage{lettrine}
 \newcommand\danger{\lettrine[loversize=-.5]{\textdbend}{\hskip6pt}}
+\newcommand\mansee{\lettrine[loversize=-.4,
+                             lraise=.55]{\mantriangleright}{\hskip6pt}}
 \usepackage{metalogox}
 \usepackage{hologo}
 \usepackage{xcolor}
@@ -575,9 +612,9 @@
   \colorlet{cinnamon}{black}}{}
 \definecolor{gainsboro}{RGB}{222,222,222}
 \PassOptionsToPackage{bookmarks=true}{hyperref}
-\usepackage{xurl}
+\usepackage[obeyspaces]{url}
 \usepackage[numbered]{hypdoc}
-\usepackage[loadlang=en]{metastr}
+\usepackage[titlematter,loadlang=en|de|fr|es]{metastr}
 \hypersetup{
   colorlinks,
   allcolors=cinnamon,
@@ -593,7 +630,11 @@
 \bibinput{ekdosis}
 \usepackage[nospace,american]{varioref}
 \newcommand\phts{\phantomsection}
+\usepackage{nameref}
+\newcommand\vnref[1]{\vref{#1}, \enquote{\nameref{#1}}}
 \usepackage[style=oxnotes-inote,dashed]{biblatex}
+\DefineBibliographyStrings{english}{
+  seenote={cf\adddotspace n\adddotspace}}
 \DeclareSourcemap{
     \maps[datatype=bibtex]{
       \map{
@@ -602,6 +643,27 @@
     }
   }
 }
+% include seenote in parentheses
+\renewbibmacro*{footcite:note}{%
+  \ifnameundef{labelname}
+    {\printfield{label}}
+    {\printnames{labelname}}%
+  \ifsingletitle
+    {}
+    {\setunit*{\printdelim{nametitledelim}}%
+     \printfield[title]{labeltitle}}%
+  \setunit*{\addspace}%
+  \printtext{%
+    \mkbibparens{%
+    \bibstring{seenote}\addnbspace
+    \ref{cbx@\csuse{cbx at f@\thefield{entrykey}}}%
+    \iftoggle{cbx:pageref}
+      {\ifsamepage{\the\value{instcount}}
+                  {\csuse{cbx at f@\thefield{entrykey}}}
+         {}
+         {\addcomma\space\bibstring{page}\addnbspace
+          \pageref{cbx@\csuse{cbx at f@\thefield{entrykey}}}}}
+      {}}}}
 \ifbool{nocolordoc}
 {
   \usepackage{academicons}
@@ -662,6 +724,14 @@
 \metaset{contacturl}{http://www.roberalessi.net}
 \metaset{partof}{The ekdosis Package}
 \metaset[print]{partof}{The \textsf{ekdosis} Package}
+\metaset[altlang]{rightstext}{en,de,fr,es}
+\metaset[fr]{partofmessage}{%
+  Ce document fait partie de l'œuvre: \metapick[#1]{partof}.}
+\metaset[es]{partofmessage}{%
+  Este documento forma parte de la obra: \metapick[#1]{partof}.}
+\metaset[es]{licenseurlmessage}{%
+  Para ver una copia de esta licencia, siga el vínculo:
+  \metapick[#1]{licenseurl}.}
 \metaset{copyrightowner}{\metapick[#1]{author}}
 \metaset{copyrightdate}{2020--2021}
 \metaset{licensemessage}{Permission is granted to copy, distribute
@@ -674,7 +744,6 @@
 \metaset{licenseurl}{https://www.gnu.org/licenses/fdl-1.3.html}
 \metaset[print]{licenseurl}{%
   \url{https://www.gnu.org/licenses/fdl-1.3.html}}
-\metaset[cmd]{licenselogo}{\includegraphics[scale=0.75]{#1}}
 \metawritepdfinfo
 \metawritepdfaux
 \metawritepdfpreamble
@@ -780,7 +849,7 @@
 %</driver>
 % \fi
 %
-% \CheckSum{2188}
+% \CheckSum{2519}
 %
 % \CharacterTable
 %  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -857,7 +926,7 @@
 % Please send error reports and suggestions for improvements to Robert
 % Alessi:
 % \begin{itemize}
-% \item email: \mailto[ekdosis package]{alessi at roberalessi.net}
+% \item email: \mailto[ekdosis package]{Robert Alessi <alessi at roberalessi.net>}
 % \item website: \url{http://www.robertalessi.net/ekdosis}
 % \item development: \url{http://git.robertalessi.net/ekdosis}
 % \item comments, feature requests, bug reports:
@@ -915,8 +984,9 @@
 %   \end{keyfigure}
 % \end{comment}
 % 
-% The reader will find here, by way of introduction, a summarized
-% version of the first part of an article published in the
+% \lettrine{\color{cinnamon}\missaali +T+}{he reader} will find here,
+% by way of introduction, a summarized version of the first part of an
+% article published in the
 % \mkbibemph{\citefield{Alessi2020}{journaltitle}} as a contribution
 % to a Digital Humanities workshop held at Stanford University
 % (\printdate{2019-04-15}).\footcite{Alessi2020}
@@ -1123,17 +1193,66 @@
 % follows.
 %
 % \danger The reader is invited to refer to the relevant sections of
-% this documentation for more information on how to use them.
+% this documentation for more information on how to use these options.
 % 
 % \DescribeOption{layout}\phts\label{ref:layout-opt}
-% |layout|$=$\verb+float|footins+\hfill\tcboxverb{Default: float}\\
-% By default, layers of critical notes are inserted as a floating
-% environment to be printed at the bottom of pages. |layout=footins|
-% can be set to insert critical notes in the default footnote block
-% which can be considered to be a special kind of float that is
-% printed at the bottom of pages. In this case, the apparatus criticus
-% will be inserted between regular numbered footnotes, but will carry
-% no footnote mark of its own.
+% |layout|$=$\verb+float|footins|keyfloat|fitapp+
+% \hfill\tcboxverb{Default: float}
+% \begin{enumerate}
+% \item |layout=float| By default, layers of critical notes are
+%   inserted as floating environments to be printed at the bottom of
+%   the pages.
+% \item |layout=footins| This can be set to insert critical notes in
+%   the default footnote block which can be considered to be a special
+%   kind of float that is printed at the bottom of the pages. In this
+%   case, the apparatus criticus will be inserted between regular
+%   numbered footnotes, but will carry no footnote mark of its own.
+% \item \label{ref:keyfloat-opt}\newfeature[v1.3] |layout=keyfloat|
+%   does approximately the
+%   same as the default option |layout=float| but uses the
+%   \pkg{keyfloat} package\footcite{keyfloat} to generate the floating
+%   environments to be used as containers for critical footnotes. This
+%   way, the keys and values provided by this
+%   package\footcite[See][sect. 2.3, \ppno~13--16]{keyfloat} may be
+%   used to achieve such effects as append additional, informative
+%   text below the apparatus, draw a line around the apparatus block
+%   or change its width.\footnote{See below, \vpageref{ref:keyparopts}
+%   for more information.}
+% \item \label{ref:fitapp-opt}\newfeature[v1.3] |layout=fitapp| As
+%   described below in \vnref{sec:oscillating-problem}, \pkg{ekdosis}
+%   may oscillate indefinitely between different sets of page
+%   decisions when one or more apparatus entries attached to the last
+%   lines of the edition text on a given page do not fit in the
+%   apparatus block. The reader will find in this section of the
+%   documentation a detailed account of several ways to circumvent
+%   this issue. Alternatively, or rather conjointly with those ways,
+%   |layout=fitapp| can be used to instruct \pkg{ekdosis} to scale
+%   down the characters of the apparatus block so that the contentious
+%   entries can fit. This mechanism uses the \enquote{fitting} library
+%   provided by the \pkg{tcolorbox} package.\footcite[sect.~22,
+%   \ppno~\pnfmt{438--449}]{tcolorbox} When this option is set, the
+%   apparatus criticus grows normally until a predefined height is
+%   reached. This height is set to |0.5\textheight| by
+%   default.\footnote{Of course, this height can be modified. See
+%   below \vpageref{ref:appheight} for details.} From this point on,
+%   the apparatus block ceases to grow; rather, the size of the
+%   characters is reduced to allow for additional entries. As a
+%   consequence of this rationale, the total number of entries on a
+%   given page must not be too high. It is therefore advisable to use
+%   |layout=fitapp| conjointly with |maxentries| as described below
+%   \vpageref{ref:maxentries} and in \vref{sec:oscillating-problem}. %
+%   \danger If used appropriately, this mechanism gives excellent
+%   typographical results, notably with complex edition texts of which
+%   the entries in the associated apparatus can be quite abundant in
+%   number. It may even put an end to the
+%   \enquote{\hyperref[sec:oscillating-problem]{oscillating problem}}
+%   in most of the cases. However, as suitable it may be for high
+%   quality typeset texts and final, camera-ready copies, its benefit
+%   comes at the expense of slowing down the compilation process. Yet
+%   looser algorithms can be selected when speed must prevail over
+%   quality for intermediate or draft copies.\footnote{See below
+%   \vpageref{ref:fitalgorithm} for more information.}
+% \end{enumerate}
 %
 % \DescribeOption{divs}\phts\label{ref:divs-opt}
 % |divs|$=$\verb+ekdosis|latex+\hfill\tcboxverb{Default: ekdosis}\\
@@ -1203,6 +1322,53 @@
 %</example>
 % \fi
 %
+% \subsection{Setup}
+% \label{sec:setup}
+% \DescribeMacro{\ekdsetup} \newfeature[v1.3] Starting from v1.3,
+% \cs{ekdsetup} can be used to specify options that affect the general
+% behavior of \pkg{ekdosis}. \cs{ekdsetup} is a preamble-only
+% command. It accepts the following |key=value| options the number of
+% which is expected to increase as \pkg{ekdosis} grows:\\
+% \DescribeOption{showpagebreaks}\phts\label{ref:showpagebreaks-opt}
+% \unskip|showpagebreaks|$=$\verb+true|false+
+% \hfill \tcboxverb{Initially: false; Default: true}\\
+% This named argument, which defaults to |true| if used without value,
+% has specific marks printed in the margins so as to spot with a rapid
+% cast of the eye the locations of conditional page breaks generated
+% by the \cs{ekdpb} command described below \vpageref{ref:ekdpb}. By
+% default, page breaks generated by \cs{ekdpb} are identified by the
+% string |spb|\===for \enquote{soft} page break\=== whereas those
+% generated by \cs{ekdpb*} are identified by |hpb|\===for
+% \enquote{hard} page break. Furthermore, when \cs{ekdpb} triggers no
+% page break, the marker is printed between square brackets, like so:
+% |[spb]|. In this
+% way, inoperative \cs{ekdpb} can be easily spotted and removed.\\
+% \DescribeOption{spbmk} |spbmk|$=$\meta{string}
+% \hfill\tcboxverb{Default: spb}\\
+% |spbmk| is used to change the string associated to \enquote{soft}
+% page breaks.\\
+% \DescribeOption{hpbmk} |hpbmk|$=$\meta{string}
+% \hfill\tcboxverb{Default: hpb}\\
+% |hpbmk| is used to change the string associated to \enquote{hard}
+% page breaks.
+%
+% As an example, what follows has \enquote{soft} page breaks printed
+% in blue and \enquote{hard} page breaks printed in red:---
+%
+% \iffalse
+%<*example>
+% \fi
+\begin{minted}[linenos=false]{latex}
+\ekdsetup{
+  showpagebreaks,
+  spbmk = \textcolor{blue}{spb},
+  hpbmk = \textcolor{red}{hpb}
+}
+\end{minted}
+% \iffalse
+%</example>
+% \fi
+%
 % \subsection{Using a Configuration File}
 % \label{sec:using-conf-file}
 % Complex editions may use a large number of witnesses, sources and
@@ -1212,7 +1378,7 @@
 % way to avoid overloading the document preamble: all the settings
 % related to the critical edition can be gathered in a separate
 % configuration file named |\jobname-ekd.cfg|. If such a file can be
-% found, its contents is automatically read and used by
+% found, its contents are automatically read and used by
 % \pkg{ekdosis}.
 %
 % \subsection{Witnesses, Hands, Sources, Scholars \& Shorthands}
@@ -1247,7 +1413,8 @@
 % \begin{enumerate}
 % \item The unique identifier of the witness to be used both in the
 %   |.tex| source file and as an |xml:id| in the \texttt{TEI xml}
-%   output if any.
+%   output if any.\footnote{See \vpageref{ref:xmlid} for more
+%   information.}
 % \item The rendition to be used in the printed apparatus criticus,
 %   which also will be found within the |<sourceDesc>| element of the
 %   \texttt{TEI} header where the description of the witness occurs,
@@ -1258,8 +1425,8 @@
 % \end{enumerate}
 % Finally, the optional argument of \cs{DeclareWitness} accepts a
 % comma-separated list of the following \enquote{name=value} arguments
-% that are used to collect items of information to be found within
-% the |<msIdentifer>| element in the \texttt{TEI}
+% the first six of which are used to collect items of information to
+% be found within the |<msIdentifer>| element in the \texttt{TEI}
 % header:\footnote{See
 % \url{https://tei-c.org/release/doc/tei-p5-doc/en/html/MS.html\#msid}
 % for detailed information on these elements.}---\\
@@ -1276,13 +1443,17 @@
 % \DescribeOption{msName} |msName|$=$\meta{name}: The name commonly
 % used for the witness.\\
 % \DescribeOption{origDate} |origDate|$=$\meta{date}: Any form of date
-% used to identify the date of origin for the witness.
+% used to identify the date of origin for the witness.\\
+% \DescribeOption{locus} |locus|$=$\meta{locus}\newfeature[v1.3]: The
+% sequence of folio references where the edition text is found in the
+% manuscript.
 %
 % \phts\label{ref:marcianus-b}
 % To take here one example, a witness such as the \emph{Marcianus
 % Graecus}~269, referred to as manuscript \enquote*{M} in the
 % editions, which contains sixty treatises transmitted under the name
-% of Hippocrates, could be declared as follows:---
+% of Hippocrates, could be declared as follows:\footnote{The locus
+% specified refers to Hippocrates' \emph{Epidemics}, Book~6.}---
 %
 %\iffalse
 %<*example>
@@ -1293,7 +1464,8 @@
         institution=Marciana Library,
         msName=Marcianus Gr.,
         idno=269,
-        origDate=s. X]
+        origDate=s. X,
+        locus=fol. 416\textsuperscript{v}–426\textsuperscript{v}]
 \end{minted}
 % \iffalse
 %</example>
@@ -1308,7 +1480,7 @@
 % \begin{enumerate}
 % \item The unique identifier of the hand to be used both in the
 % |.tex| source file and as an |xml:id| in the \texttt{TEI xml} output
-% if any.
+% if any.\footnote{See \vpageref{ref:xmlid} for more information.}
 % \item The unique identifier of the witness the hand is related
 % to. Of course, this witness must have been declared beforehand.
 % \item The rendition to be used in the printed apparatus criticus,
@@ -1442,7 +1614,7 @@
 % \begin{enumerate}
 % \item The unique identifier of the scholar to be used both in the
 % |.tex| source file and as an |xml:id| in the \texttt{TEI xml} output
-% if any.
+% if any.\footnote{See \vpageref{ref:xmlid} for more information.}
 % \item The rendition to be used in the apparatus criticus in print,
 % which also will be found within the |<sourceDesc>| element of the
 % \texttt{TEI} header where the description of the persons cited
@@ -1554,10 +1726,12 @@
 % \vpageref{ref:declarewitness}.} a line ready to be inserted in a
 % table set to print a Conspectus Siglorum with the following items of
 % information separated by the symbol |&|: the siglum referring to the
-% witness, the contents of the |description| field and the contents of
-% the |origDate| field. An example of how one could print the
-% Conspectus Siglorum of the manuscripts of Caesar's \emph{Gallic War}
-% from the list provided \vpageref{ref:caesar-bg-sigla} follows:---
+% witness, the contents of the |description| field, followed if
+% applicable by the sequence of folios that refers to the edition
+% text, and the contents of the |origDate| field. An example of how
+% one could print the Conspectus Siglorum of the manuscripts of
+% Caesar's \emph{Gallic War} from the list provided
+% \vpageref{ref:caesar-bg-sigla} follows:---
 %
 % \captof{Conspectus Siglorum of Caesar's \emph{Gallic War}}
 % \iffalse
@@ -1731,6 +1905,8 @@
 % |nosep| must be used when for some reason no \cs{rdg} command
 % follows a \cs{lem} command that has just been used, as shown below
 % in \vref{lst:emend-coni-corr}, l.~7.
+% 
+% \needspace{2\baselineskip}
 % \danger \DescribeMacro{\ekdsep} If |nosep| be used so as to insert
 % an explanatory note after the lemma text with the \cs{note} command
 % described below \vpageref{ref:editorial-notes}, then \cs{ekdsep} can
@@ -1749,6 +1925,19 @@
 % 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
@@ -2040,6 +2229,19 @@
 %</example>
 % \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 falls 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
@@ -2447,11 +2649,11 @@
 % \iffalse
 %</example>
 % \fi
-% 
+%
+% \needspace{11\baselineskip}
 % PDF output:---
 % \medskip
 % 
-% \needspace{7\baselineskip}
 % \resetlinenumber
 % \begin{alignment}[flush,tcols=1,texts=specimen,apparatus=specimen]
 %   \begin{specimen}
@@ -3119,18 +3321,56 @@
 % \DescribeOption{initialrule} |initialrule|$=$\meta{command}
 % \phts\label{ref:initialrule}\hfill\bgroup\footnotesize
 % \tcboxverb{Default: \rule{0.4\columnwidth}{0.4pt} (initially not set)}%
-% \egroup
-% \newfeature[v1.2] |initialrule| draws a separating rule between the
-% edition text and all subsequent layers of critical notes. Of course,
-% this option only makes sense when multiple-layer apparatus criticus
-% are set. Therefore, it has no effect on single-layer apparatus
+% \egroup \newfeature[v1.2] |initialrule| draws a separating rule
+% between the edition text and all subsequent layers of critical
+% notes. Of course, this option only makes sense when multiple-layer
+% apparatus criticus are set. Therefore, it has no effect on
+% single-layer apparatus
 % criticus.\\
 % \DescribeOption{noinitialrule}\hfill\tcboxverb{Default: not set}\\
 % This is a no-value option. It removes any previously set
 % |initialrule|.
-%
+% 
 % An example of the way these hooks may be used is provided below in
 % \vref{lst:shak-sonnet1}.
+% 
+% \noindent\textbf{Option Specific to the |layout=keyfloat| Global
+% Setting}\footnote{See above \vref{ref:keyfloat-opt}.}\\
+% \DescribeOption{keyparopts}%
+% \phts\label{ref:keyparopts}|keyparopts|$=$\meta{csv options}
+% \hfill\tcboxverb{Default: empty}\\
+% \newfeature[v1.3] The comma-separated options that can be used are
+% those described in the documentation of the \pkg{keyfloat}
+% package.\footcite[sect.~2.3, \ppno~\pnfmt{13--15}]{keyfloat} As an
+% example, |keyparopts={ft, tr={made with ekdosis},| %
+% \allowbreak|lw=1.2}| will draw a tight frame around the apparatus
+% block, have the words \enquote{made with \pkg{ekdosis}} printed
+% below this block on the
+% right and set its width to |1.2\linewidth|.\\
+% \textbf{Options Specific to the |layout=fitapp| Global
+% Setting}\footnote{See above \vref{ref:fitapp-opt}.}\\
+% \DescribeOption{appheight}%
+% \phts\label{ref:appheight}|appheight|$=$\meta{dimension}
+% \hfill\tcboxverb{Default: 0.5\textheight}\\
+% \newfeature[v1.3] This option is used to change the maximum height
+% up to which the apparatus block is allowed to grow before the size
+% of the characters is reduced to allow for more entries. The value
+% must be a dimension, namely a number followed by a length unit, such
+% as |0.65\textheight|, |18cm| or |6in|.\\
+% \DescribeOption{fitalgorithm}%
+% \phts\label{ref:fitalgorithm}
+% \unskip|fitalgorithm|$=$\verb+fontsize|hybrid|areasize|squeeze+
+% \hfill\tcboxverb{Default: fontsize}\\
+% \newfeature[v1.3] The four algorithms that can be used to have the
+% entries inserted in the apparatus criticus fit to the selected
+% height are presented here from the tightest to the loosest, that is,
+% the slowest to the fastest.\footnote{See \cite[446--449]{tcolorbox}
+% for details and illustrative examples.} While it is advisable to
+% limit the use of |fontsize| to high quality typesetting for
+% camera-ready copies, |areasize| offers a satisfactory settlement
+% when speed must be given an advantage for intermediate or draft
+% copies. |squeeze| should be avoided as it gives results that are
+% offensive to the sight and unacceptable to any reader.
 %
 % \subsection{Single-Layer Apparatus Criticus}
 % \label{sec:single-layer-app}
@@ -3190,6 +3430,15 @@
 % needed to apply in the apparatus criticus a language different from
 % the one that is selected in the edition text.
 % 
+% \DescribeMacro{\SetApparatusNoteLanguage}
+% \phts\label{ref:app-note-lang}\newfeature[v1.3]
+% \cs{SetApparatusNoteLanguage}\marg{languagename} can be used when it
+% is needed to apply in text entries introduced by the mandatory
+% argument of the \cs{note} command as described in
+% \vref{ref:type-note}\===namely
+% \cs{note}\oarg{options}\marg{text}\===a language different from the
+% one that is selected in the edition text.
+% 
 % \paragraph{General Command}
 % \DescribeMacro{\SetApparatus} \cs{SetApparatus}\marg{csv list of
 % apparatus settings}\phts\label{ref:apparatus-settings-b}\\
@@ -3215,23 +3464,31 @@
 % \hfill\tcboxverb{Default: empty}\\
 % The characters to be appended at the end of the apparatus
 % block.\footnote{See also n.~\vref{fn:rm-dots}.}\\
-% \DescribeOption{rule} |rule|$=$\meta{command}\verb+|+|none|
+% \DescribeOption{rule} |rule|$=$\meta{command}
 % \hfill\tcboxverb{Default: \rule{0.4\columnwidth}{0.4pt}}\\
 % As described above, |rule| is used to draw the separating line
-% between the edition text and the apparatus criticus. |rule=none| can
-% also be used to remove the line.\\
+% between the edition text and the apparatus criticus.\\
 % \DescribeOption{norule}\hfill\tcboxverb{Default: not set}\\
-% |norule| does not accept any value and has the same effect as
-% |rule=none|.\phts\label{ref:apparatus-settings-e}\\
+% |norule| does not accept any value and is used to remove the
+% line.\phts\label{ref:apparatus-settings-e}\\
 % \DescribeOption{lang} |lang|$=$\meta{languagename}
 % \newfeature[v1.2]\phts\label{ref:app-lang-opt}
 % \hfill\tcboxverb{Default: not set}\\
-% \needspace{3\baselineskip}\noindent
 % |lang=<languagename>| is used as described
 % \vpageref[above]{ref:app-lang} when it is needed to apply in the
 % apparatus criticus a language different from the one that is
 % selected in the edition text. |languagename| can be any value
 % accepted by \pkg{babel} or \pkg{polyglossia}.
+% \DescribeOption{notelang} |notelang|$=$\meta{languagename}
+% \newfeature[v1.3]\phts\label{ref:app-note-lang-opt}
+% \hfill\tcboxverb{Default: not set}\\
+% |notelang=<languagename>| is used as described
+% \vpageref[above]{ref:app-note-lang} when is needed to apply in text
+% entries introduced by the mandatory argument of the \cs{note}
+% command as described in \vref{ref:type-note}\===namely
+% \cs{note}\oarg{options}\marg{text}\===a language different from the
+% one that is selected in the edition text. |languagename| can be any
+% value accepted by \pkg{babel} or \pkg{polyglossia}.
 % 
 % As an example, an apparatus criticus with references to line numbers
 % printed in normal font, a colon as a separator between lemma texts
@@ -3327,6 +3584,7 @@
 % \DescribeOption{rule}
 % \DescribeOption{norule}
 % \DescribeOption{lang}\phts\label{ref:apps-lang-opt}
+% \DescribeOption{notelang}
 % With regard to layout, any declared layer inherits the default values
 % described above in \vref{sec:single-layer-app}. That said, as the
 % optional argument of \cs{DeclareApparatus} accepts the exact same
@@ -3498,6 +3756,7 @@
 % they are related to. As a result of this rule, all spaces subsequent
 % to \cs{note} are ignored.
 %
+% \needspace{2\baselineskip}
 % \DescribeMacro{\note} \cs{note}\oarg{options}\marg{text}\\
 % As said above, \cs{note}, when found outside \cs{app}|{}|, is used
 % to insert in additional layers of the apparatus short comments or
@@ -3517,6 +3776,14 @@
 % \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
@@ -3524,7 +3791,12 @@
 % \pkg{ekdosis} to print the line numbers in the apparatus criticus
 % and to set the |left()| XPointer should \texttt{TEI} output be
 % required. Therefore, it must be specified. Otherwise, \pkg{ekdosis}
-% will issue an error message.\\
+% will issue an error message. However, two strictly consecutive
+% \cs{note} commands are allowed to share the same |labelb| value for
+% it may happen that consecutive notes need to refer to spans of text
+% that begin at the exact same location. In this case, \pkg{ekdosis}
+% generates only one \cs{linelabel} and one corresponding
+% |<anchor>| element in the \texttt{TEI xml} file.\\
 % \DescribeOption{labele} |labele|$=$\meta{label}\\
 % |labele| is the unique label to serve as a reference for the point
 % immediately following the lemma text. Contrary to |labelb|, |labele|
@@ -3686,6 +3958,7 @@
 % element (ll.~5--7). Otherwise, the \texttt{TEI} output would not be
 % valid.
 %
+% \needspace{4\baselineskip}
 % \section{Poetry}
 % \label{sec:poetry}
 % \subsection[The Standard \textsf{verse} Environment]{The Standard
@@ -3837,7 +4110,7 @@
 % \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
+% the entire contents of the environment are 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:--- %
@@ -4171,7 +4444,7 @@
 %   |Hudson1856|, |Butler1899| and |Walsh1908| have been declared as
 %   sources.\footnote{See above \vpageref{ref:declare-source} and
 %   below \vref{sec:references-cited-works}.}  |God| and |Stee|,
-%   resp.\ Godwin and Steevens, have been decalred as
+%   resp.\ Godwin and Steevens, have been declared as
 %   scholars.\footnote{See above \vpageref{ref:declare-scholar}.}
 % \item \cs{ekdlettrine} (l.~23) is a specific command for the
 %   \pkg{lettrine} package does not work in list
@@ -4396,11 +4669,13 @@
 % to set lineation preferences. Its argument processes the |key=value|
 % options that follow:---\\
 % \textbf{General Options}\\
-% \DescribeOption{lineation} |lineation|$=$\verb+page|document+
+% \DescribeOption{lineation} |lineation|$=$\verb+page|document|none+
 % \hfill\tcboxverb{Default: document}\\
 % |lineation=document| has the lines numbered continuously throughout
 % the document while |lineation=page| instructs \pkg{ekdosis} that the
-% numbering should start afresh at the top of each page.\\
+% numbering should start afresh at the top of each page. |none| does
+% the same as |page| but prevents the numbers from being printed in
+% the margins while keeping them in use in the apparatus criticus.\\
 % \DescribeOption{modulo} |modulo| \hfill\tcboxverb{Default: not set}\\
 % |modulo| does not accept any value. When this option is set, every
 % fifth line is numbered.\\
@@ -4536,8 +4811,9 @@
 % \pkg{babel},\footcite[See][3.2 \pno~14]{polyglossia} the general
 % advice given above in \vref{sec:alignment-hooks} applies in all
 % cases. As regards setting languages in the \texttt{TEI xml} output
-% file, the reader is invited to refer to point \vref{it:lang-subopt}
-% and \vref{sec:teixml-output}.
+% file, the reader is invited to refer to point \vref{it:lang-subopt},
+% and \vref{sec:teixml-output} including the example provided
+% \vpageref{ref:ancientgreek-ex}.
 %
 % \danger In some cases, it may be needed to apply in the apparatus
 % criticus a language different from the one that is selected in the
@@ -4971,7 +5247,7 @@
 %</example>
 % \fi
 %
-% \subsection{Using \texttt{TEI} Un-numbered Divisions}
+% \subsection{\texttt{TEI} Un-numbered Divisions}
 % \label{sec:ekddiv}
 % \danger As already described \vpageref{ref:divs-opt}, the
 % un-numbered style of division is the one that is set by default. It
@@ -5016,9 +5292,14 @@
 % being |1| and the smallest being |9|.\\
 % \DescribeOption{toc}
 % |toc|$=$\verb+book|part|chapter|section|subsection|subsubsection|paragraph|+\\
-% |subparagraph|\hfill\tcboxverb{Default: not set}\\
+% \phantom{|toc|$=$}|subparagraph|\hfill\tcboxverb{Default: not set}\\
 % If |toc| be set, the title of the division goes into the table of
-% contents at the hierarchic level that is specified as value.
+% contents at the hierarchic level that is specified as value.\\
+% \DescribeOption{mark} \newfeature[v1.3] |mark|$=$\meta{signpost}
+% \hfill\tcboxverb{Default: none}\\
+% |mark| holds the signpost to be emitted as marker for headers and
+% footers. Its value is recalled by \cs{ekdmark} as described below in
+% \vref{sec:headers-footers}.
 %
 % \paragraph{Formatting the Titles}
 % \DescribeMacro{\FormatDiv} By design, \pkg{ekdosis} does
@@ -5046,10 +5327,11 @@
 % here follows how the first three hierarchical levels could be
 % formatted as un-numbered divisions:---
 %
+% \captof{Divisions of the body text}[\label{lst:ekddiv-ex}]
 % \iffalse
 %<*example>
 % \fi
-\begin{minted}[linenos=false]{latex}
+\begin{minted}{latex}
 % Preamble:
 \FormatDiv{1}{\begin{center}\Large}{\end{center}}
 \FormatDiv{2}{\begin{center}\large}{\end{center}}
@@ -5159,6 +5441,126 @@
 %</example>
 % \fi
 %
+% \subsection{Headers and Footers}
+% \label{sec:headers-footers}
+% \newfeature[v1.3] \pkg{ekdosis} provides a mechanism of its own for
+% emitting header and footer marks. The first operation consists in
+% recording the information to be printed as signpost by means of the
+% |mark| optional argument of the \cs{ekddiv} command described above
+% in \vref{sec:ekddiv}.
+%
+% \DescribeMacro{\ekdmark} Once this is done, \cs{ekdmark} can be
+% inserted in commands used to make headers and footers where the mark
+% is to be printed.
+%
+% A common layout is that of headers in which one finds printed in
+% sequence on even pages the page number, then the author's name, and
+% on odd pages the title of the edited text, then the current
+% division, then the page number, like so:---
+%
+% \needspace{5\baselineskip}
+% \begin{xltabular}{1.0\linewidth}{|XcX|}
+%   \multicolumn{3}{l}{Even pages:}\\
+%   \hline
+%   \cs{thepage} & Hippocratis & \\
+%   \hline
+%   \multicolumn{3}{l}{Odd pages:}\\
+%   \hline
+%    & Epidemiarum liber II, \cs{ekdmark} & \hfill\cs{thepage}\\
+%   \hline
+% \end{xltabular}
+%
+% To return to the example provided by \vref{lst:ekddiv-ex}, the mark
+% of the current division would be inserted in the third-level
+% \cs{ekddiv} command printed at line~28 like so:---
+%
+% \iffalse
+%<*example>
+% \fi
+\begin{minted}[firstnumber=28,linenos]{latex}
+  \ekddiv{head=1, type=paragraph, depth=3, n=II.1.1, mark={1, 1}}
+\end{minted}
+% \iffalse
+%</example>
+% \fi
+%
+% The following example finally illustrates how the corresponding
+% headers and footers can be prepared in a straightforward way with
+% the help of the \pkg{titleps} package:\footcite{titleps}---
+%
+% \iffalse
+%<*example>
+% \fi
+\begin{minted}[linenos=false]{latex}
+% Preamble:
+\usepackage{titleps}
+\newpagestyle{edition}{
+  \sethead[\thepage][Hippocratis][]
+          {}{Epidemiarum liber II, \ekdmark}{\thepage}
+}
+% Apply the page style:
+\pagestyle{edition}
+\end{minted}
+% \iffalse
+%</example>
+% \fi
+%
+% \DescribeMacro{\endmark} It must be noted that \cs{ekdmark} is
+% designed to print the first mark that is emitted on a given page and
+% ignore the mark corresponding to any portion of text that may be
+% printed between the top of the page and the point where the first
+% mark is called. \cs{endmark} is an argument-less command that can be
+% used just at the end of that portion of text to instruct
+% \pkg{ekdosis} to print the last-emitted mark of the preceding page
+% instead of the first-emitted mark of the current page.
+%
+% \paragraph{Removing Headers and Footers}
+% Pages such as title pages must be printed with empty headers and
+% footers. \pkg{ekdosis} must be given control over every item of
+% information inserted in these areas beforehand.
+%
+% \DescribeMacro{\ekdprintmark}
+% \cs{ekdprintmark}\marg{selector}\marg{signpost} The signposts
+% printed in headers and footers must be passed as second argument of
+% \cs{ekdprintmark} so that \pkg{ekdosis} can remove them on pages
+% where printing them is not desirable. \meta{selector} refers to
+% three symbolic letters where the first can be either |H| or
+% |F|\===for \underLine{h}eader or \underLine{f}ooter\===, the second
+% |E| or |O|\===for \underLine{o}dd or \underLine{e}ven\===and the
+% third |L|, |C| or |R|\===for \underLine{l}eft, \underLine{c}enter or
+% \underLine{r}ight. The example provided above would then read as
+% follows:---
+%
+% \iffalse
+%<*example>
+% \fi
+\begin{minted}[linenos=false]{latex}
+% Preamble:
+\usepackage{titleps}
+\newpagestyle{edition}{
+  \sethead[\ekdprintmark{HEL}{\thepage}]
+          [\ekdprintmark{HEC}{Hippocratis}]
+          []
+          {}
+          {\ekdprintmark{HOC}{Epidemiarum liber II, \ekdmark}}
+          {\ekdprintmark{HOR}{\thepage}}
+}
+% Apply the page style:
+\pagestyle{edition}
+\end{minted}
+% \iffalse
+%</example>
+% \fi
+%
+% \DescribeMacro{\ekdnohfmarks} Once all signposts are marked with
+% \cs{ekdprintmark}, \cs{ekdnohfmarks} can be used at any point of the
+% document with the same effect as the \LaTeX\ standard command
+% \cs{thispagestyle}|{empty}|.
+%
+% \DescribeMacro{\ekdresethfmarks} Finally, \cs{ekdresethfmarks} is
+% provided in rare cases when it is needed to reset headers and
+% footers to their original, viz.\ printable state.
+% 
 % \section{The Tricks of the Trade}
 % \label{sec:tricks-of-trade}
 % As the |.tex| source file is compiled, \pkg{ekdosis} has to compute
@@ -5206,7 +5608,9 @@
 % pages may result in pages that break just after they begin.
 %
 % \paragraph{Conditional page breaks}
-% \DescribeMacro{\ekdpb} \cs{ekdpb}\oarg{page no}\marg{line no}
+% \phts\label{ref:ekdpb} \DescribeMacro{\ekdpb}\DescribeMacro{\ekdpb*}
+% \cs{ekdpb}\oarg{page no}\marg{line no}
+% \cs{ekdpb*}|{}| \cs{ekdpb*}|\|
 % \newfeature[v1.2]\\
 % One way to avoid this inconvenience is to use \cs{ekdpb} instead of
 % the standard \cs{pagebreak} command provided by \LaTeX\ to insert
@@ -5216,7 +5620,17 @@
 % the page number where the page break should occur. The value that is
 % expected is the page number as it is printed\===e.g.\ an Arabic,
 % Roman or alphanumeric number. If the specified conditions be not
-% met, then the page break is not triggered.
+% met, then the page break is not triggered.  Finally, the
+% \enquote{starred} version of this command forces the page break,
+% irrespective of the values specified as page or line numbers. Unlike
+% \cs{ekdpb}, which requires the lines to be numbered, \cs{ekdpb*} is
+% allowed at any point of the document: as \cs{ekdpb*} disregards the
+% number given as argument, it is equivalent to the standard \LaTeX\
+% \cs{pagebreak} command. Yet it can be used instead of the latter to
+% have marks further printed in the margins so as to spot with a
+% fleeting glance the locations where induced page breaks
+% occur.\footnote{This requires the |showpagebreaks| option to be set
+% to |true| as described above \vpageref{ref:showpagebreaks-opt}.}
 %
 % \paragraph{Using \texttt{maxentries}}
 % Another way\---should the edition text fall into the vicious circle
@@ -5264,6 +5678,17 @@
 % many of them and \pkg{ekdosis} still oscillates between different
 % sets of page decisions.
 %
+% \paragraph{The \texttt{fitapp} Global Option}
+% \newfeature[v1.3] The rationale of this option is discussed above
+% (see \vref{ref:fitapp-opt}). As this mechanism has the characters of
+% the apparatus block scaled down to allow for more entries once a
+% predefined height has been reached, \pkg{ekdosis} should settle down
+% in most of the contentious cases.\footnote{That is, cases that arise
+% \emph{after} the predefined height has been reached.} However, it is
+% advisable to use |fitapp| conjointly with |maxentries| to prevent
+% the number of allowed entries from being too high, which would
+% result in the characters being too small or even illegible.
+%
 % \subsection{Variae Quaestiones}
 % \label{sec:variae-quaestiones}
 % This section is about issues that are not strictly speaking part of
@@ -5532,18 +5957,19 @@
 % |false| by means of \cs{SetTEIxmlExport} described above.
 %
 % \paragraph{The \texttt{xml:id} Attribute}
-% As a general rule, the |xml:id| global attribute must be unique for
-% the element that bears the attribute. Furthermore, it must begin
-% with a letter or an underscore and contain no characters other that
-% letters, digits, hyphens, underscores and full stops. \pkg{ekdosis}
-% issues a warning when it finds that any \meta{unique id} of
-% \meta{unique label} expected in the first argument of
-% \cs{DeclareWitness}, \cs{DeclareHand}, \cs{DeclareSource} or
-% \cs{DeclareScholar} is not unique or breaks the rules just
-% described, but does not prevent the |.tex| source file from
-% compiling. Instead, it prints the string |<??>| in place of the
-% expected formatted siglum so that the error in the |.tex| source
-% file can be easily spotted and corrected.
+% \phts\label{ref:xmlid} As a general rule, the |xml:id| global
+% attribute must be unique for the element that bears the
+% attribute. Furthermore, it must begin with a letter or an underscore
+% and contain no characters other than letters of the Latin
+% alphabet\--- from |a| to |z|, either upper or lower case\---digits,
+% hyphens, underscores and full stops. \pkg{ekdosis} issues a warning
+% when it finds that any \meta{unique id} of \meta{unique label}
+% expected in the first argument of \cs{DeclareWitness},
+% \cs{DeclareHand}, \cs{DeclareSource} or \cs{DeclareScholar} is not
+% unique or breaks the rules just described, but does not prevent the
+% |.tex| source file from compiling. Instead, it prints the string
+% |<??>| in place of the expected formatted siglum so that the error
+% in the |.tex| source file can be easily spotted and corrected.
 %
 % \danger As the \meta{unique id} declared with \cs{DeclareShorthand}
 % is not to be exported in the \texttt{TEI xml} output file,
@@ -5790,7 +6216,8 @@
 % example illustrates how \cs{EnvtoTEI} can be used conjointly with
 % \pkg{babel} to convey information about the languages used from
 % \LaTeX\ to \texttt{TEI}:---
-% 
+%
+% \phts\label{ref:ancientgreek-ex}
 % \iffalse
 %<*example>
 % \fi
@@ -5841,6 +6268,14 @@
 % strings captured are inserted where each of them is expected in
 % the \texttt{TEI} element.
 %
+% \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
+% number that is expected in the sequence. This will prevent any
+% brackets that may be found in the captured string from being
+% interpreted.
+%
 % \danger Strings must be entered exactly as \pkg{ekdosis} will find
 % them as the |.tex| source file is compiled. Specifically,
 % \emph{control sequences}, namely the coded commands immediately
@@ -5855,8 +6290,8 @@
 % \iffalse
 %<*example>
 % \fi
-\begin{minted}[linenos=false]{latex}
-\TeXtoTEIPat{\textcolor␣{#1}{#2}}{<hi rend="#1">#2</hi>}
+\begin{minted}[linenos]{latex}
+\TeXtoTEIPat{\textcolor␣{#1}@b2}{<hi rend="#1">@b2</hi>}
 
 Sample text with a \textcolor{red}{word} in red.
 \end{minted}
@@ -5863,6 +6298,14 @@
 % \iffalse
 %</example>
 % \fi
+% 
+% \begin{remarks}
+% \item[\textsc{Rem.}]  As can be seen from l.~1, it is safe to use
+%   |#1| for the first string for color names are naturally formed of
+%   letters without braces. However, |@b2| is preferable to capture
+%   the whole second argument of \cs{textcolor} for it may contain
+%   words within braces.
+% \end{remarks}
 %
 % \iffalse
 %<*example>
@@ -5875,6 +6318,91 @@
 %</example>
 % \fi
 %
+% \subsection{Inserting Code in the \texttt{TEI xml} Ouput File}
+% \label{sec:inserting-code-tei}
+% It may be needed to insert code in the \texttt{TEI xml} output file
+% only, for example when clear enough information is written in the
+% apparatus criticus by means of such optional arguments as |pre|,
+% |post|, |prewit| or |postwit| that are not processed for \texttt{TEI
+% xml} ouput.\footnote{See above \vref{sec:single-text-editing}.}
+%
+% \needspace{2\baselineskip}
+% \DescribeMacro{\teidirect} \newfeature[v1.3] \cs{teidirect}\oarg{xml
+% attributes}\marg{xml element}\marg{code}\\
+% Two mandatory arguments are expected by \cs{teidirect}, namely the
+% \texttt{TEI xml} element followed by the contents to be found in the
+% ouput file between the opening and closing tags. Additionally,
+% attribute-value pairs to be found inside the start-tag of the
+% element can be specified in the optional argument of the command. An
+% example follows:
+% 
+% \iffalse
+%<*example>
+% \fi
+\begin{minted}[linenos]{latex}
+% Preamble:
+\DeclareWitness{GalE1.M}{Gal.E1(M)}{\emph{Monacencis Gr.}
+  231}[origDate=s. XVI]
+\DeclareWitness{GalE1.Q}{Gal.E1(Q)}{\emph{Parisinus Gr.}
+  2174}[origDate=s. XIV]
+  \DeclareShorthand{GalE1.M.Q}{Gal.E1(MQ)}{GalE1.M,GalE1.Q}
+
+% Document:
+ἐν \app{
+    \lem[wit=codd]{καύμασιν}
+    \rdg[wit=GalE1.M.Q, postwit=\unskip(23.16)]{καύματι}
+    \teidirect{note}{p. 23, l. 16 Wenkebach}}
+\end{minted}
+% \iffalse
+%</example>
+% \fi
+%
+% \begin{remarks}
+% \item |GalE1.M.Q| (l.~11) has been defined as a shorthand to denote
+%   the agreement of two otherwise defined manuscripts by means of
+%   \cs{DeclareWitness}: |GalE1.M| and |GalE1.Q|. (See ll.~2--6.)
+% \item The |postwit| optional argument has been used to further
+%   specify the location where this variant reading can be found in
+%   the critical edition of Galen's Commentary on Hippocrates'
+%   \emph{Epidemics}, Book~1 (l.~11). But as the effect of |postwit|
+%   is limited to the PDF output, \cs{teidirect} has been used to
+%   convey this item of information to the \texttt{TEI xml} ouput file
+%   (l.~12).
+% \end{remarks}
+%
+% PDF output:---
+% \medskip
+%
+% \needspace{7\baselineskip}
+% \resetlinenumber
+% \begin{alignment}[flush,tcols=1,texts=specimen,apparatus=specimen]
+%   \begin{specimen}
+%     \begin{ancientgreek}
+% ἐν \app{
+%     \lem[wit=hcodd]{καύμασιν}
+%     \rdg[wit=hGalE1.M.Q, postwit=\unskip(23.16)]{καύματι}
+%     \teidirect{note}{p. 23, l. 16 Wenkebach}}
+%     \end{ancientgreek}
+%   \end{specimen}
+% \end{alignment}
+%
+% \texttt{TEI xml} output:---
+%
+% \iffalse
+%<*example>
+% \fi
+\begin{minted}[linenos]{xml}
+<p xml:lang="grc">ἐν 
+<app>
+  <lem wit="#V #I #R #H">καύμασιν</lem>
+  <rdg wit="#GalE1.#M #GalE1.Q">καύματι</rdg>
+  <note>p. 23, l. 16 Wenkebach</note>
+</app></p>
+\end{minted}
+% \iffalse
+%</example>
+% \fi
+%
 % \subsection{Specific \texttt{TEI} Modules}
 % \label{sec:specific-tei-modules}
 % The following example illustrates how \pkg{ekdosis} can be adapted
@@ -6189,8 +6717,8 @@
 % \pkg{ekdosis} can also convert into \texttt{TEI xml} references to
 % cited works. Depending on the optional arguments used in the
 % citation command, references will be converted into |<ptr>| or
-% |<ref>| elements with the appropriate identifier supplied by means
-% of the |target| attribute.
+% |<bibl>| elements with the appropriate identifier supplied by means
+% of the |target| or |corresp| attributes.
 %
 % Of course, for this mechanism to work, Bib\TeX\ or Bib\LaTeX\ must
 % be used and connected to some |.bib| bibliographical database
@@ -6210,7 +6738,7 @@
 % \fi
 \begin{minted}[linenos=false]{bibtex}
 @Book{ReynoldsWilson1991,
-  author =	 {Reynolds, L. D. and Wilson, N. G},
+  author =	 {Reynolds, L. D. and Wilson, N. G.},
   title =	 {Scribes and Scholars},
   year =	 {1991},
   subtitle =	 {A Guide to the Translation of Greek and Latin
@@ -6306,7 +6834,9 @@
 <text>
   <body>
     <p>On textual criticism, see 
-    <ref target="#ReynoldsWilson1991">207--241</ref>.</p>
+    <bibl corresp="#ReynoldsWilson1991">
+      <biblScope>207--241</biblScope>
+    </bibl>.</p>
   </body>
   <back>
     <listBibl>
@@ -6376,8 +6906,6 @@
 %   \item Marginal edition texts: It may happen that the marginalia of
 %     manuscripts contain texts worth editing in addition to and along
 %     the main text to which they are linked by reference signs.
-%   \item Headers and footers: \cs{ekddiv} will provide top and bottom
-%     marks to be used in headers and footers.
 %   \end{enumerate}
 % \item Short-term (months):---
 %   \begin{enumerate}
@@ -7034,6 +7562,8 @@
 \RequirePackage{expkv-def}
 \newif\if at pkg@float
 \newif\if at pkg@footins
+\newif\if at pkg@keyfloat
+\newif\if at pkg@fitfloat
 \newif\if at pkg@ekddivs
 \newif\if at parnotesroman
 \newif\if at pkg@parnotes
@@ -7041,7 +7571,9 @@
 \newif\if at pkg@poetry at verse
 \ekvdefinekeys{ekdosis}{
   choice layout = {float = {\@pkg at floattrue},
-    footins = {\@pkg at floatfalse\@pkg at footinstrue}},
+    footins = {\@pkg at floatfalse\@pkg at footinstrue},
+    keyfloat = {\@pkg at floatfalse\@pkg at keyfloattrue},
+    fitfloat = {\@pkg at floatfalse\@pkg at fitfloattrue}},
   initial layout = float,
   unknown-choice layout = \PackageError{ekdosis}{unknown
     layout=#1}{`layout' must be either `float' or `footins'.},
@@ -7089,7 +7621,21 @@
 \RequirePackage{paracol}
 \RequirePackage{etoolbox}
 \RequirePackage{lineno}
-\RequirePackage{keyfloat}
+\if at pkg@float
+  \RequirePackage{trivfloat}
+  \trivfloat{ekdapparatus}
+\fi
+\if at pkg@keyfloat
+  \RequirePackage{keyfloat}
+  \def\ekd at keyparopts#1{%
+    \def\ekd at insert@keyparapp{%
+      \keyparbox[!b]{#1}{\ekd at insert@apparatus}}}
+  \ekd at keyparopts{}
+\fi
+\if at pkg@fitfloat
+  \RequirePackage{tcolorbox}
+  \tcbuselibrary{fitting,skins}
+\fi
 \RequirePackage{refcount}
 \RequirePackage{zref-user}
 \RequirePackage{zref-abspage}
@@ -7112,6 +7658,23 @@
   \luadirect{ekdosis.closestream()}
 }
 %    \end{macrocode}
+% \paragraph{Setup}
+% \begin{macro}{\ekdsetup}
+% \changes{v1.3}{2021/08/18}{new command for global options}
+% \cs{ekdsetup} is used to specify options that affect the general
+% behavior of \pkg{ekdosis}. It is a preamble-only command.
+%    \begin{macrocode}
+\ekvdefinekeys{ekd at setup}{
+  bool showpagebreaks = \ifekd at showpb,
+  store spbmk = \ekd at spbmk,
+  initial spbmk = spb,
+  store hpbmk = \ekd at hpbmk,
+  initial hpbmk = hpb,
+}
+\NewDocumentCommand{\ekdsetup}{m}{\ekvset{ekd at setup}{#1}}
+\@onlypreamble\ekdsetup
+%    \end{macrocode}
+% \end{macro}
 % \begin{macro}{\SetHooks} \cs{SetHooks} is used to set
 %   hooks meant to be shared by all declared apparatuses, such as the
 %   font size, the format of numerals, \emph{\&c.} This command can be
@@ -7120,6 +7683,8 @@
 %   \texttt{lemmastyle}}
 %   \changes{v1.2}{2021/04/02}{general hooks: new option
 %   \texttt{readingstyle}}
+%   \changes{v1.3}{2021/08/18}{general hooks: new options
+%   \texttt{keyparopts} and \texttt{appheight}}
 %    \begin{macrocode}
 \ekvdefinekeys{ekd at hooks}{
   store appfontsize = \ekd at appfontsize,
@@ -7127,6 +7692,17 @@
   store postrefnum = \ekd at postrefnum,
   store lemmastyle = \ekd at lemmastyle,
   store readingstyle = \ekd at readingstyle,
+  code keyparopts = \if at pkg@keyfloat\ekd at keyparopts{#1}\fi,
+  dimen appheight = \ekd at app@height,
+  initial appheight = .5\textheight,
+  choice fitalgorithm = {fontsize = \def\ekd at fit@algorithm{fontsize},
+    hybrid = \def\ekd at fit@algorithm{hybrid},
+    areasize = \def\ekd at fit@algorithm{areasize},
+    squeeze = \def\ekd at fit@algorithm{squeeze}},
+  initial fitalgorithm = fontsize,
+  unknown-choice fitalgorithm = \PackageError{ekdosis}{unknown
+    fitalgorithm=#1}{`fitalgorithm' must be either `fontsize',
+    `hybrid', `areasize' or `squeeze'.},
   code initialrule = \def\ekd at initial@rule{#1\NLS},
   default initialrule = \rule{0.4\columnwidth}{0.4pt},
   noval noinitialrule = \undef\ekd at initial@rule,
@@ -7148,7 +7724,8 @@
   store collection = \collection at value,
   store idno = \idno at value,
   store msName = \msName at value,
-  store origDate = \origDate at value
+  store origDate = \origDate at value,
+  store locus = \locus at value
 }
 %    \end{macrocode}
 % \begin{macro}{\DeclareWitness} \cs{DeclareWitness} is a
@@ -7171,7 +7748,8 @@
       \luastringO{\collection at value},
       \luastringO{\idno at value},
       \luastringO{\msName at value},
-      \luastringO{\origDate at value})}
+      \luastringO{\origDate at value},
+      \luastringO{\locus at value})}
     \egroup
   }
 \@onlypreamble\DeclareWitness
@@ -7325,6 +7903,16 @@
 }
 %    \end{macrocode}
 % \end{macro}
+% \begin{macro}{\teidirect}
+% \changes{v1.3}{2021/08/18}{direct insertion of elements in the
+% \texttt{TEI xml} file}
+% \cs{teidirect}\oarg{xml attributes}\marg{xml element}\marg{code}
+% does nothing in \LaTeX. Its only use is to insert elements in the
+% \texttt{TEI xml} output file.
+%    \begin{macrocode}
+\NewDocumentCommand{\teidirect}{O{}mm}{\ignorespaces}
+%    \end{macrocode}
+% \end{macro}
 % \begin{macro}{\EnvtoTEI}
 % \begin{macro}{\EnvtoTEI*}
 % \cs{EnvtoTEI}\meta{*}\marg{env name}\marg{TEI element}\oarg{TEI
@@ -7390,8 +7978,20 @@
 \@onlypreamble\AddxmlBibResource
 %    \end{macrocode}
 % \end{macro}
-%
-%\paragraph{Multiple-layer apparatuses}
+% \begin{macro}{\ekd at test@lang}
+% \cs{ekd at test@lang} is used internally by \pkg{ekdosis}. This command
+% returns \cs{ekd at lang@pkgtrue} if either \pkg{babel} or
+% \pkg{polyglossia} be used so that \cs{languagename} can be inserted
+% when and where needed in the apparatus criticus.
+%    \begin{macrocode}
+\newif\ifekd at lang@pkg
+\NewDocumentCommand{\ekd at test@lang}{}{%
+  \ltx at ifpackageloaded{babel}{\ekd at lang@pkgtrue}{}%
+  \ltx at ifpackageloaded{polyglossia}{\ekd at lang@pkgtrue}{}%
+}
+%    \end{macrocode}
+% \end{macro}
+% \paragraph{Multiple-layer apparatuses}
 % \pkg{ekdosis} must know if an entry is to be processed in a single-
 % or multiple-layer context:---
 %    \begin{macrocode}
@@ -7412,6 +8012,7 @@
   store ehook = \ehook at val,
   store maxentries = \limit at val,
   store lang = \lang at val,
+  store notelang = \notelang at val,
   initial direction = LR,
   initial delim = {},
   initial ehook = {\csname ekd at end@apparatus\endcsname}
@@ -7444,7 +8045,8 @@
     \luastringO{\bhook at val},
     \luastringO{\ehook at val},
     \luastringO{\limit at val},
-    \luastringO{\lang at val}
+    \luastringO{\lang at val},
+    \luastringO{\notelang at val}
     )}
   \egroup
 }
@@ -7473,29 +8075,42 @@
 % \cs{ekdpk}\oarg{page no}\marg{line no} is used to insert conditional
 % page breaks by specifying that the page break should occur only on a
 % given line and optionally a given page. If the specified conditions
-% are met then this command triggers \cs{pagebreak}.
+% be met then this command triggers \cs{pagebreak}.
 %    \begin{macrocode}
-\NewDocumentCommand{\ekdpb}{o m}{%
-  \def\@tmpoarg{#1}%
-  \def\@tmpmarg{#2}%
-  \luadirect{ekdosis.dolnlab(\luastringN{#2})}%
-  \linelabel{\luadirect{tex.sprint(ekdosis.getlnlab())}}%
-  \def\tmp at ln{%
-    \getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}}}%
-  \def\tmp at pg{%
-    \getpagerefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}}}%
-  \IfNoValueTF{#1}
-  {\ifnum
-    \pdf at strcmp{\@tmpmarg}{\tmp at ln} = 0
-    \pagebreak
-    \fi}
-  {\ifnum
-    \pdf at strcmp{\@tmpoarg}{\tmp at pg} = 0
-    \ifnum
-    \pdf at strcmp{\@tmpmarg}{\tmp at ln} = 0
-    \pagebreak
-    \fi
-    \fi
+\newcounter{ekd at pb}
+\globalcounter{ekd at pb}
+\NewDocumentCommand{\ekdpb}{s o m}{%
+  \IfBooleanTF{#1}
+  {\ifekd at showpb\marginpar{\ekd at hpbmk}\fi
+    \pagebreak}
+  {%
+    \def\@tmpoarg{#2}%
+    \def\@tmpmarg{#3}%
+    \stepcounter{ekd at pb}%
+    \linelabel{ekdpb:\theekd at pb}%
+    \def\tmp at ln{%
+      \getrefnumber{ekdpb:\theekd at pb}}%
+    \def\tmp at pg{%
+      \getpagerefnumber{ekdpb:\theekd at pb}}%
+    \IfNoValueTF{#2}
+    {\ifnum
+      \pdf at strcmp{\@tmpmarg}{\tmp at ln} = 0
+      \ifekd at showpb\marginpar{\ekd at spbmk}\fi
+      \pagebreak
+      \else
+      \ifekd at showpb\marginpar{[\ekd at spbmk]}\fi
+      \fi}
+    {\ifnum
+      \pdf at strcmp{\@tmpoarg}{\tmp at pg} = 0
+      \ifnum
+      \pdf at strcmp{\@tmpmarg}{\tmp at ln} = 0
+      \ifekd at showpb\marginpar{\ekd at spbmk}\fi
+      \pagebreak
+      \else
+      \ifekd at showpb\marginpar{[\ekd at spbmk]}\fi
+      \fi
+      \fi
+    }%
   }\ignorespaces
 }
 %    \end{macrocode}
@@ -7507,6 +8122,7 @@
 \newif\ifekd at state
 \newif\ifekd at isinapp
 \newif\ifekd at isinlem
+\newif\ifekd at appinapp
 %    \end{macrocode}
 % The next boolean is shared with \pkg{arabluatex}. \cs{LRnum} is used
 % internally to ensure that numerals referring to line spans are
@@ -7581,7 +8197,11 @@
   initial rule = \rule{0.4\columnwidth}{0.4pt},
   noval norule = \def\ekd at default@rule{\mbox{}},
   store lang = \ekd at singleapp@lang,
-  initial lang = \ltx at ifpackageloaded{babel}{\languagename}{}
+  initial lang = \ltx at ifpackageloaded{babel}{\languagename}{%
+    \ltx at ifpackageloaded{polyglossia}{\languagename}{}},
+  store notelang = \ekd at singleapp@note at lang,
+  initial notelang = \ltx at ifpackageloaded{babel}{\languagename}{%
+  \ltx at ifpackageloaded{polyglossia}{\languagename}{}}
 }
 %    \end{macrocode}
 % \begin{macro}{\SetApparatus}
@@ -7650,6 +8270,18 @@
   \def\ekd at singleapp@lang{#1}}
 %    \end{macrocode}
 % \end{macro}
+% \begin{macro}{\SetApparatusNoteLanguage}
+% \changes{v1.3}{2021/08/18}{defines an alternate language to be
+% applied in note apparatus entries}
+% \cs{SetApparatusNoteLang}\marg{languagename} can be used when
+% it is needed to apply in entries introduced by the \cs{note} command
+% a language different from the one that is selected in the edition
+% text.
+%    \begin{macrocode}
+\NewDocumentCommand{\SetApparatusNoteLanguage}{m}{%
+  \def\ekd at singleapp@note at lang{#1}}
+%    \end{macrocode}
+% \end{macro}
 % \begin{macro}{\footnoteruletrue}
 % \begin{macro}{\footnoterulefalse}
 % As \pkg{ekdosis} takes care of drawing a rule separating the main
@@ -7723,6 +8355,42 @@
 % apparatus criticus, a conditional is first defined.
 %    \begin{macrocode}
 \newif\ifekd at inside@app
+%    \end{macrocode}
+% Then \cs{ekd at fitapp} is defined for |layout=fitapp|:---
+%    \begin{macrocode}
+\if at pkg@fitfloat
+  \newtcboxfit{\ekd at fitapp}{%
+    blankest,
+    fit basedim = \f at size pt,
+    fit fontsize macros,
+    fit height from=0pt to \ekd at app@height,
+    fit algorithm = \ekd at fit@algorithm,
+    float=!b}
+\fi
+%    \end{macrocode}
+% Finally two commands are used to actually insert the apparatus
+% depending on the value set in the |layout| global option.
+%    \begin{macrocode}
+\long\def\ekd at insert@apparatus{%
+  \unless\ifekd at mapps
+  \ifrtl at app\pardir TRT\leavevmode\textdir TRT\else
+    \pardir TLT\leavevmode\textdir TLT\fi
+  \fi
+  \if at pkg@parnotes
+   \if at parnotesroman
+    \renewcommand*{\theparnotemark}{\roman{parnotemark}}\fi
+   \parnoteclear\fi
+  \ekd at inside@apptrue
+  \ekd at appfontsize
+  \ifekd at mapps
+    \ifdefined\ekd at initial@rule
+      \ekd at initial@rule
+    \fi
+  \fi
+  \apparatus\unless\ifekd at mapps\ekd at end@apparatus\fi
+  \ekd at inside@appfalse
+  \if at pkg@parnotes\parnotes\parnotereset\fi    
+}%
 \def\add@@apparatus{%
   \if at pkg@parnotes\parnotes\else\fi
   \if at pkg@footins
@@ -7750,27 +8418,16 @@
   \egroup
   \fi
   \if at pkg@float
-  \keyparbox[!b]{}{%
-    \unless\ifekd at mapps
-      \ifrtl at app\pardir TRT\leavevmode\textdir TRT\else
-        \pardir TLT\leavevmode\textdir TLT\fi
-    \fi
-    \if at pkg@parnotes
-    \if at parnotesroman
-    \renewcommand*{\theparnotemark}{\roman{parnotemark}}\else\fi
-    \parnoteclear\else\fi
-    \ekd at inside@apptrue
-    \ekd at appfontsize
-    \ifekd at mapps
-      \ifdefined\ekd at initial@rule
-        \ekd at initial@rule
-      \fi
-    \fi
-    \apparatus\unless\ifekd at mapps\ekd at end@apparatus\fi
-    \ekd at inside@appfalse
-    \if at pkg@parnotes\parnotes\parnotereset\else\fi
-  }%
+  \begin{ekdapparatus}[!b]%
+    \ekd at insert@apparatus
+  \end{ekdapparatus}%
   \fi
+  \if at pkg@keyfloat
+    \ekd at insert@keyparapp
+  \fi
+  \if at pkg@fitfloat
+    \ekd at fitapp{\ekd at insert@apparatus}%
+  \fi
 }
 %    \end{macrocode}
 % Before inserting any new entry, \cs{add at apparatus} calls
@@ -7802,7 +8459,7 @@
   {\luadirect{tex.sprint(ekdosis.mdvappend(\luastringO{#2},
       \luastringO{#1}))}}}
 %    \end{macrocode}
-% \paragraph{Lineation settings}
+% \paragraph{Lineation Settings}
 % \begin{macro}{\outerlinenumbers}
 % \begin{macro}{\innerlinenumbers}
 % \pkg{ekdosis} does not use the \enquote{pagewise} numbering mode
@@ -7849,7 +8506,9 @@
 \newif\ifekd at elidednumbers
 \ekvdefinekeys{ekd at lineation}{
   choice lineation = {page = \ekd at pagelineationtrue,
-    document = \ekd at pagelineationfalse},
+    document = \ekd at pagelineationfalse,
+    none = \ekd at pagelineationtrue
+           \renewcommand\thelinenumber{}},
   unknown-choice lineation = \PackageError{ekdosis}{unknown
     lineation=#1}{`lineation' must be either `page' or `document'.},
   choice vlineation = {page = \ekd at pagevlineationtrue,
@@ -7921,14 +8580,16 @@
   \leavevmode
   \begingroup
   \ekvset{appnote}{#1}%
-  \ekd at isinapptrue%
+  \ifekd at isinapp\ekd at appinapptrue\fi
+  \ekd at isinapptrue
   \stepcounter{ekd at lab}%
   \zlabel{ekd:\theekd at lab}%
   \luadirect{ekdosis.storeabspg(
     \luastring{\zref at extract{ekd:\theekd at lab}{abspage}})}%
-  \ifekd at state\add at apparatus\fi%
+  \ifekd at state\add at apparatus\fi
   \luadirect{tex.sprint(ekdosis.removesp(\luastringN{#2}))}%
-  \ekd at isinappfalse%
+  \ekd at isinappfalse
+  \ekd at appinappfalse
   \endgroup}
 %    \end{macrocode}
 % \end{macro}
@@ -7988,10 +8649,16 @@
     \fi
     \fi%
     \else
-    \LRnum{\getrefnumber{#1}}--%
-    \LRnum{\getpagerefnumber{#2}}.%
-    \LRnum{\getrefnumber{#2}}\unexpanded\expandafter{\ekd at postrefnum}% issue pg and ln nos
+    \ifboolexpr{bool {ekd at pagelineation} or bool {ekd at pagevlineation}}
+      {\LRnum{\getrefnumber{#1}}--%
+      \LRnum{\getpagerefnumber{#2}}.%
+      \LRnum{\getrefnumber{#2}}\unexpanded\expandafter{\ekd at postrefnum}}% issue pg and ln nos
+      {\LRnum{\getrefnumber{#1}}--%
+      \LRnum{\getrefnumber{#2}}\unexpanded\expandafter{\ekd at postrefnum}}% issue the nos
     \fi%
+    \ifekdn at forcenum
+      \LRnum{\getrefnumber{#1}}\unexpanded\expandafter{\ekd at postrefnum}% force the no
+    \fi
   }%
 }
 %    \end{macrocode}
@@ -8021,6 +8688,28 @@
       {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevlnlab())}-b}}
       =
       0
+    %%%begin
+    \ifnum%
+    \pdf at strcmp{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}%
+    {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevlnlab())}-e}}
+    =
+    0
+    \ifekd at appinapp
+    \ifnum%
+    \pdf at 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 at postrefnum}% issue the no
+    \fi
+    \fi
+    \else
+    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
+      \unexpanded\expandafter{\ekd at postrefnum}% issue the no
+    \fi
+    %%% end
       \else
       \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
         \unexpanded\expandafter{\ekd at postrefnum}% issue the no
@@ -8035,10 +8724,32 @@
     {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevlnlab())}-b}}
     =
     0
+    %%%begin
+    \ifnum%
+    \pdf at strcmp{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}%
+    {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevlnlab())}-e}}
+    =
+    0
+    \ifekd at appinapp
+    \ifnum%
+    \pdf at 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 at postrefnum}% issue the no
     \fi
+    \fi
+    \else
+    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
+      \unexpanded\expandafter{\ekd at postrefnum}% issue the no
+    \fi
+    %%% end
+    \else
+    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
+      \unexpanded\expandafter{\ekd at postrefnum}% issue the no
+    \fi
     %
     \else
     \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
@@ -8059,11 +8770,19 @@
     \fi
     \fi%
     \else
-    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}--%
-    \LRnum{\getpagerefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}.%
-    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}%
-      \unexpanded\expandafter{\ekd at postrefnum}% issue pg and ln nos
+    \ifboolexpr{bool {ekd at pagelineation} or bool {ekd at pagevlineation}}
+      {\LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}--%
+      \LRnum{\getpagerefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}.%
+      \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}%
+        \unexpanded\expandafter{\ekd at postrefnum}}% issue pg and ln nos
+      {\LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}--%
+      \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}%
+        \unexpanded\expandafter{\ekd at postrefnum}}% issue the nos
     \fi%
+    \ifekdl at forcenum
+    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
+      \unexpanded\expandafter{\ekd at postrefnum}% force the no
+    \fi
   }%
 }
 %    \end{macrocode}
@@ -8070,6 +8789,8 @@
 % Define keys to be used by the optional arguments of \cs{lem} and
 % \cs{rdg}:---
 %    \begin{macrocode}
+\newif\ifekdl at forcenum
+\newif\ifekdl at nonum
 \ekvdefinekeys{lem}{
   code wit = \def\ekdlr at wit{#1},
   code source = \def\ekdlr at source{#1},
@@ -8081,6 +8802,8 @@
   code postwit = \def\ekdlr at postwit{#1},
   store type = \ekdlr at type,
   store sep = \ekdl at sep,
+  noval nonum = \ekdl at nonumtrue,
+  noval num = \ekdl at forcenumtrue,
   bool nolem = \ifekdl at nolem,
   bool nosep = \ifekdl at nosep,
   initial sep = \ekdsep
@@ -8113,8 +8836,9 @@
 %    \end{macrocode}
 % \end{macro}
 % \begin{macro}{\app at lang}
-% This macro is used internally by \cs{lem}, \cs{rdg} and \cs{note} to
-% set the language for apparatus entries.
+% \begin{macro}{\app at note@lang}
+% \cs{app at lang} is used internally by \cs{lem} and \cs{rdg} to set the
+% language for apparatus entries. \cs{note} uses \cs{\app at note@lang}.
 %    \begin{macrocode}
 \def\app at lang{%
   \ifekd at mapps
@@ -8123,8 +8847,16 @@
   \ekd at singleapp@lang
   \fi
 }
+\def\app at note@lang{%
+  \ifekd at mapps
+  \luadirect{tex.sprint(ekdosis.getappnotelang(\luastring{\ekdan at type}))}%
+  \else
+  \ekd at singleapp@note at lang
+  \fi
+}
 %    \end{macrocode}
 % \end{macro}
+% \end{macro}
 % \begin{macro}{\lem}
 % \cs{lem}\oarg{options}\marg{lemma text} inserts \meta{lemma text}
 % both in the edition text and in the apparatus criticus by default,
@@ -8137,7 +8869,10 @@
   \luadirect{ekdosis.dolnlab(\luastringN{#2})}%
   \null
   \bgroup%
+  \ekdl at forcenumfalse
+  \ekdl at nonumfalse
   \ekvset{lem}{#1}%
+  \ekd at test@lang
   \ifekd at mapps%
     \ifnum%
     \luadirect{tex.sprint(ekdosis.get_bagunits(\luastringO{\ekdan at type}))}
@@ -8157,7 +8892,7 @@
     \else%
     \ifsubsq at unit\unexpanded\expandafter{\ekd at unit@delim}\fi%
     \fi%
-    \current at ref}%\hskip .25em}%
+    \unless\ifekdl at nonum\current at ref\fi}%\hskip .25em}%
   \else%
   \ifbool{al at rlmode}{%
     \edef\lem at app{%
@@ -8168,7 +8903,7 @@
       \else%
       \ifsubsq at unit\unexpanded\expandafter{\ekd at unit@delim}\fi%
       \fi%
-      \current at ref%\hskip .25em
+      \unless\ifekdl at nonum\current at ref\fi%\hskip .25em
       \ifdefined\ekdlr at alt%
         \ifdefined\ekdlr at post%
           \space\unexpanded\expandafter{\ekdlr at post}\space\else\fi
@@ -8203,11 +8938,11 @@
       \else%
       \ifsubsq at unit\unexpanded\expandafter{\ekd at unit@delim}\fi%
       \fi%
-      \current at ref%\hskip .25em
+      \unless\ifekdl at nonum\current at ref\fi%\hskip .25em
       \ifdefined\ekdlr at alt%
         \ifdefined\ekdlr at pre%
           \space\unexpanded\expandafter{\ekdlr at pre}\space\else\fi
-        \ltx at ifpackageloaded{babel}%
+        \ifbool{ekd at lang@pkg}%
         {{\unexpanded\expandafter{\ekd at lemmastyle}%
             \noexpand\selectlanguage{\app at lang}%
             \unexpanded\expandafter{\ekdlr at alt}}}%
@@ -8218,7 +8953,7 @@
       \else
         \ifdefined\ekdlr at pre%
           \space\unexpanded\expandafter{\ekdlr at pre}\space\else\fi
-          \ltx at ifpackageloaded{babel}%
+          \ifbool{ekd at lang@pkg}%
           {{\unexpanded\expandafter{\ekd at lemmastyle}%
               \noexpand\selectlanguage{\app at lang}%
               \unexpanded{#2}}}{%
@@ -8257,6 +8992,7 @@
 \NewDocumentCommand{\rdg}{O{} m}{%
   \bgroup%
   \ekvset{rdg}{#1}%
+  \ekd at test@lang
   % \ifekdr at nordg\append at app{}\else% do we need \append at app{} here? If
   %                               % so, keep in mind \ifekd at mapps,
   %                               like so:
@@ -8298,7 +9034,7 @@
       \ifdefined\ekdlr at alt%
         \ifdefined\ekdlr at pre%
           \space\unexpanded\expandafter{\ekdlr at pre}\space\else\fi
-        \ltx at ifpackageloaded{babel}%
+        \ifbool{ekd at lang@pkg}%
         {{\unexpanded\expandafter{\ekd at readingstyle}%
             \noexpand\selectlanguage{\app at lang}%
             \unexpanded\expandafter{\ekdlr at alt}}}%
@@ -8309,7 +9045,7 @@
       \else
         \ifdefined\ekdlr at pre%
           \space\unexpanded\expandafter{\ekdlr at pre}\space\else\fi
-          \ltx at ifpackageloaded{babel}%
+          \ifbool{ekd at lang@pkg}%
           {{\unexpanded\expandafter{\ekd at readingstyle}%
               \noexpand\selectlanguage{\app at lang}\unexpanded{#2}}}{%
             {\unexpanded\expandafter{\ekd at readingstyle}\unexpanded{#2}}}%
@@ -8338,6 +9074,7 @@
 % Define keys to be used by the optional argument of \cs{note} when
 % this command is found outside \cs{app}:---
 %    \begin{macrocode}
+\newif\ifekdn at forcenum
 \ekvdefinekeys{note}{
   store type = \ekdan at type,
   store lem = \ekdn at lem,
@@ -8346,7 +9083,9 @@
   store sep = \ekdn at sep,
   bool nosep = \ifekdn at nosep,
   initial type = default,
-  initial sep = \ekdsep
+  initial sep = \ekdsep,
+  bool nonum = \ifekdn at nonum,
+  noval num = \ekdn at forcenumtrue
 }
 %    \end{macrocode}
 % \cs{note at noapp} is used internally when a \cs{note} command is found
@@ -8361,6 +9100,7 @@
   \leavevmode
   \bgroup%
   \ekvset{note}{#1}%
+  \ekd at test@lang
   \stepcounter{ekd at lab}%
   \zlabel{ekd:\theekd at lab}%
   \luadirect{ekdosis.storeabspg(
@@ -8391,7 +9131,7 @@
       \else%
         \ifsubsq at unit\unexpanded\expandafter{\ekd at unit@delim}\fi%
       \fi%
-      \current at ref@arg{\ekdn at labelb}{\ekdn at labele}%\hskip .25em
+      \unless\ifekdn at nonum\current at ref@arg{\ekdn at labelb}{\ekdn at labele}\fi%\hskip .25em
       \ifdefined\ekdn at lem%
       {\textdir TRT\unexpanded\expandafter{\ekd at lemmastyle}%
         \unexpanded\expandafter{\ekdn at lem}}%
@@ -8407,9 +9147,9 @@
       \else%
         \ifsubsq at unit\unexpanded\expandafter{\ekd at unit@delim}\fi%
       \fi%
-      \current at ref@arg{\ekdn at labelb}{\ekdn at labele}%\hskip .25em
+      \unless\ifekdn at nonum\current at ref@arg{\ekdn at labelb}{\ekdn at labele}\fi%\hskip .25em
       \ifdefined\ekdn at lem
-        \ltx at ifpackageloaded{babel}%
+        \ifbool{ekd at lang@pkg}%
         {{\unexpanded\expandafter{\ekd at lemmastyle}%
             \noexpand\selectlanguage{\app at lang}%
               \unexpanded\expandafter{\ekdn at lem}}}%
@@ -8418,8 +9158,8 @@
           \unless\ifekdn at nosep
           \unexpanded\expandafter{\ekdn at sep}\fi
           \else\fi%
-          \ltx at ifpackageloaded{babel}%
-          {{\noexpand\selectlanguage{\app at lang}\unexpanded{#2}}}{%
+          \ifbool{ekd at lang@pkg}%
+          {{\noexpand\selectlanguage{\app at note@lang}\unexpanded{#2}}}{%
             {\unexpanded{#2}}}}}%
   \ifekd at mapps%
   \unconditional at appin[\ekdan at type]{\note at contents}%
@@ -8466,25 +9206,25 @@
   \egroup%
 }
 \NewDocumentCommand{\ekd at note@star}{O{} m}{%
-  \if at pkg@parnotes
-    \bgroup%
-      \ekvset{ekd at note}{#1}%
-      \edef\note at contents{%
-        \ekvifdefinedNoVal{ekd at note}{pre}{}{%
-          \unexpanded\expandafter{\pre at value}}%
-        \unskip\noexpand\parnote{\unexpanded{#2}}%
-        \ekvifdefinedNoVal{ekd at note}{post}{}{%
-          \unexpanded\expandafter{\post at value}}%
-      }%
-      \append at app{\note at contents}%
-    \egroup%
+  \bgroup
+  \ekvset{ekd at note}{#1}%
+  \edef\note at contents{%
+    \ekvifdefinedNoVal{ekd at note}{pre}{}{%
+      \unexpanded\expandafter{\pre at value}}%
+    \if at pkg@parnotes
+      \unskip\noexpand\parnote{\unexpanded{#2}}%
+    \else
+      \unskip\noexpand\footnote{\unexpanded{#2}}%
+    \fi
+    \ekvifdefinedNoVal{ekd at note}{post}{}{%
+      \unexpanded\expandafter{\post at value}}%
+  }%
+  \ifekd at mapps
+    \append at app[\ekdan at type]{\note at contents}%
   \else
-    \ifekd at mapps%
-    \append at app[\ekdan at type]{\note at contents}%
-    \else%
     \append at app{\note at contents}%
-    \fi%
-  \fi%
+  \fi
+  \egroup
 }
 \NewDocumentCommand{\note at app}{s O{} +m}{%
   \ifbool{al at rlmode}{%
@@ -8781,6 +9521,116 @@
   }
 %    \end{macrocode}
 % \end{environment}
+% \paragraph{Headers and Footers}
+% \pkg{ekdosis} provides a mechanism of its own for headers and
+% footers as follows. Most of it is handled by \textsf{Lua}
+% functions.
+% \begin{macro}{\ekd at storemark}
+% \cs{ekd at storemark} is used internally by the |mark| optional
+% argument of \cs{ekddiv} described below to store marks to be
+% printed at specific places in headers or footers.
+%    \begin{macrocode}
+\NewDocumentCommand{\ekd at storemark}{m}{%
+  \stepcounter{ekd at lab}%
+  \label{ekd:\theekd at lab}%
+  \luadirect{ekdosis.storehfmark(
+    \luastring{\getpagerefnumber{ekd:\theekd at lab}},
+    \luastringN{#1})}%
+}
+%    \end{macrocode}
+% \end{macro}
+% \begin{macro}{\endmark}
+% \changes{v1.3}{2021/08/18}{prints the last-emitted mark of the
+% preceding page}
+% By default, \cs{ekdmark} described below prints the first mark
+% that is emitted on a given page and ignores the mark corresponding
+% to any portion of text that may be printed between the top of the
+% page and the point where the first mark is called. \cs{endmark} is
+% an argument-less command that can be used just at the end of that
+% portion of text to instruct \pkg{ekdosis} to print the last-emitted
+% mark of the preceding page instead of the first-emitted mark of the
+% current page.
+%    \begin{macrocode}
+\NewDocumentCommand{\endmark}{}{%
+  \stepcounter{ekd at lab}%
+  \label{ekd:\theekd at lab}%
+  \luadirect{ekdosis.storehfmark(
+    \luastring{\getpagerefnumber{ekd:\theekd at lab}},
+    "", "endmk")}%
+  \ifdefined\xspace\xspace\fi
+}
+%    \end{macrocode}
+% \end{macro}
+% \begin{macro}{\edkmark}
+% \changes{v1.3}{2021/08/18}{prints marks in headers or footers}
+% \cs{ekdmark} is an argument-less command called in commands used to
+% make headers and footers where the marks stored by means of the
+% |mark| optional argument of \cs{ekddiv} are to be printed.
+%    \begin{macrocode}
+\NewDocumentCommand{\ekdmark}{}{%
+  \luadirect{tex.sprint(ekdosis.gethfmark(\luastring{\thepage}))}%
+}
+%    \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ekdprintmark}
+% \changes{v1.3}{2021/08/18}{prints or removes the marks in headers
+% and footers} \cs{ekdprintmark}\marg{selector}\marg{signpost} The
+% signposts printed in headers and footers must be 
+% passed as second argument of \cs{ekdprintmark} so that \pkg{ekdosis}
+% can remove them on pages where printing them is not
+% desirable. \meta{selector} refers to three symbolic letters where
+% the first can be either |H| or |F|\===for \underLine{h}eader or
+% \underLine{f}ooter\===, the second |E| or |O|\===for \underLine{o}dd
+% or \underLine{e}ven\===and the third |L|, |C| or |R|\===for
+% \underLine{l}eft, \underLine{c}enter or \underLine{r}ight:---
+%    \begin{macrocode}
+\ekvdefinekeys{ekd at marks}{
+  choice mark = {HEL = \def\ekd at mk{HEL},
+    HEC = \def\ekd at mk{HEC},
+    HER = \def\ekd at mk{HER},
+    HOL = \def\ekd at mk{HOL},
+    HOC = \def\ekd at mk{HOC},
+    HOR = \def\ekd at mk{HOR},
+    FEL = \def\ekd at mk{FEL},
+    FEC = \def\ekd at mk{FEC},
+    FEL = \def\ekd at mk{FER},
+    FOL = \def\ekd at mk{FOL},
+    FOC = \def\ekd at mk{FOC},
+    FOL = \def\ekd at mk{FOR}},
+  unknown-choice mark = \PackageError{ekdosis}{unknown mark=#1}{`mark'
+    must be either `HEL', `HEC', `HER', `HOL', `HOC', `HOR', `FEL', 
+    \MessageBreak `FEC', `FER', `FOL', `FOC' or `FOR'.}
+}
+\NewDocumentCommand{\ekdprintmark}{m m}{%
+  \bgroup
+  \ekvset{ekd at marks}{mark = #1}%
+  \luadirect{tex.sprint(ekdosis.printmark(\luastringN{#2},
+    \luastringO{\ekd at mk}))}%
+  \egroup
+}
+%    \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ekdnofhmarks}
+% \changes{v1.3}{2021/08/18}{removes headers and footers on specific
+% pages} Once the signposts are marked with \cs{ekdprintmark},
+% \cs{ekdnohfmarks} has the same effect as the \LaTeX\ standard
+% command \cs{thispagestyle}|{empty}|.
+%    \begin{macrocode}
+\NewDocumentCommand{\ekdnohfmark}{}{%
+  \luadirect{ekdosis.nohfmark()}%
+}
+%    \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ekdresethfmarks}
+% \changes{v1.3}{2021/08/18}{marks headers and footers as printable}
+% \cs{ekdresethfmarks} can be used in rare cases when it is needed to
+% reset headers and footers to their original, viz.\ printable state.
+%    \begin{macrocode}
+\NewDocumentCommand{\ekdresethfmarks}{}{%
+  \luadirect{ekdosis.resethfmark()}%
+}
+%    \end{macrocode}
+% \end{macro}
 % \paragraph{Divisions of the Body}
 % \pkg{ekdosis} can convert \cs{book}, \cs{part}, \cs{chapter},
 % \cs{section}, \cs{subsec{\allowbreak}tion} and \cs{subsubsection}
@@ -8817,6 +9667,7 @@
   code head = \def\head at value{#1},
   code barehead = \def\barehead at value{#1},
   store depth = \depth at value,
+  code mark = \ekd at storemark{#1},
   choice toc = {book = \def\toc at value{book},
                 part = \def\toc at value{part},
                 chapter = \def\toc at value{chapter},
@@ -9071,6 +9922,9 @@
 local app = lpeg.Cs("app")
 local lemrdg = lpeg.Cs(lpeg.Cs("lem") + lpeg.Cs("rdg"))
 local note = lpeg.Cs("note")
+local inlem = lpeg.Cs{ "<lem" * ((1 - (lpeg.P"<lem" + lpeg.P"</lem>")) + lpeg.V(1))^0 * "</lem>" }
+local inanchor = lpeg.Cs{ "<anchor" * ((1 - (lpeg.P"<" + lpeg.P">")) + lpeg.V(1))^0 * ">" }
+local inopeningnote = lpeg.Cs{ "<note" * ((1 - (lpeg.P"<" + lpeg.P">")) + lpeg.V(1))^0 * ">" }
 local lnbrk = lpeg.Cs("\\\\")
 local poemline = lpeg.Cs(lnbrk * spcenc^-1 * lpeg.S("*!")^-1 * bsqbrackets^-1 * spcenc^-1)
 local poemlinebreak = lpeg.Cs(lnbrk * spcenc^-1 * lpeg.P(">") * bsqbrackets^-1 * spcenc^-1)
@@ -9127,7 +9981,7 @@
 
 local function checkxmlid(str)
    if string.find(str, "^[0-9]")
-      or string.find(str, "[:; ]")
+      or string.find(str, "[%{%}%[%]%(%):; ]")
    then
       return false
    else
@@ -9194,7 +10048,8 @@
 			    Collection,
 			    Idno,
 			    MsName,
-			    OrigDate)
+			    OrigDate,
+			    Locus)
    if xmlidfound(id)
    then
       tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
@@ -9230,6 +10085,10 @@
 	 listWit[indexwit].history = {}
 	 listWit[indexwit].history.origin = {origDate = OrigDate}
       end
+      if Locus ~= "" then
+	 listWit[indexwit].msContents = {}
+	 listWit[indexwit].msContents.msItemStruct = {locus = Locus}
+      end
    end
    return true
 end
@@ -9374,19 +10233,22 @@
    ctrl = str
    if opt == "tei" then
       for i = 1,#shorthands do
-	 str = string.gsub(str, shorthands[i].a, shorthands[i].c)
+	 local tempa = string.gsub(shorthands[i].a, "([%-%.%_])", "%%%1")
+	 str = string.gsub(str, tempa, shorthands[i].c)
       end
       for i = 1,#idsRend do
-	 str  = string.gsub(str, "(%f[%w])"..idsRend[i].xmlid.."(%,)",
+	 local tempb = string.gsub(idsRend[i].xmlid, "([%-%.%_])", "%%%1")
+	 str  = string.gsub(str, "(%f[%w%-%.%_])"..tempb.."(%,)",
 			    "%1#"..idsRend[i].xmlid.."%2")
-	 ctrl = string.gsub(ctrl, idsRend[i].xmlid.."%,", "")
+	 ctrl = string.gsub(ctrl, tempb.."%,", "")
       end
       str = string.gsub(str, "%,(%s-)([%#])", " %2")
       str = string.gsub(str, "%,$", "")
    else
       for i = 1,#idsRend do
-	 str  = string.gsub(str, idsRend[i].xmlid.."%,", idsRend[i].abbr)
-	 ctrl = string.gsub(ctrl, idsRend[i].xmlid.."%,", "")
+	 local tempc = string.gsub(idsRend[i].xmlid, "([%-%.%_])", "%%%1")
+	 str  = string.gsub(str, tempc.."%,", idsRend[i].abbr)
+	 ctrl = string.gsub(ctrl, tempc.."%,", "")
       end
    end
    -- if string.find(ctrl, "[A-Za-z0-9]")
@@ -9409,6 +10271,10 @@
    {a="marginpar", b="note", c=" place=\"margin\""},
    {a="footnote", b="note", c=" place=\"bottom\""},
    {a="enquote", b="quote", c=""},
+   {a="prname *", b="span",
+    c=" xml:lang=\"ar-Latn\" type=\"transliterated\""},
+   {a="prname", b="span",
+    c=" xml:lang=\"ar-Latn\" type=\"transliterated\" subtype=\"arabtex\""},
    {a="txtrans", b="s", c=" xml:lang=\"ar-Latn\" type=\"transliterated\""},
    {a="textbf", b="hi", c=" rend=\"bold\""},
    {a="textit", b="hi", c=" rend=\"italic\""},
@@ -9415,8 +10281,8 @@
    {a="textsc", b="hi", c=" rend=\"smallcaps\""},
    {a="textsf", b="hi", c=" rend=\"sf\""},
    {a="arbup", b="hi", c=" rend=\"sup\""},
-   {a="txarb", b="s", c=" xml:lang=\"arb\""},
-   {a="arb", b="foreign",
+   {a="txarb", b="foreign", c=" xml:lang=\"arb\""},
+   {a="arb", b="span",
     c=" xml:lang=\"ar-Latn\" type=\"transliterated\" subtype=\"arabtex\""}
 }
 
@@ -9428,15 +10294,23 @@
    {a="\\resetvlinenumber%s+", b=""},
    {a="\\resetlinenumber%s+%[(.-)%]", b=""},
    {a="\\resetlinenumber%s+", b=""},
+   {a="\\ekdresethfmarks%s+", b=""},
    {a="\\indentpattern%s+{(.-)}", b=""},
+   {a="\\ekdnohfmark%s+", b=""},
    {a="\\settowidth%s+{(.-)}{(.-)}", b=""},
    {a="\\poemlines%s+{(.-)}", b=""},
    {a="\\pagebreak%s+%[[1-4]%]", b=""},
    {a="\\pagebreak%s+", b=""},
+   {a="\\teidirect%s+(%b[]){(.-)}(%b{})", b="<%2 ekd at os%1ekd at cs>ekd at ob%3ekd at cb</%2>"},
+   {a="\\teidirect%s+{(.-)}(%b{})", b="<%1>ekd at ob%2ekd at cb</%1>"},
    {a="\\altrfont%s+", b=""},
-   {a="\\mbox%s+{(.-)}", b="%1"},
-   {a="\\LR%s+{(.-)}", b="%1"},
-   {a="\\RL%s+{(.-)}", b="%1"},
+   {a="\\endmark%s+", b=""},
+   {a="\\ekdpb%s+%*?%[(.-)%]{(.-)}", b=""},
+   {a="\\ekdpb%s+%*?{(.-)}", b=""},
+   {a="\\ekdpb%s+%*\\?", b=""},
+   {a="\\mbox%s+(%b{})", b="ekd at ob%1ekd at cb"},
+   {a="\\LR%s+(%b{})", b="ekd at ob%1ekd at cb"},
+   {a="\\RL%s+(%b{})", b="ekd at ob%1ekd at cb"},
    {a="\\%=%=%=%s?", b="—"},
    {a="\\%-%-%-%s?", b="—"},
    {a="\\%=%=%s?", b="–"},
@@ -9443,7 +10317,8 @@
    {a="\\%-%-%s?", b="–"},
    {a="\\%=%/%s?", b="‐"},
    {a="\\%-%/%s?", b="‐"},
-   {a="\\vin%s+", b=""}
+   {a="\\vin%s+", b=""},
+   {a="\\uc%s+(%b{})", b="ekd at ob%1ekd at cb"}
 }
 
 local envtotags = {
@@ -9487,8 +10362,12 @@
 
 function ekdosis.newpatttotag(pat, repl)
    pat = string.gsub(pat, "([%[%]])", "%%%1")
+   pat = string.gsub(pat, "%@b[1-9]", "(%%b{})")
+   pat = string.gsub(pat, "%@s[1-9]", "(%%b[])")
    pat = string.gsub(pat, "%#[1-9]", "(.-)")
    repl = string.gsub(repl, "%#([1-9])", "%%%1")
+   repl = string.gsub(repl, "%@b([1-9])", "ekd at ob%%%1ekd at cb")
+   repl = string.gsub(repl, "%@s([1-9])", "ekd at os%%%1ekd at cs")
    if isintable(texpatttotags, pat)
    then
       local index = get_a_index(pat, texpatttotags)
@@ -9581,6 +10460,22 @@
    return str
 end
 
+local function remove_extra_anchors(str)
+   str = gsub(str, lpeg.Cs("</note>") * inanchor * inopeningnote, function(enote, anchor, bnote)
+   			local id_one = string.gsub(anchor, "(%<anchor )(.-)(/%>)", "%2")
+   			id_one = string.sub(get_attr_value(id_one, "xml:id"), 2, -2)
+   			local id_two = string.match(bnote, "target%=.-right%((.-)%)")
+   			id_two = string.gsub(id_two, ".-right%((.-)%)", "%1")
+   			if id_one == id_two
+   			then
+   			   return string.format("%s%s", enote, bnote)
+   			else
+   			   return string.format("%s%s%s", enote, anchor, bnote)
+   			end
+   end)
+   return str
+end
+
 local function app_totei(str)
    str = gsub(str,
 	      dblbkslash *
@@ -9667,7 +10562,16 @@
 end
 
 local function relocate_notes(str)
-   str = string.gsub(str, "(%<lem.-%>.-)(%<note.->.-%<%/note%>)(.-%<%/lem%>)", "%1%3%2")
+   str = gsub(str, inlem, function(arg)
+		 local notes = {}
+		 for i in string.gmatch(arg, "%<note.-%>.-%<%/note%>")
+		 do
+		    table.insert(notes, i)
+		 end
+		 allnotes = table.concat(notes)
+		 arg = string.gsub(arg, "%<note.->.-%<%/note%>", "")
+		 return string.format("%s%s", arg, allnotes)
+   end)
    return str
 end
 
@@ -9786,6 +10690,10 @@
 local function texpatttotei(str)
    for i = 1,#texpatttotags do
       str = string.gsub(str, texpatttotags[i].a, texpatttotags[i].b)
+      str = string.gsub(str, "ekd at ob%{", "")
+      str = string.gsub(str, "%}ekd at cb", "")
+      str = string.gsub(str, "ekd at os%[", "")
+      str = string.gsub(str, "%]ekd at cs", "")
    end
    return str
 end
@@ -9811,7 +10719,8 @@
 				 "Please pick another id.}}")
 		 else
 		 end
-		 return string.format("%s <ref target=\"#%s\">%s</ref>", pre, body, post)
+		 return string.format("%s <bibl corresp=\"#%s\"><biblScope>%s</biblScope></bibl>",
+				      pre, body, post)
    end)
    str = gsub(str, lpeg.P("\\")
 		 * citecmds
@@ -9831,7 +10740,7 @@
 				 "Please pick another id.}}")
 		 else
 		 end
-		 return string.format("<ref target=\"#%s\">%s</ref>", body, post)
+		 return string.format("<bibl corresp=\"#%s\"><biblScope>%s</biblScope></bibl>", body, post)
    end)
    str = gsub(str, lpeg.P("\\")
 		 * citecmds
@@ -9987,6 +10896,86 @@
    return str
 end
 
+--headers and footers
+local hfmarks = {}
+
+function ekdosis.storehfmark(page, mk, opt)
+   if opt == "endmk"
+   then
+      local emark = hfmarks[#hfmarks].mark
+      table.insert(hfmarks, {a = page, mark = emark})
+   else
+      table.insert(hfmarks, {a = page, mark = mk})
+   end
+   return true
+end
+
+local printhfmarks = {
+   HEL = true,
+   HEC = true,
+   HER = true,
+   HOL = true,
+   HOC = true,
+   HOR = true,
+   FOL = true,
+   FOC = true,
+   FOR = true,
+   FEL = true,
+   FEC = true,
+   FER = true,
+}
+
+function ekdosis.nohfmark()
+   printhfmarks.HEL = false
+   printhfmarks.HEC = false
+   printhfmarks.HER = false
+   printhfmarks.HOL = false
+   printhfmarks.HOC = false
+   printhfmarks.HOR = false
+   printhfmarks.FOL = false
+   printhfmarks.FOC = false
+   printhfmarks.FOR = false
+   printhfmarks.FEL = false
+   printhfmarks.FEC = false
+   printhfmarks.FER = false
+end
+
+function ekdosis.resethfmark()
+   printhfmarks.HEL = true
+   printhfmarks.HEC = true
+   printhfmarks.HER = true
+   printhfmarks.HOL = true
+   printhfmarks.HOC = true
+   printhfmarks.HOR = true
+   printhfmarks.FOL = true
+   printhfmarks.FOC = true
+   printhfmarks.FOR = true
+   printhfmarks.FEL = true
+   printhfmarks.FEC = true
+   printhfmarks.FER = true
+end
+
+function ekdosis.printmark(str, mk)
+   if printhfmarks[mk]
+   then
+      return str
+   else
+      printhfmarks[mk] = true
+      return ""
+   end
+end
+
+function ekdosis.gethfmark(page)
+   local indexpage = get_a_index(page, hfmarks)
+   if hfmarks[indexpage] ~= nil
+   then
+      return hfmarks[indexpage].mark
+   else
+      return hfmarks[#hfmarks-1].mark or ""
+   end
+end
+
+-- divisions of the body text
 local divdepth = {
    book = 1,
    part = 2,
@@ -10195,7 +11184,7 @@
 
 local function close_ekddivs_in_between(str)
    local maxdepth = 1
-   for i in string.gmatch(str, "<div.-depth=\"(%d)\".->", "%1")
+   for i in string.gmatch(str, "<div.-[Dd]epth=\"(%d)\".->", "%1")
    do
       if tonumber(i) > tonumber(maxdepth)
       then
@@ -10220,9 +11209,9 @@
 			      do
 				 closedivs = closedivs.."</div>"
 				 firstdivindex = firstdivindex - 1
+				 bdivii = string.gsub(bdivii, "depth", "Depth")
 			      end
 			   end
-			   bdivii = string.gsub(bdivii, "depth", "Depth")
 			   return string.format("%s%s%s%s%s%s%s%s",
 						bdivi, ndivi, edivi, between,
 						closedivs, bdivii, ndivii, edivii)
@@ -10255,9 +11244,9 @@
 			      do
 			   	 closedivs = closedivs.."</div"..used_ndivs[firstdivindex].a..">"
 			   	 firstdivindex = firstdivindex - 1
+				 bdivii = string.gsub(bdivii, "div", "Div")
 			      end
 			   end
-			   bdivii = string.gsub(bdivii, "div", "Div")
 			   return string.format("%s%s%s%s%s%s%s%s",
 						bdivi, ndivi, edivi, between,
 						closedivs, bdivii, ndivii, edivii)
@@ -10276,6 +11265,7 @@
    str = xml_entities(str)
    str = texpatttotei(str)
    str = note_totei(str)
+   str = remove_extra_anchors(str)
    str = app_totei(str)
    str = rdgGrp_totei(str)
    str = lem_rdg_totei(str)
@@ -10384,7 +11374,14 @@
 	       end
 	       f:write("</handDesc>", "\n")
 	       f:write("</physDesc>", "\n")
-      else end
+	    else end
+	    if listWit[i].msContents ~= nil then
+	       f:write("<msContents>", "\n")
+	       f:write("<msItemStruct>", "\n")
+	       f:write("<locus>", textotei(listWit[i].msContents.msItemStruct.locus), "</locus>", "\n")
+	       f:write("</msItemStruct>", "\n")
+	       f:write("</msContents>", "\n")
+	    end
 	    if listWit[i].history ~= nil then
 	       f:write("<history>", "\n")
 	       f:write("<origin>", "\n")
@@ -10525,7 +11522,15 @@
    else
       date = ""
    end
-   return siglum.."&"..name.."&"..date
+   if listWit[indexwit].msContents ~= nil
+      and
+      listWit[indexwit].msContents.msItemStruct ~= nil
+   then
+      locus = listWit[indexwit].msContents.msItemStruct.locus
+   else
+      locus = ""
+   end
+   return siglum.."&"..name.." "..locus.."&"..date
 end
 -- end basic TeX Conspectus siglorum
 
@@ -10804,7 +11809,8 @@
 			      appbhook,
 			      appehook,
 			      applimit,
-			      applang)
+			      applang,
+			      appnotelang)
    if isintable(apparatuses, teitype)
    then
       tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
@@ -10819,7 +11825,8 @@
 				 bhook = appbhook,
 				 ehook = appehook,
 				 limit = applimit,
-				 lang = applang})
+				 lang = applang,
+				 notelang = appnotelang})
    end
    bagunits[teitype] = 1
    return true
@@ -10835,6 +11842,16 @@
    end
 end
 
+function ekdosis.getappnotelang(teitype)
+   i = get_a_index(teitype, apparatuses)
+   if apparatuses[i].notelang ~= ""
+   then
+      return apparatuses[i].notelang
+   else
+      return "\\languagename"
+   end
+end
+
 function ekdosis.getappdelim(str)
    for i = 1,#apparatuses
    do
@@ -10873,7 +11890,7 @@
 
 function ekdosis.limit_bagunits(teitype)
    local limit = tonumber(getapplimit(teitype))
-   if limit >= 10 and bagunits[teitype] > limit
+   if limit >= 10 and bagunits[teitype] >= limit
    then
       bagunits[teitype] = 2
       return "\\pagebreak"
@@ -11129,6 +12146,8 @@
 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
 local current_lemma = nil
@@ -11142,6 +12161,7 @@
 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)
@@ -11164,9 +12184,19 @@
    return prev_lnlab
 end
 
+function ekdosis.getprevprevlnlab()
+   return prev_prev_lnlab
+end
+
 function ekdosis.setnotelab(str)
    current_notelab = str
-   return "\\linelabel{" .. current_notelab .. "}"
+   if isfound(notelabs, current_notelab)
+   then
+      return ""
+   else
+      table.insert(notelabs, current_notelab)
+      return "\\linelabel{" .. current_notelab .. "}"
+   end
 end
 
 function ekdosis.getnotelab()
@@ -11182,8 +12212,12 @@
    return prev_notelab
 end
 
-local function remove_note(str)
-   str = gsub(str, dblbkslash * lpeg.P("note") * cmdargs, "")
+local cmdstorm = lpeg.P(lpeg.P("note")
+			   + lpeg.P("linelabel")
+			   + lpeg.P("index"))
+
+local function remove_from_app(str)
+   str = gsub(str, dblbkslash * cmdstorm * cmdargs, "")
    return str
 end
 
@@ -11197,7 +12231,7 @@
       "\\linelabel{" .. current_lnlab .. "-e}"
       ..
       "\\csname append at app\\endcsname{"
-      .. remove_note(str) .. "}"
+      .. remove_from_app(str) .. "}"
    else
    return "\\linelabel{" .. current_lnlab .. "-b}\\wordboundary{}"
       ..
@@ -11206,7 +12240,7 @@
       "\\linelabel{" .. current_lnlab .. "-e}"
       ..
       "\\csname append at app\\endcsname" .. "[" .. teitype ..  "]{"
-      .. remove_note(str) .. "}"
+      .. remove_from_app(str) .. "}"
    end
 end
 

Modified: trunk/Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.lua
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.lua	2021-08-18 20:47:09 UTC (rev 60270)
+++ trunk/Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.lua	2021-08-18 20:47:26 UTC (rev 60271)
@@ -51,6 +51,9 @@
 local app = lpeg.Cs("app")
 local lemrdg = lpeg.Cs(lpeg.Cs("lem") + lpeg.Cs("rdg"))
 local note = lpeg.Cs("note")
+local inlem = lpeg.Cs{ "<lem" * ((1 - (lpeg.P"<lem" + lpeg.P"</lem>")) + lpeg.V(1))^0 * "</lem>" }
+local inanchor = lpeg.Cs{ "<anchor" * ((1 - (lpeg.P"<" + lpeg.P">")) + lpeg.V(1))^0 * ">" }
+local inopeningnote = lpeg.Cs{ "<note" * ((1 - (lpeg.P"<" + lpeg.P">")) + lpeg.V(1))^0 * ">" }
 local lnbrk = lpeg.Cs("\\\\")
 local poemline = lpeg.Cs(lnbrk * spcenc^-1 * lpeg.S("*!")^-1 * bsqbrackets^-1 * spcenc^-1)
 local poemlinebreak = lpeg.Cs(lnbrk * spcenc^-1 * lpeg.P(">") * bsqbrackets^-1 * spcenc^-1)
@@ -107,7 +110,7 @@
 
 local function checkxmlid(str)
    if string.find(str, "^[0-9]")
-      or string.find(str, "[:; ]")
+      or string.find(str, "[%{%}%[%]%(%):; ]")
    then
       return false
    else
@@ -174,7 +177,8 @@
 			    Collection,
 			    Idno,
 			    MsName,
-			    OrigDate)
+			    OrigDate,
+			    Locus)
    if xmlidfound(id)
    then
       tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
@@ -210,6 +214,10 @@
 	 listWit[indexwit].history = {}
 	 listWit[indexwit].history.origin = {origDate = OrigDate}
       end
+      if Locus ~= "" then
+	 listWit[indexwit].msContents = {}
+	 listWit[indexwit].msContents.msItemStruct = {locus = Locus}
+      end
    end
    return true
 end
@@ -354,19 +362,22 @@
    ctrl = str
    if opt == "tei" then
       for i = 1,#shorthands do
-	 str = string.gsub(str, shorthands[i].a, shorthands[i].c)
+	 local tempa = string.gsub(shorthands[i].a, "([%-%.%_])", "%%%1")
+	 str = string.gsub(str, tempa, shorthands[i].c)
       end
       for i = 1,#idsRend do
-	 str  = string.gsub(str, "(%f[%w])"..idsRend[i].xmlid.."(%,)",
+	 local tempb = string.gsub(idsRend[i].xmlid, "([%-%.%_])", "%%%1")
+	 str  = string.gsub(str, "(%f[%w%-%.%_])"..tempb.."(%,)",
 			    "%1#"..idsRend[i].xmlid.."%2")
-	 ctrl = string.gsub(ctrl, idsRend[i].xmlid.."%,", "")
+	 ctrl = string.gsub(ctrl, tempb.."%,", "")
       end
       str = string.gsub(str, "%,(%s-)([%#])", " %2")
       str = string.gsub(str, "%,$", "")
    else
       for i = 1,#idsRend do
-	 str  = string.gsub(str, idsRend[i].xmlid.."%,", idsRend[i].abbr)
-	 ctrl = string.gsub(ctrl, idsRend[i].xmlid.."%,", "")
+	 local tempc = string.gsub(idsRend[i].xmlid, "([%-%.%_])", "%%%1")
+	 str  = string.gsub(str, tempc.."%,", idsRend[i].abbr)
+	 ctrl = string.gsub(ctrl, tempc.."%,", "")
       end
    end
    -- if string.find(ctrl, "[A-Za-z0-9]")
@@ -389,6 +400,10 @@
    {a="marginpar", b="note", c=" place=\"margin\""},
    {a="footnote", b="note", c=" place=\"bottom\""},
    {a="enquote", b="quote", c=""},
+   {a="prname *", b="span",
+    c=" xml:lang=\"ar-Latn\" type=\"transliterated\""},
+   {a="prname", b="span",
+    c=" xml:lang=\"ar-Latn\" type=\"transliterated\" subtype=\"arabtex\""},
    {a="txtrans", b="s", c=" xml:lang=\"ar-Latn\" type=\"transliterated\""},
    {a="textbf", b="hi", c=" rend=\"bold\""},
    {a="textit", b="hi", c=" rend=\"italic\""},
@@ -395,8 +410,8 @@
    {a="textsc", b="hi", c=" rend=\"smallcaps\""},
    {a="textsf", b="hi", c=" rend=\"sf\""},
    {a="arbup", b="hi", c=" rend=\"sup\""},
-   {a="txarb", b="s", c=" xml:lang=\"arb\""},
-   {a="arb", b="foreign",
+   {a="txarb", b="foreign", c=" xml:lang=\"arb\""},
+   {a="arb", b="span",
     c=" xml:lang=\"ar-Latn\" type=\"transliterated\" subtype=\"arabtex\""}
 }
 
@@ -408,15 +423,23 @@
    {a="\\resetvlinenumber%s+", b=""},
    {a="\\resetlinenumber%s+%[(.-)%]", b=""},
    {a="\\resetlinenumber%s+", b=""},
+   {a="\\ekdresethfmarks%s+", b=""},
    {a="\\indentpattern%s+{(.-)}", b=""},
+   {a="\\ekdnohfmark%s+", b=""},
    {a="\\settowidth%s+{(.-)}{(.-)}", b=""},
    {a="\\poemlines%s+{(.-)}", b=""},
    {a="\\pagebreak%s+%[[1-4]%]", b=""},
    {a="\\pagebreak%s+", b=""},
+   {a="\\teidirect%s+(%b[]){(.-)}(%b{})", b="<%2 ekd at os%1ekd at cs>ekd at ob%3ekd at cb</%2>"},
+   {a="\\teidirect%s+{(.-)}(%b{})", b="<%1>ekd at ob%2ekd at cb</%1>"},
    {a="\\altrfont%s+", b=""},
-   {a="\\mbox%s+{(.-)}", b="%1"},
-   {a="\\LR%s+{(.-)}", b="%1"},
-   {a="\\RL%s+{(.-)}", b="%1"},
+   {a="\\endmark%s+", b=""},
+   {a="\\ekdpb%s+%*?%[(.-)%]{(.-)}", b=""},
+   {a="\\ekdpb%s+%*?{(.-)}", b=""},
+   {a="\\ekdpb%s+%*\\?", b=""},
+   {a="\\mbox%s+(%b{})", b="ekd at ob%1ekd at cb"},
+   {a="\\LR%s+(%b{})", b="ekd at ob%1ekd at cb"},
+   {a="\\RL%s+(%b{})", b="ekd at ob%1ekd at cb"},
    {a="\\%=%=%=%s?", b="—"},
    {a="\\%-%-%-%s?", b="—"},
    {a="\\%=%=%s?", b="–"},
@@ -423,7 +446,8 @@
    {a="\\%-%-%s?", b="–"},
    {a="\\%=%/%s?", b="‐"},
    {a="\\%-%/%s?", b="‐"},
-   {a="\\vin%s+", b=""}
+   {a="\\vin%s+", b=""},
+   {a="\\uc%s+(%b{})", b="ekd at ob%1ekd at cb"}
 }
 
 local envtotags = {
@@ -467,8 +491,12 @@
 
 function ekdosis.newpatttotag(pat, repl)
    pat = string.gsub(pat, "([%[%]])", "%%%1")
+   pat = string.gsub(pat, "%@b[1-9]", "(%%b{})")
+   pat = string.gsub(pat, "%@s[1-9]", "(%%b[])")
    pat = string.gsub(pat, "%#[1-9]", "(.-)")
    repl = string.gsub(repl, "%#([1-9])", "%%%1")
+   repl = string.gsub(repl, "%@b([1-9])", "ekd at ob%%%1ekd at cb")
+   repl = string.gsub(repl, "%@s([1-9])", "ekd at os%%%1ekd at cs")
    if isintable(texpatttotags, pat)
    then
       local index = get_a_index(pat, texpatttotags)
@@ -561,6 +589,22 @@
    return str
 end
 
+local function remove_extra_anchors(str)
+   str = gsub(str, lpeg.Cs("</note>") * inanchor * inopeningnote, function(enote, anchor, bnote)
+   			local id_one = string.gsub(anchor, "(%<anchor )(.-)(/%>)", "%2")
+   			id_one = string.sub(get_attr_value(id_one, "xml:id"), 2, -2)
+   			local id_two = string.match(bnote, "target%=.-right%((.-)%)")
+   			id_two = string.gsub(id_two, ".-right%((.-)%)", "%1")
+   			if id_one == id_two
+   			then
+   			   return string.format("%s%s", enote, bnote)
+   			else
+   			   return string.format("%s%s%s", enote, anchor, bnote)
+   			end
+   end)
+   return str
+end
+
 local function app_totei(str)
    str = gsub(str,
 	      dblbkslash *
@@ -647,7 +691,16 @@
 end
 
 local function relocate_notes(str)
-   str = string.gsub(str, "(%<lem.-%>.-)(%<note.->.-%<%/note%>)(.-%<%/lem%>)", "%1%3%2")
+   str = gsub(str, inlem, function(arg)
+		 local notes = {}
+		 for i in string.gmatch(arg, "%<note.-%>.-%<%/note%>")
+		 do
+		    table.insert(notes, i)
+		 end
+		 allnotes = table.concat(notes)
+		 arg = string.gsub(arg, "%<note.->.-%<%/note%>", "")
+		 return string.format("%s%s", arg, allnotes)
+   end)
    return str
 end
 
@@ -766,6 +819,10 @@
 local function texpatttotei(str)
    for i = 1,#texpatttotags do
       str = string.gsub(str, texpatttotags[i].a, texpatttotags[i].b)
+      str = string.gsub(str, "ekd at ob%{", "")
+      str = string.gsub(str, "%}ekd at cb", "")
+      str = string.gsub(str, "ekd at os%[", "")
+      str = string.gsub(str, "%]ekd at cs", "")
    end
    return str
 end
@@ -791,7 +848,8 @@
 				 "Please pick another id.}}")
 		 else
 		 end
-		 return string.format("%s <ref target=\"#%s\">%s</ref>", pre, body, post)
+		 return string.format("%s <bibl corresp=\"#%s\"><biblScope>%s</biblScope></bibl>",
+				      pre, body, post)
    end)
    str = gsub(str, lpeg.P("\\")
 		 * citecmds
@@ -811,7 +869,7 @@
 				 "Please pick another id.}}")
 		 else
 		 end
-		 return string.format("<ref target=\"#%s\">%s</ref>", body, post)
+		 return string.format("<bibl corresp=\"#%s\"><biblScope>%s</biblScope></bibl>", body, post)
    end)
    str = gsub(str, lpeg.P("\\")
 		 * citecmds
@@ -967,6 +1025,86 @@
    return str
 end
 
+--headers and footers
+local hfmarks = {}
+
+function ekdosis.storehfmark(page, mk, opt)
+   if opt == "endmk"
+   then
+      local emark = hfmarks[#hfmarks].mark
+      table.insert(hfmarks, {a = page, mark = emark})
+   else
+      table.insert(hfmarks, {a = page, mark = mk})
+   end
+   return true
+end
+
+local printhfmarks = {
+   HEL = true,
+   HEC = true,
+   HER = true,
+   HOL = true,
+   HOC = true,
+   HOR = true,
+   FOL = true,
+   FOC = true,
+   FOR = true,
+   FEL = true,
+   FEC = true,
+   FER = true,
+}
+
+function ekdosis.nohfmark()
+   printhfmarks.HEL = false
+   printhfmarks.HEC = false
+   printhfmarks.HER = false
+   printhfmarks.HOL = false
+   printhfmarks.HOC = false
+   printhfmarks.HOR = false
+   printhfmarks.FOL = false
+   printhfmarks.FOC = false
+   printhfmarks.FOR = false
+   printhfmarks.FEL = false
+   printhfmarks.FEC = false
+   printhfmarks.FER = false
+end
+
+function ekdosis.resethfmark()
+   printhfmarks.HEL = true
+   printhfmarks.HEC = true
+   printhfmarks.HER = true
+   printhfmarks.HOL = true
+   printhfmarks.HOC = true
+   printhfmarks.HOR = true
+   printhfmarks.FOL = true
+   printhfmarks.FOC = true
+   printhfmarks.FOR = true
+   printhfmarks.FEL = true
+   printhfmarks.FEC = true
+   printhfmarks.FER = true
+end
+
+function ekdosis.printmark(str, mk)
+   if printhfmarks[mk]
+   then
+      return str
+   else
+      printhfmarks[mk] = true
+      return ""
+   end
+end
+
+function ekdosis.gethfmark(page)
+   local indexpage = get_a_index(page, hfmarks)
+   if hfmarks[indexpage] ~= nil
+   then
+      return hfmarks[indexpage].mark
+   else
+      return hfmarks[#hfmarks-1].mark or ""
+   end
+end
+
+-- divisions of the body text
 local divdepth = {
    book = 1,
    part = 2,
@@ -1175,7 +1313,7 @@
 
 local function close_ekddivs_in_between(str)
    local maxdepth = 1
-   for i in string.gmatch(str, "<div.-depth=\"(%d)\".->", "%1")
+   for i in string.gmatch(str, "<div.-[Dd]epth=\"(%d)\".->", "%1")
    do
       if tonumber(i) > tonumber(maxdepth)
       then
@@ -1200,9 +1338,9 @@
 			      do
 				 closedivs = closedivs.."</div>"
 				 firstdivindex = firstdivindex - 1
+				 bdivii = string.gsub(bdivii, "depth", "Depth")
 			      end
 			   end
-			   bdivii = string.gsub(bdivii, "depth", "Depth")
 			   return string.format("%s%s%s%s%s%s%s%s",
 						bdivi, ndivi, edivi, between,
 						closedivs, bdivii, ndivii, edivii)
@@ -1235,9 +1373,9 @@
 			      do
 			   	 closedivs = closedivs.."</div"..used_ndivs[firstdivindex].a..">"
 			   	 firstdivindex = firstdivindex - 1
+				 bdivii = string.gsub(bdivii, "div", "Div")
 			      end
 			   end
-			   bdivii = string.gsub(bdivii, "div", "Div")
 			   return string.format("%s%s%s%s%s%s%s%s",
 						bdivi, ndivi, edivi, between,
 						closedivs, bdivii, ndivii, edivii)
@@ -1256,6 +1394,7 @@
    str = xml_entities(str)
    str = texpatttotei(str)
    str = note_totei(str)
+   str = remove_extra_anchors(str)
    str = app_totei(str)
    str = rdgGrp_totei(str)
    str = lem_rdg_totei(str)
@@ -1364,7 +1503,14 @@
 	       end
 	       f:write("</handDesc>", "\n")
 	       f:write("</physDesc>", "\n")
-      else end
+	    else end
+	    if listWit[i].msContents ~= nil then
+	       f:write("<msContents>", "\n")
+	       f:write("<msItemStruct>", "\n")
+	       f:write("<locus>", textotei(listWit[i].msContents.msItemStruct.locus), "</locus>", "\n")
+	       f:write("</msItemStruct>", "\n")
+	       f:write("</msContents>", "\n")
+	    end
 	    if listWit[i].history ~= nil then
 	       f:write("<history>", "\n")
 	       f:write("<origin>", "\n")
@@ -1505,7 +1651,15 @@
    else
       date = ""
    end
-   return siglum.."&"..name.."&"..date
+   if listWit[indexwit].msContents ~= nil
+      and
+      listWit[indexwit].msContents.msItemStruct ~= nil
+   then
+      locus = listWit[indexwit].msContents.msItemStruct.locus
+   else
+      locus = ""
+   end
+   return siglum.."&"..name.." "..locus.."&"..date
 end
 -- end basic TeX Conspectus siglorum
 
@@ -1784,7 +1938,8 @@
 			      appbhook,
 			      appehook,
 			      applimit,
-			      applang)
+			      applang,
+			      appnotelang)
    if isintable(apparatuses, teitype)
    then
       tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
@@ -1799,7 +1954,8 @@
 				 bhook = appbhook,
 				 ehook = appehook,
 				 limit = applimit,
-				 lang = applang})
+				 lang = applang,
+				 notelang = appnotelang})
    end
    bagunits[teitype] = 1
    return true
@@ -1815,6 +1971,16 @@
    end
 end
 
+function ekdosis.getappnotelang(teitype)
+   i = get_a_index(teitype, apparatuses)
+   if apparatuses[i].notelang ~= ""
+   then
+      return apparatuses[i].notelang
+   else
+      return "\\languagename"
+   end
+end
+
 function ekdosis.getappdelim(str)
    for i = 1,#apparatuses
    do
@@ -1853,7 +2019,7 @@
 
 function ekdosis.limit_bagunits(teitype)
    local limit = tonumber(getapplimit(teitype))
-   if limit >= 10 and bagunits[teitype] > limit
+   if limit >= 10 and bagunits[teitype] >= limit
    then
       bagunits[teitype] = 2
       return "\\pagebreak"
@@ -2109,6 +2275,8 @@
 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
 local current_lemma = nil
@@ -2122,6 +2290,7 @@
 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)
@@ -2144,9 +2313,19 @@
    return prev_lnlab
 end
 
+function ekdosis.getprevprevlnlab()
+   return prev_prev_lnlab
+end
+
 function ekdosis.setnotelab(str)
    current_notelab = str
-   return "\\linelabel{" .. current_notelab .. "}"
+   if isfound(notelabs, current_notelab)
+   then
+      return ""
+   else
+      table.insert(notelabs, current_notelab)
+      return "\\linelabel{" .. current_notelab .. "}"
+   end
 end
 
 function ekdosis.getnotelab()
@@ -2162,8 +2341,12 @@
    return prev_notelab
 end
 
-local function remove_note(str)
-   str = gsub(str, dblbkslash * lpeg.P("note") * cmdargs, "")
+local cmdstorm = lpeg.P(lpeg.P("note")
+			   + lpeg.P("linelabel")
+			   + lpeg.P("index"))
+
+local function remove_from_app(str)
+   str = gsub(str, dblbkslash * cmdstorm * cmdargs, "")
    return str
 end
 
@@ -2177,7 +2360,7 @@
       "\\linelabel{" .. current_lnlab .. "-e}"
       ..
       "\\csname append at app\\endcsname{"
-      .. remove_note(str) .. "}"
+      .. remove_from_app(str) .. "}"
    else
    return "\\linelabel{" .. current_lnlab .. "-b}\\wordboundary{}"
       ..
@@ -2186,7 +2369,7 @@
       "\\linelabel{" .. current_lnlab .. "-e}"
       ..
       "\\csname append at app\\endcsname" .. "[" .. teitype ..  "]{"
-      .. remove_note(str) .. "}"
+      .. remove_from_app(str) .. "}"
    end
 end
 

Modified: trunk/Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.sty	2021-08-18 20:47:09 UTC (rev 60270)
+++ trunk/Master/texmf-dist/tex/lualatex/ekdosis/ekdosis.sty	2021-08-18 20:47:26 UTC (rev 60271)
@@ -41,7 +41,7 @@
 %% Running "make inst" installs the files in the user's TeX tree.
 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
 \ProvidesPackage{ekdosis}
-    [2021/04/02 v1.2 Typesetting TEI xml-compliant critical editions]
+    [2021/08/18 v1.3 Typesetting TEI xml-compliant critical editions]
 \RequirePackage{iftex}
 \RequireLuaTeX
 \RequirePackage{expkv-opt}
@@ -48,6 +48,8 @@
 \RequirePackage{expkv-def}
 \newif\if at pkg@float
 \newif\if at pkg@footins
+\newif\if at pkg@keyfloat
+\newif\if at pkg@fitfloat
 \newif\if at pkg@ekddivs
 \newif\if at parnotesroman
 \newif\if at pkg@parnotes
@@ -55,7 +57,9 @@
 \newif\if at pkg@poetry at verse
 \ekvdefinekeys{ekdosis}{
   choice layout = {float = {\@pkg at floattrue},
-    footins = {\@pkg at floatfalse\@pkg at footinstrue}},
+    footins = {\@pkg at floatfalse\@pkg at footinstrue},
+    keyfloat = {\@pkg at floatfalse\@pkg at keyfloattrue},
+    fitfloat = {\@pkg at floatfalse\@pkg at fitfloattrue}},
   initial layout = float,
   unknown-choice layout = \PackageError{ekdosis}{unknown
     layout=#1}{`layout' must be either `float' or `footins'.},
@@ -95,7 +99,21 @@
 \RequirePackage{paracol}
 \RequirePackage{etoolbox}
 \RequirePackage{lineno}
-\RequirePackage{keyfloat}
+\if at pkg@float
+  \RequirePackage{trivfloat}
+  \trivfloat{ekdapparatus}
+\fi
+\if at pkg@keyfloat
+  \RequirePackage{keyfloat}
+  \def\ekd at keyparopts#1{%
+    \def\ekd at insert@keyparapp{%
+      \keyparbox[!b]{#1}{\ekd at insert@apparatus}}}
+  \ekd at keyparopts{}
+\fi
+\if at pkg@fitfloat
+  \RequirePackage{tcolorbox}
+  \tcbuselibrary{fitting,skins}
+\fi
 \RequirePackage{refcount}
 \RequirePackage{zref-user}
 \RequirePackage{zref-abspage}
@@ -112,6 +130,15 @@
 \AtEndDocument{
   \luadirect{ekdosis.closestream()}
 }
+\ekvdefinekeys{ekd at setup}{
+  bool showpagebreaks = \ifekd at showpb,
+  store spbmk = \ekd at spbmk,
+  initial spbmk = spb,
+  store hpbmk = \ekd at hpbmk,
+  initial hpbmk = hpb,
+}
+\NewDocumentCommand{\ekdsetup}{m}{\ekvset{ekd at setup}{#1}}
+\@onlypreamble\ekdsetup
 \ekvdefinekeys{ekd at hooks}{
   store appfontsize = \ekd at appfontsize,
   store refnumstyle = \ekd at refnumstyle,
@@ -118,6 +145,17 @@
   store postrefnum = \ekd at postrefnum,
   store lemmastyle = \ekd at lemmastyle,
   store readingstyle = \ekd at readingstyle,
+  code keyparopts = \if at pkg@keyfloat\ekd at keyparopts{#1}\fi,
+  dimen appheight = \ekd at app@height,
+  initial appheight = .5\textheight,
+  choice fitalgorithm = {fontsize = \def\ekd at fit@algorithm{fontsize},
+    hybrid = \def\ekd at fit@algorithm{hybrid},
+    areasize = \def\ekd at fit@algorithm{areasize},
+    squeeze = \def\ekd at fit@algorithm{squeeze}},
+  initial fitalgorithm = fontsize,
+  unknown-choice fitalgorithm = \PackageError{ekdosis}{unknown
+    fitalgorithm=#1}{`fitalgorithm' must be either `fontsize',
+    `hybrid', `areasize' or `squeeze'.},
   code initialrule = \def\ekd at initial@rule{#1\NLS},
   default initialrule = \rule{0.4\columnwidth}{0.4pt},
   noval noinitialrule = \undef\ekd at initial@rule,
@@ -135,7 +173,8 @@
   store collection = \collection at value,
   store idno = \idno at value,
   store msName = \msName at value,
-  store origDate = \origDate at value
+  store origDate = \origDate at value,
+  store locus = \locus at value
 }
 \NewDocumentCommand{\DeclareWitness}{m m m O{}}{%
   \bgroup
@@ -150,7 +189,8 @@
       \luastringO{\collection at value},
       \luastringO{\idno at value},
       \luastringO{\msName at value},
-      \luastringO{\origDate at value})}
+      \luastringO{\origDate at value},
+      \luastringO{\locus at value})}
     \egroup
   }
 \@onlypreamble\DeclareWitness
@@ -214,6 +254,7 @@
     \luastringN{#2},
     \luastringN{#3})}
 }
+\NewDocumentCommand{\teidirect}{O{}mm}{\ignorespaces}
 \NewDocumentCommand{\EnvtoTEI}{s m m O{}}{%
   \IfBooleanTF{#1}{%
   \luadirect{ekdosis.newenvtotag(\luastringN{#2},
@@ -237,6 +278,11 @@
   \luadirect{ekdosis.addxmlbibresource(\luastringN{#1})}
 }
 \@onlypreamble\AddxmlBibResource
+\newif\ifekd at lang@pkg
+\NewDocumentCommand{\ekd at test@lang}{}{%
+  \ltx at ifpackageloaded{babel}{\ekd at lang@pkgtrue}{}%
+  \ltx at ifpackageloaded{polyglossia}{\ekd at lang@pkgtrue}{}%
+}
 \newif\ifekd at mapps
 \ekvdefinekeys{ekd at newapp}{
   choice direction = {LR = \def\direction at val{LR},
@@ -251,6 +297,7 @@
   store ehook = \ehook at val,
   store maxentries = \limit at val,
   store lang = \lang at val,
+  store notelang = \notelang at val,
   initial direction = LR,
   initial delim = {},
   initial ehook = {\csname ekd at end@apparatus\endcsname}
@@ -270,7 +317,8 @@
     \luastringO{\bhook at val},
     \luastringO{\ehook at val},
     \luastringO{\limit at val},
-    \luastringO{\lang at val}
+    \luastringO{\lang at val},
+    \luastringO{\notelang at val}
     )}
   \egroup
 }
@@ -279,27 +327,40 @@
   \luadirect{ekdosis.addto_bagunits(\luastringO{#1}, \luastringN{#2})}%
   \ignorespaces
 }
-\NewDocumentCommand{\ekdpb}{o m}{%
-  \def\@tmpoarg{#1}%
-  \def\@tmpmarg{#2}%
-  \luadirect{ekdosis.dolnlab(\luastringN{#2})}%
-  \linelabel{\luadirect{tex.sprint(ekdosis.getlnlab())}}%
-  \def\tmp at ln{%
-    \getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}}}%
-  \def\tmp at pg{%
-    \getpagerefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}}}%
-  \IfNoValueTF{#1}
-  {\ifnum
-    \pdf at strcmp{\@tmpmarg}{\tmp at ln} = 0
-    \pagebreak
-    \fi}
-  {\ifnum
-    \pdf at strcmp{\@tmpoarg}{\tmp at pg} = 0
-    \ifnum
-    \pdf at strcmp{\@tmpmarg}{\tmp at ln} = 0
-    \pagebreak
-    \fi
-    \fi
+\newcounter{ekd at pb}
+\globalcounter{ekd at pb}
+\NewDocumentCommand{\ekdpb}{s o m}{%
+  \IfBooleanTF{#1}
+  {\ifekd at showpb\marginpar{\ekd at hpbmk}\fi
+    \pagebreak}
+  {%
+    \def\@tmpoarg{#2}%
+    \def\@tmpmarg{#3}%
+    \stepcounter{ekd at pb}%
+    \linelabel{ekdpb:\theekd at pb}%
+    \def\tmp at ln{%
+      \getrefnumber{ekdpb:\theekd at pb}}%
+    \def\tmp at pg{%
+      \getpagerefnumber{ekdpb:\theekd at pb}}%
+    \IfNoValueTF{#2}
+    {\ifnum
+      \pdf at strcmp{\@tmpmarg}{\tmp at ln} = 0
+      \ifekd at showpb\marginpar{\ekd at spbmk}\fi
+      \pagebreak
+      \else
+      \ifekd at showpb\marginpar{[\ekd at spbmk]}\fi
+      \fi}
+    {\ifnum
+      \pdf at strcmp{\@tmpoarg}{\tmp at pg} = 0
+      \ifnum
+      \pdf at strcmp{\@tmpmarg}{\tmp at ln} = 0
+      \ifekd at showpb\marginpar{\ekd at spbmk}\fi
+      \pagebreak
+      \else
+      \ifekd at showpb\marginpar{[\ekd at spbmk]}\fi
+      \fi
+      \fi
+    }%
   }\ignorespaces
 }
 \newbool{do at app}
@@ -306,6 +367,7 @@
 \newif\ifekd at state
 \newif\ifekd at isinapp
 \newif\ifekd at isinlem
+\newif\ifekd at appinapp
 \providebool{al at rlmode}
 \@ifpackageloaded{arabluatex}{}{%
   \def\setRL{\booltrue{al at rlmode}\pardir TRT\textdir TRT}
@@ -356,7 +418,11 @@
   initial rule = \rule{0.4\columnwidth}{0.4pt},
   noval norule = \def\ekd at default@rule{\mbox{}},
   store lang = \ekd at singleapp@lang,
-  initial lang = \ltx at ifpackageloaded{babel}{\languagename}{}
+  initial lang = \ltx at ifpackageloaded{babel}{\languagename}{%
+    \ltx at ifpackageloaded{polyglossia}{\languagename}{}},
+  store notelang = \ekd at singleapp@note at lang,
+  initial notelang = \ltx at ifpackageloaded{babel}{\languagename}{%
+  \ltx at ifpackageloaded{polyglossia}{\languagename}{}}
 }
 \NewDocumentCommand{\SetApparatus}{m}{
   \ekvset{default at app}{#1}
@@ -369,6 +435,8 @@
 \NewDocumentCommand{\SetUnitDelimiter}{m}{\def\ekd at unit@delim{#1}}
 \NewDocumentCommand{\SetApparatusLanguage}{m}{%
   \def\ekd at singleapp@lang{#1}}
+\NewDocumentCommand{\SetApparatusNoteLanguage}{m}{%
+  \def\ekd at singleapp@note at lang{#1}}
 \newif\iffootnoterule
 \footnoteruletrue
 \let\dflt at footnoterule\footnoterule
@@ -401,6 +469,35 @@
 \newif\ifsubsq at unit
 \subsq at unittrue
 \newif\ifekd at inside@app
+\if at pkg@fitfloat
+  \newtcboxfit{\ekd at fitapp}{%
+    blankest,
+    fit basedim = \f at size pt,
+    fit fontsize macros,
+    fit height from=0pt to \ekd at app@height,
+    fit algorithm = \ekd at fit@algorithm,
+    float=!b}
+\fi
+\long\def\ekd at insert@apparatus{%
+  \unless\ifekd at mapps
+  \ifrtl at app\pardir TRT\leavevmode\textdir TRT\else
+    \pardir TLT\leavevmode\textdir TLT\fi
+  \fi
+  \if at pkg@parnotes
+   \if at parnotesroman
+    \renewcommand*{\theparnotemark}{\roman{parnotemark}}\fi
+   \parnoteclear\fi
+  \ekd at inside@apptrue
+  \ekd at appfontsize
+  \ifekd at mapps
+    \ifdefined\ekd at initial@rule
+      \ekd at initial@rule
+    \fi
+  \fi
+  \apparatus\unless\ifekd at mapps\ekd at end@apparatus\fi
+  \ekd at inside@appfalse
+  \if at pkg@parnotes\parnotes\parnotereset\fi
+}%
 \def\add@@apparatus{%
   \if at pkg@parnotes\parnotes\else\fi
   \if at pkg@footins
@@ -428,27 +525,16 @@
   \egroup
   \fi
   \if at pkg@float
-  \keyparbox[!b]{}{%
-    \unless\ifekd at mapps
-      \ifrtl at app\pardir TRT\leavevmode\textdir TRT\else
-        \pardir TLT\leavevmode\textdir TLT\fi
-    \fi
-    \if at pkg@parnotes
-    \if at parnotesroman
-    \renewcommand*{\theparnotemark}{\roman{parnotemark}}\else\fi
-    \parnoteclear\else\fi
-    \ekd at inside@apptrue
-    \ekd at appfontsize
-    \ifekd at mapps
-      \ifdefined\ekd at initial@rule
-        \ekd at initial@rule
-      \fi
-    \fi
-    \apparatus\unless\ifekd at mapps\ekd at end@apparatus\fi
-    \ekd at inside@appfalse
-    \if at pkg@parnotes\parnotes\parnotereset\else\fi
-  }%
+  \begin{ekdapparatus}[!b]%
+    \ekd at insert@apparatus
+  \end{ekdapparatus}%
   \fi
+  \if at pkg@keyfloat
+    \ekd at insert@keyparapp
+  \fi
+  \if at pkg@fitfloat
+    \ekd at fitapp{\ekd at insert@apparatus}%
+  \fi
 }
 \def\add at apparatus{%
   \test at apparatus%
@@ -498,7 +584,9 @@
 \newif\ifekd at elidednumbers
 \ekvdefinekeys{ekd at lineation}{
   choice lineation = {page = \ekd at pagelineationtrue,
-    document = \ekd at pagelineationfalse},
+    document = \ekd at pagelineationfalse,
+    none = \ekd at pagelineationtrue
+           \renewcommand\thelinenumber{}},
   unknown-choice lineation = \PackageError{ekdosis}{unknown
     lineation=#1}{`lineation' must be either `page' or `document'.},
   choice vlineation = {page = \ekd at pagevlineationtrue,
@@ -544,14 +632,16 @@
   \leavevmode
   \begingroup
   \ekvset{appnote}{#1}%
-  \ekd at isinapptrue%
+  \ifekd at isinapp\ekd at appinapptrue\fi
+  \ekd at isinapptrue
   \stepcounter{ekd at lab}%
   \zlabel{ekd:\theekd at lab}%
   \luadirect{ekdosis.storeabspg(
     \luastring{\zref at extract{ekd:\theekd at lab}{abspage}})}%
-  \ifekd at state\add at apparatus\fi%
+  \ifekd at state\add at apparatus\fi
   \luadirect{tex.sprint(ekdosis.removesp(\luastringN{#2}))}%
-  \ekd at isinappfalse%
+  \ekd at isinappfalse
+  \ekd at appinappfalse
   \endgroup}
 \def\current at ref@arg#1#2{{%\textdir TLT%
     \unexpanded\expandafter{\ekd at refnumstyle}%
@@ -604,10 +694,16 @@
     \fi
     \fi%
     \else
-    \LRnum{\getrefnumber{#1}}--%
-    \LRnum{\getpagerefnumber{#2}}.%
-    \LRnum{\getrefnumber{#2}}\unexpanded\expandafter{\ekd at postrefnum}% issue pg and ln nos
+    \ifboolexpr{bool {ekd at pagelineation} or bool {ekd at pagevlineation}}
+      {\LRnum{\getrefnumber{#1}}--%
+      \LRnum{\getpagerefnumber{#2}}.%
+      \LRnum{\getrefnumber{#2}}\unexpanded\expandafter{\ekd at postrefnum}}% issue pg and ln nos
+      {\LRnum{\getrefnumber{#1}}--%
+      \LRnum{\getrefnumber{#2}}\unexpanded\expandafter{\ekd at postrefnum}}% issue the nos
     \fi%
+    \ifekdn at forcenum
+      \LRnum{\getrefnumber{#1}}\unexpanded\expandafter{\ekd at postrefnum}% force the no
+    \fi
   }%
 }
 \def\current at ref{{%\textdir TLT%
@@ -632,6 +728,28 @@
       {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevlnlab())}-b}}
       =
       0
+    %%%begin
+    \ifnum%
+    \pdf at strcmp{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}%
+    {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevlnlab())}-e}}
+    =
+    0
+    \ifekd at appinapp
+    \ifnum%
+    \pdf at 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 at postrefnum}% issue the no
+    \fi
+    \fi
+    \else
+    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
+      \unexpanded\expandafter{\ekd at postrefnum}% issue the no
+    \fi
+    %%% end
       \else
       \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
         \unexpanded\expandafter{\ekd at postrefnum}% issue the no
@@ -646,10 +764,32 @@
     {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevlnlab())}-b}}
     =
     0
+    %%%begin
+    \ifnum%
+    \pdf at strcmp{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}%
+    {\getrefnumber{\luadirect{tex.sprint(ekdosis.getprevlnlab())}-e}}
+    =
+    0
+    \ifekd at appinapp
+    \ifnum%
+    \pdf at 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 at postrefnum}% issue the no
     \fi
+    \fi
+    \else
+    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
+      \unexpanded\expandafter{\ekd at postrefnum}% issue the no
+    \fi
+    %%% end
+    \else
+    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
+      \unexpanded\expandafter{\ekd at postrefnum}% issue the no
+    \fi
     %
     \else
     \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
@@ -670,13 +810,23 @@
     \fi
     \fi%
     \else
-    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}--%
-    \LRnum{\getpagerefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}.%
-    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}%
-      \unexpanded\expandafter{\ekd at postrefnum}% issue pg and ln nos
+    \ifboolexpr{bool {ekd at pagelineation} or bool {ekd at pagevlineation}}
+      {\LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}--%
+      \LRnum{\getpagerefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}.%
+      \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}%
+        \unexpanded\expandafter{\ekd at postrefnum}}% issue pg and ln nos
+      {\LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}--%
+      \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}%
+        \unexpanded\expandafter{\ekd at postrefnum}}% issue the nos
     \fi%
+    \ifekdl at forcenum
+    \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
+      \unexpanded\expandafter{\ekd at postrefnum}% force the no
+    \fi
   }%
 }
+\newif\ifekdl at forcenum
+\newif\ifekdl at nonum
 \ekvdefinekeys{lem}{
   code wit = \def\ekdlr at wit{#1},
   code source = \def\ekdlr at source{#1},
@@ -688,6 +838,8 @@
   code postwit = \def\ekdlr at postwit{#1},
   store type = \ekdlr at type,
   store sep = \ekdl at sep,
+  noval nonum = \ekdl at nonumtrue,
+  noval num = \ekdl at forcenumtrue,
   bool nolem = \ifekdl at nolem,
   bool nosep = \ifekdl at nosep,
   initial sep = \ekdsep
@@ -714,12 +866,22 @@
   \ekd at singleapp@lang
   \fi
 }
+\def\app at note@lang{%
+  \ifekd at mapps
+  \luadirect{tex.sprint(ekdosis.getappnotelang(\luastring{\ekdan at type}))}%
+  \else
+  \ekd at singleapp@note at lang
+  \fi
+}
 \NewDocumentCommand{\lem}{O{} m}{%
   \ekd at isinlemtrue%
   \luadirect{ekdosis.dolnlab(\luastringN{#2})}%
   \null
   \bgroup%
+  \ekdl at forcenumfalse
+  \ekdl at nonumfalse
   \ekvset{lem}{#1}%
+  \ekd at test@lang
   \ifekd at mapps%
     \ifnum%
     \luadirect{tex.sprint(ekdosis.get_bagunits(\luastringO{\ekdan at type}))}
@@ -739,7 +901,7 @@
     \else%
     \ifsubsq at unit\unexpanded\expandafter{\ekd at unit@delim}\fi%
     \fi%
-    \current at ref}%\hskip .25em}%
+    \unless\ifekdl at nonum\current at ref\fi}%\hskip .25em}%
   \else%
   \ifbool{al at rlmode}{%
     \edef\lem at app{%
@@ -750,7 +912,7 @@
       \else%
       \ifsubsq at unit\unexpanded\expandafter{\ekd at unit@delim}\fi%
       \fi%
-      \current at ref%\hskip .25em
+      \unless\ifekdl at nonum\current at ref\fi%\hskip .25em
       \ifdefined\ekdlr at alt%
         \ifdefined\ekdlr at post%
           \space\unexpanded\expandafter{\ekdlr at post}\space\else\fi
@@ -785,11 +947,11 @@
       \else%
       \ifsubsq at unit\unexpanded\expandafter{\ekd at unit@delim}\fi%
       \fi%
-      \current at ref%\hskip .25em
+      \unless\ifekdl at nonum\current at ref\fi%\hskip .25em
       \ifdefined\ekdlr at alt%
         \ifdefined\ekdlr at pre%
           \space\unexpanded\expandafter{\ekdlr at pre}\space\else\fi
-        \ltx at ifpackageloaded{babel}%
+        \ifbool{ekd at lang@pkg}%
         {{\unexpanded\expandafter{\ekd at lemmastyle}%
             \noexpand\selectlanguage{\app at lang}%
             \unexpanded\expandafter{\ekdlr at alt}}}%
@@ -800,7 +962,7 @@
       \else
         \ifdefined\ekdlr at pre%
           \space\unexpanded\expandafter{\ekdlr at pre}\space\else\fi
-          \ltx at ifpackageloaded{babel}%
+          \ifbool{ekd at lang@pkg}%
           {{\unexpanded\expandafter{\ekd at lemmastyle}%
               \noexpand\selectlanguage{\app at lang}%
               \unexpanded{#2}}}{%
@@ -831,6 +993,7 @@
 \NewDocumentCommand{\rdg}{O{} m}{%
   \bgroup%
   \ekvset{rdg}{#1}%
+  \ekd at test@lang
   % \ifekdr at nordg\append at app{}\else% do we need \append at app{} here? If
   %                               % so, keep in mind \ifekd at mapps,
   %                               like so:
@@ -872,7 +1035,7 @@
       \ifdefined\ekdlr at alt%
         \ifdefined\ekdlr at pre%
           \space\unexpanded\expandafter{\ekdlr at pre}\space\else\fi
-        \ltx at ifpackageloaded{babel}%
+        \ifbool{ekd at lang@pkg}%
         {{\unexpanded\expandafter{\ekd at readingstyle}%
             \noexpand\selectlanguage{\app at lang}%
             \unexpanded\expandafter{\ekdlr at alt}}}%
@@ -883,7 +1046,7 @@
       \else
         \ifdefined\ekdlr at pre%
           \space\unexpanded\expandafter{\ekdlr at pre}\space\else\fi
-          \ltx at ifpackageloaded{babel}%
+          \ifbool{ekd at lang@pkg}%
           {{\unexpanded\expandafter{\ekd at readingstyle}%
               \noexpand\selectlanguage{\app at lang}\unexpanded{#2}}}{%
             {\unexpanded\expandafter{\ekd at readingstyle}\unexpanded{#2}}}%
@@ -907,6 +1070,7 @@
   \fi%
   \egroup%
 }
+\newif\ifekdn at forcenum
 \ekvdefinekeys{note}{
   store type = \ekdan at type,
   store lem = \ekdn at lem,
@@ -915,12 +1079,15 @@
   store sep = \ekdn at sep,
   bool nosep = \ifekdn at nosep,
   initial type = default,
-  initial sep = \ekdsep
+  initial sep = \ekdsep,
+  bool nonum = \ifekdn at nonum,
+  noval num = \ekdn at forcenumtrue
 }
 \NewDocumentCommand{\note at noapp}{O{} +m}{%
   \leavevmode
   \bgroup%
   \ekvset{note}{#1}%
+  \ekd at test@lang
   \stepcounter{ekd at lab}%
   \zlabel{ekd:\theekd at lab}%
   \luadirect{ekdosis.storeabspg(
@@ -951,7 +1118,7 @@
       \else%
         \ifsubsq at unit\unexpanded\expandafter{\ekd at unit@delim}\fi%
       \fi%
-      \current at ref@arg{\ekdn at labelb}{\ekdn at labele}%\hskip .25em
+      \unless\ifekdn at nonum\current at ref@arg{\ekdn at labelb}{\ekdn at labele}\fi%\hskip .25em
       \ifdefined\ekdn at lem%
       {\textdir TRT\unexpanded\expandafter{\ekd at lemmastyle}%
         \unexpanded\expandafter{\ekdn at lem}}%
@@ -967,9 +1134,9 @@
       \else%
         \ifsubsq at unit\unexpanded\expandafter{\ekd at unit@delim}\fi%
       \fi%
-      \current at ref@arg{\ekdn at labelb}{\ekdn at labele}%\hskip .25em
+      \unless\ifekdn at nonum\current at ref@arg{\ekdn at labelb}{\ekdn at labele}\fi%\hskip .25em
       \ifdefined\ekdn at lem
-        \ltx at ifpackageloaded{babel}%
+        \ifbool{ekd at lang@pkg}%
         {{\unexpanded\expandafter{\ekd at lemmastyle}%
             \noexpand\selectlanguage{\app at lang}%
               \unexpanded\expandafter{\ekdn at lem}}}%
@@ -978,8 +1145,8 @@
           \unless\ifekdn at nosep
           \unexpanded\expandafter{\ekdn at sep}\fi
           \else\fi%
-          \ltx at ifpackageloaded{babel}%
-          {{\noexpand\selectlanguage{\app at lang}\unexpanded{#2}}}{%
+          \ifbool{ekd at lang@pkg}%
+          {{\noexpand\selectlanguage{\app at note@lang}\unexpanded{#2}}}{%
             {\unexpanded{#2}}}}}%
   \ifekd at mapps%
   \unconditional at appin[\ekdan at type]{\note at contents}%
@@ -1013,25 +1180,25 @@
   \egroup%
 }
 \NewDocumentCommand{\ekd at note@star}{O{} m}{%
-  \if at pkg@parnotes
-    \bgroup%
-      \ekvset{ekd at note}{#1}%
-      \edef\note at contents{%
-        \ekvifdefinedNoVal{ekd at note}{pre}{}{%
-          \unexpanded\expandafter{\pre at value}}%
-        \unskip\noexpand\parnote{\unexpanded{#2}}%
-        \ekvifdefinedNoVal{ekd at note}{post}{}{%
-          \unexpanded\expandafter{\post at value}}%
-      }%
-      \append at app{\note at contents}%
-    \egroup%
+  \bgroup
+  \ekvset{ekd at note}{#1}%
+  \edef\note at contents{%
+    \ekvifdefinedNoVal{ekd at note}{pre}{}{%
+      \unexpanded\expandafter{\pre at value}}%
+    \if at pkg@parnotes
+      \unskip\noexpand\parnote{\unexpanded{#2}}%
+    \else
+      \unskip\noexpand\footnote{\unexpanded{#2}}%
+    \fi
+    \ekvifdefinedNoVal{ekd at note}{post}{}{%
+      \unexpanded\expandafter{\post at value}}%
+  }%
+  \ifekd at mapps
+    \append at app[\ekdan at type]{\note at contents}%
   \else
-    \ifekd at mapps%
-    \append at app[\ekdan at type]{\note at contents}%
-    \else%
     \append at app{\note at contents}%
-    \fi%
-  \fi%
+  \fi
+  \egroup
 }
 \NewDocumentCommand{\note at app}{s O{} +m}{%
   \ifbool{al at rlmode}{%
@@ -1207,6 +1374,54 @@
   \luadirect{ekdosis.flushenvdata()}
   \luadirect{ekdosis.flushcolnums()}
   }
+\NewDocumentCommand{\ekd at storemark}{m}{%
+  \stepcounter{ekd at lab}%
+  \label{ekd:\theekd at lab}%
+  \luadirect{ekdosis.storehfmark(
+    \luastring{\getpagerefnumber{ekd:\theekd at lab}},
+    \luastringN{#1})}%
+}
+\NewDocumentCommand{\endmark}{}{%
+  \stepcounter{ekd at lab}%
+  \label{ekd:\theekd at lab}%
+  \luadirect{ekdosis.storehfmark(
+    \luastring{\getpagerefnumber{ekd:\theekd at lab}},
+    "", "endmk")}%
+  \ifdefined\xspace\xspace\fi
+}
+\NewDocumentCommand{\ekdmark}{}{%
+  \luadirect{tex.sprint(ekdosis.gethfmark(\luastring{\thepage}))}%
+}
+\ekvdefinekeys{ekd at marks}{
+  choice mark = {HEL = \def\ekd at mk{HEL},
+    HEC = \def\ekd at mk{HEC},
+    HER = \def\ekd at mk{HER},
+    HOL = \def\ekd at mk{HOL},
+    HOC = \def\ekd at mk{HOC},
+    HOR = \def\ekd at mk{HOR},
+    FEL = \def\ekd at mk{FEL},
+    FEC = \def\ekd at mk{FEC},
+    FEL = \def\ekd at mk{FER},
+    FOL = \def\ekd at mk{FOL},
+    FOC = \def\ekd at mk{FOC},
+    FOL = \def\ekd at mk{FOR}},
+  unknown-choice mark = \PackageError{ekdosis}{unknown mark=#1}{`mark'
+    must be either `HEL', `HEC', `HER', `HOL', `HOC', `HOR', `FEL',
+    \MessageBreak `FEC', `FER', `FOL', `FOC' or `FOR'.}
+}
+\NewDocumentCommand{\ekdprintmark}{m m}{%
+  \bgroup
+  \ekvset{ekd at marks}{mark = #1}%
+  \luadirect{tex.sprint(ekdosis.printmark(\luastringN{#2},
+    \luastringO{\ekd at mk}))}%
+  \egroup
+}
+\NewDocumentCommand{\ekdnohfmark}{}{%
+  \luadirect{ekdosis.nohfmark()}%
+}
+\NewDocumentCommand{\ekdresethfmarks}{}{%
+  \luadirect{ekdosis.resethfmark()}%
+}
 \NewDocumentCommand{\MkBodyDivs}{mmmmmm}{
   \luadirect{ekdosis.mkdivdepths(
     \luastringN{#1},
@@ -1224,6 +1439,7 @@
   code head = \def\head at value{#1},
   code barehead = \def\barehead at value{#1},
   store depth = \depth at value,
+  code mark = \ekd at storemark{#1},
   choice toc = {book = \def\toc at value{book},
                 part = \def\toc at value{part},
                 chapter = \def\toc at value{chapter},



More information about the tex-live-commits mailing list.