From 43b431b5fe4c1bc012d095356b5fa2e9615840e7 Mon Sep 17 00:00:00 2001
From: Robert Alessi <alessi@robertalessi.net>
Date: Fri, 27 Mar 2020 15:52:26 +0100
Subject: testapparatus needs to retrieve both column and page numbers at the
 same time

---
 ekdosis.dtx | 42 +++++++++++++++++-------------------------
 1 file changed, 17 insertions(+), 25 deletions(-)

(limited to 'ekdosis.dtx')

diff --git a/ekdosis.dtx b/ekdosis.dtx
index e7d3660..ac4ae66 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -147,9 +147,9 @@ Running "make install" installs the files in the local TeX tree.
 \usepackage{hyperxmp}
 \usepackage{uri}
 \usepackage[numbered]{hypdoc}
-\hypersetup{unicode=true, colorlinks, allcolors=cinnamon,
-  linktocpage=true, pdfauthor={Robert Alessi}, pdftitle={The
-    ekdosis package}, pdfcontactemail={alessi@robertalessi.net},
+\hypersetup{unicode=true, colorlinks, allcolors=cinnamon, keeppdfinfo,
+  linktocpage=true, pdfauthor={Robert Alessi}, pdftitle={The ekdosis
+    package}, pdfcontactemail={alessi@robertalessi.net},
   pdfcontacturl={http://www.robertalessi.net/ekdosis},
   pdfcopyright={Copyright (C) 2018 Robert Alessi
     <alessi@robertalessi.net>. This document is licensed under the
@@ -1083,6 +1083,7 @@ Running "make install" installs the files in the local TeX tree.
   store texts = \texts@value,
   store apparatus = \apparatus@value,
   bool paired = \ifekd@paired,
+  bool pagelineation = \ifekd@pagelineation,
   initial tcols = 2,
   initial lcols = 1,
   initial texts = edition;translation,
@@ -1094,6 +1095,10 @@ Running "make install" installs the files in the local TeX tree.
 \NewDocumentCommand{\ekd@storecol}{m}{%
   \luadirect{ekdosis.storecurcol(\luastring{\thecolumn})}%
 }
+\patchcmd{\pcol@nextpage}{%
+  \endgroup}{%
+  \ifekd@pagelineation\resetlinenumber\fi
+  \endgroup}{}{}
 \NewDocumentEnvironment{alignment}{O{}}
 {%
   \ekvset{align}{#1}%
@@ -1104,6 +1109,7 @@ Running "make install" installs the files in the local TeX tree.
   \luadirect{ekdosis.mkenvdata(
     \luastring{\apparatus@value}, "apparatus"
     )}
+  \setrunninglinenumbers
   \luadirect{tex.sprint(ekdosis.mkenv())}
   \ifekd@paired
   \begin{paracol}[\lcols@num]{\tcols@num}
@@ -2204,34 +2210,20 @@ function ekdosis.appin_out(str, nl)
    return true
 end
 
+local curcol_curabspg = {}
+
 function ekdosis.testapparatus()
    if curcol ~= "x"
    then
-      if prevcol == nil or curcol ~= prevcol
+      if isfound(curcol_curabspg, curcol.."-"..cur_abs_pg)
       then
-   	 prevcol = curcol
-   	 if next(apparatuses) ~= nil then
-   	    reset_bagunits()
-   	 end
-   	 return "\\booltrue{do@app}"
+	 return "\\boolfalse{do@app}"
       else
-   	 -- return "\\boolfalse{do@app}"
-	 if tonumber(pg_ii) < tonumber(pg_i)
-	 or tonumber(pg_ii) < tonumber(cur_abs_pg) then
-	    pg_i = cur_abs_pg
-	    if next(apparatuses) ~= nil then
-	       reset_bagunits()
-	    end
-	    return "\\booltrue{do@app}"
-	 elseif tonumber(pg_ii) == tonumber(pg_i) then
-	    return "\\boolfalse{do@app}"
-	 elseif tonumber(pg_ii) > tonumber(pg_i) then
-	    pg_i = cur_abs_pg
-	    if next(apparatuses) ~= nil then
-	       reset_bagunits()
-	    end
-	    return "\\booltrue{do@app}"
+	 table.insert(curcol_curabspg, curcol.."-"..cur_abs_pg)
+	 if next(apparatuses) ~= nil then
+	    reset_bagunits()
 	 end
+	 return "\\booltrue{do@app}"
       end
    else
       if tonumber(pg_ii) < tonumber(pg_i)
-- 
cgit v1.2.3

