diff options
author | Robert Alessi <alessi@robertalessi.net> | 2020-04-01 10:40:35 +0200 |
---|---|---|
committer | Robert Alessi <alessi@robertalessi.net> | 2020-04-01 10:40:35 +0200 |
commit | 4be162d76a3e4fa3450f685f0d2291dbb34a7bdd (patch) | |
tree | 11dad6ffb1648599e7e5447ee5ebb7bbb9d640c6 | |
parent | 18cfe1b93e2dd8e9ad7c563e4ccee78a2302767c (diff) | |
download | ekdosis-4be162d76a3e4fa3450f685f0d2291dbb34a7bdd.tar.gz |
make \resetlinenumber work over columns which don't cross page boudaries
-rw-r--r-- | ekdosis.dtx | 71 |
1 files changed, 56 insertions, 15 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx index 0c3b6e2..aadd46b 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx | |||
@@ -1046,9 +1046,8 @@ Running "make install" installs the files in the local TeX tree. | |||
1046 | \luadirect{tex.sprint(ekdosis.appout())}} | 1046 | \luadirect{tex.sprint(ekdosis.appout())}} |
1047 | \NewDocumentCommand{\test@apparatus}{}{% | 1047 | \NewDocumentCommand{\test@apparatus}{}{% |
1048 | \luadirect{tex.sprint(ekdosis.testapparatus())}} | 1048 | \luadirect{tex.sprint(ekdosis.testapparatus())}} |
1049 | \NewDocumentCommand{\EkdosisStart}{}{% | 1049 | \NewDocumentCommand{\ekd@storecol}{}{% |
1050 | \stepcounter{ekd@lab}% | 1050 | \luadirect{ekdosis.storecurcol(\luastring{\thecolumn})}% |
1051 | \zlabel{ekd:\theekd@lab}% | ||
1052 | } | 1051 | } |
1053 | \NewDocumentCommand{\EkdosisOn}{}{% | 1052 | \NewDocumentCommand{\EkdosisOn}{}{% |
1054 | \ekd@statetrue} | 1053 | \ekd@statetrue} |
@@ -1064,11 +1063,12 @@ Running "make install" installs the files in the local TeX tree. | |||
1064 | } | 1063 | } |
1065 | \NewDocumentEnvironment{ekdosis}{+b}{% | 1064 | \NewDocumentEnvironment{ekdosis}{+b}{% |
1066 | \ekd@setlineno% | 1065 | \ekd@setlineno% |
1067 | \begin{runninglinenumbers} | 1066 | \runninglinenumbers |
1068 | \EkdosisStart | 1067 | % \EkdosisStart |
1069 | \EkdosisOn#1}{% | 1068 | \EkdosisOn#1}{% |
1070 | \EkdosisOff | 1069 | \EkdosisOff |
1071 | \end{runninglinenumbers}% | 1070 | % \EkdosisStop |
1071 | \endrunninglinenumbers% | ||
1072 | \iftei@export\luadirect{ekdosis.exporttei(\luastringN{#1})}\else\fi} | 1072 | \iftei@export\luadirect{ekdosis.exporttei(\luastringN{#1})}\else\fi} |
1073 | % \end{macrocode} | 1073 | % \end{macrocode} |
1074 | % Alignment:--- | 1074 | % Alignment:--- |
@@ -1088,13 +1088,28 @@ Running "make install" installs the files in the local TeX tree. | |||
1088 | \NewDocumentCommand{\SetEkdosisAlignment}{m}{ | 1088 | \NewDocumentCommand{\SetEkdosisAlignment}{m}{ |
1089 | \ekvset{ekd@align}{#1} | 1089 | \ekvset{ekd@align}{#1} |
1090 | } | 1090 | } |
1091 | \NewDocumentCommand{\ekd@storecol}{m}{% | ||
1092 | \luadirect{ekdosis.storecurcol(\luastring{\thecolumn})}% | ||
1093 | } | ||
1094 | \patchcmd{\pcol@nextpage}{% | 1091 | \patchcmd{\pcol@nextpage}{% |
1095 | \endgroup}{% | 1092 | \endgroup}{% |
1096 | \ifekd@pagelineation\resetlinenumber\fi | 1093 | \ifekd@pagelineation\resetlinenumber\fi |
1097 | \endgroup}{}{} | 1094 | \endgroup}{}{} |
1095 | \NewDocumentCommand{\EkdosisStart}{}{% | ||
1096 | \ekd@storecol% | ||
1097 | \stepcounter{ekd@lab}% | ||
1098 | \zlabel{ekd:\theekd@lab}% | ||
1099 | \luadirect{% | ||
1100 | ekdosis.storeabspg(\luastring{\zref@extract{ekd:\theekd@lab}{abspage}}, | ||
1101 | "pg_i")}% | ||
1102 | \ifekd@pagelineation | ||
1103 | \luadirect{tex.sprint(ekdosis.checkresetlineno())} | ||
1104 | \fi | ||
1105 | } | ||
1106 | \NewDocumentCommand{\EkdosisStop}{}{% | ||
1107 | \stepcounter{ekd@lab}% | ||
1108 | \zlabel{ekd:\theekd@lab}% | ||
1109 | \luadirect{% | ||
1110 | ekdosis.storeabspg(\luastring{\zref@extract{ekd:\theekd@lab}{abspage}}, | ||
1111 | "pg_ii")}% | ||
1112 | } | ||
1098 | \NewDocumentEnvironment{alignment}{O{}} | 1113 | \NewDocumentEnvironment{alignment}{O{}} |
1099 | {% | 1114 | {% |
1100 | \ekvset{ekd@align}{#1}% | 1115 | \ekvset{ekd@align}{#1}% |
@@ -1913,17 +1928,38 @@ function ekdosis.closestream() | |||
1913 | end | 1928 | end |
1914 | 1929 | ||
1915 | local cur_abs_pg = 0 | 1930 | local cur_abs_pg = 0 |
1931 | local pg_i = nil | ||
1932 | local pg_ii = nil | ||
1933 | local prevcol = nil | ||
1934 | local curcol = "x" | ||
1935 | |||
1936 | local check_resetlineno = {} | ||
1916 | 1937 | ||
1917 | function ekdosis.update_abspg(n) | 1938 | function ekdosis.update_abspg(n) |
1918 | cur_abs_pg = n | 1939 | cur_abs_pg = n |
1919 | return true | 1940 | return true |
1920 | end | 1941 | end |
1921 | 1942 | ||
1922 | function ekdosis.storeabspg(n) | 1943 | function ekdosis.storeabspg(n, pg) |
1944 | if pg == "pg_i" then | ||
1945 | pg_i = n | ||
1946 | elseif pg == "pg_ii" then | ||
1947 | pg_ii = n | ||
1948 | table.insert(check_resetlineno, curcol.."-"..pg_ii) | ||
1949 | end | ||
1923 | cur_abs_pg = n | 1950 | cur_abs_pg = n |
1924 | return true | 1951 | return true |
1925 | end | 1952 | end |
1926 | 1953 | ||
1954 | function ekdosis.checkresetlineno() | ||
1955 | if isfound(check_resetlineno, curcol.."-"..pg_i) | ||
1956 | then | ||
1957 | return "" | ||
1958 | else | ||
1959 | return "\\resetlinenumber" | ||
1960 | end | ||
1961 | end | ||
1962 | |||
1927 | -- | 1963 | -- |
1928 | -- Build environments to be aligned | 1964 | -- Build environments to be aligned |
1929 | -- | 1965 | -- |
@@ -1955,8 +1991,9 @@ function ekdosis.mkenvdata(str, opt) | |||
1955 | end | 1991 | end |
1956 | end | 1992 | end |
1957 | 1993 | ||
1958 | local prevcol = nil | 1994 | -- the following two variables are already set above |
1959 | local curcol = "x" | 1995 | -- local prevcol = nil |
1996 | -- local curcol = "x" | ||
1960 | 1997 | ||
1961 | function ekdosis.storecurcol(n) | 1998 | function ekdosis.storecurcol(n) |
1962 | curcol = n | 1999 | curcol = n |
@@ -1983,18 +2020,22 @@ function ekdosis.mkenv() | |||
1983 | then | 2020 | then |
1984 | table.insert(environments, "\\NewDocumentEnvironment{".. aligned_texts[i].text.."}{}" | 2021 | table.insert(environments, "\\NewDocumentEnvironment{".. aligned_texts[i].text.."}{}" |
1985 | .."{\\begin{nthcolumn}{".. aligned_texts[i].column.."}" | 2022 | .."{\\begin{nthcolumn}{".. aligned_texts[i].column.."}" |
1986 | .."\\begin{ekdosis}" | 2023 | .."\\EkdosisStart" |
1987 | .."\\csname ekd@storecol\\endcsname{\\thecolumn}" | 2024 | .."\\begin{ekdosis}" |
2025 | -- .."\\csname ekd@storecol\\endcsname" | ||
1988 | .."\\par" | 2026 | .."\\par" |
1989 | .."}{\\end{ekdosis}" | 2027 | .."}{\\end{ekdosis}" |
2028 | .."\\EkdosisStop" | ||
1990 | .."\\end{nthcolumn}}") | 2029 | .."\\end{nthcolumn}}") |
1991 | table.insert(environments, "\\NewDocumentEnvironment{".. aligned_texts[i].text.."*}{}" | 2030 | table.insert(environments, "\\NewDocumentEnvironment{".. aligned_texts[i].text.."*}{}" |
1992 | .."{\\begin{nthcolumn*}{".. aligned_texts[i].column.."}[]" | 2031 | .."{\\begin{nthcolumn*}{".. aligned_texts[i].column.."}[]" |
2032 | .."\\EkdosisStart" | ||
1993 | .."\\begin{ekdosis}" | 2033 | .."\\begin{ekdosis}" |
1994 | .."\\csname ekd@storecol\\endcsname{\\thecolumn}" | 2034 | -- .."\\csname ekd@storecol\\endcsname" |
1995 | .."\\par" | 2035 | .."\\par" |
1996 | .."}{" | 2036 | .."}{" |
1997 | .."\\end{ekdosis}" | 2037 | .."\\end{ekdosis}" |
2038 | .."\\EkdosisStop" | ||
1998 | .."\\end{nthcolumn*}}") | 2039 | .."\\end{nthcolumn*}}") |
1999 | else | 2040 | else |
2000 | table.insert(environments, "\\NewDocumentEnvironment{".. aligned_texts[i].text.."}{}" | 2041 | table.insert(environments, "\\NewDocumentEnvironment{".. aligned_texts[i].text.."}{}" |