From f9aaa3838259336c024df786fbd42d9b19e5c13e Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Fri, 6 Mar 2015 22:25:59 +0000
Subject: eledmac (6mar15)

git-svn-id: svn://tug.org/texlive/trunk@36447 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/tex/latex/eledmac/eledpar.sty | 168 +++++++++++++++++++++---
 1 file changed, 153 insertions(+), 15 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/eledmac/eledpar.sty')

diff --git a/Master/texmf-dist/tex/latex/eledmac/eledpar.sty b/Master/texmf-dist/tex/latex/eledmac/eledpar.sty
index 33e6f5951d2..bb531abde26 100644
--- a/Master/texmf-dist/tex/latex/eledmac/eledpar.sty
+++ b/Master/texmf-dist/tex/latex/eledmac/eledpar.sty
@@ -23,8 +23,9 @@
 %%   This work consists of the files listed in the README file.
 %% 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{eledpar}[2015/02/27 v1.12.1 eledmac extension for parallel texts]%
+\ProvidesPackage{eledpar}[2015/03/06 v1.13.0 eledmac extension for parallel texts]%
 
+\RequirePackage{xspace}%
 \newif\ifshiftedpstarts
 \let\shiftedversestrue\shiftedpstartstrue
 \let\shiftedversesfalse\shiftedpstartsfalse
@@ -33,9 +34,6 @@
 \DeclareOption{parledgroup}{\parledgrouptrue}
 \DeclareOption{widthliketwocolumns}{\widthliketwocolumnstrue}%
 \ProcessOptions%
-  \l@dpairingfalse
-  \l@dpagingfalse
-  \ledRcolfalse
 \newdimen\Lcolwidth
   \Lcolwidth=0.45\textwidth
 \newdimen\Rcolwidth
@@ -702,6 +700,42 @@
     \fi
   \fi}
 
+\newcommand{\newseries@eledpar}[1]{%
+    \csgdef{onlysideX@#1}{}%
+    \csgdef{onlyXside@#1}{}%
+    \global\newbool{keepforXside@#1}%
+    \global\newbool{keepforsideX@#1}%
+    \expandafter\list@create\csname footnote#1@mk\endcsname%
+    \expandafter\newcommand\csname footnote#1nomk\endcsname[1]{%
+       \toggletrue{nomk@}%
+       \csuse{footnote#1}{##1}%
+       \togglefalse{nomk@}%
+       \letcs{\@tmp}{footnote#1@mk}%
+       \numdef\@tmpa{\csuse{c@footnote#1}}%
+       \global\xright@appenditem{\@tmpa}\to\@tmp%
+       \global\cslet{footnote#1@mk}{\@tmp}%
+   }%
+    \expandafter\newcommand\csname footnote#1mk\endcsname{%
+       \letcs{\@tmp}{footnote#1@mk}%
+       \gl@p\@tmp\to\@tmpa%
+       \global\cslet{footnote#1@mk}{\@tmp}%
+       \letcs{\old@footnote}{c@footnote#1}%
+       \setcounter{footnote#1}{\@tmpa}%
+       \protected@csxdef{@thefnmark#1}{\csuse{thefootnote#1}}%
+       \csuse{@footnotemark#1}%
+       \setcounter{footnote#1}{\old@footnote}%
+       \xspace%
+    }%
+}%
+\newhookcommand@series{onlysideX}%
+
+\newhookcommand@series{onlyXside}%
+
+\newcommand{\init@series@eledpar}{%
+  \def\do##1{\newseries@eledpar{##1}}%
+  \dolistloop{\@series}%
+}%
+\init@series@eledpar%
 
 \list@create{\list@pstartL@pc}%
 \list@create{\list@pstartR@pc}%
@@ -1450,6 +1484,90 @@
 
 \let\ledsavedprintlines\printlines
 
+\newcommand\print@Xnotes@forpages[1]{%
+   \ifcsempty{onlyXside@#1}{%
+     \csuse{#1footstart}{#1}%
+     \csuse{#1footgroup}{#1}%
+   }%
+   {%
+     \ifboolexpr{%
+       ((test {\ifcsstring{onlyXside@#1}{L}} and not test{\ifnumodd{\c@page}})%
+       or%
+       (test {\ifcsstring{onlyXside@#1}{R}} and test{\ifnumodd{\c@page}}))%
+       }%
+      {%
+         \csuse{#1footstart}{#1}%
+         \csuse{#1footgroup}{#1}%
+         \global\count\csuse{#1footins}=0%
+         \global\skip\csuse{#1footins}=0pt%
+          \csuse{Xnotefontsize@#1}%
+          \global\advance\dimen\csuse{#1footins} by -\baselineskip%
+       \global\boolfalse{keepforXside@#1}%
+       }%
+       {%
+         \global\booltrue{keepforXside@#1}%
+         \global\count\csuse{#1footins}=\csuse{default@#1footins}%
+         \global\skip\csuse{#1footins}=\csuse{beforeXnotes@#1}%
+         \bgroup%
+            \csuse{Xnotefontsize@#1}%
+            \global\advance\dimen\csuse{#1footins} by \baselineskip%
+         \egroup%
+       }%
+     }%
+}%
+\newcommand{\correct@Xfootins@box}[1]{%
+  \ifbool{keepforXside@#1}{%
+      \csuse{Xnotefontsize@#1}%
+      \splittopskip=0pt%
+      \global\setbox\csuse{#1footins}=\vbox{%
+        \vsplit\csuse{#1footins} to \dimexpr\ht\csuse{#1footins}-1pt\relax%
+        \vskip \dimexpr-0.5\baselineskip-\lineskip-0.5pt\relax%
+        \unvbox\csuse{#1footins}%
+      }%
+  }{}%
+}%
+\newcommand\print@notesX@forpages[1]{%
+   \ifcsempty{onlysideX@#1}{%
+     \csuse{footstart#1}{#1}%
+     \csuse{footgroup#1}{#1}%
+   }%
+   {%
+     \ifboolexpr{%
+       ((test {\ifcsstring{onlysideX@#1}{L}} and not test{\ifnumodd{\c@page}})%
+       or%
+       (test {\ifcsstring{onlysideX@#1}{R}} and test{\ifnumodd{\c@page}}))%
+       }%
+      {%
+         \csuse{footstart#1}{#1}%
+         \csuse{footgroup#1}{#1}%
+         \global\count\csuse{footins#1}=0%
+         \global\skip\csuse{footins#1}=0pt%
+          \csuse{notefontsizeX@#1}%
+          \global\advance\dimen\csuse{footins#1} by -\baselineskip%
+       \global\boolfalse{keepforsideX@#1}%
+       }%
+       {%
+         \global\booltrue{keepforsideX@#1}%
+         \global\count\csuse{footins#1}=\csuse{default@footins#1}%
+         \global\skip\csuse{footins#1}=\csuse{beforenotesX@#1}%
+         \bgroup%
+            \csuse{notefontsizeX@#1}%
+            \global\advance\dimen\csuse{footins#1} by \baselineskip%
+         \egroup%
+       }%
+     }%
+}%
+\newcommand{\correct@footinsX@box}[1]{%
+  \ifbool{keepforsideX@#1}{%
+      \csuse{notefontsizeX@#1}%
+      \splittopskip=0pt%
+      \global\setbox\csuse{footins#1}=\vbox{%
+        \vsplit\csuse{footins#1} to \dimexpr\ht\csuse{footins#1}-1pt\relax%
+        \vskip \dimexpr-0.5\baselineskip-\lineskip-0.5pt\relax%
+        \unvbox\csuse{footins#1}%
+      }%
+  }{}%
+}%
 \list@create{\labelref@listR}
 
 \def\l@dmake@labelsR#1|#2|#3|#4|#5{%
@@ -1613,7 +1731,6 @@
     \let\stanza@hang\relax
     \let\endlock\relax
   \else
-%%%    \interlinepenalty\@M % this screws things up, but I don't know why
     \rightskip\z@ plus 1fil\relax
   \fi
   \ifnum\usenamecount{szp@0@}=\z@
@@ -1624,14 +1741,16 @@
     \sza@penalty
     \global\advance\stanza@count\@ne
     \@astanza@line}%
-  \def\&{%
-    \endlock\mbox{}
-    \pend
-    \endstanzaextra}%
+  \def\&{\@stopastanza}%
   \pstart
   \@astanza@line
 }{}
 
+\newcommandx{\@stopastanza}[1][1,usedefault]{%
+    \endlock\mbox{}%
+    \pend[#1]%
+    \endstanzaextra%
+}%
 \newcommand*{\@astanza@line}{%
   \ifnum\value{stanzaindentsrepetition}=0
       \parindent=\csname sza@\number\stanza@count
@@ -1855,7 +1974,7 @@
       \@writelinesinparL
       \@writelinesinparR
       \check@pstarts
-            \ifbypstart@
+        \ifbypstart@%
            \write\linenum@out{\string\@set[1]}
            \resetprevline@
         \fi
@@ -2010,6 +2129,8 @@
   \ifnum\l@dnumpstartsL=\l@dnumpstartsR\else
     \led@err@BadLeftRightPstarts{\the\l@dnumpstartsL}{\the\l@dnumpstartsR}%
   \fi
+  \setlength{\Lcolwidth}{\textwidth}%
+  \setlength{\Rcolwidth}{\textwidth}%
   \cleartol@devenpage
   \begingroup
     \l@dzeropenalties
@@ -2021,6 +2142,8 @@
     \global\l@dpscR=\z@
     \writtenlinesLfalse
     \writtenlinesRfalse
+    \let\print@Xnotes\print@Xnotes@forpages%
+    \let\print@notesX\print@notesX@forpages%
     \check@pstarts
     \loop\if@pstarts
       \global\advance\l@dpscL \@ne
@@ -2051,7 +2174,6 @@
 {        \loop\ifaraw@text
           \checkpageL
           \l@duselanguage{\theledlanguageL}%
-%%%          \begingroup
 {            \loop\ifl@dsamepage%
               \ifdefstring{\@eledsectnotoc}{L}{\ledsectnotoc}{}
               \csuse{before@pstartL@\the\l@dpscL}%
@@ -2062,7 +2184,13 @@
                 {}%
               \advance\numpagelinesL \@ne
               \ifshiftedpstarts
-                      \ifdim\ht\l@dleftbox>0pt\hb@xt@ \hsize{\ledstrutL\unhbox\l@dleftbox}\fi%
+                      \ifdim\ht\l@dleftbox>0pt\hb@xt@%
+                        \hsize{\ledstrutL\unhbox\l@dleftbox}%
+                      \else%
+                        \dimen0=\pagetotal%
+                        \advance\dimen0 by \baselineskip%
+                        \global\pagetotal=\dimen0%
+                      \fi%
               \else%
                       \parledgroup@correction@notespacing{L}
                       \hb@xt@ \hsize{\ledstrutL\unhbox\l@dleftbox}%
@@ -2097,7 +2225,13 @@
                 {}%
               \advance\numpagelinesR \@ne
               \ifshiftedpstarts
-                      \ifdim\ht\l@drightbox>0pt\hb@xt@ \hsize{\ledstrutR\unhbox\l@drightbox}\fi%
+                      \ifdim\ht\l@drightbox>0pt\hb@xt@%
+                        \hsize{\ledstrutR\unhbox\l@drightbox}%
+                      \else%
+                        \dimen0=\pagetotal%
+                        \advance\dimen0 by \baselineskip%
+                        \global\pagetotal=\dimen0%
+                      \fi%
               \else%
                       \parledgroup@correction@notespacing{R}
                       \hb@xt@ \hsize{\ledstrutR\unhbox\l@drightbox}%
@@ -2138,6 +2272,7 @@
     \global\instanzaLfalse
     \global\instanzaRfalse
  \l@dprintingpagesfalse%
+ \newpage\null%Needed to prevent final notes overlap line number
   \ignorespaces}
 
 \newcommand*{\ledstrutL}{\strut}
@@ -2153,14 +2288,17 @@
   \fi
   \ifodd\c@page\hbox{}\clearpage\fi}
 \newcommand*{\clearl@dleftpage}{%
-  \clearpage
+  \ifdim\pagetotal=0pt\hbox{}\fi%
+  \newpage%
   \ifodd\c@page\else
     \led@err@LeftOnRightPage
     \hbox{}%
     \cleardoublepage
   \fi}
+
 \newcommand*{\clearl@drightpage}{%
-  \clearpage
+  \ifdim\pagetotal=0pt\hbox{}\fi%
+  \newpage%
   \ifodd\c@page
     \led@err@RightOnLeftPage
     \hbox{}%
-- 
cgit v1.2.3

