%%
%% This is file `reledpar.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% reledpar.dtx  (with options: `code')
%% 
%%   Author: Author: Peter Wilson ; Herries Press herries dot press at earthlink dot net ; Maïeul Rouquette maieul at maieul dot net
%%   Copyright 2004, 2005 Peter R. Wilson
%%  2011- Maïeul Rouquette
%%   This work may be distributed and/or modified under the
%%   conditions of the LaTeX Project Public License, either
%%   version 1.3 of this license or (at your option) any
%%   later version.
%%   The latest version of the license is in
%%      http://www.latex-project.org/lppl.txt
%%   and version 1.3 or later is part of all distributions of
%%   LaTeX version 2003/06/01 or later.
%% 
%%   This work has the LPPL maintenance status "maintained".
%% 
%%   This work consists of the files listed in the README file.
%% 





\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{reledpar}[2019/01/22 v2.22.2 reledmac extension for parallel texts]%

\RequirePackage{xspace}%
\RequirePackage{xkeyval}
\def\@par@this@sync@option{}%
\newif\ifshiftedpstarts
\DeclareOptionX{shiftedpstarts}{%
 \shiftedpstartstrue%
 \apptocmd{\@par@this@sync@option}{shifted}{}{}%
}%
\newif\ifadvancedshiftedpstarts
\DeclareOptionX{advancedshiftedpstarts}{%
  \advancedshiftedpstartstrue%
  \shiftedpstartstrue%
  \apptocmd{\@par@this@sync@option}{advancedshifted}{}{}%
}%
\newif\ifnomaxlines%
\DeclareOptionX{nomaxlines}{%
  \nomaxlinestrue%
  \apptocmd{\@par@this@sync@option}{nomax}{}{}%
}%
\newif\ifnosyncpstarts%
\DeclareOptionX{nosyncpstarts}{%
  \shiftedpstartstrue%
  \nomaxlinestrue%
  \nosyncpstartstrue%
  \apptocmd{\@par@this@sync@option}{nosync}{}{}%
}%
\newif\ifmovecolumnspositiononrightpage%
\DeclareOptionX{movecolumnspositiononrightpage}{%
 \movecolumnspositiononrightpagetrue%
}%
\newif\if@sidenotesmarginpage%
\DeclareOptionX{sidenotesmarginpage}{%
 \@sidenotesmarginpagetrue%
}%
\DeclareOptionX{parledgroup}{\parledgrouptrue}
\DeclareOptionX{widthliketwocolumns}{\widthliketwocolumnstrue}%
\DeclareOptionX{continuousnumberingwithcolumns}{\continuousnumberingwithcolumnstrue}%
\DeclareOptionX{sameparallelpagenumber}{\sameparallelpagenumbertrue}
\DeclareOptionX{prevpgnotnumbered}{\prevpgnotnumberedtrue}
\DeclareOptionX{prevpgstyle}{\gdef\prevpgstyle{#1}}%
\ProcessOptionsX%
\newdimen\Lcolwidth
  \Lcolwidth=0.45\textwidth
\newdimen\Rcolwidth
  \Rcolwidth=0.45\textwidth
\newdimen\Lcolwidth@pages
\newdimen\Rcolwidth@pages
\newcommand{\reledpar@error}[2]{\PackageError{reledpar}{#1}{#2}}
\newcommand{\reledpar@warning}[1]{\PackageWarning{reledpar}{#1}}%
\newcommand*{\led@err@TooManyPstarts}{%
  \reledpar@error{Too many \string\pstart\space without printing.
                Some text will be lost}{\@ehc}}
\newcommand*{\led@err@BadLeftRightPstarts}[2]{%
  \reledpar@error{The numbers of left (#1) and right (#2)
                \string\pstart s do not match}{\@ehc}}
\providebool{syntax@}
\newcommand*{\led@err@LeftOnRightPage}{%
  \notbool{syntax@}%
    {\reledpar@error{The left page has ended on a right page}{\@ehc}}%
    {}%
  }
\newcommand*{\led@err@RightOnLeftPage}{%
  \notbool{syntax@}%
    {\reledpar@error{The right page has ended on a left page}{\@ehc}}
    {}%
  }%
\newcommand*{\led@err@Leftside@PreviousNotPrinted}{%
  \reledpar@error{You call a new Leftside environment while the previous one has not been typeset by \string\Pages\space or \string\Columns}{\@ehc}}
\newcommand*{\led@err@Rightside@PreviousNotPrinted}{%
  \reledpar@error{You call a new Rightside environment while the previous one has not been typeset by \string\Pages\space or \string\Columns}{\@ehc}}
\newcommand*{\led@err@Pages@InsideEnv}{%
  \reledpar@error{\string\Pages\space must be called *outside* of the `pages` environment}{\@ehc}}
\newcommand*{\led@err@Columns@InsideEnv}{%
  \reledpar@error{\string\Columns\space must be called *outside* of the `pairs` environment}{\@ehc}}
\newcommand*{\led@err@Pages@WithoutEnv}{%
  \reledpar@error{\string\Pages\space called without previous `pages` environment}{\@ehc}}
\newcommand*{\led@err@Columns@WithoutEnv}{%
  \reledpar@error{\string\Columns\space called without previous `pairs` environment}{\@ehc}}
\newcommand*{\led@err@Pages@WithoutRightside}{%
  \reledpar@error{\string\Pages\space called without any preceding `Rightside` environment (or environment without content)}{\@ehc}}%
\newcommand*{\led@err@Pages@WithoutLeftside}{%
  \reledpar@error{\string\Pages\space called without any preceding `Leftside` environment (or environment without content)}{\@ehc}}%
  \newcommand*{\led@err@Columns@WithoutRightside}{%
  \reledpar@error{\string\Columns\space called without any preceding `Rightside` environment (or environment without content)}{\@ehc}}%
\newcommand*{\led@err@Columns@WithoutLeftside}{%
  \reledpar@error{\string\Columns\space called without any preceding `Leftside` environment (or environment without content)}{\@ehc}}%
\newcommand{\led@error@fail@patch@thepage}{%
  \reledpar@error{Fail to patch \string\@thepage\space command.}{\@ehc}%
}%
\newcommand{\led@error@fail@patch@pagenumbering}{%
  \reledpar@error{Fail to patch \string\pagenumbering\space command.}{\@ehc}%
}%
\newcommand{\led@error@note@called@onrightside}[1]{%
  \reledpar@error{#1 called on right side, despite your configuring it to be for the left side only}{\@ehc}%
}%
\newcommand{\led@error@note@called@onleftside}[1]{%
  \reledpar@error{#1 called on left side, despite your configuring it to be for the right side only}{\@ehc}%
}%
\newcommand{\led@error@fail@patch@@mempnum}{%
  \reledpar@error{Fail to patch \string\@mempnum\space command.}{\@ehc}%
}%
\newcommand{\led@error@fail@patch@@outputpage}{%
  \reledpar@error{Fail to patch \string\@outputpage\space command.}{\@ehc}%
}%
\newcommand{\led@error@edtext@later@now}{%
  \reledpar@error{You call \the\edtext@later\space \string\edtextlater\space commands, but \the\edtext@now\space \string\edtextnow\space commands}{\@ehc}% (did I follow your intent correctly here?)
}%
\newcommand*{\led@warn@ChangeSyncOption}[1]{%
  \reledpar@warning{You have changed synchronization's options since the last run. We have not read line-list file #1. Please run LaTeX again.}%
}%
\newcommand{\led@warn@setting@in@rightside}[1]{%
  \reledpar@warning{You use #1 inside rightside environment.\MessageBreak%
  Such behavior is deprecated.\MessageBreak%
  Use instead #1R or #1* in your preamble.}%
}
\newcommand{\led@error@missing@numbering}[1]{%
  \reledpar@error{Missing \string\pstart\space ...\space\string\pend\space inside `#1` environment}{\@ehc}%
}%
\providecommand*{\newnamebox}[1]{%
  \expandafter\newbox\csname #1\endcsname}
\providecommand*{\setnamebox}[1]{%
  \expandafter\setbox\csname #1\endcsname}
\providecommand*{\unhnamebox}[1]{%
  \expandafter\unhbox\csname #1\endcsname}
\providecommand*{\unvnamebox}[1]{%
  \expandafter\unvbox\csname #1\endcsname}
\providecommand*{\namebox}[1]{%
                     \csname #1\endcsname}

\newcommand*{\ifcsboxvoid}[1]{%
  \ifcsname#1\endcsname%
    \expandafter\ifvoid\csname #1\endcsname%
      \expandafter\expandafter%
      \expandafter\@firstoftwo%
    \else%
      \expandafter\expandafter%
      \expandafter\@secondoftwo%
    \fi%
  \else%
    \expandafter\@firstoftwo%
  \fi%
}%
\providecommand*{\newnamecount}[1]{%
  \expandafter\newcount\csname #1\endcsname}
\providecommand*{\usenamecount}[1]{%
                       \csname #1\endcsname}

\newcount\section@numR
  \section@numR=\z@
  \pst@rtedLfalse
\newif\ifpst@rtedR

\newcommand*{\beginnumberingR}{%
  \ifnumberingR
    \led@err@NumberingStarted
    \endnumberingR
  \fi
  \global\l@dnumpstartsR \z@
  \global\pst@rtedRfalse
  \global\numberingRtrue
  \global\afterendnumberingRfalse%
  \global\advance\section@numR \@ne
  \global\absline@numR \z@
  \gdef\normal@page@breakR{}
  \gdef\l@prev@pbR{}
  \gdef\l@prev@nopbR{}
  \global\line@numR \z@
  \global\@lockR \z@
  \global\sub@lockR \z@
  \global\sublines@Rfalse
  \global\let\next@page@numR\relax
  \global\let\this@section@next@page@numR\relax%
  \global\let\sub@change\relax
  \global\last@page@numR=-10000%
  \global\stopmsdata@inserted@true%
  \global\let\@msdata@list\relax%
  \global\csundef{@msdata@\add@msd@cR @dataR}%
  \ifcontinuousnumberingwithcolumns%
    \ifnumbering%
      \global\resumenumberingR@starttrue%
    \fi%
    \ifnumberpstart%
      \addtocounter{pstartR}{1}%
    \fi%
  \else%
    \setcounter{pstartR}{1}%
  \fi%
  \message{Section \the\section@numR R }%
  \line@list@stuffR{\jobname.\extensionchars\the\section@numR R}%
  \l@dend@stuff
  \begingroup
  \initnumbering@sectcountR
  \gdef\eled@sectionsR@@{}%
  \if@noeled@sec\else%
    \makeatletter%
      \InputIfFileExists%
      {\l@auxdir\jobname.eledsec\the\section@numR R}%
      {}%
      {\led@warn@NoFile{\l@auxdir\jobname.eledsec\the\section@numR R}}%
    \makeatother%
    \immediate\openout\eled@sectioningR@out=\l@auxdir\jobname.eledsec\the\section@numR R\relax%
  \fi%
}
\def\endnumberingR{%
  \ifnumberingR
    \global\numberingRfalse
    \global\afterendnumberingRtrue%
    \normal@pars
    \ifnum\l@dnumpstartsR=0%
      \led@err@NumberingWithoutPstart%
    \fi%
    \global\page@numR=\this@section@page@numR%
    \global\last@page@numR=\this@section@last@page@numR%
    \global\let\next@page@numR\this@section@next@page@numR%
    \ifl@dpairing
      \global\pst@rtedRfalse
    \else
      \ifx\insertlines@listR\empty\else
        \global\noteschanged@true
      \fi
      \ifx\line@listR\empty\else
        \global\noteschanged@true
      \fi
    \fi
    \ifnoteschanged@
      \led@mess@NotesChanged
    \fi
  \else
    \led@err@NumberingNotStarted
  \fi
  \endgroup
  \if@noeled@sec\else%
    \immediate\closeout\eled@sectioningR@out%
  \fi%
  }

\newcounter{chapterR}
\newcounter{sectionR}
\newcounter{subsectionR}
\newcounter{subsubsectionR}

\newcount\old@chapter%
\newcount\old@section%
\newcount\old@subsection%
\newcount\old@subsubsection%
\newcommand{\save@section@number}{%
  \ifdefined\c@chapter%
   \global\old@chapter\value{chapter}%
  \fi%
  \global\old@section\value{section}%
  \global\old@subsection\value{subsection}%
  \global\old@subsubsection\value{subsubsection}%
}%
\newcommand{\initnumbering@sectcountR}{
 \ifdefined\c@chapter%
   \setcounter{chapterR}{\old@chapter}%
 \fi%
 \setcounter{sectionR}{\old@section}%
 \setcounter{subsectionR}{\old@subsection}%
 \setcounter{subsubsectionR}{\old@subsubsection}%
 \set@sectcountR%
}
\newcommand{\set@sectcountR}{%
    \let\c@chapter\c@chapterR%
    \let\c@section\c@sectionR%
    \let\c@subsection\c@subsectionR%
    \let\c@subsubsection\c@subsubsectionR%
}%
\newcount\pausenumbering@page@numR%
\newcommand*{\pausenumberingR}{%
  \ifx\this@section@next@page@numR\relax%
    \global\pausenumbering@page@numR=0%
  \else%
    \global\pausenumbering@page@numR=\this@section@next@page@numR%
  \fi%
  \endnumberingR%
  \global\numberingRtrue%
  \global\afterendnumberingRfalse%
}%
\newif\ifresumenumberingR@start%
\newcommand*{\resumenumberingR}{%
  \ifnumberingR
     \global\pst@rtedRtrue
     \global\advance\section@numR \@ne
     \global\resumenumberingR@starttrue%
     \led@mess@SectionContinued{\the\section@numR R}%
     \line@list@stuffR{\jobname.\extensionchars\the\section@numR R}%
     \l@dend@stuff
     \begingroup%
     \initnumbering@sectcountR%
  \else
     \led@err@NumberingShouldHaveStarted
     \endnumberingR
     \beginnumberingR
  \fi}

\newcommand*{\memorydumpL}{%
  \endnumbering
  \numberingtrue
  \global\pst@rtedLtrue
  \global\advance\section@num \@ne
     \led@mess@SectionContinued{\the\section@num}%
  \line@list@stuff{\jobname.\extensionchars\the\section@num}%
  \l@dend@stuff}

\newcommand*{\memorydumpR}{%
  \endnumberingR
  \numberingRtrue
  \global\pst@rtedRtrue
  \global\advance\section@numR \@ne
     \led@mess@SectionContinued{\the\section@numR R}%
  \line@list@stuffR{\jobname.\extensionchars\the\section@numR R}%
  \l@dend@stuff}



\newcommand*{\lineationR}[1]{{%
  \ifnumbering
    \led@err@LineationInNumbered
  \else
    \def\@tempa{#1}\def\@tempb{page}%
    \ifx\@tempa\@tempb
        \global\bypage@Rtrue
        \global\bypstart@Rfalse
         \unless\ifnocritical@%
           \Xpstart[][false]%
         \fi%
    \else
       \def\@tempb{pstart}%
       \ifx\@tempa\@tempb
           \global\bypage@Rfalse
           \global\bypstart@Rtrue
           \unless\ifnocritical@%
             \Xpstart%
           \fi%
       \else
           \def\@tempb{section}
           \ifx\@tempa\@tempb
             \global\bypage@Rfalse%
             \global\bypstart@Rfalse%
             \unless\ifnocritical@%
               \Xpstart[][false]%
             \fi%
           \else
             \led@warn@BadLineation
           \fi%
       \fi
    \fi
  \fi}}
\WithSuffix\newcommand\lineation*[1]{%
  \lineation{#1}%
  \lineationR{#1}%
}%

\newcount\line@marginR
\line@marginR=\@ne

\newcommand{\linenummarginR}[1]{%
  \l@dgetline@margin{#1}%
  \ifnum\@l@dtempcntb>\m@ne%
    \global\line@marginR=\@l@dtempcntb%
  \fi%
}
\WithSuffix\newcommand\linenummargin*[1]{%
  \l@dgetline@margin{#1}%
  \ifnum\@l@dtempcntb>\m@ne%
    \global\line@marginR=\@l@dtempcntb%
    \global\line@margin=\@l@dtempcntb%
  \fi%
}
\ifmovecolumnspositiononrightpage%
  \linenummargin{inner}%
  \linenummarginR{outer}%
\fi%

\newcount\line@margin@columnsR%
\line@margin@columnsR=\m@ne%

\newcommand{\linenummarginColumns}[1]{%
  \l@dgetline@margin{#1}%
  \ifnum\@l@dtempcntb>\m@ne%
    \global\line@margin@columns=\@l@dtempcntb%
  \fi%
}%

\WithSuffix\newcommand\linenummarginColumns*[1]{%
  \l@dgetline@margin{#1}%
  \ifnum\@l@dtempcntb>\m@ne%
    \global\line@margin@columns=\@l@dtempcntb%
    \global\line@margin@columnsR=\@l@dtempcntb%
  \fi%
}%

\newcommand{\linenummarginColumnsR}[1]{%
  \l@dgetline@margin{#1}%
  \ifnum\@l@dtempcntb>\m@ne%
    \global\line@margin@columnsR=\@l@dtempcntb%
  \fi%
}%

\def\linenum@OnlyPages@ForColumns{}%
\newcommand{\linenumOnlyPagesForColumns}[1]{%
  \gdef\linenum@OnlyPages@ForColumns{#1}%
}%

\def\linenum@OnlyPages@ForColumnsR{}%
\newcommand{\linenumOnlyPagesForColumnsR}[1]{%
  \gdef\linenum@OnlyPages@ForColumnsR{#1}%
}%
\newcounter{firstlinenumR}
  \setcounter{firstlinenumR}{5}
\newcounter{linenumincrementR}
  \setcounter{linenumincrementR}{5}
\newcounter{firstsublinenumR}
  \setcounter{firstsublinenumR}{5}
\newcounter{sublinenumincrementR}
  \setcounter{sublinenumincrementR}{5}

\WithSuffix\newcommand\firstlinenum*[1]{%
  \setcounter{firstlinenumR}{#1}%
  \setcounter{firstlinenum}{#1}%
}
\WithSuffix\newcommand\linenumincrement*[1]{%
  \setcounter{linenumincrementR}{#1}%
  \setcounter{linenumincrement}{#1}%
}
\WithSuffix\newcommand\firstsublinenum*[1]{%
  \setcounter{firstsublinenumR}{#1}%
  \setcounter{firstsublinenum}{#1}%
}
\WithSuffix\newcommand\sublinenumincrement*[1]{%
  \setcounter{sublinenumincrementR}{#1}%
  \setcounter{sublinenumincrement}{#1}%
}
\newcommand\firstlinenumR[1]{%
  \setcounter{firstlinenumR}{#1}%
}
\newcommand\linenumincrementR[1]{%
  \setcounter{linenumincrementR}{#1}%
}
\newcommand\firstsublinenumR[1]{%
  \setcounter{subfirstlinenumR}{#1}%
}
\newcommand\sublinenumincrementR[1]{%
  \setcounter{sublinenumincrementR}{#1}%
}
\newcommand{\setRlineflag}[1]{%
  \gdef\@Rlineflag{#1}%
}
\setRlineflag{R}
\newcommand*{\linenumrepR}[1]{\@arabic{#1}}
\newcommand*{\sublinenumrepR}[1]{\@arabic{#1}}

\newcommand*{\linenumberstyleR}[1]{%
  \def\linenumrepR##1{\@nameuse{@#1}{##1}}}
\newcommand*{\sublinenumberstyleR}[1]{%
  \def\sublinenumrepR##1{\@nameuse{@#1}{##1}}}
\WithSuffix\newcommand\linenumberstyle*[1]{%
  \linenumberstyle{#1}%
  \linenumberstyleR{#1}%
}%

\WithSuffix\newcommand\sublinenumberstyle*[1]{%
  \sublinenumberstyle{#1}%
  \sublinenumberstyleR{#1}%
}%
\newif\iflinenumberLevenifblank
\newif\iflinenumberRevenifblank
\newcommand*{\leftlinenumR}{%
  \l@dlinenumR
  \kern\linenumsep}
\newcommand*{\rightlinenumR}{%
  \kern\linenumsep
  \l@dlinenumR}
\newcommand*{\l@dlinenumR}{%
  \numlabfont%
  \ifdefstring{\Xlinenumannotationposition@side}{before}{%
    \l@wrap@ifnotemptybox{\Xwraplinenumannotation@side}{%
      \csuse{annotR@\the\absline@numR @\the\section@numR}%
      }%
  }{}%
  \linenumrepR{\line@numR}\@Rlineflag%
  \ifsublines@R
    \ifnum\subline@numR>\z@
      \unskip\fullstop\sublinenumrepR{\subline@numR}%
    \fi
  \fi%
  \ifdefstring{\Xlinenumannotationposition@side}{after}{%
    \l@wrap@ifnotemptybox{\Xwraplinenumannotation@side}{%
      \csuse{annotR@\the\absline@numR @\the\section@numR}%
      }%
  }{}%
}%

\newcount\line@numR
\newcount\subline@numR
\newcount\absline@numR
\newif\ifsublines@R%

\list@create{\line@listR}
\list@create{\insertlines@listR}
\list@create{\actionlines@listR}
\list@create{\actions@listR}
\list@create{\annot@listR}%
\newcount\page@numR
\newcount\this@section@page@numR%
\list@create{\linesinpar@listL}
\list@create{\linesinpar@listR}
\list@create{\maxlinesinpar@list}

\newcommand{\list@clearing@regR}{%
    \list@clear{\line@listR}%
    \list@clear{\insertlines@listR}%
    \list@clear{\actionlines@listR}%
    \list@clear{\actions@listR}%
    \list@clear{\linesinpar@listR}%
    \list@clear{\linesonpage@listR}
}
\newcommand{\@par@sync@option}[1]{%
  \IfStrEq{#1}{\@par@this@sync@option}%
    {}%
    {\ifledRcol%
       \led@warn@ChangeSyncOption{\jobname.\extensionchars\the\section@num}%
     \else%
       \led@warn@ChangeSyncOption{\jobname.\extensionchars\the\section@num}%
     \fi%
     \endinput%
    }%
}%
\newcommand{\@nl@regR}{%
  \ifx\l@dchset@num\relax \else
    \advance\absline@numR \@ne
    \csgdef{l@dchset@num@R\the\absline@numR}{}%To remember this line have been marked by a \setlinenum
    \set@line@action
    \let\l@dchset@num\relax
    \advance\absline@numR \m@ne
    \advance\line@numR \m@ne%   % do we need this?
  \fi
  \reset@current@annot%
  \advance\absline@numR \@ne
  \ifx\next@page@numR\relax \else
    \page@action
    \let\next@page@numR\relax
  \fi
  \ifx\sub@change\relax \else
    \ifnum\sub@change>\z@
      \sublines@Rtrue
    \else
      \sublines@Rfalse
    \fi
    \sub@action
    \let\sub@change\relax
  \fi
  \ifcase\@lockR
  \or
    \@lockR \tw@
  \or\or
    \@lockR \z@
  \fi
  \ifcase\sub@lockR
  \or
    \sub@lockR \tw@
  \or\or
    \sub@lockR \z@
  \fi
  \ifsublines@R
    \ifnum\sub@lockR<\tw@
      \advance\subline@numR \@ne
    \fi
  \else
    \ifnum\@lockR<\tw@
      \advance\line@numR \@ne \subline@numR \z@
    \fi
  \fi}

\newcount\last@page@numR
  \last@page@numR=-10000
\newcount\this@section@last@page@numR%
  \this@section@last@page@numR=-10000%




\newcount\@lockR
\newcount\sub@lockR

\newcommand*{\do@lockonR}{%
  \xright@appenditem{\the\absline@numR}\to\actionlines@listR
  \ifsublines@R
    \xright@appenditem{-1005}\to\actions@listR
    \ifnum\sub@lockR=\z@
      \sub@lockR \@ne
    \else
      \ifnum\sub@lockR=\thr@@
        \sub@lockR \@ne
      \fi
    \fi
  \else
    \xright@appenditem{-1003}\to\actions@listR
    \ifnum\@lockR=\z@
      \@lockR \@ne
    \else
      \ifnum\@lockR=\thr@@
        \@lockR \@ne
      \fi
    \fi
  \fi}


\newcommand{\do@lockoffR}{%
  \xright@appenditem{\the\absline@numR}\to\actionlines@listR
  \ifsublines@R
    \xright@appenditem{-1006}\to\actions@listR
    \ifnum\sub@lockR=\tw@
      \sub@lockR \thr@@
    \else
      \sub@lockR \z@
    \fi
  \else
    \xright@appenditem{-1004}\to\actions@listR
    \ifnum\@lockR=\tw@
      \@lockR \thr@@
    \else
      \@lockR \z@
    \fi
  \fi}

\newcount\insert@countR
\newcommand*{\@ref@regR}[2]{%
    \global\advance\@edtext@level by 1%
    \global\insert@countR=#1\relax
    \loop\ifnum\insert@countR>\z@
      \xright@appenditem{\the\absline@numR}\to\insertlines@listR
      \global\advance\insert@countR \m@ne
    \repeat
  \begingroup
    \let\@ref=\dummy@ref
    \let\@lopR\@gobble
    \let\page@action=\relax
    \let\sub@action=\relax
    \let\set@line@action=\relax
    \let\@lab=\relax
    \let\@lemma=\relax
    \let\@sw\@gobblethree%
    \let\store@annot@to@absline\@gobble%
    #2
    \global\endpage@num=\page@numR
    \global\endline@num=\line@numR
    \global\endsubline@num=\subline@numR
    \global\let\endcurrent@annot=\current@annot%
  \endgroup
    \xright@appenditem%
      {\the\page@numR|\the\line@numR|%
       \ifsublines@R \the\subline@numR \else 0\fi|%
       \the\endpage@num|\the\endline@num|%
       \ifsublines@R \the\endsubline@num \else 0\fi}\to\line@listR
    \xright@appenditem%
      {\current@annot|\endcurrent@annot}\to\annot@listR%
     \expandafter\list@create\expandafter{\csname sw@list@edtext@tmp@\the\@edtext@level\endcsname}%
     \@ref@reg@parseR{#2}%
     \global\advance\@edtext@level by -1%
}
\newcommand{\@ref@reg@parseR}[1]{%
     \providebool{lemmacommand@\the\@edtext@level}%
     \boolfalse{lemmacommand@\the\@edtext@level}%
    #1%
    \ifnum\@edtext@level>0%
      \def\create@this@edtext@level{\expandafter\list@create\expandafter{\csname sw@list@edtextR@\the\@edtext@level\endcsname}}%
      \ifcsundef{sw@list@edtextR@\the\@edtext@level}{\create@this@edtext@level}{}%
      \letcs{\@tmp}{sw@list@edtextR@\the\@edtext@level}%
      \letcs{\@tmpp}{sw@list@edtext@tmp@\the\@edtext@level}%
      \xright@appenditem{\expandonce\@tmpp}\to\@tmp%
      \global\cslet{sw@list@edtextR@\the\@edtext@level}{\@tmp}%
    \fi%
}%

\renewcommand*{\@pend}[1]{%
  \ifbypstart@\global\line@num=0\fi%
  \xright@appenditem{#1}\to\linesinpar@listL}
\renewcommand*{\@pendR}[1]{%
  \ifbypstart@R\global\line@numR=0\fi
  \xright@appenditem{#1}\to\linesinpar@listR}

\newcommand{\@pstart}[3]{%
  \ifcsdef{minpage@pstart@#1}%
    {\ifnumgreater{#2}{\csuse{minpage@pstart@#1}}%
      {\csnumgdef{minpage@pstart@#1}{#2}}%
      {}%
    }%
    {\csnumgdef{minpage@pstart@#1}{#2}}
  \csnumgdef{afterlines@pstart@#1L}{#3}%
  }%

\newcommand{\@pstartR}[3]{%
  \numdef{\@tmp}{#2-1}%Because we have not to know in which page the pstart starts, but in which pair of facing page
  \ifcsdef{minpage@pstart@#1}%
    {\ifnumgreater{\@tmp}{\csuse{minpage@pstart@#1}}%
      {\csnumgdef{minpage@pstart@#1}{\@tmp}}%
      {}%
    }%
    {\csnumgdef{minpage@pstart@#1}{\@tmp}}
   \csnumgdef{afterlines@pstart@#1R}{#3}%
}%
\renewcommand*{\@lopL}[1]{%
  \xright@appenditem{#1}\to\linesonpage@listL}
\renewcommand*{\@lopR}[1]{%
  \xright@appenditem{#1}\to\linesonpage@listR}

\newwrite\linenum@outR
\newif\iffirst@linenum@out@R
  \first@linenum@out@Rtrue

\let\next@line@list@stuffR\relax%
\newcommand*{\line@list@stuffR}[1]{%
  \global\newtoggle{notfirstrun@#1}%
  \IfFileExists{\l@auxdir#1}%
    {\global\toggletrue{notfirstrun@#1}}%
    {\global\togglefalse{notfirstrun@#1}}%
  \next@line@list@stuffR%
  \global\let\next@line@list@stuffR\relax%
  \read@linelist{#1}%
  \iffirst@linenum@out@R
     \global\first@linenum@out@Rfalse
     \immediate\openout\linenum@outR=\l@auxdir#1%
     \immediate\write\linenum@outR{\string\line@list@version{\this@line@list@version}}%
     \ifl@dpaging%
       \immediate\write\linenum@outR{\string\@par@sync@option{\@par@this@sync@option}}%
     \fi%
  \else
     \if@minipage%
       \leavevmode%
     \fi%
     \closeout\linenum@outR%
     \openout\linenum@outR=\l@auxdir#1%
  \fi%
}%

\newcommand*{\new@lineL}{%
  \ifnumberline%
    \write\linenum@out{\string\@nl[\the\c@par@page][\thepage]}%
  \fi%
}%
\newcommand*{\new@lineR}{%
  \ifnumberline%
    \write\linenum@outR{\string\@nl[\the\c@par@page][\thepar@page]}%
  \fi%
}%

\newcommand{\newseries@par}[1]{%
    \unless\ifnofamiliar@%
      \csgdef{onlysideX@#1}{}%
      \newnamebox{footins#1@kept}%
    \fi%
    \unless\ifnocritical@%
      \csgdef{Xonlyside@#1}{}%
      \newnamebox{#1footins@kept}%
    \fi%
  \unless\ifnofamiliar@%
      \newcounter{footnote#1@typeset}%
      \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%
      }%
  \fi
}%
\newcommand{\save@familiarfootnote@number}{%
  \unless\ifnofamiliar@%
    \def\do##1{\csxdef{saved@footnote##1}{\the\csname c@footnote##1\endcsname}}%
    \dolistloop{\@series}%
  \fi%
  \xdef\saved@footnote{\the\c@footnote}%
}
\newcommand{\get@familiarfootnote@number}{%
  \unless\ifnofamiliar@%
    \def\do##1{\setcounter{footnote##1@typeset}{\csuse{saved@footnote##1}}}%
    \dolistloop{\@series}%
  \fi%
  \setcounter{footnote@typeset}{\saved@footnote}%
}
\unless\ifnocritical@%
  \newhookcommand@series{Xonlyside}%
\fi%
\unless\ifnofamiliar@%
  \newhookcommand@series{onlysideX}%
\fi

\newcommand{\init@series@par}{%
  \def\do##1{\newseries@par{##1}}%
  \dolistloop{\@series}%
}%
\init@series@par%
\newcount\footnote@reading%
\newcounter{footnote@typeset}%

\list@create{\list@pstartL@pc}%
\list@create{\list@pstartR@pc}%
\def\dump@pstartL@pc{%
  \xright@appenditem{\the\c@pstartL}\to\list@pstartL@pc%
  \global\cslet{numberpstart@L\the\l@dnumpstartsL}{\ifnumberpstart}%
  \global\cslet{numberline@L\the\l@dnumpstartsL}{\ifnumberline}%
}%

\def\dump@pstartR@pc{%
  \xright@appenditem{\the\c@pstartR}\to\list@pstartR@pc%
  \global\cslet{numberpstart@R\the\l@dnumpstartsR}{\ifnumberpstart}%
  \global\cslet{numberline@R\the\l@dnumpstartsR}{\ifnumberline}%
}%

\def\restore@pstartL@pc{%
  \ifx\list@pstartL@pc\empty\else%
    \gl@p\list@pstartL@pc\to\@temp%
    \global\c@pstartL=\@temp%
  \fi%
}%
\def\restore@pstartR@pc{%
  \ifx\list@pstartR@pc\empty\else%
    \gl@p\list@pstartR@pc\to\@temp%
    \global\c@pstartR=\@temp%
  \fi%
}%
\newenvironment{pairs}{%}
  \l@dpairingtrue
  \l@dpagingfalse
  \initnumbering@quote
  \save@familiarfootnote@number%
  \if@ledgroup%
    \get@familiarfootnote@number%
  \fi%
  \save@section@number%
  \at@begin@pairs%
}{%
  \l@dpairingfalse
}

\newcommand{\AtBeginPairs}[1]{\gdef\at@begin@pairs{#1}}%
\def\at@begin@pairs{}%

\newenvironment{pages}{%
  \l@dpairingtrue
  \l@dpagingtrue
  \initnumbering@quote
  \save@familiarfootnote@number%
  \if@ledgroup%
    \get@familiarfootnote@number%
  \fi%
  \save@section@number%
  \Lcolwidth=\textwidth%
  \Rcolwidth=\textwidth%
}{%
  \l@dpairingfalse
  \l@dpagingfalse
  \global\Lcolwidth@pages=\Lcolwidth%Does not use \setlength, in case of calc package redefiniton (cf. https://github.com/latex3/latex2e/issues/58)
  \global\Rcolwidth@pages=\Rcolwidth%
}

 \newif\ifinstanzaL
 \newif\ifinstanzaR
\newenvironment{Leftside}{%
  \expandafter\ifvoid\csname l@dLcolrawbox1\endcsname\else%
   \led@err@Leftside@PreviousNotPrinted%
  \fi%
  \ledRcolfalse
  \setcounter{pstartL}{1}
  \let\pstart\pstartL
  \let\thepstart\thepstartL
  \let\pend\pendL
  \let\memorydump\memorydumpL
  \Leftsidehook
  \let\old@startstanza\@startstanza%
  \def\@startstanza[##1][##2]{\global\instanzaLtrue\old@startstanza[##1][##2]}%
}{
  \expandafter\ifvoid\csname l@dLcolrawbox1\endcsname%
    \led@error@missing@numbering{Leftside}%
  \fi%
    \Leftsidehookend}
\newcommand*{\Leftsidehook}{}
\newcommand*{\Leftsidehookend}{}
\newcommand*{\Rightsidehook}{}
\newcommand*{\Rightsidehookend}{}

\newenvironment{Rightside}{%
  \expandafter\ifvoid\csname l@dRcolrawbox1\endcsname\else%
   \led@err@Rightside@PreviousNotPrinted%
  \fi%
  \ledRcoltrue
  \let\beginnumbering\beginnumberingR
  \let\endnumbering\endnumberingR
  \let\pausenumbering\pausenumberingR
  \let\resumenumbering\resumenumberingR
  \let\memorydump\memorydumpR
  \let\thepstart\thepstartR
  \let\pstart\pstartR
  \let\pend\pendR
  \let\ledpb\ledpbR
  \let\lednopb\lednopbR
  \let\lineation\lineationR
  \Rightsidehook
  \let\old@startstanza\@startstanza%
  \def\@startstanza[##1][##2]{\global\instanzaRtrue\old@startstanza[##1][##2]}%
}{%
  \ledRcolfalse
 \expandafter\ifvoid\csname l@dRcolrawbox1\endcsname%
    \led@error@missing@numbering{Rightside}%
  \fi%
  \Rightsidehookend
}

\newcount\num@linesR
\newbox\one@lineR
\newcount\par@lineR

\newcounter{pstartL}
\renewcommand{\thepstartL}{{\bfseries\@arabic\c@pstartL}. }
\newcounter{pstartR}
\renewcommand{\thepstartR}{{\bfseries\@arabic\c@pstartR}. }

\newcommandx*{\pstartL}[2][1,2,usedefault]{%
  \if@nobreak%
    \let\@oldnobreak\@nobreaktrue%
  \else%
    \let\@oldnobreak\@nobreakfalse%
  \fi%
    \@nobreaktrue%
  \ifluatex%
    \xdef\l@luatextextdir@L{\the\textdir}%
    \xdef\l@luatexpardir@L{\the\pardir}%
    \xdef\l@luatexbodydir@L{\the\bodydir}%
  \fi%
  \ifnumbering \else%
    \led@err@PstartNotNumbered%
    \beginnumbering%
  \fi%
  \ifnumberedpar@%
    \led@err@PstartInPstart%
    \pend%
  \fi%
  \ifpst@rtedL\else%
    \list@clear{\inserts@list}%
    \global\let\next@insert=\empty%
     \global\pst@rtedLtrue%
  \fi%
  \begingroup\everypar{}%
  \global\advance\l@dnumpstartsL \@ne%
  \global\advance\pstarts@read@L \@ne%
  \ifnum\l@dnumpstartsL>\l@dc@maxchunks%
    \led@err@TooManyPstarts%
    \global\l@dnumpstartsL=\l@dc@maxchunks%
  \fi%
  \global\setnamebox{l@dLcolrawbox\the\l@dnumpstartsL}=\vbox\bgroup%
  \l@dzeropenalties%
  \ifboolexpr{%
    bool{autopar}%
    and  bool{by@autopar}%
  }%
  {}%
  {%
    \ifnumberpstart%
      \ifsidepstartnum%
        \else%
        \thepstartL%
      \fi%
    \fi%
  }%m
  \@at@start@every@pstart%
  \hsize=\Lcolwidth%
  \numberedpar@true%
  \iflabelpstart%
    \protected@edef\@currentlabel{\p@pstartL\thepstartL}%
  \fi%
  \providetoggle{before@pstartL@\the\l@dnumpstartsL @par}%
  \ifboolexpr{%
    test {\ifstrempty{#1}}%
    and test {\ifstrempty{#2}}%
    }%
    {%
      \ifat@every@pstart@star@%
        \global\togglefalse{before@pstartL@\the\l@dnumpstartsL @par}%
      \else%
        \global\toggletrue{before@pstartL@\the\l@dnumpstartsL @par}%
      \fi%
      \csgdef{before@pstartL@\the\l@dnumpstartsL}{\at@every@pstart}%
    }%
    {%
      \ifstrempty{#1}{}{%
        \global\toggletrue{before@pstartL@\the\l@dnumpstartsL @par}%
        \csgdef{before@pstartL@\the\l@dnumpstartsL}{\noindent#1}%
        }%
      \ifstrempty{#2}{}%
        {%
        \csgdef{before@pstartL@\the\l@dnumpstartsL}{#2}%
        \global\togglefalse{before@pstartL@\the\l@dnumpstartsL @par}%
        }%
    }%
   \at@every@pstart@call%
  \global\by@autoparfalse%
  \ignorespaces%
  }
\newcommandx*{\pstartR}[2][1,2,usedefault]{%
  \if@nobreak%
    \let\@oldnobreak\@nobreaktrue%
  \else%
    \let\@oldnobreak\@nobreakfalse%
  \fi%
    \@nobreaktrue%
  \ifluatex%
    \xdef\l@luatextextdir@R{\the\textdir}%
    \xdef\l@luatexpardir@R{\the\pardir}%
    \xdef\l@luatexbodydir@R{\the\bodydir}%
  \fi%
  \ifnumberingR \else%
    \led@err@PstartNotNumbered%
    \beginnumberingR%
  \fi%
  \ifnumberedpar@%
    \led@err@PstartInPstart%
    \pendR%
  \fi%
  \ifpst@rtedR\else%
    \list@clear{\inserts@listR}%
    \global\let\next@insertR=\empty%
    \global\pst@rtedRtrue%
  \fi%
  \begingroup\everypar{}%
  \global\advance\l@dnumpstartsR \@ne%
  \ifnum\l@dnumpstartsR>\l@dc@maxchunks%
    \led@err@TooManyPstarts%
    \global\l@dnumpstartsR=\l@dc@maxchunks%
  \fi%
  \global\setnamebox{l@dRcolrawbox\the\l@dnumpstartsR}=\vbox\bgroup%
    \l@dzeropenalties%
    \ifboolexpr{%
      bool{autopar}%
      and  bool{by@autopar}%
    }%
    {}%
    {%
      \ifnumberpstart%
        \ifsidepstartnum\else%
          \thepstartR%
        \fi%
      \fi%
    }%
  \@at@start@every@pstart%
  \hsize=\Rcolwidth%
  \numberedpar@true%
   \iflabelpstart%
     \protected@edef\@currentlabel{\p@pstartR\thepstartR}%
  \fi%
  \providetoggle{before@pstartR@\the\l@dnumpstartsR @par}%
  \ifboolexpr{%
    test {\ifstrempty{#1}}%
    and test {\ifstrempty{#2}}%
    }%
    {%
      \ifat@every@pstart@star@%
        \global\togglefalse{before@pstartR@\the\l@dnumpstartsR @par}%
      \else%
        \global\toggletrue{before@pstartR@\the\l@dnumpstartsR @par}%
      \fi%
      \csgdef{before@pstartR@\the\l@dnumpstartsR}{\at@every@pstart}%
    }%
    {%
      \ifstrempty{#1}{}{%
        \global\toggletrue{before@pstartR@\the\l@dnumpstartsR @par}%
        \csgdef{before@pstartR@\the\l@dnumpstartsR}{\noindent#1}%
      }%
      \ifstrempty{#2}{}%
      {%
        \csgdef{before@pstartR@\the\l@dnumpstartsR}{#2}%
        \global\togglefalse{before@pstartR@\the\l@dnumpstartsR @par}%
      }%
    }%
   \at@every@pstart@call%
   \global\by@autoparfalse%
   \ignorespaces%
  }
\newcommandx*{\pendL}[2][1,2,usedefault]{%
  \ifnumbering \else%
    \led@err@PendNotNumbered%
  \fi%
  \ifnumberedpar@ \else%
    \led@err@PendNoPstart%
  \fi%
  \@at@end@every@pend%
  \endgraf\global\num@lines=\prevgraf\egroup%
  \global\par@line=0%
  \endgroup%
  \ignorespaces%
  \@oldnobreak%
  \dump@pstartL@pc%
  \ifnumberpstart%
    \addtocounter{pstartL}{1}%
    \ifcontinuousnumberingwithcolumns%
      \addtocounter{pstart}{1}%
    \fi%
  \fi
  \parledgroup@beforenotes@save{L}%
  \providetoggle{after@pendL@\the\l@dnumpstartsL @par}%
  \ifboolexpr{%
    test {\ifstrempty{#1}}%
    and test {\ifstrempty{#2}}%
  }%
    {%
      \ifat@every@pend@star@%
        \global\togglefalse{after@pendL@\the\l@dnumpstartsL @par}%
      \else%
        \global\toggletrue{after@pendL@\the\l@dnumpstartsL @par}%
      \fi%
      \csgdef{after@pendL@\the\l@dnumpstartsL}{\at@every@pend}%
    }%
    {%
      \ifstrempty{#1}{}{%
        \global\toggletrue{after@pendL@\the\l@dnumpstartsL @par}%
        \csgdef{after@pendL@\the\l@dnumpstartsL}{\noindent#1}%
      }%
      \ifstrempty{#2}{}%
      {%
        \csgdef{after@pendL@\the\l@dnumpstartsL}{#2}%
        \global\togglefalse{after@pendL@\the\l@dnumpstartsL @par}%
      }%
    }%
}%
\newcommandx*{\pendR}[2][1,2,usedefault]{%
  \ifnumberingR \else%
    \led@err@PendNotNumbered%
  \fi%
  \ifnumberedpar@ \else%
    \led@err@PendNoPstart%
  \fi%
  \@at@end@every@pend%
  \endgraf\global\num@linesR=\prevgraf\egroup%
  \global\par@lineR=0%
  \endgroup%
  \ignorespaces%
  \@oldnobreak%
  \dump@pstartR@pc%
  \ifnumberpstart%
    \addtocounter{pstartR}{1}%
  \fi%
  \parledgroup@beforenotes@save{R}%
  \providetoggle{after@pendR@\the\l@dnumpstartsR @par}%
  \ifboolexpr{%
    test {\ifstrempty{#1}}%
    and test {\ifstrempty{#2}}%
  }%
    {%
      \ifat@every@pend@star@%
        \global\togglefalse{after@pendR@\the\l@dnumpstartsR @par}%
      \else%
        \global\toggletrue{after@pendR@\the\l@dnumpstartsR @par}%
      \fi%
      \csgdef{after@pendR@\the\l@dnumpstartsR}{\at@every@pend}}%
    {%
      \ifstrempty{#1}{}{%
        \csgdef{after@pendR@\the\l@dnumpstartsR}{\noindent#1}%
        \global\toggletrue{after@pendR@\the\l@dnumpstartsR @par}%
      }%
      \ifstrempty{#2}{}{%
          \csgdef{after@pendR@\the\l@dnumpstartsR}{#2}%
          \global\togglefalse{after@pendR@\the\l@dnumpstartsR @par}%
        }%
    }%
}

\newcommand{\AtEveryPstartCall}[1]{\gdef\at@every@pstart@call{#1}}%
\gdef\at@every@pstart@call{}%
\newif\ifprint@last@after@pendL%
\newif\ifprint@last@after@pendR%
\newbox\l@dleftbox
\newbox\l@drightbox

\newcount\countLline
  \countLline \z@
\newcount\countRline
  \countRline \z@

\newcount\@donereallinesL
\newcount\@donetotallinesL
\newcount\@donereallinesR
\newcount\@donetotallinesR

\newcommand*{\do@lineL}{%
  \letcs{\ifnumberpstart}{numberpstart@L\the\l@dpscL}%
  \letcs{\ifnumberline}{numberline@L\the\l@dpscL}%
  \advance\countLline \@ne%
  \ifvbox\namebox{l@dLcolrawbox\the\l@dpscL}%
    {\vbadness=10000%
     \splittopskip=\z@%
     \do@lineLhook%
     \l@demptyd@ta%
     \global\setbox\one@line=\vsplit\namebox{l@dLcolrawbox\the\l@dpscL}%
                           to\baselineskip}%
    \IfStrEq{\splitfirstmarks\parledgroup@}{begin}{\parledgroup@notes@startL}{}%
    \unvbox\one@line \global\setbox\one@line=\lastbox%
    \@writepageofparL%
    \getline@numL%
    \ifnum\@lock>\@ne%
      \inserthangingsymboltrue%
    \else%
      \inserthangingsymbolfalse%
    \fi%
    \setbox\l@dleftbox%
    \hb@xt@ \Lcolwidth{%
      \ifl@dhidenumber%
        \global\l@dhidenumberfalse%
        \f@x@l@cks%
      \else%
        \affixline@num%
      \fi%
      \xifinlist{\the\pstarts@typeset@L}{\eled@sections@@}%
        {\unless\ifshiftedpstarts%
          \add@apparatusL%
         \fi%
        }%
        {\print@lineL}%
      }%
    \add@penaltiesL%
    \global\advance\@donereallinesL\@ne%
    \global\advance\@donetotallinesL\@ne%
  \else%
    \iflinenumberLevenifblank
      \setbox\l@dleftbox \hb@xt@ \Lcolwidth{%
        \new@lineL%
        \l@demptyd@ta%
        \getline@numL%
        \affixline@num%
        \l@dld@ta%
        \hspace*{\Lcolwidth}%
        \ledrlfill\l@drd@ta%
      }%
    \else%
      \setbox\l@dleftbox \hb@xt@ \Lcolwidth{%
        \ifcontinuousnumberingwithcolumns%
          \new@lineL%
          \getline@numL%
        \fi%
        \hspace*{\Lcolwidth}%
      }%
    \fi%
    \global\advance\@donetotallinesL\@ne%
  \fi%
}%

\def\print@lineL{%
    \affixpstart@numL%
    \l@dld@ta%
    \add@apparatusL%
    \l@dlsn@te%
    \do@insidelineLhook%
    \csuse{insidethis@\the\absline@num @\the\section@num}%
    \global\csundef{insidethis@\the\absline@num @\the\section@num}%
    \hb@xt@ \Lcolwidth{\ledllfill\hb@xt@ \wd\one@line{%
            \ifluatex%
              \textdir\l@luatextextdir@L%
            \fi%
            \new@lineL%
            \inserthangingsymbolL%
            \l@dunhbox@line{\one@line}}\ledrlfill\l@drd@ta%
     \l@drsn@te}}%

\def\print@eledsectionL{%%
    \addtocounter{pstartL}{-1}%
    \ifdefstring{\@eledsectnotoc}{L}{\ledsectnotoc}{}
    \ifdefstring{\@eledsectmark}{L}{}{\ledsectnomark}
    \numdef{\temp@}{\pstarts@typeset@L-1}%
    \xifinlist{\temp@}{\eled@sections@@}{\@nobreaktrue}{\@nobreakfalse}%
    \@eled@sectioningtrue%
    \bgroup%
      \ifluatex%
        \textdir\l@luatextextdir@L%
        \pardir\l@luatexpardir@L%
        \bodydir\l@luatexbodydir@L%
        \ifdefstring{\l@luatextextdir@L}{TRT}{\@RTLtrue}{}%
      \fi%
      \csuse{eled@sectioning@\the\pstarts@typeset@L}%
    \egroup%
    \@eled@sectioningfalse%
    \global\csundef{eled@sectioning@\the\pstarts@typeset@L}%
    \if@RTL%
      \hspace{-3\paperwidth}%
    {\hbox{\l@dunhbox@line{\one@line}} \new@line}%
    \else%
      \hspace{3\paperwidth}%
    {\new@line \hbox{\l@dunhbox@line{\one@line}}}%
    \fi%
    \vskip\eledsection@correcting@skip%
}

\newcommand{\add@apparatusL}{%
  \if@firstlineofpage%
    \set@Xtxtbeforenotes%
    \set@txtbeforenotesX%
    \global\@firstlineofpagefalse%
  \fi%
  \ifdefstring{\ms@data@position}{msdata-regular}{%
    \insert@msdata%
    \add@inserts%
    \add@Xgroupbyline%
  }{%
    \add@inserts%
    \add@Xgroupbyline%
    \insert@msdata%
  }%
  \affixside@note%
}%
\newcommand*{\dolineLhook}[1]{\gdef\do@lineLhook{#1}}%
\newcommand*{\dolineRhook}[1]{\gdef\do@lineRhook{#1}}%
\newcommand*{\doinsidelineLhook}[1]{\gdef\do@insidelineLhook{#1}}%
\newcommand*{\doinsidelineRhook}[1]{\gdef\do@insidelineRhook{#1}}%

\newcommand*{\do@lineLhook}{}
\newcommand*{\do@lineRhook}{}
\newcommand*{\do@insidelineLhook}{}
\newcommand*{\do@insidelineRhook}{}

\newcommand*{\do@lineR}{%
  \let\linenumrepL\linenumrep%
  \let\sublinenumrepL\sublinenumrep%
  \let\linenumrep\linenumrepR%
  \let\sublinenumrep\sublinenumrepR%
  \letcs{\ifnumberpstart}{numberpstart@R\the\l@dpscR}%
  \letcs{\ifnumberline}{numberline@R\the\l@dpscR}%
  \ledRcol@true%
  \advance\countRline \@ne%
  \ifvbox\namebox{l@dRcolrawbox\the\l@dpscR}%
    {\vbadness=10000%
     \splittopskip=\z@%
     \do@lineRhook%
     \l@demptyd@ta%
     \global\setbox\one@lineR=\vsplit\namebox{l@dRcolrawbox\the\l@dpscR}%
                           to\baselineskip}%
    \IfStrEq{\splitfirstmarks\parledgroup@}{begin}{\parledgroup@notes@startR}{}%
    \unvbox\one@lineR \global\setbox\one@lineR=\lastbox%
    \@writepageofparR%
    \getline@numR%
    \ifnum\@lockR>\@ne%
      \inserthangingsymbolRtrue%
    \else%
      \inserthangingsymbolRfalse%
    \fi%
    \setbox\l@drightbox%
    \hb@xt@ \Rcolwidth{%
      \ifl@dhidenumber%
        \global\l@dhidenumberfalse%
        \f@x@l@cksR%
      \else%
        \affixline@numR%
      \fi%
     \xifinlist{\the\l@dpscR}{\eled@sectionsR@@}%
       {\unless\ifshiftedpstarts%
          \add@apparatusR%
         \fi%
       }%
       {\print@lineR}%
    }%
    \add@penaltiesR%
    \global\advance\@donereallinesR\@ne%
    \global\advance\@donetotallinesR\@ne%
  \else%
    \iflinenumberRevenifblank%
      \setbox\l@drightbox \hb@xt@ \Rcolwidth{%
        \new@lineR%
        \l@demptyd@ta%
        \getline@numR%
        \affixline@numR%
        \l@dld@ta%
        \hspace*{\Rcolwidth}%
        \ledrlfill\l@drd@ta%
      }%
    \else%
      \setbox\l@drightbox \hb@xt@ \Rcolwidth{%
        \ifcontinuousnumberingwithcolumns%
          \new@lineR%
          \getline@numR%
        \fi%
        \hspace*{\Rcolwidth}%
      }%
    \fi%
    \global\advance\@donetotallinesR\@ne%
  \fi%
  \ledRcol@false%
  \let\linenumrep\linenumrepL%
  \let\sublinenumrep\sublinenumrepL%
}

\def\print@lineR{%
    \affixpstart@numR%
    \l@dld@ta%
    \add@apparatusR%
    \l@dlsn@te%
    \do@insidelineRhook%
    \global\csundef{insidethisR@\the\absline@numR @\the\section@numR}%
    \hb@xt@ \Rcolwidth{\ledllfill\hb@xt@ \wd\one@lineR{%
       \new@lineR%
       \inserthangingsymbolR%
       \ifluatex%
              \textdir\l@luatextextdir@R%
       \fi%
       \l@dunhbox@line{\one@lineR}}\ledrlfill\l@drd@ta%
     \l@drsn@te%
    }%
}

\def\print@eledsectionR{%
    \addtocounter{pstartR}{-1}%
    \set@sectcountR%
    \ifdefstring{\@eledsectnotoc}{R}{\ledsectnotoc}{}%
    \ifdefstring{\@eledsectmark}{R}{}{\ledsectnomark}%
    \numdef{\temp@}{\l@dpscR-1}%
    \xifinlist{\temp@}{\eled@sectionsR@@}{\@nobreaktrue}{\@nobreakfalse}%
    \@eled@sectioningtrue%
    \bgroup%
      \ifluatex%
            \textdir\l@luatextextdir@R%
            \pardir\l@luatexpardir@R%
            \bodydir\l@luatexbodydir@R%
            \ifdefstring{\l@luatextextdir@L}{TRT}{\@RTLtrue}{}%
      \fi%
      \csuse{eled@sectioning@\the\l@dpscR R}%
    \egroup%
    \@eled@sectioningfalse%
    \global\csundef{eled@sectioning@\the\l@dpscR R}%
    \if@RTL%
      \hspace{-3\paperwidth}%
    {\hbox{\l@dunhbox@line{\one@lineR}} \new@lineR}%
    \else%
      \hspace{3\paperwidth}%
    {\new@lineR \hbox{\l@dunhbox@line{\one@lineR}}}%
    \fi%
    \vskip\eledsection@correcting@skip
}
\newcommand{\add@apparatusR}{%
 \if@firstlineofpageR%
   \set@Xtxtbeforenotes%
   \set@txtbeforenotesX%
   \global\@firstlineofpageRfalse%
 \fi%
 \ifdefstring{\ms@data@position}{msdata-regular}{%
    \insert@msdata%
    \add@insertsR%
    \add@Xgroupbyline%
 }{%
    \add@insertsR%
    \add@Xgroupbyline%
    \insert@msdata%
 }%
 \affixside@noteR%
}%
\newcommand*{\getline@numR}{%
  \global\advance\absline@numR \@ne
  \do@actionsR
  \do@ballastR
  \ifledgroupnotesR@\else
        \ifnumberline
          \ifsublines@R
            \ifnum\sub@lockR<\tw@
              \global\advance\subline@numR \@ne
           \fi
          \else
            \ifnum\@lockR<\tw@
              \global\advance\line@numR \@ne
              \global\subline@numR \z@
            \fi
          \fi
        \fi
  \fi
}
\newcommand*{\getline@numL}{%
  \global\advance\absline@num \@ne
  \do@actions
  \do@ballast
      \ifledgroupnotesL@\else
        \ifnumberline
           \ifsublines@
             \ifnum\sub@lock<\tw@
               \global\advance\subline@num \@ne
             \fi
           \else
             \ifnum\@lock<\tw@
                \global\advance\line@num \@ne
                \global\subline@num \z@
             \fi
           \fi
      \fi
  \fi
}

\newcommand*{\do@ballastR}{\global\ballast@count=\z@
  \begingroup
    \advance\absline@numR \@ne
    \ifnum\next@actionlineR=\absline@numR
      \ifnum\next@actionR>-1001
        \global\advance\ballast@count by -\c@ballast
       \fi
     \fi
  \endgroup}

\newif\ifl@dskipversenumberR
\newcommand*{\do@actions@fixedcodeR}{%
  \ifcase\@l@dtempcnta%
  \or%                     % 1001 = starting sublineation
    \global\sublines@Rtrue
  \or%                     % 1002 = ending sublineation
    \global\sublines@Rfalse
  \or%                     % 1003 = starting locking number
    \global\@lockR=\@ne
  \or%                     % 1004 = ending locking number
    \ifnum\@lockR=\tw@
      \global\@lockR=\thr@@
    \else
      \global\@lockR=\z@
    \fi
  \or%                     % 1005 = starting locking subnumber
     \global\sub@lockR=\@ne
  \or%                     % 1006 = ending locking subnumber
    \ifnum\sub@lockR=\tw@
      \global\sub@lockR=\thr@@
    \else
      \global\sub@lockR=\z@
    \fi
  \or%                     % 1007 = skipping numbering
    \l@dskipnumbertrue
 \or%                      % 1008 = skipping numbering in stanza
    \l@dskipversenumberRtrue%
 \or%                      % 1009 = hiding number
    \l@dhidenumbertrue%
 \or%                       % 1010 = inserting msdata
    \add@msdata%
 \else%
    \led@warn@BadAction
 \fi%
}

\newcommand*{\do@actionsR}{%
  \global\let\do@actions@nextR=\relax
  \@l@dtempcntb=\absline@numR
  \ifnum\@l@dtempcntb<\next@actionlineR\else
    \ifnum\next@actionR>-1001\relax
      \ifboolexpr{%
       bool{resumenumberingR@start}%
        and test {\ifdimgreater{\pagedepth}{\z@}}%
      }%
       {}%
       {\@firstlineofpageRtrue}%
      \global\page@numR=\next@actionR
      \ifcsdef{reset@lineR\the\absline@numR @\the\section@numR}%
         {%
         \global\line@numR=\z@ \global\subline@numR=\z@%
         }%
         {}%
      \global\resumenumberingR@startfalse%
      \add@msdata@firstlineofpage%
    \else
      \ifnum\next@actionR<-4999\relax   %  9/05 added relax here
        \@l@dtempcnta=-\next@actionR
        \advance\@l@dtempcnta by -5001\relax
        \ifsublines@R
          \global\subline@numR=\@l@dtempcnta
        \else
          \global\line@numR=\@l@dtempcnta
        \fi
      \else
        \@l@dtempcnta=-\next@actionR
        \advance\@l@dtempcnta by -1000\relax
        \do@actions@fixedcodeR
      \fi
    \fi
    \ifx\actionlines@listR\empty
      \gdef\next@actionlineR{1000000}%
    \else
      \gl@p\actionlines@listR\to\next@actionlineR
      \gl@p\actions@listR\to\next@actionR
      \global\let\do@actions@nextR=\do@actionsR
    \fi
  \fi
  \do@actions@nextR}


\newcommand*{\l@dcalcnum}[3]{%
  \ifnum #1 > #2\relax
    \@l@dtempcnta = #1\relax
    \advance\@l@dtempcnta by -#2\relax
    \divide\@l@dtempcnta by #3\relax
    \multiply\@l@dtempcnta by #3\relax
    \advance\@l@dtempcnta by #2\relax
  \else
    \@l@dtempcnta=#2\relax
  \fi}

\newcommand*{\ch@cksub@l@ckR}{%
  \ifcase\sub@lockR
  \or
    \ifnum\sublock@disp=\@ne
      \@l@dtempcntb \z@  \@l@dtempcnta \@ne
    \fi
  \or
    \ifnum\sublock@disp=\tw@
    \else
      \@l@dtempcntb \z@  \@l@dtempcnta \@ne
    \fi
  \or
    \ifnum\sublock@disp=\z@
      \@l@dtempcntb \z@  \@l@dtempcnta \@ne
    \fi
  \fi}

\newcommand*{\ch@ck@l@ckR}{%
  \ifcase\@lockR
  \or
    \ifnum\lock@disp=\@ne
      \@l@dtempcntb \z@  \@l@dtempcnta \@ne
    \fi
  \or
    \ifnum\lock@disp=\tw@
    \else
      \@l@dtempcntb \z@  \@l@dtempcnta \@ne
    \fi
  \or
    \ifnum\lock@disp=\z@
      \@l@dtempcntb \z@  \@l@dtempcnta \@ne
    \fi
  \fi}

\newcommand*{\f@x@l@cksR}{%
  \ifcase\@lockR
  \or
    \global\@lockR \tw@
  \or \or
    \global\@lockR \z@
  \fi
  \ifcase\sub@lockR
  \or
    \global\sub@lockR \tw@
  \or \or
    \global\sub@lockR \z@
  \fi}

\let\linenumberlistR\empty%
\newcommand*{\affixline@numR}{%
\ifledgroupnotesR@\else\ifnumberline
\ifl@dskipnumber
  \global\l@dskipnumberfalse
\else
  \ifsublines@R
    \@l@dtempcntb=\subline@numR
    \l@dcalcnum{\subline@numR}{\c@firstsublinenumR}{\c@sublinenumincrementR}%
    \ch@cksub@l@ckR
  \else
    \@l@dtempcntb=\line@numR
    \ifx\linenumberlistR\empty%
      \l@dcalcnum{\line@numR}{\c@firstlinenumR}{\c@linenumincrementR}%
    \else
      \@l@dtempcnta=\line@numR
      \edef\rem@inderR{,\linenumberlistR,\number\line@numR,}%
        \edef\sc@n@list{\def\noexpand\sc@n@list
        ####1,\number\@l@dtempcnta,####2|{\def\noexpand\rem@inderR{####2}}}%
      \sc@n@list\expandafter\sc@n@list\rem@inderR|%
        \ifx\rem@inderR\empty\advance\@l@dtempcnta\@ne\fi%
     \fi
     \ch@ck@l@ckR
  \fi
  \ifnum\@l@dtempcnta=\@l@dtempcntb
    \ifl@dskipversenumberR\else
      \if@twocolumn
        \if@firstcolumn
          \gdef\l@dld@ta{\llap{{\leftlinenumR}}}%
        \else
          \gdef\l@drd@ta{\rlap{{\rightlinenumR}}}%
        \fi
      \else
        \ifboolexpr{bool {l@dprintingcolumns} and test {\ifnumgreater{\line@margin@columnsR}{\m@ne}}}%
          {\@l@dtempcntb=\line@margin@columnsR}%
          {\@l@dtempcntb=\line@marginR}%
        \ifnum\@l@dtempcntb>\@ne
          \advance\@l@dtempcntb by\page@numR
        \fi
        \ifboolexpr{%
           bool {l@dprintingcolumns}%
           and (%
             (test {\ifdefstring{\linenum@OnlyPages@ForColumnsR}{left}}%
             and test {\ifnumodd{\page@numR}}%
             )%
             or%
             (test {\ifdefstring{\linenum@OnlyPages@ForColumnsR}{right}}%
             and not test {\ifnumodd{\page@numR}}%
             )%
           )%
        }%
        {}%
        {%
          \ifodd\@l@dtempcntb%
            \gdef\l@drd@ta{\rlap{{\rightlinenumR}}}%
          \else%
            \gdef\l@dld@ta{\llap{{\leftlinenumR}}}%
          \fi%
        }%
      \fi
    \fi
  \fi
  \f@x@l@cksR
\fi
\fi
\fi}

\newcommand*{\affixpstart@numL}{%
\ifsidepstartnum
\if@twocolumn
     \if@firstcolumn
       \gdef\l@dld@ta{\llap{{\leftpstartnumL}}}%
     \else
       \gdef\l@drd@ta{\rlap{{\rightpstartnumL}}}%
     \fi
    \else
     \ifboolexpr{bool {l@dprintingcolumns} and test {\ifnumgreater{\line@margin@columns}{\m@ne}}}%
          {\@l@dtempcntb=\line@margin@columns}%
          {\@l@dtempcntb=\line@margin}%
     \ifnum\@l@dtempcntb>\@ne
       \advance\@l@dtempcntb \page@num
     \fi
     \ifodd\@l@dtempcntb
       \gdef\l@drd@ta{\rlap{{\rightpstartnumL}}}%
     \else
       \gdef\l@dld@ta{\llap{{\leftpstartnumL}}}%
     \fi
    \fi
\fi
}
\newcommand*{\affixpstart@numR}{%
\ifsidepstartnum
\if@twocolumn
     \if@firstcolumn
       \gdef\l@dld@ta{\llap{{\leftpstartnumR}}}%
     \else
       \gdef\l@drd@ta{\rlap{{\rightpstartnumR}}}%
     \fi
    \else
     \ifboolexpr{bool {l@dprintingcolumns} and test {\ifnumgreater{\line@margin@columnsR}{\m@ne}}}%
          {\@l@dtempcntb=\line@margin@columnsR}%
          {\@l@dtempcntb=\line@marginR}%
     \ifnum\@l@dtempcntb>\@ne
       \advance\@l@dtempcntb \page@numR
     \fi
     \ifodd\@l@dtempcntb
       \gdef\l@drd@ta{\rlap{{\rightpstartnumR}}}%
     \else
       \gdef\l@dld@ta{\llap{{\leftpstartnumR}}}%
     \fi
    \fi
\fi
}

\newcommand*{\leftpstartnumL}{
\ifpstartnum
\thepstartL
\kern\linenumsep\global\pstartnumfalse\fi
}
\newcommand*{\rightpstartnumL}{
\ifpstartnum\kern\linenumsep
\thepstartL
\global\pstartnumfalse\fi
}
\newif\ifpstartnumR
\pstartnumRtrue
\newcommand*{\leftpstartnumR}{
\ifpstartnumR
\thepstartR
\kern\linenumsep\global\pstartnumRfalse\fi
}
\newcommand*{\rightpstartnumR}{
\ifpstartnumR\kern\linenumsep
\thepstartR
\global\pstartnumRfalse\fi
}
\list@create{\inserts@listR}
\newcommand*{\add@insertsR}{%
  \global\let\add@inserts@nextR=\relax
  \ifx\inserts@listR\empty \else
    \ifx\next@insertR\empty
      \ifx\insertlines@listR\empty
        \global\noteschanged@true
        \gdef\next@insertR{100000}%
      \else
        \gl@p\insertlines@listR\to\next@insertR
      \fi
    \fi
    \ifnum\next@insertR=\absline@numR
      \gl@p\inserts@listR\to\@insertR
      \@insertR
      \global\let\@insertR=\undefined
      \global\let\next@insertR=\empty
      \global\let\add@inserts@nextR=\add@insertsR
    \fi
  \fi
  \add@inserts@nextR}

\newcommand*{\add@penaltiesL}{}
\newcommand*{\add@penaltiesR}{}

\newcommand*{\flush@notesR}{%
  \iftoggle{notfirstrun@\jobname.\extensionchars\the\section@numR R}{%
    \@xloop%
      \ifx\inserts@listR\empty \else%
        \gl@p\inserts@listR\to\@insertR%
        \@insertR%
        \global\let\@insertR=\undefined%
    \repeat%
   }{}%
}%


\newcommand\print@Xnotes@forpages[1]{%
   \ifcsempty{Xonlyside@#1}{%
     \csuse{#1footstart}{#1}%
     \csuse{#1footgroup}{#1}%
   }%
   {%
     \ifboolexpr{%
       ((test {\ifcsstring{Xonlyside@#1}{L}} and not test{\ifnumodd{\c@page}})%
       or%
       (test {\ifcsstring{Xonlyside@#1}{R}} and test{\ifnumodd{\c@page}}))%
       }%
      {%
         \csuse{#1footstart}{#1}%
         \csuse{#1footgroup}{#1}%
         \global\count\csuse{#1footins}=\z@%
         \global\skip\csuse{#1footins}=\z@%
         \global\dimen\csuse{#1footins}=\maxdimen%
     }%
       {%
         \restore@Xnotes@settings{#1}%
       }%
     }%
}%
\newcommand{\restore@Xnotes@settings}[1]{%
  \unless\ifnocritical@
    \global\count\csuse{#1footins}=\csuse{default@#1footins}%
    \global\skip\csuse{#1footins}=\csuse{Xbeforenotes@#1}%
    \bgroup%
      \csuse{Xnotefontsize@#1}%
      \global\dimen\csuse{#1footins}=\csuse{Xmaxhnotes@#1}%
    \egroup%
    \global\setnamebox{#1footins@kept}=\box\namebox{#1footins}%
  \fi
}%
\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}=\z@%
         \global\skip\csuse{footins#1}=\z@%
         \global\dimen\csuse{footins#1}=\maxdimen%
       }%
       {%
         \restore@notesX@settings{#1}%
       }%
     }%
}%
\newcommand{\restore@notesX@settings}[1]{%
  \unless\ifnofamiliar@
    \global\count\csuse{footins#1}=\csuse{default@footins#1}%
    \global\skip\csuse{footins#1}=\csuse{beforenotesX@#1}%
    \bgroup%
      \csuse{Xnotefontsize@#1}%
    \global\dimen\csuse{footins#1}=\csuse{maxhnotesX@#1}%
    \egroup%
    \global\setnamebox{footins#1@kept}=\box\namebox{footins#1}%
  \fi
}%
\newcommand{\insert@notes@for@onlyside}{%
  \def\do##1{%
  \unless\ifnocritical@%
    \ifvoid\csuse{##1footins@kept}\else%
      \expandafter\insert\csname ##1footins\endcsname%
      \bgroup%
        \unvnamebox{##1footins@kept}%
      \egroup%
    \fi%
    \restore@Xnotes@settings{##1}%
  \fi%
  \unless\ifnofamiliar@%
    \ifvoid\csuse{footins##1@kept}\else%
      \expandafter\insert\csname footins##1\endcsname%
      \bgroup%
        \unvnamebox{footins##1@kept}%
      \egroup%
    \fi%
    \restore@notesX@settings{##1}%
  \fi%
  }%
  \dolistloop{\@series}%
}%
\newcount\edtext@now%
\newcount\edtext@later%
\newcommand{\edtextlater}[2]{%#1 lemma, #2 critical notes
  \global\advance\edtext@later by \@ne%
  \advance\@edtext@level by \@ne%
  \ifcsvoid{sw@list@edtext@\the\@edtext@level}%
              {\global\let\sw@inthisedtext\empty}%
              {\expandafter\gl@p\csname sw@list@edtext@\the\@edtext@level\endcsname\to\sw@inthisedtext}%
  \csxdef{edtext@later@\the\edtext@later}{%
      \noexpand\edtext{%
      }%
      {%
      \unexpanded{%
        \lemma{\no@expands #1}%
      }%
      \noexpand\xxref{start:edtext:later:\the\edtext@later}{end:edtext:later:\the\edtext@later}%
      \noexpand\linenum{||||||\edfont@info}%
      \unexpanded{\def\sw@inthisedtext}{\expandonce{\sw@inthisedtext}}%
      \ifledRcol%
        \unexpanded{\appto\@beforeinsertofthisedtext{\ledRcol@true}}%
        {%
          \noexpand\setcounter{pstartR}{\noexpand\xpstartref{start:edtext:later:\the\edtext@later}}%
        }%
      \else%
        \unexpanded{\appto\@beforeinsertofthisedtext{\ledRcol@false}}%
        \unexpanded{\appto\@beforeinsertofthisedtext}%
        {%
          \noexpand\setcounter{pstartL}{\noexpand\xpstartref{start:edtext:later:\the\edtext@later}}%
        }%
      \fi%
      \unexpanded{#2}%
    }%
  }%
  \edlabel{start:edtext:later:\the\edtext@later}%
  \flag@start@later%
  \bgroup%
    \def\lemma##1{%
         \ifledRcol%
           \write\linenum@outR{\string\@lemma}%
         \else%
           \write\linenum@out{\string\@lemma}%
         \fi%
    }%
    \renewcommand{\do}[1]{\expandafter\renewcommandx\csname ##1footnote\endcsname[2][1,usedefault]{}\unskip}%\unskip because of a spurious space in \newcommandx
    \dolistloop{\@series}%
    #2%
  \egroup%
  \showlemma{#1}%
  \edlabel{end:edtext:later:\the\edtext@later}%
  \flag@end@later%
  \advance\@edtext@level by -\@ne%
}%
\newcommand{\edtextnow}[0]{%
  \global\advance\edtext@now by \@ne
  \csuse{edtext@later@\the\edtext@now}%
}%
\list@create{\labelref@listR}

\def\l@dmake@labelsR#1|#2|#3|#4|#5|#6|#7{%
  \expandafter\ifx\csname the@label\csuse{XR@prefix}#7\endcsname%
    \relax%
  \else%
    \led@warn@DuplicateLabel{\csuse{XR@prefix}#7}%
  \fi%
  \csgdef{the@label\csuse{XR@prefix}#7}{#1|#2|#3|#4|#5|#6|\@Rlineflag}%
  \global\providetoggle{label@#7@ledRcol}%False is the default value of this toggle, which tells us whether a label is linked to the right or left side
  \global\toggletrue{label@#7@ledRcol}%
  \ignorespaces}
\AtBeginDocument{%
  \def\l@dmake@labelsR#1|#2|#3|#4|#5|#6|#7{}%
}

\WithSuffix\newcommand\sidenotemargin*[1]{%
  \l@dgetsidenote@margin{#1}
  \global\sidenote@marginR=\@l@dtempcntb
  \global\sidenote@margin=\@l@dtempcntb
}
\newcommand{\sidenotemarginR}[1]{%
  \l@dgetsidenote@margin{#1}%
  \global\sidenote@marginR=\@l@dtempcntb%
}%
\newcount\sidenote@marginR
\global\sidenote@marginR=\@ne%

\ifmovecolumnspositiononrightpage%
  \sidenotemargin{inner}%
  \sidenotemarginR{outer}%
\fi%

\newdimen\@morespace@leftnote@rightcolumn%
\newdimen\@morespace@rightnote@leftcolumn%

\newcommand{\get@sidenote@morespace@columns}{%
  \if@sidenotesmarginpage%
    \global\@morespace@leftnote@rightcolumn=\dimexpr\intercolumns@width + \Lcolwidth\relax%
    \global\@morespace@rightnote@leftcolumn=\dimexpr\intercolumns@width + \Rcolwidth\relax%
  \else%
    \global\@morespace@leftnote@rightcolumn=\z@%
    \global\@morespace@rightnote@leftcolumn=\z@%
  \fi%
}%
\newcommand*{\affixside@noteR}{%
    \prepare@edindex@fornote{\the\page@numR|\the\line@numR|\the\subline@numR|\the\page@numR|\the\line@numR|\the\subline@numR|}%
    \def\sidenotecontent@{}%
    \numgdef{\itemcount@}{0}%
    \def\do##1{%
        \ifnumequal{\itemcount@}{0}%
            {%
            \appto\sidenotecontent@{##1}}% Not print not separator before the 1st note
            {\appto\sidenotecontent@{\@sidenotesep ##1}%
            }%
            \numgdef{\itemcount@}{\itemcount@+1}%
    }%
    \dolistloop{\l@dcsnotetext}%
    \ifnumgreater{\itemcount@}{1}{\led@err@ManySidenotes}{}%
  \gdef\@templ@d{}%
  \gdef\@templ@n{\l@dcsnotetext\l@dcsnotetext@l\l@dcsnotetext@r}%
  \ifx\@templ@d\@templ@n \else%
    \if@twocolumn%
      \if@firstcolumn%
        \setl@dlp@rbox{##1}{\sidenotecontent@}%
      \else%
        \setl@drp@rbox{\sidenotecontent@}%
      \fi%
    \else%
      \@l@dtempcntb=\sidenote@marginR%
      \ifnum\@l@dtempcntb>\@ne%
        \advance\@l@dtempcntb by\page@numR%
      \fi%
      \ifodd\@l@dtempcntb%
        \setl@drp@rbox{\sidenotecontent@}%
        \gdef\sidenotecontent@{}%
        \numdef{\itemcount@}{0}%
        \dolistloop{\l@dcsnotetext@l}%
        \ifnumgreater{\itemcount@}{1}{\led@err@ManyLeftnotes}{}%
        \setl@dlp@rbox{\sidenotecontent@}%
      \else%
        \setl@dlp@rbox{\sidenotecontent@}%
        \gdef\sidenotecontent@{}%
        \numdef{\itemcount@}{0}%
        \dolistloop{\l@dcsnotetext@r}%
        \ifnumgreater{\itemcount@}{1}{\led@err@ManyRightnotes}{}%
        \setl@drp@rbox{\sidenotecontent@}%
      \fi%
    \fi%
  \fi%
  \advance\@edindex@fornote@\m@ne%
}

\newif\ifinserthangingsymbolR
\newcommand{\inserthangingsymbolL}{%
  \ifinserthangingsymbol%
    \ifinstanzaL%
        \hskip \@ifundefined{sza@0@}{0}{\expandafter%
          \noexpand\csname sza@0@\endcsname}\stanzaindentbase%
        \@hangingsymbol%
    \fi%
  \fi%
}%
\newcommand{\inserthangingsymbolR}{%
  \ifinserthangingsymbolR%
    \ifinstanzaR%
        \hskip \@ifundefined{sza@0@}{0}{\expandafter%
           \noexpand\csname sza@0@\endcsname}\stanzaindentbase%
        \@hangingsymbol%
    \fi%
  \fi%
}%

  \chardef\next=\catcode`\&
  \catcode`\&=\active

\newenvironmentx{astanza}[2][1,2,usedefault]{%
  \catcode`\&\active
  \global\stanza@count\@ne\stanza@modulo\@ne
  \ifnum\usenamecount{sza@0@}=\z@
    \let\stanza@hang\relax
    \let\endlock\relax
  \else
    \rightskip\z@ plus 1fil\relax
  \fi
  \ifnum\usenamecount{szp@0@}=\z@
    \let\sza@penalty\relax
  \fi
  \def&{%
    \endlock\mbox{}%
    \sza@penalty
    \global\advance\stanza@count\@ne
    \@astanza@line}%
  \def\&{\@stopastanza}%
  \ifboolexpr{%
    not test{\ifdefvoid{\at@every@stanza}}%
    and test{\ifstrempty{#1}}%
    and test{\ifstrempty{#2}}}%
    {\pstart[][\at@every@stanza]\at@start@every@stanza}%
    {\pstart[#1][#2]\at@start@every@stanza}%
  \@astanza@line
  \let\par\relax\ignorespaces%No paragraph in verses
}{}

\newcommandx{\@stopastanza}[2][1,2,usedefault]{%
  \endlock\mbox{}%
  \ifboolexpr{%
    not test{\ifdefvoid{\at@every@stop@stanza}}%
    and test{\ifstrempty{#1}}%
    and test{\ifstrempty{#2}}%
    }%
      {\before@every@stop@stanza\pend[][\at@every@stop@stanza]}%
      {\before@every@stop@stanza\pend[#1][#2]}%
}%
\newcommand*{\@astanza@line}{%
  \ifnum\value{stanzaindentsrepetition}=0
        \ifcsdef{sza@\number\stanza@count @}%
          {%
          \parindent=\csname sza@\number\stanza@count  @\endcsname\stanzaindentbase%
          }{%
          \led@err@StanzaIndentNotDefined%
          }%
  \else
        \ifcsdef{sza@\number\stanza@modulo @}{%
          \parindent=\csname sza@\number\stanza@modulo @\endcsname\stanzaindentbase%
          \managestanza@modulo%
        }%
        {%
        \led@err@StanzaIndentNotDefined%
        }%
  \fi
  \endgraf
  \stanza@hang%
  \ignorespaces}

  \catcode`\&=\next

\newcounter{stanzaL}
\newcounter{stanzaR}
\renewcommand{\thestanzaL}{%
  \textbf{\arabic{stanzaL}}%
}
\renewcommand{\thestanzaR}{%
  \textbf{\arabic{stanzaR}}%
}
\newif\ifl@dusedbabel
\patchcmd{\bbl@set@language}%
  {\select@language{\languagename}}%
  {\edef\languagename{#1}\select@language{\languagename}}%
  {}%
  {}%

\newcommand*{\l@duselanguage}[1]{}
\gdef\theledlanguageL{}
\gdef\theledlanguageR{}

\AtBeginDocument{%
  \@ifundefined{xpg@main@language}{%
    \@ifundefined{bbl@main@language}{%
    \l@dusedbabelfalse
    }{%
    \l@dusedbabeltrue
    \let\l@doldselectlanguage\selectlanguage
    \let\l@doldbbl@set@language\bbl@set@language
    \renewcommand{\selectlanguage}[1]{%
      \l@doldselectlanguage{#1}%
      \ifledRcol \gdef\theledlanguageR{#1}%
      \else      \gdef\theledlanguageL{#1}%
      \fi}
    \renewcommand*{\l@duselanguage}[1]{%
      \expandafter\l@doldselectlanguage\expandafter{#1}}
    \gdef\theledlanguageL{\bbl@main@language}%
    \gdef\theledlanguageR{\bbl@main@language}%
    }%
   }
  {    \let\old@otherlanguage\otherlanguage%
       \renewcommand{\otherlanguage}[2][]{%
        \selectlanguage[#1]{#2}%
        \ifledRcol  \gdef\theledlanguageR{#2}%
        \else      \gdef\theledlanguageL{#2}%
        \fi}%
      \renewcommand{\l@duselanguage}[1]{%
        \csuse{no\languagename @numbers}\select@language{#1}%
      }%
      \gdef\theledlanguageL{\xpg@main@language}%
      \gdef\theledlanguageR{\xpg@main@language}%
}}
\newcount\l@dc@maxchunks
\newcommand{\maxchunks}[1]{\l@dc@maxchunks=#1}
  \maxchunks{5120}

\newcount\l@dnumpstartsR

\newcount\l@dpscL
\newcount\l@dpscR

\newcommand*{\l@dsetuprawboxes}{%
  \@l@dtempcntb=\l@dc@maxchunks
  \loop\ifnum\@l@dtempcntb>\z@
    \newnamebox{l@dLcolrawbox\the\@l@dtempcntb}
    \newnamebox{l@dRcolrawbox\the\@l@dtempcntb}
    \advance\@l@dtempcntb \m@ne
  \repeat}

\newcommand*{\l@dsetupmaxlinecounts}{%
  \@l@dtempcntb=\l@dc@maxchunks
  \loop\ifnum\@l@dtempcntb>\z@
    \newnamecount{l@dmaxlinesinpar\the\@l@dtempcntb}
    \advance\@l@dtempcntb \m@ne
  \repeat}
\newcommand*{\l@dzeromaxlinecounts}{%
  \begingroup
  \@l@dtempcntb=\l@dc@maxchunks
  \loop\ifnum\@l@dtempcntb>\z@
    \global\usenamecount{l@dmaxlinesinpar\the\@l@dtempcntb}=\z@
    \advance\@l@dtempcntb \m@ne
  \repeat
  \endgroup}

\AtBeginDocument{%
  \l@dsetuprawboxes
  \l@dsetupmaxlinecounts
  \l@dzeromaxlinecounts
  \l@dnumpstartsL=\z@
  \l@dnumpstartsR=\z@
  \l@dpscL=\z@
  \l@dpscR=\z@}

\newif\if@pstarts
\newcommand*{\check@pstarts}{%
  \@pstartsfalse
  \ifnum\l@dnumpstartsL>\l@dpscL
    \@pstartstrue
  \else
    \ifnum\l@dnumpstartsR>\l@dpscR
      \@pstartstrue
    \fi
  \fi
}

\newif\ifaraw@text
\newcommand*{\checkraw@text}{%
  \araw@textfalse
  \ifvbox\namebox{l@dLcolrawbox\the\l@dpscL}
    \araw@texttrue
  \else
    \ifvbox\namebox{l@dRcolrawbox\the\l@dpscR}
      \araw@texttrue
    \fi
  \fi
}

\newcommand*{\@writelinesinparL}{%
  \edef\next{%
    \write\linenum@out{\string\@pend[\the\@donereallinesL]}}%
  \next
  \global\@donereallinesL \z@}
\newcommand*{\@writelinesinparR}{%
  \edef\next{%
    \write\linenum@outR{\string\@pendR[\the\@donereallinesR]}}%
  \next
  \global\@donereallinesR \z@}

\newcommand*{\@writepageofparL}[0]{%
  \ifnum\@donereallinesL=\z@%
    \edef\next{%
      \write\linenum@out{\string\@pstart{\the\l@dpscL}{\the\c@page}{\the\numpagelinesL}}%
    }%
    \next%
  \fi%
}%
\newcommand*{\@writepageofparR}[0]{%
  \ifnum\@donereallinesR=\z@%
    \edef\next{%
      \write\linenum@outR{\string\@pstartR{\the\l@dpscR}{\the\c@page}{\the\numpagelinesR}}%
    }%
  \next%
  \fi%
}%
\newsavebox{\@eledsectionL}%
\newsavebox{\@eledsectionR}%
\newcommand*{\Columns}{%
  \ifl@dpairing%
    \led@err@Columns@InsideEnv%
  \fi%
    \ifboolexpr{test{\ifcsboxvoid{l@dRcolrawbox1}} or test{\ifcsboxvoid{l@dLcolrawbox1}}}{%
    \ifcsboxvoid{l@dRcolrawbox1}{%
        \ifcsboxvoid{l@dLcolrawbox1}%
          {\led@err@Columns@WithoutEnv}%
          {\led@err@Columns@WithoutRightside}%
      }%
      {\led@err@Columns@WithoutLeftside}%
  }{%
  \global\l@dprintingcolumnstrue%
  \eledsection@correcting@skip=-\baselineskip% Correction for sections' titles
  \ifnum\l@dnumpstartsL=\l@dnumpstartsR\else
    \led@err@BadLeftRightPstarts{\the\l@dnumpstartsL}{\the\l@dnumpstartsR}%
  \fi
  \begingroup
    \l@dzeropenalties
    \endgraf\global\num@lines=\prevgraf
            \global\num@linesR=\prevgraf
    \global\par@line=\z@
    \global\par@lineR=\z@
    \global\l@dpscL=\z@
    \global\l@dpscR=\z@
    \get@familiarfootnote@number%
    \get@intercolumns@width%
    \get@sidenote@morespace@columns%
    \check@pstarts
    \loop\if@pstarts
        \global\pstartnumtrue
        \global\pstartnumRtrue
      \global\advance\l@dpscL \@ne
      \global\advance\l@dpscR \@ne
      \global\advance\pstarts@typeset@L\@ne%
      \restore@pstartL@pc%
      \restore@pstartR@pc%
      \Columns@print@before@pstart%
      \checkraw@text
{        \loop\ifaraw@text
            \l@duselanguage{\theledlanguageL}%
            \do@lineL
            \xifinlist{\the\pstarts@typeset@L}{\eled@sections@@}%
                {%
                \ifdefstring{\@eledsectmark}{L}%
                  {\csuse{eled@sectmark@\the\pstarts@typeset@L}%
                  }{}%
                \global\csundef{eled@sectmark@\the\pstarts@typeset@L}%
                \savebox{\@eledsectionL}{\parbox[t][][t]{\Lcolwidth}{\vbox{}\print@eledsectionL}}%\vbox{}-> prevent alignment troubles with RTL language
                }%
                {}%
            \l@duselanguage{\theledlanguageR}%
            \do@lineR
            \xifinlist{\the\l@dpscR}{\eled@sectionsR@@}
                {%
                \ifdefstring{\@eledsectmark}{R}%
                  {\csuse{eled@sectmark@\the\l@dpscR R}%
                  }{}%
                \global\csundef{eled@sectmark@\the\l@dpscR R}%
                \savebox{\@eledsectionR}{\parbox[t][][t]{\Rcolwidth}{\vbox{}\print@eledsectionR}}}%\vbox{}-> prevent alignment troubles with RTL language
                {}%
          \hb@xt@ \hsize{%
           \ifdefstring{\columns@position}{L}{}{\hfill }%
            \print@leftcolumn%
            \print@columnseparator%
            \print@rightcolumn%
            \ifdefstring{\columns@position}{R}{}{\hfill}%
          }%
          \checkraw@text
          \checkverseL
          \checkverseR
          \checkpb@columns
        \repeat}
      \@writelinesinparL
      \@writelinesinparR
      \check@pstarts
        \ifbypstart@%
           \write\linenum@out{\string\@set[1]}
           \resetprevline@
        \fi
       \ifbypstart@R
           \write\linenum@outR{\string\@set[1]}
           \resetprevline@
        \fi
        \Columns@print@after@pend%
    \repeat
    \flush@notes
    \flush@notesR
  \endgroup
  \global\l@dpscL=\z@
  \global\l@dpscR=\z@
  \global\l@dnumpstartsL=\z@
  \global\l@dnumpstartsR=\z@
  \global\l@dprintingcolumnsfalse%
  \ignorespaces
    \global\instanzaLfalse%
    \global\instanzaRfalse%
  }%
}%

\def\print@columnseparator{%
  \ifdim\beforecolumnseparator<0pt%
    \hfill%
  \else%
    \hspace{\beforecolumnseparator}%
  \fi%
  \columnseparator%
  \ifdim\aftercolumnseparator<0pt%
    \hfill%
  \else%
    \hspace{\aftercolumnseparator}%
  \fi%
}%
\newdimen\intercolumns@width%
\newcommand{\get@intercolumns@width}{%
  \global\intercolumns@width=\z@%
  \ifdefstring{\columns@position}{C}%
  {%
    \ifboolexpr{%
      test {\ifdimless{\beforecolumnseparator}{\z@}}%
      and test {\ifdimless{\aftercolumnseparator}{\z@}}%
    }%
      {%
        \global\intercolumns@width=\dimexpr%
          \columnrulewidth +%
          (\textwidth - \Lcolwidth - \Rcolwidth - \columnrulewidth)*1/2% The total of the width before and after column separator
        \relax%
      }%
      {}%
    \ifboolexpr{%
      test {\ifdimgreater{\beforecolumnseparator}{\z@}}%
      and test {\ifdimgreater{\aftercolumnseparator}{\z@}}%
    }%
      {%
        \global\intercolumns@width=\dimexpr%
          \columnrulewidth + \beforecolumnseparator + \aftercolumnseparator%
        \relax%
      }%
      {}%
    \ifboolexpr{%
      test {\ifdimgreater{\beforecolumnseparator}{\z@}}%
      and test {\ifdimless{\aftercolumnseparator}{\z@}}%
    }%
      {%
        \global\intercolumns@width=\dimexpr%
          \columnrulewidth + \beforecolumnseparator +%
          (\textwidth - \Lcolwidth - \Rcolwidth - \columnrulewidth - \beforecolumnseparator) * 1/3%
        \relax%
      }%
      {}%
    \ifboolexpr{%
      test {\ifdimless{\beforecolumnseparator}{\z@}}%
      and test {\ifdimgreater{\aftercolumnseparator}{\z@}}%
    }%
      {%
        \global\intercolumns@width=\dimexpr%
          \columnrulewidth + \aftercolumnseparator +%
          (\textwidth - \Lcolwidth - \Rcolwidth - \columnrulewidth - \aftercolumnseparator) * 1/3%
        \relax%
      }%
      {}%
  }%
  {%
    \ifboolexpr{%
      test {\ifdimless{\beforecolumnseparator}{\z@}}%
      and test {\ifdimless{\aftercolumnseparator}{\z@}}%
    }%
      {%
        \global\intercolumns@width=\dimexpr%
          \columnrulewidth +%
          (\textwidth - \Lcolwidth - \Rcolwidth - \columnrulewidth)*2/3% The total of the width before and after column separator
        \relax%
      }%
      {}%
    \ifboolexpr{%
      test {\ifdimgreater{\beforecolumnseparator}{\z@}}%
      and test {\ifdimgreater{\aftercolumnseparator}{\z@}}%
    }%
      {%
        \global\intercolumns@width=\dimexpr%
          \columnrulewidth + \beforecolumnseparator + \aftercolumnseparator%
        \relax%
      }%
      {}%
    \ifboolexpr{%
      test {\ifdimgreater{\beforecolumnseparator}{\z@}}%
      and test {\ifdimless{\aftercolumnseparator}{\z@}}%
    }%
      {%
        \global\intercolumns@width=\dimexpr%
          \columnrulewidth + \beforecolumnseparator +%
          (\textwidth - \Lcolwidth - \Rcolwidth - \columnrulewidth - \beforecolumnseparator) * 1/2%
        \relax%
      }%
      {}%
    \ifboolexpr{%
      test {\ifdimless{\beforecolumnseparator}{\z@}}%
      and test {\ifdimgreater{\aftercolumnseparator}{\z@}}%
    }%
      {%
        \global\intercolumns@width=\dimexpr%
          \columnrulewidth + \aftercolumnseparator +%
          (\textwidth - \Lcolwidth - \Rcolwidth - \columnrulewidth - \aftercolumnseparator) * 1/2%
        \relax%
      }%
      {}%
  }%
}%
\newcommand{\print@leftcolumn}{%
  \if\page@num>\page@numR%
    \@l@dtempcntb=\page@num%
  \else%
    \@l@dtempcntb=\page@numR%
  \fi%
  \ifboolexpr{%
     not bool {movecolumnspositiononrightpage}%
     or test {\ifnumodd{\@l@dtempcntb}}%
    }%
    {%
      \unhbox\l@dleftbox%
      \ifhbox\@eledsectionL%
         \usebox{\@eledsectionL}%
      \fi%
    }%
    {%
       \unhbox\l@drightbox%
       \ifhbox\@eledsectionR%
         \usebox{\@eledsectionR}%
       \fi%
    }%
}%

\newcommand{\print@rightcolumn}{%
  \if\page@num>\page@numR%
    \@l@dtempcntb=\page@num%
  \else%
    \@l@dtempcntb=\page@numR%
  \fi%
  \ifboolexpr{%
     not bool {movecolumnspositiononrightpage}%
     or test {\ifnumodd{\@l@dtempcntb}}%
    }%
    {%
      \unhbox\l@drightbox%
      \ifhbox\@eledsectionR%
        \usebox{\@eledsectionR}%
      \fi%
    }%
    {%
      \unhbox\l@dleftbox%
      \ifhbox\@eledsectionL%
         \usebox{\@eledsectionL}%
      \fi%
    }%
}%

\newcommand{\checkpb@columns}{%
    \newif\if@pb
    \newif\if@nopb
    \IfStrEq{\led@pb@setting}{before}{
    \numdef{\next@absline}{\the\absline@num+1}%
    \numdef{\next@abslineR}{\the\absline@numR+1}%
  \xifinlist{\next@absline}{\l@prev@pb}{\@pbtrue}{}%
  \xifinlist{\next@abslineR}{\l@prev@pbR}{\@pbtrue}{}
  \xifinlist{\next@absline}{\l@prev@nopb}{\@nopbtrue}{}%
  \xifinlist{\next@abslineR}{\l@prev@nopbR}{\@nopbtrue}{}
  }{}
    \IfStrEq{\led@pb@setting}{after}{
  \xifinlist{\the\absline@num}{\l@prev@pb}{\@pbtrue}{}%
  \xifinlist{\the\absline@numR}{\l@prev@pbR}{\@pbtrue}{}
  \xifinlist{\the\absline@num}{\l@prev@nopb}{\@nopbtrue}{}%
  \xifinlist{\the\absline@numR}{\l@prev@nopbR}{\@nopbtrue}{}
  }{}
\if@nopb\nopagebreak[4]\enlargethispage{\baselineskip}\fi
\if@pb\pagebreak[4]\fi
}
\newcommand*{\columnseparator}{%
  \smash{\rule[-0.2\baselineskip]{\columnrulewidth}{1.05\baselineskip}}}
\newdimen\columnrulewidth
  \columnrulewidth=\z@

\newcommand*{\columnsposition}[1]{%
  \xdef\columns@position{#1}%
  }%
\xdef\columns@position{R}%
\newlength{\beforecolumnseparator}%
\setlength{\beforecolumnseparator}{-2pt}%

\newlength{\aftercolumnseparator}%
\setlength{\aftercolumnseparator}{-2pt}%

\newcommand{\setwidthliketwocolumns}{%
  \get@intercolumns@width%As \columns is not necessary called before \setwidthliketwocolumns
  \hsize=\dimexpr \Lcolwidth + \intercolumns@width + \Rcolwidth \relax%
}%

\newcommand{\setpositionliketwocolumns@L}{%
  \renewcommand{\ledrlfill}{\hfill}%
}%

\newcommand{\setnotespositionliketwocolumns@L}{%
}%

\newcommand{\setpositionliketwocolumns@C}{%
  \doinsidelinehook{\hfill}%
  \renewcommand{\ledrlfill}{\hfill}%
}%

\newcommand{\setnotespositionliketwocolumns@C}{%
  \newdimen\temp%
  \newdimen\tempa%
  \temp=\hsize%
  \tempa=\Lcolwidth%
  \advance\tempa\Rcolwidth%
  \advance\temp-\tempa%
  \divide\temp by 2%
  \leftskip=\temp%
  \rightskip=-\temp%
}%

\newcommand{\setpositionliketwocolumns@R}{%
  \doinsidelinehook{\hfill}%
}%
\newcommand{\Columns@print@before@pstart}{%
  \ifboolexpr{%
    test{\ifcsstring{before@pstartL@\the\l@dpscL}{\at@every@pstart}}%
    and test {\ifcsstring{before@pstartR@\the\l@dpscR}{\at@every@pstart}}%
    and test {\ifdefempty{\at@every@pstart}}}%
       {}%
       {%
       \ifboolexpr{not togl{before@pstartR@\the\l@dpscR @par} and not togl{before@pstartL@\the\l@dpscL @par}}{%
         \csuse{before@pstartL@\the\l@dpscL}%
         \csuse{before@pstartR@\the\l@dpscR}%
       }{%
         \hb@xt@ \hsize{%
           \ifdefstring{\columns@position}{L}{}{\hfill }%
           \par\parbox[t][][t]{\Lcolwidth}{%
             \csuse{before@pstartL@\the\l@dpscL}%
           }%
           \print@columnseparator%
           \parbox[t][][t]{\Rcolwidth}{%
             \set@sectcountR%
             \csuse{before@pstartR@\the\l@dpscR}%
           }%
           \ifdefstring{\columns@position}{R}{}{\hfill}%
         }%
        }%
       }%
    \global\csundef{before@pstartL@\the\l@dpscL}%
    \global\csundef{before@pstartR@\the\l@dpscR}%
}%
\newcommand{\Columns@print@after@pend}{%
  \ifboolexpr{%
    test{\ifcsstring{after@pendL@\the\l@dpscL}{\at@every@pend}}%
    and test {\ifcsstring{after@pendR@\the\l@dpscR}{\at@every@pend}}%
    and test {\ifdefempty{\at@every@pend}}}%
       {}%
       {%
       \ifboolexpr{not togl{after@pendR@\the\l@dpscR @par} and not togl{after@pendL@\the\l@dpscL @par}}{%
         \csuse{after@pendL@\the\l@dpscL}%
         \csuse{after@pendR@\the\l@dpscR}%
       }{%
         \hb@xt@ \hsize{%
           \ifdefstring{\columns@position}{L}{}{\hfill }%
           \parbox[t][][t]{\Lcolwidth}{%
             \csuse{after@pendL@\the\l@dpscL}%
           }%
           \print@columnseparator%
           \parbox[t][][t]{\Rcolwidth}{%
             \set@sectcountR%
             \csuse{after@pendR@\the\l@dpscR}%
           }%
           \ifdefstring{\columns@position}{R}{}{\hfill}%
         }%
        }%
       }%
    \global\csundef{after@pendL@\the\l@dpscL}%
    \global\csundef{after@pendR@\the\l@dpscR}%
}%
\newcount\numpagelinesL
\newcount\numpagelinesR
\newcount\l@dminpagelines

\newcommandx*{\Pages}[1][1,usedefault]{%
  \ifl@dpairing%
    \led@err@Pages@InsideEnv%
  \fi%
  \ifboolexpr{test{\ifcsboxvoid{l@dRcolrawbox1}} or test{\ifcsboxvoid{l@dLcolrawbox1}}}{%
    \ifcsboxvoid{l@dRcolrawbox1}{%
        \ifcsboxvoid{l@dLcolrawbox1}%
          {\led@err@Pages@WithoutEnv}%
          {\led@err@Pages@WithoutRightside}%
      }%
      {\led@err@Pages@WithoutLeftside}%
  }{%
  \ifstrequal{#1}{mainmatter}{\Pages@mainmattertrue}{\Pages@mainmatterfalse}%
  \eledsection@correcting@skip=-2\baselineskip% line correcting for section titles.
  \parledgroup@notespacing@set@correction%
  \typeout{}%
  \typeout{*************************** PAGES ***************************}%
  \ifnum\l@dnumpstartsL=\l@dnumpstartsR\else%
    \led@err@BadLeftRightPstarts{\the\l@dnumpstartsL}{\the\l@dnumpstartsR}%
  \fi%
  \cleartol@devenpage%
  \global\l@dprintingpagestrue%
  \begingroup%
    \Lcolwidth=\Lcolwidth@pages%
    \Rcolwidth=\Rcolwidth@pages%
    \l@dzeropenalties%
    \endgraf\global\num@lines=\prevgraf%
            \global\num@linesR=\prevgraf%
    \global\par@line=\z@%
    \global\par@lineR=\z@%
    \global\l@dpscL=\z@%
    \global\l@dpscR=\z@%
    \writtenlinesLfalse%
    \writtenlinesRfalse%
    \get@familiarfootnote@number%
    \let\print@Xnotes\print@Xnotes@forpages%
    \let\print@notesX\print@notesX@forpages%
    \check@pstarts%
    \loop\if@pstarts%
      \global\advance\l@dpscL \@ne%
      \global\advance\l@dpscR \@ne%
      \getlinesfromparlistL%
      \getlinesfromparlistR%
      \l@dcalc@maxoftwo{\@cs@linesinparL}{\@cs@linesinparR}%
          {\usenamecount{l@dmaxlinesinpar\the\l@dpscL}}%
      \check@pstarts%
    \repeat%
    \global\l@dpscL=\z@%
    \global\l@dpscR=\z@%
    \getlinesfrompagelistL%
    \getlinesfrompagelistR%
    \l@dcalc@minoftwo{\@cs@linesonpageL}{\@cs@linesonpageR}%
        {\l@dminpagelines}%
    \check@pstarts%
    \if@pstarts%
      \global\advance\l@dpscL \@ne%
      \global\advance\l@dpscR \@ne%
      \global\advance\pstarts@typeset@L\@ne%
      \restore@pstartL@pc%
      \restore@pstartR@pc%
      \global\@donereallinesL=\z@%
      \global\@donetotallinesL=\z@%
      \global\@donereallinesR=\z@%
      \global\@donetotallinesR=\z@%
      \checkraw@text%
{        \loop\ifaraw@text%
          \checkpageL%
          \l@duselanguage{\theledlanguageL}%
{            \loop\ifl@dsamepage%
              \ifdefstring{\@eledsectnotoc}{L}{\ledsectnotoc}{}%
              \csuse{before@pstartL@\the\l@dpscL}%
              \global\csundef{before@pstartL@\the\l@dpscL}%
              \do@lineL%
              \xifinlist{\the\pstarts@typeset@L}{\eled@sections@@}%
                {\print@eledsectionL}%
                {}%
              \advance\numpagelinesL \@ne%
              \ifshiftedpstarts%
                      \ifdim\ht\l@dleftbox>0pt%
                        \parledgroup@correction@notespacing{L}%
                        \hb@xt@ \hsize{\ledstrutL\unhbox\l@dleftbox}%
                      \else%
                        \xifinlist{\the\pstarts@typeset@L}{\eled@sections@@}%
                          {\add@apparatusL}%
                          {}%
                        \unless\ifadvancedshiftedpstarts%
                          \dimen0=\pagetotal%
                          \advance\dimen0 by \baselineskip%
                          \global\pagetotal=\dimen0%
                        \else%
                          \ifnomaxlines%
                            \numdef{\@tmp}{\the\l@dpscL+1}%
                            \ifcsdef{minpage@pstart@\@tmp}{%
                              \ifnumless{\the\c@page}{\csuse{minpage@pstart@\@tmp}}%
                              {\dimen0=\pagetotal%
                               \advance\dimen0 by \baselineskip%
                               \global\pagetotal=\dimen0%
                               }%
                              {}%
                            }{}%
                          \fi%
                        \fi%
                      \fi%
              \else%
                      \parledgroup@correction@notespacing{L}%
                      \hb@xt@ \hsize{\ledstrutL\unhbox\l@dleftbox}%
              \fi%
              \get@nextboxL%
              \global\l@dskipversenumberfalse%
                  \ifprint@last@after@pendL%
                     \csuse{after@pendL@\the\l@dpscL}%
                     \global\csundef{after@pendL@\the\l@dpscL}%
                   \fi%
              \checkpageL%
              \checkverseL%
              \checkpbL%
            \repeat%
            \ifl@dpagefull%
              \@writelinesonpageL{\the\numpagelinesL}%
            \else%
              \@writelinesonpageL{1000}%
            \fi%
            \numpagelinesL \z@%
            \parledgroup@correction@notespacing@init%
            \clearl@dleftpage }%
          \checkpageR%
          \l@duselanguage{\theledlanguageR}%
{            \loop\ifl@dsamepage%
              \set@sectcountR%
              \ifdefstring{\@eledsectnotoc}{R}{\ledsectnotoc}{}%
              \csuse{before@pstartR@\the\l@dpscR}%
              \global\csundef{before@pstartR@\the\l@dpscR}%
              \do@lineR%
              \xifinlist{\the\l@dpscR}{\eled@sectionsR@@}%
                {\print@eledsectionR}%
                {}%
              \advance\numpagelinesR \@ne%
              \ifshiftedpstarts%
                      \ifdim\ht\l@drightbox>0pt%
                        \parledgroup@correction@notespacing{R}%
                        \hb@xt@ \hsize{\ledstrutR\unhbox\l@drightbox}%
                      \else%
                        \xifinlist{\the\l@dpscR}{\eled@sectionsR@@}%
                          {\add@apparatusR}%
                          {}%
                        \unless\ifadvancedshiftedpstarts%
                          \dimen0=\pagetotal%
                          \advance\dimen0 by \baselineskip%
                          \global\pagetotal=\dimen0%
                        \else%
                          \ifnomaxlines%
                            \numdef{\@tmp}{\the\l@dpscR+1}%
                            \ifcsdef{minpage@pstart@\@tmp}{%
                              \ifnumless{\the\c@page}{\csuse{minpage@pstart@\@tmp}}%
                              {\dimen0=\pagetotal%
                               \advance\dimen0 by \baselineskip%
                               \global\pagetotal=\dimen0%
                               }%
                              {}%
                            }{}%
                          \fi%
                        \fi%
                      \fi%
              \else%
                      \parledgroup@correction@notespacing{R}%
                      \hb@xt@ \hsize{\ledstrutR\unhbox\l@drightbox}%
              \fi%
              \get@nextboxR%
              \global\l@dskipversenumberRfalse%
                  \ifprint@last@after@pendR%
                     \csuse{after@pendR@\the\l@dpscR}%
                     \global\csundef{after@pendR@\the\l@dpscR}%
                   \fi%
              \checkpageR%
              \checkverseR%
              \checkpbR%
            \repeat%
            \ifl@dpagefull%
              \@writelinesonpageR{\the\numpagelinesR}%
            \else%
              \@writelinesonpageR{1000}%
            \fi%
            \numpagelinesR=\z@%
            \parledgroup@correction@notespacing@init%
            \clearl@drightpage}%
          \checkraw@text%
          \ifaraw@text%
            \getlinesfrompagelistL%
            \getlinesfrompagelistR%
            \l@dcalc@minoftwo{\@cs@linesonpageL}{\@cs@linesonpageR}%
                             {\l@dminpagelines}%
          \fi%
        \repeat}%
    \fi%
    \flush@notes%
    \flush@notesR%
  \endgroup%
  \global\l@dpscL=\z@%
  \global\l@dpscR=\z@%
  \global\l@dnumpstartsL=\z@%
  \global\l@dnumpstartsR=\z@%
    \global\instanzaLfalse%
    \global\instanzaRfalse%
  \global\l@dprintingpagesfalse%
   \ifnum\edtext@later=\edtext@now%
   \else%
     \led@error@edtext@later@now%
   \fi%
   \global\edtext@later=\z@%
   \global\edtext@now=\z@%
 \finish@Pages@notes%
  \ignorespaces}}%

\newcommand{\finish@Pages@notes}{%
  \def\do##1{%
    \ifnocritical@%
      \global\newnamebox{##1footins}%
    \fi
    \ifnofamiliar@%
      \global\newnamebox{footins##1}%
    \fi
      \restore@Xnotes@settings{##1}%
      \restore@notesX@settings{##1}%
    \ifvoid\csuse{##1footins}%
      \ifvoid\csuse{footins##1}\else%
        \newpage\null%
        \listbreak%
      \fi%
    \else%
      \newpage\null%
      \listbreak%
    \fi%
  }%
  \dolistloop{\@series}%
}%
\newcommand*{\ledstrutL}{}
\newcommand*{\ledstrutR}{}

\providecommand{\cleartoevenpage}[1][\@empty]{%
  \clearpage
  \ifodd\c@page\hbox{}#1\clearpage\fi}

\newcommand*{\cleartol@devenpage}{%
  \ifdim\pagetotal<\topskip%  on an empty page
  \else
    \clearpage
    \Pages@mainmatter%
  \fi
  \ifodd\c@page%
    \ifprevpgnotnumbered%
      \addtocounter{par@page}{-1}%
    \fi%
    \ifdef{\prevpgstyle}{\thispagestyle{\prevpgstyle}}{}%
    \hbox{}\clearpage%
  \fi%
}%
\newcommand*{\clearl@dleftpage}{%
  \ifdim\pagetotal=0pt\hbox{}\fi%
  \newpage%
  \insert@notes@for@onlyside%
  \ifodd\c@page\else
    \led@err@LeftOnRightPage
    \hbox{}%
    \cleardoublepage
  \fi}

\newcommand*{\clearl@drightpage}{%
  \ifdim\pagetotal=0pt\hbox{}\fi%
  \newpage%
  \insert@notes@for@onlyside%
  \ifodd\c@page
    \led@err@RightOnLeftPage
    \hbox{}%
    \cleartoevenpage
  \fi}

\newcommand*{\getlinesfromparlistL}{%
  \ifx\linesinpar@listL\empty
    \gdef\@cs@linesinparL{0}%
  \else
    \gl@p\linesinpar@listL\to\@cs@linesinparL
  \fi}
\newcommand*{\getlinesfromparlistR}{%
  \ifx\linesinpar@listR\empty
    \gdef\@cs@linesinparR{0}%
  \else
    \gl@p\linesinpar@listR\to\@cs@linesinparR
  \fi}

\newcommand*{\getlinesfrompagelistL}{%
  \ifx\linesonpage@listL\empty
    \gdef\@cs@linesonpageL{1000}%
  \else
    \gl@p\linesonpage@listL\to\@cs@linesonpageL
  \fi}
\newcommand*{\getlinesfrompagelistR}{%
  \ifx\linesonpage@listR\empty
    \gdef\@cs@linesonpageR{1000}%
  \else
    \gl@p\linesonpage@listR\to\@cs@linesonpageR
  \fi}

\newcommand*{\@writelinesonpageL}[1]{%
  \edef\next{\write\linenum@out{\string\@lopL{#1}}}%
  \next}
\newcommand*{\@writelinesonpageR}[1]{%
  \edef\next{\write\linenum@outR{\string\@lopR{#1}}}%
  \next}

\newcommand*{\l@dcalc@maxoftwo}[3]{%
  \ifnum #2>#1\relax
    #3=#2\relax
  \else
    #3=#1\relax
  \fi}
\newcommand*{\l@dcalc@minoftwo}[3]{%
  \ifnum #2<#1\relax
    #3=#2\relax
  \else
    #3=#1\relax
  \fi}

\newif\ifl@dsamepage
  \l@dsamepagetrue
\newif\ifl@dpagefull

\newcommand*{\checkpageL}{%
  \l@dpagefulltrue
  \l@dsamepagetrue
  \check@goal
  \ifdim\pagetotal<\ledthegoal
    \ifnum\numpagelinesL<\l@dminpagelines
    \else
      \ifnomaxlines%
      \else%
        \l@dsamepagefalse%
        \l@dpagefullfalse%
      \fi%
    \fi
  \else
    \l@dsamepagefalse
    \l@dpagefulltrue
  \fi%
  \ifprint@last@after@pendL%
     \l@dpagefullfalse%
     \l@dsamepagefalse%
     \print@last@after@pendLfalse%
  \fi%
  }%

\newcommand*{\checkpageR}{%
  \l@dpagefulltrue
  \l@dsamepagetrue
  \check@goal
  \ifdim\pagetotal<\ledthegoal
    \ifnum\numpagelinesR<\l@dminpagelines
    \else
      \ifnomaxlines%
      \else%
        \l@dsamepagefalse%
        \l@dpagefullfalse%
      \fi%
    \fi
  \else
    \l@dsamepagefalse
    \l@dpagefulltrue
  \fi%
  \ifprint@last@after@pendR%
     \l@dpagefullfalse%
     \l@dsamepagefalse%
     \print@last@after@pendRfalse%
  \fi%
  }%

\newcommand{\checkpbL}{
   \IfStrEq{\led@pb@setting}{after}{
     \xifinlist{\the\absline@num}{\l@prev@pb}{\l@dpagefulltrue\l@dsamepagefalse}{}
     \xifinlist{\the\absline@num}{\l@prev@nopb}{\l@dpagefullfalse\l@dsamepagetrue}{}
   }{}
   \IfStrEq{\led@pb@setting}{before}{
     \numdef{\next@absline}{\the\absline@num+1}
     \xifinlist{\next@absline}{\l@prev@pb}{\l@dpagefulltrue\l@dsamepagefalse}{}
     \xifinlist{\next@absline}{\l@prev@nopb}{\l@dpagefullfalse\l@dsamepagetrue}{}
   }{}
}

\newcommand{\checkpbR}{
   \IfStrEq{\led@pb@setting}{after}{
     \xifinlist{\the\absline@numR}{\l@prev@pbR}{\l@dpagefulltrue\l@dsamepagefalse}{}
     \xifinlist{\the\absline@numR}{\l@prev@nopbR}{\l@dpagefullfalse\l@dsamepagetrue}{}
     }{}
   \IfStrEq{\led@pb@setting}{before}{
     \numdef{\next@abslineR}{\the\absline@numR+1}
     \xifinlist{\next@abslineR}{\l@prev@pbR}{\l@dpagefulltrue\l@dsamepagefalse}{}
     \xifinlist{\next@abslineR}{\l@prev@nopbR}{\l@dpagefullfalse\l@dsamepagetrue}{}
   }{}
}
\newcommand{\checkverseL}{%
\ifinstanzaL%
  \iflednopbinverse%
    \ifinserthangingsymbol%
      \numgdef{\prev@abslineverse}{\the\absline@num-1}%
      \IfStrEq{\led@pb@setting}{after}{\lednopbnum{\prev@abslineverse}}{}%
      \IfStrEq{\led@pb@setting}{before}{%
        \ifnum\numpagelinesL<3%
          \ledpbnum{\prev@abslineverse}%
        \fi%
      }{}%
    \fi%
  \fi%
\fi%
}
\newcommand{\checkverseR}{%
\ifinstanzaR%
  \iflednopbinverse%
    \ifinserthangingsymbolR%
      \numgdef{\prev@abslineverse}{\the\absline@numR-1}%
      \IfStrEq{\led@pb@setting}{after}{\lednopbnumR{\prev@abslineverse}}{}%
      \IfStrEq{\led@pb@setting}{before}{%
        \ifnum\numpagelinesR<3%
          \ledpbnumR{\prev@abslineverse}%
        \fi%
      }{}%
    \fi%
  \fi%
\fi%
}
\newdimen\ledthegoal
\ifshiftedpstarts
       \newcommand*{\@goalfraction}{0.95}
\else
       \newcommand*{\@goalfraction}{0.9}
\fi

\newcommand*{\check@goal}{%
  \ledthegoal=\@goalfraction\pagegoal}
\newcommand{\setgoalfraction}[1]{%
  \xdef\@goalfraction{#1}%
}
\newif\ifwrittenlinesL
\newif\ifwrittenlinesR

\newif\if@getnextbox%
\newcommand*{\get@nextboxL}{%
  \ifvbox\namebox{l@dLcolrawbox\the\l@dpscL}% box is not empty
  \else%                                      box is empty
    \@getnextboxtrue%Should be local, but be cautious
    \ifnum\usenamecount{l@dmaxlinesinpar\the\l@dpscL}>\@donetotallinesL
      \parledgroup@notes@endL%
      \unless\ifnosyncpstarts%
        \@getnextboxfalse%
        \ifnomaxlines%
          \ifdim\pagetotal<\ledthegoal%
            \numdef{\@tmp}{\l@dpscL+1}%
            \ifcsdef{afterlines@pstart@\@tmp R}{%
              \ifnumless{\numpagelinesL}{\csuse{afterlines@pstart@\@tmp R}}%
                 {}%
                 {\ifcsdef{minpage@pstart@\@tmp}%
                   {\ifnumless{\the\c@page}{\csuse{minpage@pstart@\@tmp}}%
                     {\ifnum\numpagelinesL=\l@dminpagelines%
                          \@getnextboxtrue%
                      \fi%
                     }%
                     {\@getnextboxtrue}}%
                   {\@getnextboxtrue}%
                 }%
              }%
              {}%
          \fi%
        \fi%
      \fi%
    \else%
       \ifnomaxlines%
         \numdef{\@tmp}{\the\l@dpscL+1}%
         \ifcsdef{minpage@pstart@\@tmp}{%
           \ifnumless{\the\c@page}{\csuse{minpage@pstart@\@tmp}}%
             {\ifdimgreater{\pagetotal}{\ledthegoal}%
                {\@getnextboxtrue}%
                {\@getnextboxfalse}%
             }%
             {\@getnextboxtrue}%
         }{}%
       \fi%
    \fi%
    \if@getnextbox%
      \ifnum\usenamecount{l@dmaxlinesinpar\the\l@dpscL}=\@donetotallinesL
        \parledgroup@notes@endL
      \fi
      \ifwrittenlinesL\else
        \@writelinesinparL
        \writtenlinesLtrue
      \fi
      \ifnum\l@dnumpstartsL>\l@dpscL
        \writtenlinesLfalse
         \ifbypstart@
            \global\line@num=0%
            \resetprevline@%
          \fi
         \csuse{after@pendL@\the\l@dpscL}%
         \global\csundef{after@pendL@\the\l@dpscL}%
        \l@dcalc@maxoftwo{\the\usenamecount{l@dmaxlinesinpar\the\l@dpscL}}%
                         {\the\@donetotallinesL}%
                         {\usenamecount{l@dmaxlinesinpar\the\l@dpscL}}%
        \global\@donetotallinesL \z@
        \global\advance\l@dpscL \@ne
        \global\advance\pstarts@typeset@L\@ne%
        \global\pstartnumtrue%
        \restore@pstartL@pc%
        \parledgroup@notes@endL
        \parledgroup@correction@notespacing@final{L}
      \else
        \print@last@after@pendLtrue%
      \fi
    \fi
  \fi}
\newcommand*{\get@nextboxR}{%
  \ifvbox\namebox{l@dRcolrawbox\the\l@dpscR}% box is not empty
  \else%                                      box is empty
    \@getnextboxtrue%
    \ifnum\usenamecount{l@dmaxlinesinpar\the\l@dpscR}>\@donetotallinesR
      \parledgroup@notes@endR
      \unless\ifnosyncpstarts%
        \@getnextboxfalse%
        \ifnomaxlines%
          \ifdim\pagetotal<\ledthegoal%
            \numdef{\@tmp}{\l@dpscR+1}%
            \ifcsdef{afterlines@pstart@\@tmp L}{%
              \ifnumless{\numpagelinesL}{\csuse{afterlines@pstart@\@tmp L}}%
                 {}%
                 {\ifcsdef{minpage@pstart@\@tmp}%
                   {\ifnumless{\the\c@page}{\csuse{minpage@pstart@\@tmp}}%
                     {\ifnum\numpagelinesR=\l@dminpagelines%
                          \@getnextboxtrue%
                      \fi%
                     }%
                     {\@getnextboxtrue}}%
                   {\@getnextboxtrue}%
                 }%%
              }%
              {}%
          \fi%
        \fi%
      \fi%
    \else%
       \ifnomaxlines%
         \numdef{\@tmp}{\the\l@dpscR+1}%
         \ifcsdef{minpage@pstart@\@tmp}{%
           \ifnumless{\the\c@page}{\csuse{minpage@pstart@\@tmp}}%
             {\ifdimgreater{\pagetotal}{\ledthegoal}%
                {\@getnextboxtrue}%
                {\@getnextboxfalse}%
             }%
             {\@getnextboxtrue}%
         }{}
       \fi%
    \fi%
    \if@getnextbox%
      \ifnum\usenamecount{l@dmaxlinesinpar\the\l@dpscR}=\@donetotallinesR
        \parledgroup@notes@endR
      \fi
      \ifwrittenlinesR\else
        \@writelinesinparR
        \writtenlinesRtrue
      \fi
      \ifnum\l@dnumpstartsR>\l@dpscR
        \writtenlinesRfalse
        \ifbypstart@R
             \global\line@numR=0%
             \resetprevline@%
        \fi
        \csuse{after@pendR@\the\l@dpscR}%
        \global\csundef{after@pendR@\the\l@dpscR}%
        \l@dcalc@maxoftwo{\the\usenamecount{l@dmaxlinesinpar\the\l@dpscR}}%
                         {\the\@donetotallinesR}%
                         {\usenamecount{l@dmaxlinesinpar\the\l@dpscR}}%
        \global\@donetotallinesR \z@
        \global\advance\l@dpscR \@ne
        \global\pstartnumRtrue%
        \restore@pstartR@pc%
        \parledgroup@notes@endR
        \parledgroup@correction@notespacing@final{R}
      \else
          \print@last@after@pendRtrue%
      \fi
    \fi
  \fi}

\newif\ifPages@mainmatter
\newcommand{\Pages@mainmatter}{%
    \ifPages@mainmatter%
      \pagenumbering{arabic}%
      \addtocounter{page}{1}%
      \addtocounter{par@page}{-1}%
      \patchcmd{\thepage}{page}{par@page}{}{}%
    \fi%
}
\pretocmd{\chapter}{%
  \ifl@dprintingpages%
    \vbox{}%
  \fi%
  }%
  {}%
  {}%
\newcommand{\eledsectnotoc}[1]{\xdef\@eledsectnotoc{#1}}
\eledsectnotoc{R}
\newcommand{\eledsectmark}[1]{\xdef\@eledsectmark{#1}}
\eledsectmark{L}
\newskip\eledsection@correcting@skip
\newwrite\eled@sectioningR@out
\def\l@prev@pbR{}
\def\l@prev@nopbR{}
\newcommand{\ledpbR}{\write\linenum@outR{\string\led@pbR}}
\newcommand{\ledpbnumR}[1]{\write\linenum@outR{\string\led@pbnumR{#1}}}
\newcommand{\lednopbR}{\write\linenum@outR{\string\led@nopbR}}
\newcommand{\lednopbnumR}[1]{\write\linenum@outR{\string\led@nopbnumR{#1}}}
\newcommand{\led@pbR}{\listxadd{\l@prev@pbR}{\the\absline@numR}}
\newcommand{\led@pbnumR}[1]{\listxadd{\l@prev@pbR}{#1}}
\newcommand{\led@nopbR}{\listxadd{\l@prev@nopbR}{\the\absline@numR}}
\newcommand{\led@nopbnumR}[1]{\listxadd{\l@prev@nopbR}{#1}}
\newmarks\parledgroup@
\newmarks\parledgroup@series
\newmarks\parledgroup@type
\newcommand{\parledgroup@notes@startL}{%
  \ifnum\usenamecount{l@dmaxlinesinpar\the\l@dpscL}>0%
    \IfStrEq{\splitfirstmarks\parledgroup@type}{footnoteX}{\csuse{bhooknoteX@\splitfirstmarks\parledgroup@series}}{}%
    \IfStrEq{\splitfirstmarks\parledgroup@type}{Xfootnote}{\csuse{bhookXnote@\splitfirstmarks\parledgroup@series}}{}%
  \fi%
  \global\ledgroupnotesL@true%
  \insert@noterule@ledgroup{L}%
}
\newcommand{\parledgroup@notes@startR}{%
  \ifnum\usenamecount{l@dmaxlinesinpar\the\l@dpscR}>0%
    \IfStrEq{\splitfirstmarks\parledgroup@type}{footnoteX}{\csuse{bhooknoteX@\splitfirstmarks\parledgroup@series}}{}%
    \IfStrEq{\splitfirstmarks\parledgroup@type}{Xfootnote}{\csuse{bhookXnote@\splitfirstmarks\parledgroup@series}}{}%
  \fi%
  \global\ledgroupnotesR@true%
  \insert@noterule@ledgroup{R}%
}
\newcommand{\parledgroup@notes@endL}{%
  \global\ledgroupnotesL@false%
}
\newcommand{\parledgroup@notes@endR}{%
  \global\ledgroupnotesR@false%
}
\newcommand{\insert@noterule@ledgroup}[1]{
    \IfStrEq{\splitbotmarks\parledgroup@}{begin}{%
      \IfStrEq{\splitbotmarks\parledgroup@type}{Xfootnote}{
        \csuse{ifledgroupnotes#1@}
          \vskip\skip\csuse{mp\splitbotmarks\parledgroup@series footins}
          \csuse{\splitbotmarks\parledgroup@series footnoterule}
        \fi
        }
        {}
        \IfStrEq{\splitbotmarks\parledgroup@type}{footnoteX}{
          \csuse{ifledgroupnotes#1@}
           \vskip\skip\csuse{mpfootins\splitbotmarks\parledgroup@series}
           \csuse{footnoterule\splitbotmarks\parledgroup@series}
           \fi
           }{}
        }
    {}
}
\newcommand{\setparledgroupnotespacing}[1]{\gdef\@parledgroupnotespacing{#1}}
\newcommand{\@parledgroupnotespacing}{}
\dimdef{\parledgroup@notespacing@correction}{0pt}
\newcommand{\parledgroup@notespacing@set@correction}{%
  {\@getfirstseries\csuse{Xnotefontsize@\@firstseries}%We suppose all the series has the same footnote size setup
 \@parledgroupnotespacing\dimgdef{\temp@spacing}{\baselineskip}}%
  \dimgdef{\parledgroup@notespacing@correction}{\baselineskip-\temp@spacing}%
}
\newcommand{\parledgroup@correction@notespacing@init}{
  \dimdef{\parledgroup@notespacing@correction@accumulated}{0pt}
  \dimdef{\parledgroup@notespacing@correction@modulo}{0pt}
}
\parledgroup@correction@notespacing@init
\newcommand{\parledgroup@correction@notespacing@final}[1]{
    \ifparledgroup
    \vspace{\parledgroup@notespacing@correction@accumulated}
    \parledgroup@correction@notespacing@init%
    \ifstrequal{#1}{L}{
        \numdef{\@checking}{\the\l@dpscL-1}
    }{
      \numdef{\@checking}{\the\l@dpscR-1}
    }
    \dimdef{\@beforenotes@current@diff}{\csuse{@parledgroup@beforenotes@\@checking L}-\csuse{@parledgroup@beforenotes@\@checking R}}%
    \ifstrequal{#1}{L}%
      {% Left
      \ifdimgreater{\@beforenotes@current@diff}{0pt}{}{\vspace{-\@beforenotes@current@diff}}%
      }%
      {% Right
      \ifdimgreater{\@beforenotes@current@diff}{0pt}{\vspace{\@beforenotes@current@diff}}{}
      }%
  \fi
}
\newcommand{\parledgroup@correction@notespacing}[1]{%
    \csuse{ifledgroupnotes#1@}%
      \vspace{-\parledgroup@notespacing@correction}%
      \dimdef{\parledgroup@notespacing@correction@accumulated}{\parledgroup@notespacing@correction@accumulated+\parledgroup@notespacing@correction}%
      \dimdef{\parledgroup@notespacing@correction@modulo}{\parledgroup@notespacing@correction@modulo+\parledgroup@notespacing@correction}%
      \ifdimless{\parledgroup@notespacing@correction@modulo}{\baselineskip}{}{\advance\numpagelinesL -\@ne%
      \dimdef{\parledgroup@notespacing@correction@modulo}{\parledgroup@notespacing@correction@modulo-\baselineskip}%
     }% mean greater than equal
    \fi%
}
\dimdef\parledgroup@beforenotesL{0pt}
\dimdef\parledgroup@beforenotesR{0pt}
\newcommand{\parledgroup@beforenotes@save}[1]{
  \ifparledgroup
    \csdimgdef{@parledgroup@beforenotes@\the\csuse{l@dnumpstarts#1}#1}{\csuse{parledgroup@beforenotes#1}}
    \csdimgdef{parledgroup@beforenotes#1}{0pt}
  \fi
}

\ifeledmaccompat@%

  \unless\ifnocritical@
  \let\onlyXside\Xonlyside
  \fi
\fi
\endinput
%%
%% End of file `reledpar.sty'.
