% \iffalse meta-comment
%
% reledpar.dtx
% Author: Peter Wilson (Herries Press) herries dot press at earthlink dot net
% Maintainer: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.
%
%
%<*driver>
\documentclass[twoside]{ltxdoc}
\usepackage[T1]{fontenc}
\usepackage{url}
\usepackage{xr-hyper}
  \usepackage[draft=false,
              plainpages=false,
              pdfpagelabels,
              bookmarksnumbered,
%              hyperindex=true
              hyperindex=false
             ]{hyperref}
\addtolength\marginparwidth{30pt}
\usepackage{doctools}
\usepackage[mono=false]{libertine}
\usepackage[series={A,B},noend,noeledsec,nofamiliar]{reledmac}
\usepackage{reledpar}
\usepackage{suffix}
\usepackage{csquotes}
\usepackage[english]{babel}
\usepackage{graphicx,metalogo,longtable}
\makeatletter
  \renewenvironment{theglossary}{%
      \@restonecoltrue\if@twocolumn\@restonecolfalse\fi
      \columnseprule \z@  \columnsep 35\p@
      \glossary@prologue%
      \GlossaryParms \let\item\@idxitem \ignorespaces}
    {\if@restonecol\onecolumn\else\clearpage\fi}
  \def\theindex{\@restonecoltrue\if@twocolumn\@restonecolfalse\fi
    \columnseprule \z@  \columnsep 35\p@
    \index@prologue%
    \IndexParms \let\item\@idxitem \ignorespaces}
  \def\endtheindex{\if@restonecol\onecolumn\else\clearpage\fi}
  \@mparswitchfalse
\makeatother
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\renewcommand{\MakeUppercase}[1]{#1}
 \newcommand{\edmac}{\protect\package{EDMAC}\xspace}
 \newcommand{\tabmac}{\protect\package{tabmac}\xspace}
 \newcommand{\edstanza}{\protect\package{edstanza}\xspace}

 \newcommand{\ledmac}{\protect\package{ledmac}\xspace}
 \newcommand{\Ledmac}{\protect\package{Ledmac}\xspace}
 \newcommand{\ledpar}{\protect\package{ledpar}\xspace}
 \newcommand{\Ledpar}{\protect\package{Ledpar}\xspace}


 \newcommand{\eledmac}{\protect\package{eledmac}\xspace}
 \newcommand{\Eledmac}{\protect\package{Eledmac}\xspace}
 \newcommand{\eledpar}{\protect\package{eledpar}\xspace}
 \newcommand{\Eledpar}{\protect\package{Eledpar}\xspace}

 \newcommand{\reledmac}{\protect\package{reledmac}\xspace}
 \newcommand{\Reledmac}{\protect\package{Reledmac}\xspace}
 \newcommand{\reledpar}{\protect\package{reledpar}\xspace}
 \newcommand{\Reledpar}{\protect\package{Reledpar}\xspace}

 \let\macpackage\reledmac
 \let\parpackage\reledpar
 \let\Macpackage\reledmac
 \let\Parpackage\reledpar

  \newcommand{\texbook}{\textit{TeXbook}\xspace}
  \newcommand{\thetexbook}{\textit{The TeXbook}\xspace}
\pagestyle{headings}
\setcounter{StandardModuleDepth}{1}
% Some commands are defined here, and not in the commented part, because \externaldocument require them.
\externaldocument[reledmac-]{reledmac}
\begin{document}
  \raggedbottom
  \DocInput{reledpar.dtx}
\end{document}
%</driver>
%
% \fi
% \newcommand{\reff}[1]{\ref{#1} p.~\pageref{#1}}
% \newcommand\reffsamefile[1]{\reff{#1}}
% \makeatletter
% \newcommand*{\DescribeIt}{\leavevmode\@bsphack\begingroup\MakePrivateLetters
%  \Describe@It}
% \newcommand*{\Describe@It}[1]{\endgroup
%   \marginpar{\raggedleft\PrintDescribeEnv{#1}}%
%   \SpecialItIndex{#1}\@esphack\ignorespaces}
% \newcommand*{\SpecialItIndex}[1]{\@bsphack
%   \index{#1\actualchar{\protect\ttfamily#1}\encapchar usage}\@esphack}
% \DoNotIndex{\@,\@@par,\@beginparpenalty,\@empty}
% \DoNotIndex{\@flushglue,\@input}
% \DoNotIndex{\@makefnmark,\@makeother,\@maketitle}
% \DoNotIndex{\@namedef,\@ne,\@spaces,\@tempa}
% \DoNotIndex{\@tempb,\@tempswafalse,\@tempswatrue}
% \DoNotIndex{\@thanks,\@thefnmark,\@topnum}
% \DoNotIndex{\@@,\@elt,\@forloop,\@fortmp,\@gtempa,\@totalleftmargin}
% \DoNotIndex{\",\/,\@ifundefined,\@nil,\@verbatim,\@vobeyspaces}
% \DoNotIndex{\|,\~,\ ,\active,\advance,\aftergroup,\begingroup,\bgroup}
% \DoNotIndex{\mathcal,\csname,\def,\documentstyle,\dospecials,\edef}
% \DoNotIndex{\egroup}
% \DoNotIndex{\else,\endcsname,\endgroup,\endinput,\endtrivlist}
% \DoNotIndex{\expandafter,\fi,\fnsymbol,\futurelet,\gdef,\global}
% \DoNotIndex{\hbox,\hss,\if,\if@inlabel,\if@tempswa,\if@twocolumn}
% \DoNotIndex{\ifcase}
% \DoNotIndex{\ifcat,\iffalse,\ifx,\ignorespaces,\index,\input,\item}
% \DoNotIndex{\jobname,\kern,\leavevmode,\leftskip,\let,\llap,\lower}
% \DoNotIndex{\m@ne,\next,\newpage,\nobreak,\noexpand,\nonfrenchspacing}
% \DoNotIndex{\obeylines,\or,\protect,\raggedleft,\rightskip,\rm,\sc}
% \DoNotIndex{\setbox,\setcounter,\small,\space,\string,\strut}
% \DoNotIndex{\strutbox}
% \DoNotIndex{\thefootnote,\thispagestyle,\topmargin,\trivlist,\tt}
% \DoNotIndex{\twocolumn,\typeout,\vss,\vtop,\xdef,\z@}
% \DoNotIndex{\,,\@bsphack,\@esphack,\@noligs,\@vobeyspaces,\@xverbatim}
% \DoNotIndex{\`,\catcode,\end,\escapechar,\frenchspacing,\glossary}
% \DoNotIndex{\hangindent,\hfil,\hfill,\hskip,\hspace,\ht,\it,\langle}
% \DoNotIndex{\leaders,\long,\makelabel,\marginpar,\markboth,\mathcode}
% \DoNotIndex{\mathsurround,\mbox,\newcount,\newdimen,\newskip}
% \DoNotIndex{\nopagebreak}
% \DoNotIndex{\parfillskip,\parindent,\parskip,\penalty,\raise,\rangle}
% \DoNotIndex{\section,\setlength,\TeX,\topsep,\underline,\unskip,\verb}
% \DoNotIndex{\vskip,\vspace,\widetilde,\\,\%,\@date,\@defpar}
% \DoNotIndex{\[,\{,\},\]}
% \DoNotIndex{\count@,\ifnum,\loop,\today,\uppercase,\uccode}
% \DoNotIndex{\baselineskip,\begin,\tw@}
% \DoNotIndex{\a,\b,\c,\d,\e,\f,\g,\h,\i,\j,\k,\l,\m,\n,\o,\p,\q}
% \DoNotIndex{\r,\s,\t,\u,\v,\w,\x,\y,\z,\A,\B,\C,\D,\E,\F,\G,\H}
% \DoNotIndex{\I,\J,\K,\L,\M,\N,\O,\P,\Q,\R,\S,\T,\U,\V,\W,\X,\Y,\Z}
% \DoNotIndex{\1,\2,\3,\4,\5,\6,\7,\8,\9,\0}
% \DoNotIndex{\!,\#,\$,\&,\',\(,\),\+,\.,\:,\;,\<,\=,\>,\?,\_}
% \DoNotIndex{\discretionary,\immediate,\makeatletter,\makeatother}
% \DoNotIndex{\meaning,\newenvironment,\par,\relax,\renewenvironment}
% \DoNotIndex{\repeat,\scriptsize,\selectfont,\the,\undefined}
% \DoNotIndex{\arabic,\do,\makeindex,\null,\number,\show,\write,\@ehc}
% \DoNotIndex{\@author,\@ehc,\@ifstar,\@sanitize,\@title,\everypar}
% \DoNotIndex{\if@minipage,\if@restonecol,\ifeof,\ifmmode}
% \DoNotIndex{\lccode,\newtoks,\onecolumn,\openin,\p@,\SelfDocumenting}
% \DoNotIndex{\settowidth,\@resetonecoltrue,\@resetonecolfalse,\bf}
% \DoNotIndex{\clearpage,\closein,\lowercase,\@inlabelfalse}
% \DoNotIndex{\selectfont,\mathcode,\newmathalphabet,\rmdefault}
% \DoNotIndex{\bfdefault}
% \DoNotIndex{\newcommand,\renewcommand,\providecommand}
% \DoNotIndex{\ ,\to}
%
% \newcommand{\dtxfilename}{\texttt{reledpar.dtx}}
% \GetFileInfo{reledpar.sty}
% ^^A Put changes in the right order: see http://tex.stackexchange.com/a/74113/7712
%  \let\org@changes@\changes@
%    \def\my@changes v#1.#2.#3\@nil{%
%      \org@changes@{v#1.\six@digits{#2}.#3=v#1.#2.#3}%
%    }%
%    \newcommand*{\six@digits}[1]{%
%      \ifnum#1<100000 0\fi
%      \ifnum#1<10000 0\fi
%      \ifnum#1<1000 0\fi
%      \ifnum#1<100 0\fi
%      \two@digits{#1}%
%    }%
%    \renewcommand*{\changes@}[1]{%
%            \my@changes#1.\@nil
%    }%
%\makeatother
%
% \changes{v0.1.0}{2004/12/10}{First public release}
% \changes{v0.2.0}{2005/01/01}{Fix babel problems}
% \changes{v0.3.0}{2005/03/24}{Reorganize for ledarab}
% \changes{v0.3.a}{2005/03/30}{Minor \protect\cs{linenummargin} fix}
% \changes{v0.3.b}{2005/04/08}{Improved parallel page balancing}
% \changes{v0.3.c}{2011/06/16}{Compatibilty with Polyglossia}
% \changes{v0.4.0}{2011/08/03}{No more ledparpatch. All patches are now in the main file.}
% \changes{v0.5.0}{2011/08/21}{Corrections about \protect\cs{section} and other titles in numbered sections}
% \changes{v0.6.0}{2011/08/22}{Be able to us \protect\cs{chapter} in parallel pages.}
% \changes{v0.7.0}{2011/08/31}{Add \protect\option{shiftedverses} option which makes there is no blank between two parallel verses with inequal length.}
% \changes{v0.8.0}{2011/09/16}{Possibility to have a symbol on each hanging of verses, like in the french typography. Redefine  the commande \protect\cs{hangingsymbol} to define the character.}
% \changes{v0.9.0}{2011/10/01}{Possibilty to number the pstart with the commands \protect\cs{numberpstarttrue}.}
% \changes{v0.9.1}{2011/10/02}{The numbering of the pstarts restarts on each \protect\cs{beginnumbering}.}
% \changes{v0.9.2}{2011/11/08}{Debug: with \protect\cs{Columns}, the hanging indentation now runs on the left columns and the hanging symbol is shown only when \protect\cs{stanza} is used.}
% \changes{v0.9.3}{2011/11/18}{\protect\cs{thepstartL} and \protect\cs{thepstartR}  use now \protect\cs{bfseries} and not \protect\cs{bf}, which is deprecated and makes conflicts with memoir class.}
% \changes{v0.10.0}{2012/04/04}{\protect\cs{edlabel} commands which start a paragraph are now put in the right place.}
% \changes{v0.10.0}{2012/04/04}{\protect\cs{edlabel} commands on the right side are now correctly indicated.}
% \changes{v1.0.0}{2012/09/14}{Compatibility with eledmac. Change name to eledpar.}
% \changes{v1.0.1}{2012/09/16}{Correction on \protect\cs{numberonlyfirstinline} with lineation by pstart or by page.}
% \changes{v1.1.0}{2012/09/25}{The \protect\option{shiftedverses} options becomes \protect\option{shiftedpstarts}.}
% \changes{v1.2.0}{2012/10/15}{Support for \protect\cs{led}\meta{section} commands in parallel texts.}
% \changes{v1.3.2}{2012/12/11}{Debug with some classes.}
% \changes{v1.4.3}{2013/10/27}{Corrects a false hanging verse when a verse is exactly the length of a line.}
% \changes{v1.5.0}{2013/11/08}{Add, as in eledmac, features to manage page breaks.}
% \changes{v1.7.0}{2014/04/14}{Add, as in eledmac, features to make crossrefs with pstart numbers.}
% \changes{v1.8.0}{2014/08/05}{Debug eledmac sectioning command after using \protect\cs{resumenumbering}.}
% \changes{v1.8.0}{2014/08/05}{Compatibility with \protect\package{musixtex}.}
% \changes{v1.8.0}{2014/08/05}{Add, as in eledmac, option to insert something after \protect\cs{pend}s / verses.}
% \changes{v1.8.0}{2014/08/05}{Add, as in eledmac, option to insert something between \protect\cs{pstart}s / verse.}
% \changes{v1.8.0}{2014/08/05}{Add, as in eledmac, new system of sectioning commands.}
% \changes{v1.8.2}{2014/08/15}{Debug left and side note (bugs added by 1.8.0)}
% \changes{v1.8.2}{2014/08/15}{Debug \protect\cs{eledxxx} with some paper sizes}
% \changes{v1.8.3}{2014/08/31}{Add \protect\cs{noeledxxx}, as in eledmac}
% \changes{v1.9.0}{2014/09/16}{Compatibility with \protect\cs{Xnoteswidthliketwocolumns} and \protect\cs{notesXwidthliketwocolumns}}
% \changes{v1.10.0}{2015/01/12}{Restore critical notes in \protect\cs{eledsection} in parallel columns (this bug was added in 1.8.2).}
% \changes{v1.10.0}{2015/01/12}{Compatibility with \protect\cs{AtEveryPstart} and \protect\cs{AtEveryPend}}
% \changes{v1.11.0}{2015/01/23}{Compatibility of standard footnotes with some biblatex styles.}
% \changes{v1.12.0}{2015/02/23}{Compatibility with \LuaLaTeX\ RTL languages.}
% \changes{v1.13.0}{2015/03/06}{With parallel pages, long notes can now flow from the Left to the right side and from the Right to the left side.}
% \changes{v1.13.0}{2015/03/06}{Fix a bug in shiftedpstarts when size difference between pstarts is very important.}
% \changes{v1.14.0}{2015/03/22}{The \protect\cs{newif}s are not followed by boolean values set to false, because it is the \TeX\ default setting.}
% \changes{v1.14.0}{2015/03/22}{Fix a bug with line number position when using \protect\cs{eledsection} and similar commands for RTL texts with \LuaLaTeX.}
% \changes{v1.15.0}{2015/04/13}{Add \protect\cs{AtEveryPstartCall}.}
% \changes{v1.15.0}{2015/04/13}{Fix vertical spurious space before right \protect\cs{eledchapter} (bug added in v1.13.0).}
% \changes{v1.15.0}{2015/04/13}{Prevent vertical space when using \protect\cs{AtEveryPstart} or \protect\cs{AtEveryPend} with a command which prints nothing}
% \changes{v1.16.0}{2015/05/18}{Fix a bug with nofamiliar / nocritical option of eledmac.}
% \changes{v1.16.0}{2015/05/18}{Error message when using \protect\cs{beginnumbering}\ldots\protect\cs{endnumbering} without \protect\cs{pstart}.}
% \changes{v1.16.0}{2015/05/18}{Error message when starting a Leftside/a Rightside while the previous one has not been yet typeset.}
% \changes{v1.16.0}{2015/05/18}{Error message when calling \protect\cs{Pages} inside \protect\env{pages} environment and \protect\cs{Columns} inside \protect\env{pairs} environment.}
% \changes{v1.16.0}{2015/05/18}{New package option sameparallelpagenumber to have the same page number for both left and right side.}
% \changes{v1.16.1}{2015/05/20}{Write information about line-list file version in the correct file.}
% \changes{v1.16.2}{2015/05/29}{Fix a bug when adding empty lines before a \protect\cs{pend} in combination with some specific penalties setting.}
% \changes{v1.17.0}{2015/06/02}{Add compatibility of optional argument of \protect\cs{pstart}/\protect\cs{pend} and \protect\cs{AtEveryPstart}/\protect\cs{AtEveryPend} with two columns mode.}
% \changes{v2.0.0}{2015/07/19}{Many code refactored and moved to \reledmac.}
% \changes{v2.0.0}{2015/07/19}{Package's name becomes \reledpar.}
% \changes{v2.0.0}{2015/07/19}{Fix some bugs with \protect\option{sameparallelpagenumber} option.}
% \changes{v2.0.0}{2015/07/19}{Totally new implementation of \protect\option{sameparallelpagenumber} option.}
% \changes{v2.1.0}{2015/07/27}{Fix a bug with \protect\cs{setparledgroupnotespacing} with the shiftedpstarts option.}
% \changes{v2.1.0}{2015/07/27}{Fix incompatibility between optional argument of \protect\cs{pstart} and \protect\cs{numberpstarttrue}}
% \changes{v2.1.0}{2015/07/27}{Options to custom empty right page before \protect\cs{Pages}.}
% \changes{v2.1.0}{2015/07/27}{Fix a bug when using \protect\cs{pagenumbering} with memoir (bug added in v2.0.0).}
% \changes{v2.1.0}{2015/07/27}{Fix a bug when using \protect\cs{eledsection} and related on right pages when page width is short.}
% \changes{v2.2.0}{2015/08/08}{\protect\env{astanza} environment can take an optional argument, which will be the optional argument of \protect\cs{pstart} started by this environment.}
% \changes{v2.2.0}{2015/08/08}{New tools to number stanza}
% \changes{v2.2.1}{2015/08/13}{Fix a bug with optional argument of last left \protect\cs{pend}}
% \changes{v2.3.0}{2015/09/05}{Fix a bug with title number in parallel columns}
% \changes{v2.3.0}{2015/09/05}{Change some internal codes in order to provide compatibility with \LaTeX\ release of october~2015}
% \changes{v2.3.0}{2015/09/05}{New line setting command suffixed by R to set only the right side.}
% \changes{v2.4.0}{2015/09/29}{New way of (not) synchronizing the parallel pages.}
% \changes{v2.4.0}{2015/09/29}{Option to switch to \protect\cs{mainmatter} when calling \protect\cs{Pages}}
% \changes{v2.5.0}{2015/10/14}{New commands \protect\cs{linenummarginR} and \protect\cs{linenummargin*}}
% \changes{v2.5.0}{2015/10/14}{Fix a bug introduced in v1.15.0 which made hanging indentation in verse not work anymore.}
% \changes{v2.5.0}{2015/10/14}{Disable empty lines as paragraph in astanza.}
% \changes{v2.5.1}{2015/10/19}{Fix spurious space when using optional argument of \protect\env{astanza} environment (introduced in v2.5.0).}
% \changes{v2.5.2}{2015/10/26}{Fix a bug introduced in v2.5.0 with \protect\cs{linenummargin}, \protect\cs{firstlinenum}, \protect\cs{linenumincrement}, \protect\cs{firstsublinenum}, \protect\cs{sublinenumincrement}.}
% \changes{v2.6.0}{2015/11/13}{\protect\cs{printlinesR} deleted}
% \changes{v2.6.0}{2015/11/13}{\protect\cs{Xlineflag}  and \protect\cs{Xendlineflag} added}
% \changes{v2.6.0}{2015/11/13}{Fix a bug with footnote numbering when using the same series of familiar footnotes on both sides.}
% \changes{v2.6.0}{2015/11/13}{Error message when calling \protect\cs{Pages} or \protect\cs{Columns} without previous \protect\env{pages} or \protect\env{pairs} environnment.}
% \changes{v2.6.0}{2015/11/13}{Fix compatibility with \protect\package{babel} (broken in v2.0.0).}
% \changes{v2.6.0}{2015/11/13}{No error messages about ends of left / right page when using the \protect\cs{syntaxonly} command of the \protect\package{syntonly} package.}
% \hyphenation{man-u-script man-u-scripts}
% \changes{v2.6.0}{2015/11/13}{Fix a bug with right side title number when using title commands before \protect\env{pages} or \protect\env{columns} environments.}
% \changes{v2.6.1}{2015/11/20}{Fix a bug, introduced in v2.6.0, with footnote numbering when using \protect\package{perpage} package.}
% \changes{v2.6.2}{2015/11/29}{Fix (again) bugs with footnote numbering in parallel typesetting while using \protect\env{ledgroup} environments (bug added in v2.6.0).}
% \changes{v2.6.2}{2015/11/29}{Fix a bug (added in v2.6.0) with footnote numbering in parallel typesetting while using \protect\package{polyglossia} with specific numbering systems (like Greek).}
% \changes{v2.6.3}{2015/12/13}{Fix spurious dot when using \protect\cs{linenummargin} on right side (introduced in v2.5.0).}
% \changes{v2.7.0}{2016/01/15}{\protect\macpackage cross-referencing can take advantage of \protect\package{xr} package.}
% \changes{v2.7.1}{2016/03/06}{Fix a bug added in \protect\reledmac~2.8.2, when typesetting parallel text just after a sectioning command}
% \changes{v2.8.0}{2016/03/23}{{Allow continuing line numbering between normal text and parallel text, using \protect\cs{pausenumbering} and \protect\cs{resumenumbering} and the \protect\option{continuousnumberingwithcolumns} options.}}
% \changes{v2.8.0}{2016/03/23}{Fix a bug when the right line number style is not the same to the left line number style}
% \changes{v2.8.0}{2016/03/23}{Add \protect\cs{linenumberLevenifblanktrue} and \protect\cs{linenumberRevenifblank} commands}
% \changes{v2.9.0}{2016/05/08}{Add \protect\cs{AtEveryStanza} and \protect\cs{AtEveryStopStanza}.}
% \changes{v2.9.0}{2016/05/08}{More specific error messages.}
% \changes{v2.9.1}{2016/05/25}{Prevent \protect\cs{Xtxtbeforenotes} hook from causing notes to go beyond the bottom margin}
% \changes{v2.10.0}{2016/06/02}{Add new tools to make apparatuses of manuscripts}
% \changes{v2.11.0}{2016/06/16}{Compatibility with \protect\reledmac's \protect\option{auxdir} option.}
% \changes{v2.12.0}{2016/07/01}{Add \protect\cs{edtextlater} and \protect\cs{edtextnow}.}
% \changes{v2.12.0}{2016/07/01}{Fix a bug with \protect\cs{lineationR}.}
% \changes{v2.12.0}{2016/07/01}{Fix a bug with \protect\cs{AtBeginPairs}.}
% \changes{v2.13.0}{2016/07/22}{Compatibility with the new features of \protect\macpackage 2.15.0}
% \changes{v2.13.1}{2016/09/26}{Simplification of the code concerning the sectioning command}
% \changes{v2.14.0}{2016/10/02}{New commands to have specific line margins for text running in parallel columns}
% \changes{v2.14.0}{2016/10/02}{Add \protect\cs{linenumberlistR}, equivalent to \protect\cs{linenumberlist} for the right side.}
% \changes{v2.14.0}{2016/10/02}{When indexing texts in sidenotes with \protect\cs{edtext}, referring to the line number where the sidenote is called.}
% \changes{v2.14.0}{2016/10/02}{More explicit error message when the stanza indentation is not defined.}
% \changes{v2.14.0}{2016/10/02}{Error message when left / right side are not defined.}
% \changes{v2.14.1}{2016/10/16}{Fix a bug with vertical space before sectioning command in optional argument of \protect\cs{pstart} (bug added in v2.13.1).}
% \changes{v2.14.1}{2016/10/16}{Fix a bug when using \protect\cs{markboth} on \protect\cs{doinsidelineLhook} and \protect\cs{doinsidelineRhook}.}
% \changes{v2.14.2}{2016/10/31}{Fix spurious space with \protect\cs{edtextlater}.}
% \changes{v2.14.3}{2016/11/04}{Fix a bug in \protect\cs{edtextnow}.}
% \changes{v2.14.4}{2016/11/14}{Take into account \protect\cs{linenumberstyle} when using \protect\cs{edlineref}.}
% \changes{v2.15.0}{2016/12/12}{Add \protect\option{movecolumnspositiononrightpage} option.}
% \changes{v2.15.0}{2016/12/12}{New macro \protect\cs{sidenotemarginR}, fix default value to right.}
% \changes{v2.15.0}{2016/12/12}{Fix a bug with \protect\cs{msdata} when using multiple \protect\cs{beginnumbering}\ldots\protect\cs{endnumbering}}
% \changes{v2.15.0}{2016/12/12}{Fix a bug about space before sectioning commands after a pairs environment (bug added in v.~2.14.4).}
% \changes{v2.15.0}{2016/12/12}{Fix a bug with page break when using \protect\cs{columns} (bug added in v.~2.14.1).}
% \changes{v2.16.0}{2016/12/23}{Compatibility with \protect\cs{setmsdataposition}}
% \changes{v2.16.1}{2017/01/03}{Restore sidenotes on left side, deleted by mistake in v2.16.0}
% \changes{v2.16.2}{2017/01/25}{Change log message when numbered files still don't exist, in order to improve compatibility with \protect\emph{latexmk}.}
% \changes{v2.16.3}{2017/02/10}{Fix a bug when setting \protect\cs{aftercolumnseparator}.}
% \changes{v2.17.0}{2017/02/22}{Change code for compatibility with \protect\reledmac 2.18.0}
% \changes{v2.17.1}{2017/03/26}{Fix a bug with \protect\option{prevpgstyle} option when not using \protect\option{prevpgnotnumbered}.}
% \changes{v2.17.3}{2017/04/20}{Fix a bug when using multiple sidenotes on the same line, on right side.}
% \changes{v2.17.4}{2017/04/28}{Fix bugs with sublines in parallel typesetting.}
% \changes{v2.18.0}{2017/05/04}{Compatibility with v2.20.0 of \protect\reledmac.}
% \changes{v2.19.0}{2017/06/08}{Compatibility with v2.22.0 of \protect\reledmac.}
% \changes{v2.19.1}{2017/06/15}{Fix a bug with \protect\cs{edtext} in sectioning command with shiftedpstarts mode.}
% \changes{v2.19.2}{2017/07/07}{\protect\option{continuousnumberingwithcolumns} also works for the pstart number.}
% \changes{v2.19.3}{2017/07/17}{Fix a bug with \protect\option{nopbinverse} when using consecutive \protect\cs{Pages}.}
% \changes{v2.19.3}{2017/07/17}{Do not print footnotes at the first run.}
% \changes{v2.19.4}{2017/07/31}{Optimisation of the code in order to not print footnotes at the first run.}
% \changes{v2.19.5}{2017/08/10}{Fix a bug added in \protect\environment{astanza} in v.~2.18.0}
% \changes{v2.20.0}{2017/10/15}{Add \protect\option{sidenotesmarginpage} option to make the sidenotes refer to page margins and not column margins.}
% \changes{v2.20.0}{2017/08/17}{Fix incompatibility between \protect\cs{lineation}\protect\arg{page} and \protect\option{continuousnumberingwithcolumns} option}
% \changes{v2.20.0}{2017/08/17}{Fix a bug with \protect\cs{continuousnumberingwithcolumns} when using multiple series of continued numbering text. Now, the line number are correctly reset at each \protect\cs{beginnumbering}.}
% \changes{v2.20.0}{2017/08/17}{Fix a bug with \protect\option{continuousnumberingwithcolumns} and inner / outer notes and line numbering.}
% \changes{v2.20.0}{2017/08/17}{Add \protect\cs{linenumOnlyPagesForColumns} and \protect\cs{linenumOnlyPagesForColumnsR} to tell to print the line numbers associated with a column only on some specific pages (for example, only on right pages).}
% \changes{v2.20.0}{2017/08/17}{Fix a bug with \protect\option{continuousnumberingwithcolumns} when a \protect\cs{beginnumbering} is called after another \protect\cs{beginnumbering}\ldots\protect\cs{endnumbering}.}
% \changes{v2.20.0}{2017/08/17}{Fix a bug with \protect\option{widthliketwocolumns} when manually setting \protect\cs{beforecolumnseparator} and \protect\cs{aftercolumnseparator}.}
% \changes{v2.20.0}{2017/08/17}{Fix compatibility between \protect\option{continuousnumberingwithcolumns} and \protect\cs{numberpstartfalse}.}
% \changes{v2.20.1}{2017/08/23}{Fix bug with \protect\option{continuousnumberingwithcolumns} when left column and right column have not the same size.}
% \changes{v2.20.2}{2017/08/31}{Fix bugs with \protect\option{continuousnumberingwithcolumns} when going to a new page}
% \changes{v2.21.0}{2017/11/11}{Add compatibility with new features of \protect\reledmac 2.26.0}
% \changes{v2.21.1}{2017/11/22}{Fix bug with \protect\cs{linenumberannotation}}
% \changes{v2.21.2}{2018/01/08}{Fix bug with \protect\cs{Xpstart} and \protect\cs{edtextlater}}
% \changes{v2.21.3}{2018/01/18}{Fix bug when using \protect\cs{numberpstarttrue} and alterning between manual \protect\cs{pstart} and automatic \protect\cs{pstart} produced by \protect\cs{autopar}}
% \changes{v2.21.4}{2018/01/18}{Fix bug with using \protect\cs{eledsection} and related when alternate normal typesetting and parallel typesetting}
% \changes{v2.21.5}{2018/02/28}{Compatibility with reledmac v.~2.26.6}
% \changes{v2.21.6}{2018/04/06}{Fix page number in footnote and endnotes when using \protect\option{sameparallelpagenumber} option}
% \changes{v2.21.7}{2018/04/07}{Compatibility with \protect\macpackage 2.26.7}
% \changes{v2.21.8}{2018/05/02}{Fix bug with critical footnotes line number when alternating between \protect\cs{numberlinefalse} and \protect\cs{numberlinetrue}.}
% \changes{v2.21.8}{2018/05/02}{Fix bug with marginal line number in parallel typesetting when alternating between \protect\cs{numberlinefalse} and \protect\cs{numberlinetrue}.}
% \changes{v2.21.8}{2018/05/02}{Workaround with a bug of \protect\LaTeX 2018/04/01 patch level 3 to generate the .sty file from a .ins file}
% \changes{v2.21.9}{2018/07/19}{Fix (little) bug when using \protect\package{calc} package.}
% \changes{v2.22.0}{2018/09/13}{Compatibility with \protect\cs{doinsidethislinehook} macro.}
% \changes{v2.22.1}{2019/01/08}{Really reset line number annotation at each line}
% \changes{v2.22.2}{2019/01/22}{Fix bug with \protect\cs{Xonlyside} and \protect\cs{onlysideX}}
% \changes{v2.22.3}{2019/07/21}{When using \protect\cs{parindentX} or \protect\cs{Xparindent} and stanza, use the normal indentation in the footnote, not the verse indentation.}
% \changes{v2.23.0}{2020/03/08}{Add \protect\cs{Leftpagehook} and \protect\cs{Rightpagehook}.}
% \changes{v2.23.0}{2020/03/08}{Add hanging symbol feature to \protect\env{astanza}.}
% \changes{v2.23.1}{2020/04/19}{Fix bug when using \protect\package{polyglossia} v1.45 or later.}
% \changes{v2.24.0}{2020/05/31}{Add startstanzaindentsrepetition feature.}
% \changes{v2.24.0}{2020/05/31}{Add antilabe feature.}
% \changes{v2.24.1}{2020/08/19}{Makes \protect\cs{numberstantzatrue} working with \protect\env{astanza}.}
% \changes{v2.24.1}{2020/08/19}{Fix incompatibility between lineation by \protect\cs{pstart} and (a)stanza.}
% \changes{v2.24.2}{2020/09/16}{Fix some bugs with lineation by page, when a numbered section starts at the very beginning of page.}
% \changes{v2.24.3}{2020/11/08}{Fix bug with hanging verse in parallel typesetting.}
% \changes{v2.25.0}{2020/11/29}{Add compatibility with \protect\cs{linenumannotationothersidetrue} of \protect\macpackage.}
% \changes{v2.25.1}{2021/01/21}{\protect\cs{ifsublines@R} migrated to \protect\macpackage}
% \changes{v2.25.2}{2021/09/27}{Fix incompatibility with \protect\package{babel} v3.61}
% \changes{v2.25.3}{2022/04/22}{Fix incompatibility with \protect\package{polyglossia} v1.55}
% \changes{v2.25.4}{2023/07/04}{Fix bug with \protect\cs{linenumOnlyPagesForColumnsR} and multiple numbered sections}
% \changes{v2.25.5}{2023/07/20}{Fix bug with hyperlink when using \protect\cs{footnoteXnomk}}
% \changes{v2.25.6}{2024/02/26}{Make \protect\cs{doinsidethislinehook} working on right side}
% \changes{v2.25.7}{2024/07/23}{Fix compatibility with \protect\package{polyglossia} 2.2}
% ^^A PW added following as the definitions are at some unknown elsewhere
%
% \newcommand{\egstart}{%
%    \par
%    \begingroup
%    \centering
%    \begin{minipage}{0.45\textwidth}}
% \newcommand{\egmid}{%
%    \end{minipage}\hfill\begin{minipage}{0.45\textwidth}}
% \newcommand{\egend}{%
%    \end{minipage}\par\endgroup}
%
% \title{Parallel typesetting for critical editions: \\
%       the \parpackage package\thanks{This file (\dtxfilename)
% has version number \fileversion, last revised \filedate.}}
% \author{%
% Ma\"ieul Rouquette\thanks{\texttt{maieul at maieul dot net}}
% {\small based on the original \ledpar  by}
% Peter Wilson \\
% Herries Press\thanks{\texttt{herries dot press at earthlink dot net}}\\
% }
%
% \date{}
%
%
% \maketitle
%
%
% \begin{abstract}
% The \macpackage package  has been used for some time for typesetting critical
% editions. The \parpackage package is an extension to \macpackage
% which enables texts and their critical apparatus to be typeset in
% parallel, either in two columns or on pairs of facing pages.
%
%
% \Parpackage  provides many tools and options. Normally, they are all documented in this file.
% Also provided is a help folder, \enquote{\href{examples/.}{examples}}. The folder contains additional examples (although not for all cases).
% Examples starting by \enquote{3-} are for basic uses, those starting by \enquote{4-} are for advanced uses.
%
% To report bugs, please go to ledmac's GitHub page and click \enquote{New Issue}: \url{https://github.com/maieul/ledmac/issues/}. You must open an account with github.com to access my page (maieul/ledmac).  GitHub accounts are free for open-source users. You can report bug in English or in French (better).
%
% You can subscribe to the \macpackage email list in:\\ \url{http://geekographie.maieul.net/146}
% \end{abstract}
% \renewcommand{\numberline}[1]{#1~}
% \tableofcontents
%
%
%
% \section{Introduction}
%
%
% \subsection{Aim of this package}
%
%    Some critical editions contain texts in more than one form, such as
% a set of verses in one language and their translations in another. In
% such cases there is a desire to be able to typeset the two texts, together
% with any critical apparatus, in parallel. The \parpackage package
% is an extension to \macpackage that enables two texts and their
% apparatus to be set in parallel, either in two columns or on pairs of
% facing pages.
%
%    The package has to try and coerce \TeX{} into paths it was not designed
% for. Use of the package, therefore, may produce some surprising results.
% In this case, please reports them to the author via github's issues: \url{https://github.com/maieul/ledmac/issues/}.

% This manual contains a general description of how to use
% \parpackage starting in section~\ref{howto};
% the complete source code for the package,
% with extensive documentation (in sections~\ref{overview}
% through \ref{end});
% and an Index to the source code. As \parpackage is an adjunct to \macpackage
% we assume that you have read the \macpackage manual. Also \parpackage requires
% \macpackage to be used, in the version distributed with version.
%
% You do not need to  read the source code for this package in order to
% use it but doing so may help to answer any questions you might have. The documentation's sections are numbered in roman numeral.
%
% On a first reading,
% We suggest that you should skip anything after the general documentation in
% first sections  until~\ref{overview},
% unless you are particularly interested in the innards of \parpackage.
%
% \subsection{Historical overview}
% Many of the code of this package is based on the \eledpar package, which was based on the \ledpar, created as an extension of the \ledmac package.
%
% Names of the package related to parallel typesetting have moved in parallel of names of the package related to critical edition.
%
% Please read \macpackage's handbook in order to understand this evolution.
%
% \section{Options}
% The package can be loaded with a number of global options which are listed
% here. Those options are fully described in the paragraphs devoted to their feature.
% \subsection{Synchronization's options}
% Please read the paragraph on synchronization's option on \reff{syncoption} to understand better those options.
% \begin{description}
%    \item [shiftedpstarts] prevents white space between paragraphs on facing pages,
%       the white space necessary to sync pages is collected at the bottom of
%       the page instead.
%    \item [advancedshiftedpstarts] does the same as \option{shiftedpstarts}, but
%       the pstart shift are not counted to determine when cutting the page. That
%       could help to avoid page with blank lines at the bottom.
%    \item [nomaxlines] allows facing pages to have different numbers of lines.
%    \item [nosyncpstarts] disables syncing on facing pages. In that case the pages
%       are filled as two streams normal.
% \end{description}
% \subsection{Other options}
% \begin{description}
%    \item [parledgroup]  allows the use of \env{ledgroup} environment with \parpackage.\footnote{This option can either be used on \macpackage or \parpackage.}
%    \item [widthliketwocolumns] set the width of the text printed in a single
%       column to be the same as the width of the text printed in two parallel
%       columns with \parpackage. This is useful when alternating between normal and
%       parallel typesetting.\footnote{This option can either be used on \macpackage or \parpackage.}
%   \item [continuousnumberingwithcolumns] allow you to alternate between normal typesetting and parallel column typesetting without resetting the line number (see \reff{continuousnumberingwithcolumns}).
%    \item [sidenotesmarginpage] makes the sidenotes be placed on the margin of the page and not on the margin of the columns.
%    \item [sameparallelpagenumber] sets page numbers on facing pages to the same value.
%    \item [prevpgnotnumbered] enables that the page before facing pages (the one
%       automatically inserted to start parallel pages on a left page) is not
%       counted. This applies only if the page is empty.
%    \item[movecolumnspositiononrightpage] make the left column on the right page become the right column, and the left column become the right column.
% It allows to have a text running on the inner column, and an other one on the outer column.
% \end{description}
%
%
% \section{General}\label{howto}
%
% A file may mix \emph{numbered} and \emph{unnumbered} text.
% Numbered text is printed with marginal line numbers and can include
% footnotes and endnotes that are referenced to those line numbers:
% this is how you will want to print the text that you are editing.
% Unnumbered text is not printed with line numbers, and you can't
% use \macpackage's note commands with it: this is appropriate for
% introductions and other material added by the editor around the
% edited text.
%
% The \parpackage package lets you typeset two \emph{numbered} texts in
% parallel\footnote{You can use, anyway, \protect\cs{numberlinefalse} to disable printing of line numbers.}.
% This can be done either as setting the \enquote{Leftside} and \enquote{Rightside}
% texts in two columns or on facing pages.
% In the paired pages case footnotes are placed at the bottom of the page
% on which they are called out --- that is, footnotes belonging to the left
% are set at the foot of a left (even numbered) page, and those for right
% texts are at the bottom of the relevant right (odd numbered) page. However,
% in the columnar case, all footnotes are set at the bottom left of the
% page on which they are called out --- they are not set below the
% relevant column.
%
%
%
% \Macpackage essentially puts each chunk of numbered text
% (the text within a \protect\cs{pstart} \ldots \protect\cs{pend}) into a box and then
% following the \protect\cs{pend} extracts the text line by line from the box
% to number and print it. More precisely, the text is first put into the
% the box as though it was being typeset as normal onto a page and
% any notes are stored without being typeset. Then each typeset line
% is extracted from the box and any notes for that line are recalled.
% The line, with any notes, is then output for printing, possibly with
% a line number attached. Effectively, all the text is typeset and then
% afterwards all the notes are typeset.
%
%
% \Parpackage similarly puts the left and right chunks into boxes but can't
% immediately output the text after a \protect\cs{pend} --- it has to wait until
% after both the left and right texts have been collected before it can
% start processing. This means that several boxes are required and possibly
% \TeX\  has to store a lot of text in its memory; both the number of potential
% boxes and memory are limited. If \TeX's memory is overfilled the recourse is
% to reduce the amount of text stored before printing.
%
% \DescribeMacro{\maxchunks}
% It is possible to have multiple chunks in the left and right texts before
% printing them. The macro \protect\cs{maxchunks}\marg{num} specifies the maximum
% number of chunks within the left or right texts. This is initially set as: \\
% \verb?\maxchunks{5120}? \\
% meaning that there can be up to 5120 chunks in the left text and up to
% 5120 chunks in
% the right text, requiring a total of 10240 boxes. If you need more chunks
% then you can increase \protect\cs{maxchunks}. The \protect\cs{maxchunks} must be called in the preamble.
%
% If you \protect\cs{maxchunks} is too little
%you can get a \parpackage{} error message along the
% lines: \enquote{Too many \protect\cs{pstart} without printing. Some text will be lost.}
% then you will have to either increase \protect\cs{maxchunks} or use the
% parallel printing commands (\protect\cs{Columns} or \protect\cs{Pages}) more frequently.
%
% When typesetting verse using \protect\cs{stanza}, each line is treated as a chunk,
% so be warned that if you are setting parallel verses you might have to
% increase \protect\cs{maxchunks} much more than it appears at first sight.
%
%    In general, \macpackage is a \TeX\  resource hog, and \parpackage{} only
% makes things worse in this respect.
%
% \section{Parallel columns}\label{columns}
% \subsection{Basic use}
% \DescribeEnv{pairs}
% Numbered text that is to be set in columns must be within a \verb?pairs?
% environment. Within the environment the text for the lefthand and righthand
% columns is placed within the \verb?Leftside? and \verb?Rightside?
% environments, respectively; these are described in more detail below
% in section~\ref{leftright}.
%
% \DescribeMacro{\Columns}
% The command \protect\cs{Columns} typesets the texts in the previous pair of
% \verb?Leftside? and \verb?Rightside? environments.
% The general scheme for parallel columns looks like this:
% \begin{verbatim}
% \begin{pairs}
% \begin{Leftside} reledmac numbered text commands \end{Leftside}
% \begin{Rightside} reledmac numbered text commands \end{Rightside}
% \end{pairs}
% \Columns
% \begin{pairs}
% \begin{Leftside} reledmac numbered text commands \end{Leftside}
% ...
% \end{pairs}
% \Columns
% \end{verbatim}
%
%
% Keep in mind that the \protect\cs{Columns} \textbf{must be} outside of the \verb+pairs+ environment.
% \DescribeMacro{\AtBeginPairs}
% \changes{v1.9.0}{2014/09/16}{Add \protect\cs{AtBeginPairs} macro.}
% You can use the macro \protect\cs{AtBeginPairs} to insert a code at the beginning of each \verb+pairs+ environments.
% That could be useful to add the \protect\cs{sloppy} macro to prevent overfull hboxes in two columns.
% \begin{verbatim}
% \AtBeginPairs{\sloppy}
% \end{verbatim}
% There is no required pagebreak before or after the columns.
% \subsection{Setting}
% \subsubsection{Column's width}
% \DescribeMacro{\Lcolwidth}
% \DescribeMacro{\Rcolwidth}
% The lengths \protect\cs{Lcolwidth} and \protect\cs{Rcolwidth} are the widths of the left
% and right columns, respectively. By default, these are: \\
% \verb?\setlength{\Lcolwidth}{0.45\textwidth}? \\
% \verb?\setlength{\Rcolwidth}{0.45\textwidth}? \\
% They may be adjusted if one text tends to be \enquote{bulkier} than the other.
% \subsubsection{Column's separator}
% \DescribeMacro{\columnrulewidth}
% \DescribeMacro{\columnseparator}
% The macro \protect\cs{columnseparator} is called between each left/right pair
% of lines. By default it inserts a vertical rule of width
% \protect\cs{columnrulewidth}. As this is initially defined to be 0pt the rule
% is invisible. For a visible rule between the columns you could try: \\
% \verb?\setlength{\columnrulewidth}{0.4pt}? \\
% You can also modify \protect\cs{columnseparator} if you want more control.
% \subsubsection{Column's positions}
% \DescribeMacro{\columnsposition}
% \changes{v1.8.0}{2014/08/05}{Add \protect\cs{columnsposition}.}
% By default, columns are positioned to the right of the page.
% However, you can use \protect\cs{columnsposition}\verb+{L}+ to align them to the left,
% or \protect\cs{columnsposition}\verb+{C}+ to center them.
%
% When you use \protect\cs{stanza}, the visible rule may shift when a verse has a hanging indent. To prevent shifting, use \protect\cs{setstanzaindents} outside the \verb|Leftside| or \verb|Rightside| environment.
%
%
% \DescribeMacro{\beforecolumnseparator}\DescribeMacro{\aftercolumnseparator}
% \changes{v1.8.0}{2014/08/05}{Add \protect\cs{beforecolumnseparator} and \protect\cs{aftercolumnseparator}.}
% By default, the spaces around column separator are the same as the space:
% \begin{itemize}
%  \item On the left of columns, if columns are aligned right.
%  \item On the right of columns, if columns are aligned left.
%  \item On both the left and right columns, if columns are centered.
% \end{itemize}
% You can redefine \protect\cs{beforecolumnseparator} and \protect\cs{aftercolumnseparator} length to define spaces before or after the column separator, instead of letting \parpackage calculate them automatically.
% \begin{verbatim}
% \setlength{\beforecolumnseparator}{length}
% \setlength{\aftercolumnseparator}{length}
% \end{verbatim}
% If you want to revert to the previous behavior, just set with a negative value.
% \subsubsection{Mixing two columns and one column texts}
% \DescribeMacro{\widthliketwocolumns}
% If you want to mix two-column with single-column text, you can align horizontally single-column text to two-column text with \protect\cs{widthliketwocolumnstrue}. To reset this feature, use \protect\cs{widthliketwocolumnsfalse}.
% You can also use \option{widthliketwocolumns} as a global option when loading \macpackage or \parpackage.

%
% \DescribeMacro{\Xnoteswidthliketwocolumns}
% \DescribeMacro{\notesXwidthliketwocolumns}
% In most cases, you should use \protect\cs{widthliketwocolumns} in combination with \protect\cs{Xnoteswidthliketwocolumns} and \protect\cs{notesXwidthliketwocolumns} to align the critical/familiar footnotes with the two colums.
% See \macpackage's handbook for more details.
%
% \subsubsection{Schemas of column typesetting}
% Domenico Cufalo wrote a schema of the parallel column typesetting parameters, with explanations.
% You can read the file \href{run:doc-more/page-typesetting-columns.pdf}{doc-more/page-typesetting-columns.pdf}.
%
% \subsubsection{Continuous numbering between single and double column texts}
% \label{continuousnumberingwithcolumns}If you want to have continuous line
% numbers between multiple columns and single columns, use the
% \option{continuousnumberingwithcolumns} option when loading \macpackage
% or \parpackage.
% You will need to use \cs{pausenumbering}\ldots
% \cs{resumenumbering} in addition to \cs{beginnumbering}\ldots
% \cs{endnumbering} (see \reff{reledmac-pause}).
%
% The best way to understand the behaviour of \cs{pausenumbering} and
% \cs{resumenumbering} is to think of the left-column text as a continuation of
% single-column text (or, vice versa, to think of single-column text as
% left-column text), and of the right-column as independent text, which needs to be
% synchronised with the left one manually. The numbering commands in a
% right column are interconnected with each other, and not with the respective
% left-column commands.
%
% This means that you must switch between single-column and left-column
% text using \cs{beginnumbering}\ldots\cs{pausenumbering}\ldots
% \cs{resumenumbering}\ldots\cs{pausenumbering}\ldots
% \cs{resumenumbering}\ldots\cs{endnumbering}.
%
% On the other side, the first right column must always begin with
% \cs{beginnumbering}, no matter if the corresponding left-column started
% with \cs{resumenumbering} or not; this is because numbering in the right
% column has not been started yet. Then, for consecutive chunks of
% right-column text you should use \cs{pausenumbering}\ldots
% \cs{resumenumbering}.
%
% You must use \cs{endnumbering} in a right column in the following cases:
% \begin{itemize}
%  \item there is also a \cs{endnumbering} in the left column, because the line numbering ends with a two columns mode (e.g. at the end of a document);
%  \item there will be a \cs{endnumbering} in a text after the columns, in a single column mode, because the ligne numbering finishes with single column mode text.
% \end{itemize}
% Without this, you will
% get wrong numbering when a right column reappears next time.
%
% The file
% \file{examples/4-reledpar_column_mix_with_not_column-continuous-numbering.tex}
% covers all these cases.
% \subsection{Note about \cs{AtEveryPstart*} and \cs{AtEveryPend*}}
% The content of \cs{AtEveryPstart} / \cs{AtEveryPend} (without star) is added before every \cs{pstart} / after every \cs{pend}, distinguishing between the left and the right side.
%
% The content of \cs{AtEveryPstart*} / \cs{AtEveryPend*} (with star) is added before every \cs{pstart} / after every \cs{pend}, but there is no distinction between the left and right sides: the content is inserted \enquote{for the two columns as a whole}.
%
% However, as this content is also added when we typeset pages in parallel, \reledmac must add it once for left  \cs{pstart} and once for right \cs{pstart}.
% So if you use it to add vertical spacing, it will be problematic in parallel columns, as you will have the vertical spacing two times (vertical spacing will be twice as large as expected).
% A solution is to add a test inside to distinguish between parallel typesetting in columns or on pages.
% \begin{verbatim}
%\AtEveryPstart*{%
%\ifl@dprintingcolumns
%  \vspace{0.125\baselineskip}
%\else
%  \vspace{0.25\baselineskip}
%\fi
%}
% \end{verbatim}
% \section{Keeping translation in the outside/inside column}
% By default, \parpackage works with left and right columns.
% However, it is possible to work with inner and outer column.
% In this case, use the \option{movecolumnspositiononrightpage} at loading time of the package.
%
% The \env{Leftside} environment will correspond to the inner column, and the \env{Rightside} environment will correspond to the outer column.
%
% \section{Facing pages}\label{pages}
% \subsection{Basic usage}
% \DescribeEnv{pages}
% Numbered text that is to be set on facing pages must be within a \verb?pages?
% environment. Within the environment the text for the lefthand and righthand
% pages is placed within the \verb?Leftside? and \verb?Rightside?
% environments, respectively.
%
% \DescribeMacro{\Pages}
% The command \protect\cs{Pages} typesets the texts in the previous pair of
% \verb?Leftside? and \verb?Rightside? environments.
% The general scheme for parallel pages looks like this:
% \begin{verbatim}
% \begin{pages}
% \begin{Leftside} reledmac numberied text commands \end{Leftside}
% \begin{Rightside} reledmac numbered text commands \end{Rightside}
% \begin{Leftside} reledmac numbered text commands \end{Leftside}
% ...
% \end{pages}
% \Pages
% \end{verbatim}
% The \verb?Leftside? text is set on lefthand (even numbered) pages and
% the \verb?Rightside? text is set on righthand (odd numbered) pages.
% Each \protect\cs{Pages} command starts a new even numbered page. After parallel
% typesetting is finished, a new page is started.
% Note that the \protect\cs{Pages} \textbf{must be} outside of the \verb+pages+ environment.
% \subsection{Setting}
% \subsubsection{Text width}
% \DescribeMacro{\Lcolwidth}
% \DescribeMacro{\Rcolwidth}
% Within the \verb?pages? environment the lengths \protect\cs{Lcolwidth} and
% \protect\cs{Rcolwidth} are the widths of the left
% and right pages, respectively. By default, these are set to the normal
% textwidth for the document, but can be changed within the environment if
% necessary.
% \subsubsection[Way of synchronizing]{Way of synchronizing\footnote{There is a French version of this article on \url{http://geekographie.maieul.net/185}.}}\label{syncoption}
% Synchronization of left and right texts in parallel processing
% requires some \enquote{numbered} auxiliary files to be written (namely \verb+.1+,
%\verb+.1R+, \verb+.2+, \verb+.2R+, and so forth), the content of which may change as long
%as synchronization is not complete. This usually requires \LaTeX\ to be
%run several times. Therefore, it is advised to use in conjunction
%utilities such as latexmk to ensure that synchronization is complete.
%
%Numbered paragraphs which are contained between the \cs{pstart} and \cs{pend}
%macros are thereafter called \enquote{chunks}.
%
%In short, the default setting is designed in such a way that
%corresponding chunks of text are always kept in synchronization, even
%at the cost of page padding, as it may result in leaving blank lines
%between chunks of text. Conversely, using in conjunction
%\option{advancedshiftedpstarts} and \option{nomaxlines} settings ensures that pages
%are filled with text to full advantage—at the cost of the chunks not
%being kept in synchronization—and every chunk starts on the facing
%page of its corresponding chunk.
%
%To understand better how each of the synchronization settings of
%\parpackage works, one must first understand how the default setting of
%\parpackage synchronizes the left and right chunks.
%
%The aim of the default setting is twofold:
%\begin{itemize}
%\item To ensure that left pages contain what is to be on left side and
%that right pages contain what is to be on right side.
%\item To ensure that every chunk starts on the page that is facing its
%corresponding chunk.
%\end{itemize}
%
%As regards the latter, \parpackage checks that both of the following
%rules are respected:
%\begin{itemize}
%\item The numbers of lines of every pair of chunks must be identical. To
%keep this rule, \parpackage may insert some blank lines at the bottom of
%the chunk that is shorter so that it may eventually have the same
%number of lines as the one that is longer.
%\item The main content of two facing pages, apart from critical and
%familiar footnotes, must have the same numbers of lines, including
%those that may be blank. Consequently, if one left page contains more
%notes than the corresponding right page, the bottom of the right page
%must be left blank.
%\end{itemize}
%
%Each of these rules can be modified by a number of optional
%synchronization settings in \parpackage:
%\begin{enumerate}
%\item Regarding the number of lines a pair of chunks may have:
%  \begin{enumerate}
%    \item 'shiftedpstarts' setting merely moves any added blank lines from
%the bottom of the chunks to the bottom of the page. It does not allow
%to have more lines on a given page as it just removes the blank lines
%between the chunks and does nothing more. To understand better how
%this work, you may compare the total amounts of lines of text on a
%given page whether you have activated this setting or not: you will
%see that both amounts are the same.
%    \item 'advancedshiftedpstarts' prevents any blank lines from being
%inserted at the bottom of the chunks, also taking them away from the
%total amount of lines the page may have. This allows to get more lines
%on the pages. However, please note that:
%        \begin{itemize}
%          \item Blank lines are taken into account as \parpackage moves from one to
%the following chunk of text, so that every pair of chunks may always
%start on the same facing pages.
%          \item Consequently, blank lines continue to be taken into account in
%the calculation of the amount of lines a given pair of pages may have.
%This is why when a longer chunk runs from one page to another the
%shorter corresponding one also runs across pages, even if this may
%result in some blank vertical space being left on the first page.
%        \end{itemize}
%    \end{enumerate}
%    \item As regards the number of lines per page, including blank ones, the
%\option{nomaxlines} setting disregards the rule that forces two facing pages
%to have the same numbers of lines. So it allows to have more text on
%the pages. Then, by a complex mechanism it is ensured that two
%corresponding chunks may always start on the same facing pages,
%provided that \option{shiftedpstarts} or \option{advancedshiftedpstarts} settings
%shall not be activated.
%\end{enumerate}
%
%Lastly, one may disregard all of the synchronization rules and content
%himself with parallel texts typesetting. To achieve this, please use
%the \option{nosyncpstarts} setting.
%
%Please note that every change of synchronization setting resets the
%content of the \enquote{numbered} auxiliary files to make sure that \parpackage
%does not try to make the synchronization with wrong calculations.
% \subsubsection{Page number}\label{sameparallelpagenumber}
% \changes{v1.15.0}{2015/05/18}{Add sameparallelpagenumber option.}
% By default, \protect\cs{Pages} use the standard \LaTeX\ page number scheme.
% This means that pages are numbered continuously following printed-book conventions: from left-hand to right-hand side, left-hand pages having even numbers, right-hand pages having odd numbers.
%
% However, you can use the package option \verb+sameparallelpagenumber+ to have the same page number for both left and right side.
% In this case, this setting will apply only for pages typeset by \protect\cs{Pages}, not for \enquote{normal} pages.
%
% Please also read advising in \reff{par@page}.
%
%
% \subsubsection{Page breaking}
% \DescribeMacro{\setgoalfraction}
% When doing parallel pages \parpackage{} has to guess where \TeX\ is going to
% put pagebreaks and hopefully get there first in order to put the pair of
% texts on their proper pages. When it thinks that the fraction
% \protect\cs{@goalfraction} of a page has been filled, it finishes that page and
% starts on the other side's text. The standard value is 0.9.
%
%
% If you think you can get more on a page, increase this. On the other hand,
% if some left text overflows onto an odd numbered page or some right text
% onto an even page, try reducing it.
% You can change it using \cs{setgoalfraction}\marg{newvalue}.
%  \subsubsection{Right page before \cs{Pages}}
% When \cs{Pages} are called, it starts at a new left page, in order to have parallel pages.
% Consequently, if it is called on a left page, it clears the current page and then lets
% a right void page.
%
% \Parpackage  provides two options to customize this (eventual) right page.
% \label{prevpgnotnumbered}
% \begin{description}
% \item[prevpgstyle=\meta{style}] in order to set the style of this page. A common value of \meta{style} is \verb+empty+.
% Use \verb+prevpgstyle=empty+ will suppress header and footer in this page.
% Please also read advising in \reff{par@page}.
% \item[prevpgnotnumbered] will make this page won't be counted in the page counter.
%
% \end{description}
% \subsubsection{Notes about \protect\cs{mainmatter}}
% If you use \cs{frontmatter}, do not use \cs{mainmatter} directly before \cs{Pages} because it could create spurious empty pages.
%
% Use instead \cs{pages} with the optional argument \verb+[mainmatter]+.
% In this case, the content of \cs{Pages} will start on a left side, without any spurious empty page, and the left pages will be odd (and not event like in normal way), the first one being \verb+1+.
%
%  \subsection{Critical and familiar footnotes}
% Of course, in \enquote{Facing pages},  the \macpackage's  both critical and familiar footnotes can be used.
% However, some specific points must  be taken into consideration.
% \subsubsection{Notes height setting}
% Since \protect\package{eledpar} v1.13.0, long notes in facing pages can flow from left to right pages, and \emph{vice-versa}.
%
% However, the \macpackage default setting for the maximum alloted size to notes is  greater than \protect\cs{textheight}. That makes impossible for long notes to flow across pages.%
% \footnote{The same applies to \LaTeX\ normal notes. Read \url{http://tex.stackexchange.com/a/228283/7712} for technical informations.}
% We have not changed this default setting, because we do not want to break compatibility with older version of \macpackage and we want to be as close as possible to default \LaTeX's feature.
%
% So, you MUST change the default setting via \protect\cs{Xmaxhnotes} (for critical notes) and \protect\cs{maxhnotesX} (for familiar notes).
% Both commands are explained in \macpackage handbook (\reff{reledmac-Xmaxhnotes}).
% As an advisable setting:
% \begin{verbatim}
% \AtBeginDocument{%
%    \Xmaxhnotes{0.6\textheight}
%    \maxhnotesX{0.6\textheight}
% }
% \end{verbatim}
% \subsubsection{About the numbering of familiar footnotes}
% If you use the same series of familiar footnotes on both sides, the numbers won't be correct in the first run. There will be a continuous numbering for left notes, and a continuous numbering for right notes.
% However,  after the second run, the numbering will be continuous, alternating between the left and right side.
% For example if you have two left pages and two right pages, with one note by page, you will obtain the following numbering at the first run: 1 (left page), 3 (right page), 2 (left page),  4 (right page). But at the next run, you will obtain: 1 (left page), 2 (right page), 3 (left page), 4 (right page).
%
% If you use parallel columns, during the second of run of typesetting the footnote numbering will not run down the columns. Instead, it will read both column lines completely across the page, and number footnotes from left to right.
% \subsubsection{Using \protect\package{perpage} package}\label{perpage}
%
% It follows from what has been said in the preceding paragraph that if you use the \cs{MakePerPage} command of the \cs{perpage} package for footnotes called in parallel typesetting, you must append to the counter the suffix \verb+@typeset+.
%
% So do not set:
% \begin{verbatim}
% \MakePerPage{footnote}
% \MakePerPage{footnoteA}
% \MakePerPage{footnoteB}
% \end{verbatim}
% But set:
% \begin{verbatim}
% \MakePerPage{footnote@typeset}
% \MakePerPage{footnoteA@typeset}
% \MakePerPage{footnoteB@typeset}
% \end{verbatim}

% \subsubsection{Notes for one side only}
% \DescribeMacro{\Xonlyside}
% \DescribeMacro{\onlysideX}
% You may want to typeset notes on one side only (either left or right).
% Use \protect\cs{Xonlyside}\oarg{s}\marg{p} to set critical notes, and \protect\cs{onlysideX}\oarg{s}\marg{p} to set familiar notes.
% \meta{p} must be set to \verb+L+ for notes to be confined only on the left side and to \verb+R+ for  notes to be confined only on the right side.
%
% Notice that these options just tell you \LaTeX\ to not continue long notes on the other side.
% It is not designed to allow you to call footnotes on one side but print them on the other side.
% \subsubsection{Familiar notes called on the right side, but to be printed on the left side}\label{reledpar-nomk}
% \DescribeMacro{\footnoteXnomk}
% \DescribeMacro{\footnoteXmk}
% As often happens, the left side has less room for text.
% We may want to call familiar notes in the right side while using at the same time the available space in the left side to print them.
%
% To achieve this, we call \protect\cs{footnoteXnomk}\marg{notecontent} in the left side. \verb+X+ is to be replaced by the series letter. We do this call in the left side after the word which matches up to the one in the right side after which we want to insert the actual footnote mark.
%
% In the right side, we call \protect\cs{footnoteXmk} at the place we want to have the footnote mark. X is to be replaced by the series letter.
% For example:
% \begin{verbatim}
%   \begin{Leftside}
%    \beginnumbering
%     \pstart
%      A little cat\footnoteAnomk{A note.}. And so one ...
%     \pend
%    \endnumbering
%   \end{Leftside}
%   \begin{Rightside}
%    \beginnumbering
%     \pstart
%      Un petit chat\footnoteAmk. And so one ...
%     \pend
%    \endnumbering
%   \end{Rightside}
% \end{verbatim}
% \subsection{Critical notes called on leftside but printed on right side}
% Sometimes, you need to print the critical notes on the right side, despite the fact that they refer to the lemmas on the left side.
% In this case, you must use \cs{edtextlater} and \cs{edtextnow}.
% \DescribeMacro{\edtextlater}
% The \cs{edtextlater}\marg{lemma}\marg{footnote command} command must be called on the same side as the lemma.
% It is similar to the standard \cs{edtext} command, but does not add the footnote immediately on the page, keeping it for later.
% \DescribeMacro{\edtextnow}
% \cs{edtextnow} must be called on the side on which you want to print the lemma, approximately at the point corresponding to the equivalent \cs{edtextlater} command.
% It will add the notes stored by the equivalent \cs{edtextlater} command.
%
% The relationship between the \cs{edtextlater} and \cs{edtextnow} commands is determined by the order of calling: the first \cs{edtextnow} corresponds to the first \cs{edtextlater}, the second \cs{edtextnow} corresponds to the second \cs{edtextlater} etc.
%
%
% \cs{edtextnow} is a parameterless macro, so it gobbles the following space.
% If you want to keep it, add \verb+{}+ or backslash followed by a space.
%
% \subsection{Using line flag}
% \DescribeMacro{\Xlineflag}
% \DescribeMacro{\Xendlineflag}
% Use \cs{Xlineflag}\oarg{s} to add right line flag (\reff{Rlineflag}) to right critical footnotes and  \cs{Xendlineflag}\oarg{s} to add it to right critical endnotes.
% \section{Left and right texts}\label{leftright}
% \subsection{Environments}
% Parallel texts are divided into Leftside and Rightside. The form of the
% contents of these two are independent of whether they will be set
% in columns or pages.
%
% \DescribeEnv{Leftside}
% \DescribeEnv{Rightside}
% The left text is put within the \verb?Leftside? environment and the
% right text likewise in the \verb?Rightside? environment. The number of
% \verb?Leftside? and \verb?Rightside? environments must be the same.
% \subsection{Numbering text lines and paragraphs}
%
% \DescribeMacro{\beginnumbering}
% \DescribeMacro{\endnumbering}
% Each section of numbered text must be preceded by
% \protect\cs{beginnumbering} and followed by \protect\cs{endnumbering}, like: \\
% \protect\cs{beginnumbering} \\
% \meta{text} \\
% \protect\cs{endnumbering} \\
% These have to be separately specified within \verb?Leftside? and
% \verb?Rightside? environments.
%
% The \protect\cs{beginnumbering} macro resets the line number to zero,
% reads an auxiliary file called \meta{jobname}.\file{nn} (where
% \meta{jobname} is the name of the main input file for this job,
% and \file{nn} is 1 for the first numbered section, 2 for
% the second section, and so on), and then creates a new version of
% this auxiliary file to collect information during this run.
% Separate auxiliary files are maintained for right hand texts and
% these are named \meta{jobname}.\file{nnR}, using the \enquote{R} to distinguish
% them from the left hand and serial (non-parallel) texts.
%
% \DescribeMacro{\memorydump}
% The command \protect\cs{memorydump} effectively performs an \protect\cs{endumbering}
% immediately followed by a \protect\cs{beginnumbering} while not restarting the
% numbering sequence. This has the effect of clearing \TeX's memory of previous
% texts and any associated notes, allowing
% longer apparent streams of parallel texts. The command should be applied
% to both left and right texts, and after making sure that all previous
% notes have been output. For example, along the lines of:
% \begin{verbatim}
% \begin{pages}
% \begin{Leftside}
%   \beginnumbering
%   ...
% \end{Leftside}
% \begin{Rightside}
%   \beginnumbering
%   ...
% \end{Rightside}
% \end{pages}
% \Pages
% \begin{pages}
% \begin{Leftside}
%   \memorydump
%   ...
% \end{Leftside}
% \begin{Rightside}
%   \memorydump
%   ...
% \end{pages}
% \end{verbatim}
%
%
%\changes{v0.9.0}{2011/10/01}{Possibility to number \protect\cs{pstart}.}
% It is possible to insert a number at every \protect\cs{pstart} command.
% You must use the \DescribeMacro{\numberpstarttrue}\protect\cs{numberpstarttrue} command to have it.
% You can stop the numbering with \DescribeMacro{\numberpstartfalse}\protect\cs{numberpstartfalse}.
%
% You can modify the number by changing the values of the \verb+pstartL+ and \verb+pstartR+ counters (for left and right side, respectively). For example:
% \begin{verbatim}
% \setcounter{pstartL}{0}% To reset the counter of pstart for the left side.
% \end{verbatim}
% You can redefine the commands \DescribeMacro{\thepstartL}\protect\cs{thepstartL} and \DescribeMacro{\thepstartR}\protect\cs{thepstartR} to change style.
% The numbering restarts on each \protect\cs{beginnumbering}.
%
% \DescribeMacro{\skipnumbering}
% The command \protect\cs{skipnumbering} when inserted in a line of parallel text
% causes the numbering of that particular line to be skipped. This can
% useful if you are putting some kind of marker (even if it is only a
% blank line) between stanzas. Remember, parallel texts must be numbered
% and this provides a way to slip in an \enquote{unnumbered}  line.
%
% \changes{v1.21.0}{2015/04/13}{Add \protect\cs{hidenumbering}}
% \DescribeMacro{\hidenumbering}
% When inserted into a numbered line the macro \protect\cs{hidenumbering} causes
% the number for that particular line to be hidden; namely, no line number will print.
% Note that if you use it in \protect\cs{stanza}, you must call it at the beginning of the verse.
% \subsection{First line number and line number increment}
% \DescribeMacro{\firstlinenum}
% \DescribeMacro{\linenumincrement}
% \DescribeMacro{\firstsublinenum}
% \DescribeMacro{\sublinenumincrement}
% Following
% \protect\cs{firstlinenum}\marg{num} the first line number will be \meta{num}, and
% following \protect\cs{linenumincrement}\marg{num} only every \meta{num}th
% line will have a printed number.
%
%
% The lineation commands which finish by a \verb+R+ apply for right text.
% The lineation commands which are starred apply for both left and right texts.
% The lineation command which does not finish by a \verb+R+ and who are not starred apply for the left side.
% \textbf{%
% However, these commands apply to right side when they are called inside a \environment{left} environment.
% However, such features should not be used any more. The recommended practice is to add all setting commands to the preamble.
%}
% \DescribeMacro{\firstlinenum*}
% \DescribeMacro{\linenumincrement*}
% \DescribeMacro{\firstsublinenum*}
% \DescribeMacro{\sublinenumincrement*}
% The starred versions change both left and right numbering schemes.
%
% \DescribeMacro{\firstlinenumR}
% \DescribeMacro{\linenumincrementR}
% \DescribeMacro{\firstsublinenumR}
% \DescribeMacro{\sublinenumincrementR}
% The suffixed version change the right side, without regard to the position they are called.
% \subsection{Lineation system}
% \DescribeMacro{\lineationR}
% \protect\cs{lineationR} macro is the equivalent of \macpackage \protect\cs{lineation} macro for the right side.
% \DescribeMacro{\lineation*}

% \protect\cs{lineation*} macro is the equivalent of \macpackage \protect\cs{lineation} macro for both sides.
%
% \Macpackage allows you to define a \cs{linenumberlist} to explicitly define (\reff{reledmac-linenumberlist}) in which line the line number will be printed.
% In parallel typesetting, this command affects only left side.
% For right side, you have to define \cs{linenumberlistR}.
% \subsection{Line number style}
% \DescribeMacro{\linenumberstyleR}
% \DescribeMacro{\sublinenumberstyleR}
% \DescribeMacro{\linenumberstyle*}
% \DescribeMacro{\sublinenumberstyle*}
% \cs{linenumberstyleR} is the equivalent of \macpackage \cs{linenumberstyle} for right text.
% \cs{sublinenumberstyleR} is the equivalent of \macpackage \cs{sublinenumberstyle} right text.
% The starred version are for both side.
% \subsection{Line number margin}
% \DescribeMacro{\linenummarginR}
% \DescribeMacro{\linenummargin*}
% \cs{linenummarginR}\marg{margin} sets the line margin for right side.
% \cs{linenummargin*}\marg{margin} sets for both side.
% \meta{margin} can be, as for \macpackage's \cs{linenummargin} one of these values: \verb+left+, \verb+right+, \verb+inner+, \verb+outer+.
%
% \DescribeMacro{\linenummarginColumns}
% \DescribeMacro{\linenummarginColumnsR}
% \DescribeMacro{\linenummarginColumns*}
% Suppose you typeset texts both in parallel pages (or in normal typesetting) and in parallel columns.
% In this case, your setting of line margin in parallel pages (or in normal typesetting) could be different from your setting of line margin in parallel columns.
% For example, you could want to have line numbers on the right when your are in parallel pages (or in normal typesetting), but when you are in parallel columns, to have them on the left for the left column and on the right for the right column.
%
% In this case, you can use \cs{linenummarginColumns}, which overrides the default setting for the left column, \cs{linenummarginColumnsR} which overrides the default setting for the right column, and \cs{linenummarginColumns*}, which overrides the default for both left and right columns.
%
% \DescribeMacro{\linenumOnlyPagesForColumns}
% \DescribeMacro{\linenumOnlyPagesForColumnsR}
% Another usual case is when you have text in parallel columns and want to get line numbers only on the outer margin.
% In this case, you need to get line numbers on the left side of the left column on left pages and on the right side of the right column on the right pages.
%
% Reciprocally, if you want line numbers only in the inner margin, you need to get line numbers on the right side of the right column on left pages and on the left side of the left column on the right pages.
%
% In both cases, you need, for one column, to have line numbers only on one page of a double page.
%
% You can use \cs{linenumOnlyPagesForColumns} and \cs{linenumOnlyPagesForColumnsR} to get this result:
% \begin{verbatim}
% \linenummargin{left}
% \linenummarginR{right}
% % To get only on the outer margin
% \linenumOnlyPagesForColumns{left}
% \linenumOnlyPagesForColumnsR{right}
% % To get only on the inner margin
% \linenumOnlyPagesForColumns{right}
% \linenumOnlyPagesForColumnsR{left}
% % To get on the inner or the outer margin
% \linenumOnlyPagesForColumns{}
% \linenumOnlyPagesForColumnsR{}
% \end{verbatim}
% Note that these settings only apply when we are typesetting columns (as, if we are not typesetting columns, the \enquote{inner} and \enquote{outer} setting of \cs{linenummargin} and \cs{linenummarginR} are enough).
%
% \DescribeMacro{\linenumberLevenifblanktrue}
% \DescribeMacro{\linenumberRevenifblanktrue}
% By default, when a blank line is printed on one side, no line number is printed for the sake of synchronizing with the other side.
% However, line numbers can be printed for blank lines as well.
% Use \cs{linenumberLevenifblanktrue} to enable this on the left side and \cs{linenumberRevenifblanktrue} for the right side.
%
% \subsection{Line flag}
% \DescribeMacro{\setRlineflag}\label{Rlineflag}
% A \enquote{R}  is appended to the line numbers of the
% right texts.
% This may be useful for parallel columns but for parallel pages it might
% be more appropriate to redefine it using \protect\cs{setRlineflag}\marg{flag}.
% Use \verb?\setRlineflag{}? to empty it.
%
% \subsection{Chunks}
% \DescribeMacro{\pstart}
% \DescribeMacro{\pend}
% In a serial (non-parallel) mode, each numbered paragraph, or chunk,
% is contained
% between the \protect\cs{pstart} and \protect\cs{pend} macros, and the paragraph is output
% when the \protect\cs{pend} macro occurs. The situation is somewhat different
% with parallel typesetting as the left text (contained within \protect\cs{pstart}
% and \protect\cs{pend} groups within the \verb?Leftside? environment) has to be
% set in parallel with the right text (contained within its own \protect\cs{pstart}
% and \protect\cs{pend} groups within the corresponding \verb?Rightside? environment)
% the \protect\cs{pend} macros cannot immediately initiate any typesetting ---
% this has to be controlled by the \protect\cs{Columns} or \protect\cs{Pages} macros.
% Several chunks may be specified within a \verb?Leftside? or
% \verb?Rightside? environment.
% A multi-chunk text then looks like:
% \begin{verbatim}
% \begin{...side}
%   % \beginnumbering
%   \pstart first chunk \pend
%   \pstart  second chunk \pend
%   ...
%   \pstart  last chunk \pend
%   % \endnumbering
% \end{...side}
% \end{verbatim}
% Numbering, via \protect\cs{beginnumbering} and \protect\cs{endnumbering}, may extend
% across several \verb?Leftside? or \verb?Rightside? environments.
% Remember, though,
% that the left/right sides are effectively independent of each other.
%
% \DescribeMacro{\autopar}
% The \protect\cs{autopar} macro can be used, instead of manually inserting \protect\cs{pstart}\ldots\protect\cs{pends}. Please read \macpackage's  handbook (\reff{reledmac-autopar}).


% \subsection{\protect\cs{AtEveryPstart} and \protect\cs{AtEveryPstartCall}}
% In general, remember that the moment where a \protect\cs{pstart} is called is different
% from the moment when  the \protect\cs{pstart}\ldots\protect\cs{pend} content is printed, which is when \protect\cs{Pages} or \protect\cs{Columns} is processed.
%
% Consequently:
% \begin{itemize}
%  \item The argument of \protect\cs{AtEveryPstart} (see \reff{reledmac-AtEveryPstart}) is called before every chunk is printed, except if you used an optional argument for the \protect\cs{pstart}.
%  \item The argument of \protect\cs{AtEveryPstartCall} is called before every \protect\cs{pstart}.
% \end{itemize}
% \subsection{Language setting}
% If you are using the
% \protect\package{babel} package or the \protect\package{polyglossia} package ,with different languages
% (via, say, \protect\cs{selectlanguage}) for the left and right texts it is
% particularly important to select the appropriate language within the
% \verb?Leftside? and \verb?Rightside? environments. The initial language
% selected for the right text is the \protect\package{babel} package's default. Also,
% it is the \emph{last} language setting  in a side that controls the
% language used in any notes for that side when they get printed. If
% you are using multilingual notes then it is probably safest to explicitly
% specify the language(s) for each note rather than relying on the language
% selection for the side. The right side language is also
% applied to the right side line numbers.
%
% \subsection{Executing code at each line}
% \DescribeMacro{\dolineLhook}
% \DescribeMacro{\dolineRhook}
% \cs{dolineLhook} and \cs{dolineRhook} are the equivalent to the \macpackage \cs{dolinehook}, respectively for left and right side.
%
% \DescribeMacro{\doinsidelineLhook}
% \DescribeMacro{\doinsidelineRhook}
% \cs{doinsidelineLhook} and \cs{doinsidelineRhook} are the equivalent to the \macpackage \cs{doinsidelinehook}, for the left and the right sides respectively.
%
% About these two hooks, read \macpackage's handbook (\reff{reledmac-linehook}).
%
% \subsection{Executing code at each page}
% \DescribeMacro{\Rightpagehook}
% \DescribeMacro{\Leftpagehook}
% When typesetting parallel pages, the \cs{Leftpagehook} and \cs{Rightpagehook} macros
% are executed each time \Parpackage switches to Left / Right page.
%
% These macro are initially void. You can redefine them using \cs{renewcommand}.
% \section{Verse}
%
% If you are typesetting verses with \macpackage you can use the \protect\cs{stanza}
% construct, and you can also use this in right or left parallel texts.
% In this case each verse line is a chunk which has two implications.
% (1) you can unexpectedly exceed the \protect\cs{maxchunks} limit or the overall
% limit on the number of boxes, and (2) left and right verse lines are
% matched, which may not be desirable if one side requires more print lines
% for verse lines than the other does.
%
% \DescribeEnv{astanza}
% \Parpackage provides an \env{astanza} environment which you can use instead
% of \cs{stanza}. A \env{astanza} environment is a chunk. Consequently left and right \emph{verse} are matched, and not, as with standard \cs{stanza}, left and right \emph{verse lines}.
%
% Within the
% \env{astanza} environment each verse line is treated as an individual paragraph,
% so there must be no blank lines in the environment otherwise there will
% be some extraneous vertical spacing.
% To use \env{astanza}, simply replace \cs{stanza} by \cs{begin}\arg{astanza} and
% add \cs{end}\arg{astanza} after the ending \expandafter\cs\expandafter{\&}.
%
% The difference between \env{astanza} and \cs{stanza} is, that the latter syncs
% verse by verse, while the environment syncs stanza by stanza.
%
%    If you get an error message along the lines of \enquote{Missing number,
% treated as zero \protect\cs{sza@0@}} it is because you have forgotten to use
% \protect\cs{setstanzaindents} to set the stanza indents.
%
% As \env{astanza} is a specific type of \cs{pstart}\ldots\cs{pend} structure, you can:
% \begin{itemize}
% \item Add optional argument (in brackets) after \cs{begin}\arg{astanza}, as the optional argument of \cs{pstart}.
% \item Use optional argument after the last \expandafter\cs\expandafter{\&} as optional argument of \cs{pend}.
%
% \end{itemize}
%
%
% \DescribeMacro{\sethangingsymbol}Like in \macpackage, you could use the \protect\cs{sethangingsymbol} command  to insert a character in each hanging line. If you use it, you must run \LaTeX\ two time. Example for the French typography
%\begin{verbatim}
%\sethangingsymbol{[\,}
%\end{verbatim}
%  You can also use it to force hanging verse to be flush right:
% \begin{verbatim}
% \sethangingsymbol{\protect\hfill}
% \end{verbatim}
%
%
% When you use \protect\cs{lednopb} make sure to use it on both sides in the corresponding
% verses to keep the pages in sync.
%
% \DescribeMacro{\thestanzaL}
% \DescribeMacro{\thestanzaR}
% When using \cs{stanzanumtrue} (\reff{reledmac-numbering-stanza}) in parallel typesetting, \verb+stanza+ counter is replaced by \verb+stanzaL+ counter in left side and by \verb+stanzaR+ counter in right side. Consequently, you can redefine \cs{thestanzaL} and \cs{thestanzaR} to change their aspect.
%
% \section{Side notes}
% As in \macpackage, you must use one of the following commands to add side notes: \protect\cs{ledsidenote}, \protect\cs{ledleftnote}, \protect\cs{ledrightnote}, \protect\cs{ledouternote}, \protect\cs{ledinnernote}.
%
% The \protect\cs{sidenotemargin} defines the margin of the sidenote for either left or right side, depending on the current environment.
%
% The \cs{sidenotemarginR} defines the margin of the sidenote for the right side.
%
% You can use \protect\cs{sidenotemargin*} to define it for both sides.
%
% When typesetting parallel columns, the margin where a sidenote is placed is one of the margins of the column the sidenote is called.
% However, you can load \parpackage with the \option{sidenotesmarginpage} to use the margin of the page, and not of the column.
% \section{Parallel ledgroups}
% \subsection{General}
% \changes{v1.6.0}{2013/12/13}{Add tool and documentation for parallel ledgroups}
% You can also make parallel ledgroups (see the documentation of \macpackage about ledgroups, \reff{reledmac-ledgroup}).
% To do it you have:
% \begin{itemize}
%   \item To load \parpackage package with the \verb+parledgroup+ option, or to add \protect\cs{parledgrouptrue}.
%   \item To push each ledgroup between \protect\cs{pstart}\ldots\protect\cs{pend} command.
% \end{itemize}
% See the following example:
% \begin{verbatim}
%   \begin{pages}
%    \begin{Leftside}
%      \beginnumbering
%      \pstart
%        \begin{ledgroup}
%          ledgroup content
%        \end{ledgroup}
%      \pend
%      \pstart
%        \begin{ledgroup}
%          ledgroup content
%        \end{ledgroup}
%      \pend
%      \endnumbering
%    \end{Leftside}
%    \begin{Rightside}
%      \beginnumbering
%      \pstart
%        \begin{ledgroup}
%          ledgroup content
%        \end{ledgroup}
%      \pend
%      \pstart
%        \begin{ledgroup}
%          ledgroup content
%        \end{ledgroup}
%      \pend
%      \endnumbering
%    \end{Rightside}
%   \end{pages}
%   \Pages
% \end{verbatim}
% \subsection{Parallel ledgroups and \protect\package{setspace} package}
% If you use the \protect\package{setspace} package and want your notes in parallel ledgroups to be single-spaced (not half-spaced or double-spaced), just add to your preamble:
% \begin{verbatim}
% \setparledgroupnotespacing{\singlespacing}
% \end{verbatim}
% \emph{In effect, to have correct spacing, do not change the font size of your notes}.
%
% \section{Sectioning commands}
% \changes{v1.8.0}{2014/08/05}{New sectioning commands, as in eledmac.}
% The standard sectioning commands of \macpackage are available, and provide parallel sectioning, for both two-column and two-page layout.
%
% \DescribeMacro{\eledsectnotoc}
% By default, the section commands of the right side are not added to the table of contents.
% But you can change it, using \protect\cs{eledsectnotoc}\marg{arg}, where \meta{arg} could be \verb+L+ (for left side) or \verb+R+ (for right side).
%
% \DescribeMacro{\eledsectmark}
% By default, the headers are tokens from the left side. You can change them, using \cs{eledsectmark}\marg{arg}, where \meta{arg} could be \verb+L+ (for left side) or \verb+R+ (for right side).
% \section{Notes about page number}\label{par@page}
% If you use \verb+sameparallepagenumber+ option (\reff{sameparallelpagenumber} or \verb+prevpgnotnumbered+ option (\reff{prevpgnotnumbered}), please read the following paragraph if you want to manipulate page numbers manually.
%
% In order to implement these two options, \parpackage uses its own page counter, called \verb+par@page+.
% Consequently, if you use at least one of these options:
% \begin{enumerate}
% \item If you modify \cs{thepage} command, use the value of \verb+par@page+ counter inside and not the value of \verb+page+ counter.
% \item If you want to modify a page number, modify the value of \verb+page+ counter AND the value \verb+par@page+ counter.
% \end{enumerate}
% Notes that \parpackage automatically do it when you use \protect\cs{frontmatter} and \protect\cs{mainmatter} commands.
%
% \StopEventually{}
% \clearpage
% \renewcommand{\thesection}{\Roman{section}}
% \renewcommand\theHsection{\Roman{section}}
% \setcounter{section}{0}
% \section{Implementation overview}\label{overview}
%
%    \TeX\ is designed to process a single stream of text, which may include
% footnotes, tables, and so on. It just keeps converting its input into
% a stream typeset pages. It was not designed for typesetting two texts
% in parallel, where it has to alternate from one to the other. Further,
% \TeX essentially processes its input one paragraph at a time --- it is
% very difficult to get at the \enquote{internals} of a paragraph such as the
% individual lines in case you want to number them or put some mark at the
% start or end of the lines.
%
%    \Macpackage solves the problem of line numbering by putting the paragraph
% in typeset form into a box, and then extracting the lines one by one
% from the box for \TeX\  to put them onto the page with the appropriate page
% breaks. Most of the \macpackage code is concerned with handling this box
% and its contents.
%
%    \Parpackage's solution to the problem of parallel texts is to put the two
% texts into separate boxes, and then appropriately extract the pairs of
% lines from the boxes. This involves duplicating
% much of the original box code for an extra right text box. The other,
% smaller,
% part of the code is concerned with coordinating the line extractions from
% the boxes.
%
%
% \section{Preliminaries}
% \label{preliminaries}\relax
% \subsection{Package's  meta-data}
% Announce the name and version of the package, which is
% targeted for \LaTeX 2e. The package also requires the \macpackage
% package, however we do not load it automatically, because we prefer users to know it.
%
%    \begin{macrocode}
%<*code>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{reledpar}[2024/07/23 v2.25.7 reledmac extension for parallel texts]%

%    \end{macrocode}
% \subsection{Package's requirement}
% Few commands use \protect\cs{xspace} command.
%    \begin{macrocode}
\RequirePackage{xspace}%
%    \end{macrocode}
% \subsection{Package's options}
% We use \package{xkeyval} in order to manage options with arguments.
%
%    \begin{macrocode}
\RequirePackage{xkeyval}
%    \end{macrocode}
% \subsection{Package's options}
% \subsubsection{Synchronization's options}
% \begin{macro}{\@par@this@sync@option}
% The \cs{par@sync@option} stores the options of synchronization.
% It use to ensure these options do not change between two run.
%    \begin{macrocode}
\def\@par@this@sync@option{}%
%    \end{macrocode}
% \end{macro}
%  With the \option{shiftedpstarts} option a long pstart on the left side (or on the right side) does not make a blank on the corresponding pstart, but the blank is put on the bottom of the page. Consequently, the pstarts on the parallel pages are shifted, but the shift stops at every end of pages.
% \begin{macro}{\ifshiftedpstarts}
%    \begin{macrocode}
\newif\ifshiftedpstarts
\DeclareOptionX{shiftedpstarts}{%
 \shiftedpstartstrue%
 \apptocmd{\@par@this@sync@option}{shifted}{}{}%
}%
%    \end{macrocode}
% \end{macro}
%  With the \option{advancedshiftedpstarts} option a long pstart on the left side (or on the right side) does not make a blank on the corresponding pstart, but the blank is put on the bottom of the page. Consequently, the pstarts on the parallel pages are shifted, but the shift stops at every end of pages.
% Differing to \option{shiftedpstarts}, the pstart shift are not counted to determine when cutting the page. That could help to avoid page with blank lines at the bottom.
% \begin{macro}{\ifshiftedpstarts}
%    \begin{macrocode}
\newif\ifadvancedshiftedpstarts
\DeclareOptionX{advancedshiftedpstarts}{%
  \advancedshiftedpstartstrue%
  \shiftedpstartstrue%
  \apptocmd{\@par@this@sync@option}{advancedshifted}{}{}%
}%
%    \end{macrocode}
% \end{macro}
% With the option \option{nomaxlines}, \parpackage allows facing pages to have not the same number of lines.
% \begin{macro}{\ifnomaxlines}
%    \begin{macrocode}
\newif\ifnomaxlines%
\DeclareOptionX{nomaxlines}{%
  \nomaxlinestrue%
  \apptocmd{\@par@this@sync@option}{nomax}{}{}%
}%
%    \end{macrocode}
% \end{macro}
% With the option \option{nosyncpstarts}, \parpackage only alternate between left and right side, and does not try to obtain the same number of line in corresponding page.
% \begin{macro}{\ifnosyncpstarts}
%    \begin{macrocode}
\newif\ifnosyncpstarts%
\DeclareOptionX{nosyncpstarts}{%
  \shiftedpstartstrue%
  \nomaxlinestrue%
  \nosyncpstartstrue%
  \apptocmd{\@par@this@sync@option}{nosync}{}{}%
}%
%    \end{macrocode}
% \end{macro}
% \subsubsection{Position options}
% \begin{macro}{\ifmovecolumnspositiononrightpage}
% The \cs{ifmovecolumnspositiononrightpage} boolean is set to true if, for a right page, we want the left column become a right column and the right column become a left column.
%    \begin{macrocode}
\newif\ifmovecolumnspositiononrightpage%
\DeclareOptionX{movecolumnspositiononrightpage}{%
 \movecolumnspositiononrightpagetrue%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{if@sidenotesmarginpage}
% With the \option{sidenotesmarginpage}, a left sidenote called in a right column will be printed at the left of the page, and a right sidenote called in a left column will be printed at the right of the page.
%    \begin{macrocode}
\newif\if@sidenotesmarginpage%
\DeclareOptionX{sidenotesmarginpage}{%
 \@sidenotesmarginpagetrue%
}%
%    \end{macrocode}
% \end{macro}
% \subsubsection{Other options}
% The \verb+parledgroup+ can be called either on \macpackage or \parpackage.
%    \begin{macrocode}
\DeclareOptionX{parledgroup}{\parledgrouptrue}
%    \end{macrocode}
% \begin{macro}{\ifwidthliketwocolumns}
% The \verb|widthliketwocolumns| and \verb+continuousnumberingwithcolumns+ options can be called either on \macpackage or \parpackage.
% \changes{v1.9.0}{2014/09/16}{Added widthliketwocolumns option}
%    \begin{macrocode}
\DeclareOptionX{widthliketwocolumns}{\widthliketwocolumnstrue}%
\DeclareOptionX{continuousnumberingwithcolumns}{\continuousnumberingwithcolumnstrue}%
%    \end{macrocode}
% \end{macro}
% Options related to page numbering.
% The booleans are defined in \macpackage.
%    \begin{macrocode}
\DeclareOptionX{sameparallelpagenumber}{\sameparallelpagenumbertrue}
\DeclareOptionX{prevpgnotnumbered}{\prevpgnotnumberedtrue}
%    \end{macrocode}
% \begin{macro}{\prevpgstyle}
% We store on \protect\cs{prevpgstyle} the argument of the option \verb+prevpgstyle+.
%    \begin{macrocode}
\DeclareOptionX{prevpgstyle}{\gdef\prevpgstyle{#1}}%
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
\ProcessOptionsX%
%    \end{macrocode}
% \subsection{Determining side and category of parallel processing}
%  As noted above, much of the code is a duplication of the original
% \macpackage{} code to handle the extra box(es) for the right hand side text,
% and sometimes for the left hand side as well. In order to distinguish
% we use \enquote{R} or \enquote{L} in the names of macros for the right and left code.
% The specifics of \enquote{L} and \enquote{R} are normally hidden from the user by
% letting the \verb?Leftside? and \verb?Rightside? environments set things
% up appropriately.
%
% \begin{macro}{\ifl@dpairing}
% \begin{macro}{\ifl@dpaging}
% \begin{macro}{\ifledRcol}
% \protect\cs{ifl@dpairing} is set TRUE if we are processing parallel texts and
% \protect\cs{ifl@dpaging} is also set TRUE if we are doing parallel pages.
% \protect\cs{ifledRcol} is set TRUE if we are doing the right hand text.
% They are defined in \macpackage.
% \changes{v0.3.0}{2005/02/24}{Moved \protect\cs{ifl@dpairing} to eledmac}
% \changes{v0.9.0}{2005/10/01}{Moved \protect\cs{iflledRcol} and \protect\cs{ifnumberingR} to eledmac}
% \changes{v1.9.1}{2014/09/30}{Moved \protect\cs{ifl@dpaging} to eledmac}
% \changes{v1.13.0}{2015/03/06}{Remove false boolean settings  which are not needed.}
% \end{macro}
% \end{macro}
% \end{macro}
% \subsection{Text's width}
% \begin{macro}{\Lcolwidth}
% \begin{macro}{\Rcolwidth}
% The widths of the left and right parallel columns (or pages).
% The suffixed versions are not manipulated directly by user, but we use them to be certain to have the same coldwitdh in the \env{pages} environment and in the \cs{Pages} command.
%    \begin{macrocode}
\newdimen\Lcolwidth
  \Lcolwidth=0.45\textwidth
\newdimen\Rcolwidth
  \Rcolwidth=0.45\textwidth
\newdimen\Lcolwidth@pages
\newdimen\Rcolwidth@pages
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Messages}
%
% All the error and warning messages are collected here as macros.
%
% \begin{macro}{\reledpar@error}
% \changes{v1.8.2}{2014/08/15}{Errors specific to eledpar send to eledpar handbook}
%    \begin{macrocode}
\newcommand{\reledpar@error}[2]{\PackageError{reledpar}{#1}{#2}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\reledpar@warning}
%    \begin{macrocode}
\newcommand{\reledpar@warning}[1]{\PackageWarning{reledpar}{#1}}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@err@TooManyPstarts}
%    \begin{macrocode}
\newcommand*{\led@err@TooManyPstarts}{%
  \reledpar@error{Too many \string\pstart\space without printing.
                Some text will be lost}{\@ehc}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\led@err@polyglossiaTooOld}
%    \begin{macrocode}
\newcommand{\led@err@polyglossiaTooOld}{%
  \reledpar@error{You use the polyglosia package.%
  \MessageBreak However, reledpar requires version 2022/04/10 v1.55 or later of the polyglossia package.%
  \MessageBreak Please update your polyglossia version}{\@ehc}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@err@BadLeftRightPstarts}
%    \begin{macrocode}
\newcommand*{\led@err@BadLeftRightPstarts}[2]{%
  \reledpar@error{The numbers of left (#1) and right (#2)
                \string\pstart s do not match}{\@ehc}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\led@err@LeftOnRightPage}
% \begin{macro}{\led@err@RightOnLeftPage}
%    \begin{macrocode}
\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}}
    {}%
  }%
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\led@err@Leftside@PreviousNotPrinted}
% \begin{macro}{\led@err@Rightside@PreviousNotPrinted}
%    \begin{macrocode}
\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}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\led@err@Pages@InsideEnv}
% \begin{macro}{\led@err@Columns@InsideEnv}
%    \begin{macrocode}
\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}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\led@err@Pages@WithoutEnv}
% \begin{macro}{\led@err@Columns@WithoutEnv}
%    \begin{macrocode}
\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}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\led@err@Pages@WithoutRightside}
% \begin{macro}{\led@err@Pages@WithoutLeftside}
% \begin{macro}{\led@err@Columns@WithoutRightside}
% \begin{macro}{\led@err@Columns@WithoutLeftside}
%    \begin{macrocode}
\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}}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\led@error@fail@patch@thepage}
%    \begin{macrocode}
\newcommand{\led@error@fail@patch@thepage}{%
  \reledpar@error{Fail to patch \string\@thepage\space command.}{\@ehc}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@error@fail@patch@pagenumbering}
%    \begin{macrocode}
\newcommand{\led@error@fail@patch@pagenumbering}{%
  \reledpar@error{Fail to patch \string\pagenumbering\space command.}{\@ehc}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@error@note@called@onrightside}
% \begin{macro}{\led@error@note@called@onleftside}
%    \begin{macrocode}
\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}%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\led@error@fail@patch@@mempnum}
%    \begin{macrocode}
\newcommand{\led@error@fail@patch@@mempnum}{%
  \reledpar@error{Fail to patch \string\@mempnum\space command.}{\@ehc}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@error@fail@patch@@outputpage}
%    \begin{macrocode}
\newcommand{\led@error@fail@patch@@outputpage}{%
  \reledpar@error{Fail to patch \string\@outputpage\space command.}{\@ehc}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@error@edtext@later@now}
%    \begin{macrocode}
\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?)
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@warn@ChangeSyncOption}
%    \begin{macrocode}
\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.}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@warn@setting@in@rightside}
%    \begin{macrocode}
\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.}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\led@error@missing@numbering}
%    \begin{macrocode}
\newcommand{\led@error@missing@numbering}[1]{%
  \reledpar@error{Missing \string\pstart\space ...\space\string\pend\space inside `#1` environment}{\@ehc}%
}%
%    \end{macrocode}
% \end{macro}
% \subsection{Naming macros}
%
%    The \LaTeX\ kernel provides \protect\cs{@namedef} and \protect\cs{@namuse} for defining
% and using macros that may have non-letters in their names. We need
% something similar here as we are going to need and use some numbered
% boxes and counters.
%
% \begin{macro}{\newnamebox}
% \begin{macro}{\setnamebox}
% \begin{macro}{\unhnamebox}
% \begin{macro}{\unvnamebox}
% \begin{macro}{\namebox}
% A set of macros for creating and using \enquote{named} boxes; the macros are called
% after the regular box macros, but including the string \enquote{name}.
%    \begin{macrocode}
\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}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\ifcsboxvoid}
% The \cs{ifcsboxvoid} command comes on top of the \package{etoolbox} package.
% The first argument is a box name, the second is the \meta{true} value, the third the \meta{false} value.
% If the first argument refers to a non-existing box, or if it refers to a box that is void, the \meta{true} value is returned. otherwise, \meta{false} is returned.
%    \begin{macrocode}
\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%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\newnamecount}
% \begin{macro}{\usenamecount}
% Macros for creating and using \enquote{named} counts.
%    \begin{macrocode}
\providecommand*{\newnamecount}[1]{%
  \expandafter\newcount\csname #1\endcsname}
\providecommand*{\usenamecount}[1]{%
                       \csname #1\endcsname}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \section{Sectioning commands}
%
% \begin{macro}{\section@numR}
% This is the right side equivalent of \protect\cs{section@num}.
%
% Each section will read and write an associated \enquote{line-list
% file}, containing information used to do the numbering. Normally
% the file will be called \meta{jobname}\file{.nn}, where \file{nn} is the
% section number. However, for right side texts the file is called
% \meta{jobname}\file{.nnR}. The \protect\cs{extensionchars} applies to the
% right side files just as it does to the normal files.
%    \begin{macrocode}
\newcount\section@numR
  \section@numR=\z@
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\ifpst@rtedL}
% \begin{macro}{\ifpst@rtedR}
% \protect\cs{ifpst@rtedL} is set FALSE at the start of left side numbering, and
% similarly for \protect\cs{ifpst@rtedR}.
% \protect\cs{ifpst@rtedL} is defined in \macpackage.
% \changes{v0.3.0}{2005/02/24}{Moved \protect\cs{ifpst@rtedL} to eledmac}
%    \begin{macrocode}
  \pst@rtedLfalse
\newif\ifpst@rtedR

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \changes{v1.8.0}{2014/07/24}{\protect\cs{beginnumbering} is defined only on \protect\package{eledmac}, not on \protect\package{eledpar}.}
%
% \begin{macro}{\beginnumberingR}
% This is the right text equivalent of \protect\cs{beginnumbering}, and begins
% a section of numbered text.
%    \begin{macrocode}
\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%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\endnumbering}
% This is the left text version of the regular \protect\cs{endnumbering} and must
% follow the last text for a left text numbered section.
% It sets \protect\cs{ifpst@rtedL} to FALSE. It is fully defined in \macpackage.
% \end{macro}
%
% \begin{macro}{\endnumberingR}
% This is the right text equivalent of \protect\cs{endnumbering} and must follow the
% last text for a right text numbered section.
%    \begin{macrocode}
\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%
  }

%    \end{macrocode}
% \end{macro}
% \begin{macro}{\initnumbering@sectcountR}
% \begin{macro}{\save@section@number}
% \begin{macro}{\set@sectcountR}
% \changes{v1.2.1}{2012/11/01}{For the right section, the counter is defined only once.}
% We do not want the right side section commands to be numbered after the left side ones,
% instead we want them numbered after which is typeset before the \env{pages} or \env{columns} environments.
% we switch the \LaTeX\ counter in \protect\cs{numberingR}.
%
%    \begin{macrocode}
\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%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\pausenumberingR}
% \begin{macro}{\resumenumberingR}
% \begin{macro}{\ifresumenumberingR@start}
% \begin{macro}{\pausenumbering@page@numR}
% These are the right text equivalents of \protect\cs{pausenumbering} and
% \protect\cs{resumenumbering}.
% \changes{v1.8.3}{2014/08/31}{Debug \protect\cs{resumenumberingR}}
%    \begin{macrocode}
\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}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\memorydumpL}
% \begin{macro}{\memorydumpR}
% \protect\cs{memorydump} is a shorthand for \protect\cs{pausenumbering}\protect\cs{resumenumbering}.
% This will clear the memorised stuff for the previous chunks while
% keeping the numbering going.
%    \begin{macrocode}
\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}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
%
% \section{Line counting}
% \label{lineation}
%

% \subsection{Setting lineation reset}
% \changes{v0.11.0}{2012/06/11}{Lineation can be by pstart (like in eledmac 0.15).}
% \changes{v1.0.0}{2012/09/14}{Debug in lineation by pstart}
% Sometimes you want line numbers that start at $1$ at the top of each
% page; sometimes you want line numbers that start at $1$ at each \protect\cs{pstart}; other times you want line numbers that start at $1$ at the start
% of each section and increase regardless of page breaks.
% \Parpackage lets you choose different schemes for the left and right texts.
% \changes{v2.0.0}{2015/07/19}{\protect\cs{ifbypage@} and \protect\cs{ifbypstart@R} defined in \eledmac.}

%
% \begin{macro}{\lineationR}
% \protect\cs{lineationR}\marg{word} is the macro used to select the
% lineation system for right texts.
% Its argument is a string: either \verb+page+, \verb+pstart+ or \verb+section+.
% \changes{v1.15.0}{2015/04/13}{As \protect\cs{lineation}, \protect\cs{lineationR} automatically set the \protect\cs{pstartinfootnote}.}
%    \begin{macrocode}
\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}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lineation*}
% \changes{v1.8.2}{2014/08/15}{Add \protect\cs{lineation*}}
% \protect\cs{lineation*} change the lineation system for both sides.
%    \begin{macrocode}
\WithSuffix\newcommand\lineation*[1]{%
  \lineation{#1}%
  \lineationR{#1}%
}%
%    \end{macrocode}
% \end{macro}

% \subsection{Setting line number margin}
% \begin{macro}{\linenummargin}
% \begin{macro}{\line@marginR}
% You call \protect\cs{linenummargin}\marg{word} to specify which margin you want your
% right text's line numbers in; it takes one argument, a string.
% You can put the line numbers in the same margin on every page using
% \verb+left+ or \verb+right+; or you can use \verb+inner+ or
% \verb+outer+ to get them in the inner or outer margins.
% You can change this within a numbered section, but the
% change may not take effect just when you would like; if it is done between
% paragraphs nothing surprising should happen.
%
% For right texts the selection is recorded in the count \protect\cs{line@marginR},
% otherwise in the count \protect\cs{line@margin}:
% $0$ for left, $1$ for right, $2$ for outer, and $3$ for inner.
%
% It is defined only once time, in \reledmac.
%
% \changes{v0.3.a}{2005/03/30}{Do not just set \protect\cs{line@marginR} in \protect\cs{linenummargin}}
% \changes{v2.0.0}{2015/07/19}{\protect\cs{linenummargin} now defined only once time in \reledmac.}
%    \begin{macrocode}
\newcount\line@marginR
%    \end{macrocode}
% By default put right text numbers at the right.
%    \begin{macrocode}
\line@marginR=\@ne

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\linenummarginR}
% \begin{macro}{\linenummargin*}
% \cs{linenummarginR} applies directly for right side, while \cs{linenummargin*} applies for both side.
%    \begin{macrocode}
\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%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\linenummarginColumns*}
% \begin{macro}{\linenummarginColumns}
% \begin{macro}{\linenummarginColumnsR}
% The \cs{linenummarginColumns} macro overrides the definition of the line margin when typesetting in parallel columns.
%    \begin{macrocode}

\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%
}%

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\linenumOnlyPagesForColumns}
% \begin{macro}{\linenumOnlyPagesForColumnsR}
% \cs{linenumOnlyPagesForColumns} and \cs{linenumOnlyPagesForColumnsR} make the line numbers be printed only on left/right page for the left/right column.
%    \begin{macrocode}
\def\linenum@OnlyPages@ForColumns{}%
\newcommand{\linenumOnlyPagesForColumns}[1]{%
  \gdef\linenum@OnlyPages@ForColumns{#1}%
}%

\def\linenum@OnlyPages@ForColumnsR{}%
\newcommand{\linenumOnlyPagesForColumnsR}[1]{%
  \gdef\linenum@OnlyPages@ForColumnsR{#1}%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \subsection{Setting lineation start and step}
% \begin{macro}{\c@firstlinenumR}
% \begin{macro}{\c@linenumincrementR}
% The following counters tell \macpackage  which right text lines should be
% printed with line numbers. \verb+firstlinenumR+ is the number of the
% first line in each section that gets a number;
% \verb+linenumincrementR+
% is the difference between successive numbered lines. The initial
% values of these counters produce labels on lines $5$, $10$, $15$, etc.
% \verb+linenumincrementR+ must be at least $1$.
%
%    \begin{macrocode}
\newcounter{firstlinenumR}
  \setcounter{firstlinenumR}{5}
\newcounter{linenumincrementR}
  \setcounter{linenumincrementR}{5}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\c@firstsublinenumR}
% \begin{macro}{\c@sublinenumincrementR}
% The following parameters are just like \verb+firstlinenumR+ and
% \verb+linenumincrementR+, but for sub-line numbers.
% \verb+sublinenumincrementR+ must be at least $1$.
%
%    \begin{macrocode}
\newcounter{firstsublinenumR}
  \setcounter{firstsublinenumR}{5}
\newcounter{sublinenumincrementR}
  \setcounter{sublinenumincrementR}{5}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\firstlinenum}
% \begin{macro}{\linenumincrement}
% \begin{macro}{\firstsublinenum}
% \begin{macro}{\sublinenumincrement}
% \begin{macro}{\firstlinenum*}
% \begin{macro}{\linenumincrement*}
% \begin{macro}{\firstsublinenum*}
% \begin{macro}{\sublinenumincrement*}
% \changes{v1.5.0}{2013/11/08}{Add starred version of \protect\cs{firstlinenum}, \protect\cs{linenumincrement}, \protect\cs{firstsublinenum}, \protect\cs{sublinenumincrement} to change both Left and Rightside.}
% These are the user's macros for changing (sub) line numbers. They are
% defined in \macpackage.
% The starred versions are specific to \protect\package{eledpar}.
% \changes{v2.0.0}{2015/07/19}{\protect\cs{firstlinenum}, \protect\cs{linenumincrement}, \protect\cs{firstsublinenum}, \protect\cs{sublinenumincrement} are now defined only in \macpackage.}
%    \begin{macrocode}
\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}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\firstlinenumR}
% \begin{macro}{\linenumincrementR}
% \begin{macro}{\firstsublinenumR}
% \begin{macro}{\sublinenumincrementR}
% And the \enquote{R} suffixed version.
%    \begin{macrocode}
\newcommand\firstlinenumR[1]{%
  \setcounter{firstlinenumR}{#1}%
}
\newcommand\linenumincrementR[1]{%
  \setcounter{linenumincrementR}{#1}%
}
\newcommand\firstsublinenumR[1]{%
  \setcounter{subfirstlinenumR}{#1}%
}
\newcommand\sublinenumincrementR[1]{%
  \setcounter{sublinenumincrementR}{#1}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \subsection{Setting line flag}
% \begin{macro}{\Rlineflag}
% This is appended to the line numbers of right text.
%    \begin{macrocode}
\newcommand{\setRlineflag}[1]{%
  \gdef\@Rlineflag{#1}%
}
\setRlineflag{R}
%    \end{macrocode}
% \end{macro}
% \subsection{Setting line number style}
% \begin{macro}{\linenumrepR}
% \begin{macro}{\sublinenumrepR}
% \protect\cs{linenumrepR}\marg{ctr} typesets the right line number \meta{ctr}, and
% similarly \protect\cs{sublinenumrepR} for subline numbers.
% \changes{v0.3.0}{2005/02/10}{Added \protect\cs{linenumrepR} and \protect\cs{sublinenumrepR}}
%    \begin{macrocode}
\newcommand*{\linenumrepR}[1]{\@arabic{#1}}
\newcommand*{\sublinenumrepR}[1]{\@arabic{#1}}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\linenumberstyleR}
% \begin{macro}{\sublinenumberstyleR}
% The style can be changed by some user level command
%    \begin{macrocode}
\newcommand*{\linenumberstyleR}[1]{%
  \def\linenumrepR##1{\@nameuse{@#1}{##1}}}
\newcommand*{\sublinenumberstyleR}[1]{%
  \def\sublinenumrepR##1{\@nameuse{@#1}{##1}}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\linenumberstyle*}
% \begin{macro}{\sublinenumberstyle*}
% And for both side.
%    \begin{macrocode}
\WithSuffix\newcommand\linenumberstyle*[1]{%
  \linenumberstyle{#1}%
  \linenumberstyleR{#1}%
}%

\WithSuffix\newcommand\sublinenumberstyle*[1]{%
  \sublinenumberstyle{#1}%
  \sublinenumberstyleR{#1}%
}%
%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \subsection{Print marginal line number}
% \begin{macro}{\iflinenumberLevenifblank}
% \begin{macro}{\iflinenumberRevenifblank}
% \cs{iflinenumberLevenifblank} and \cs{iflinenumberRevenifblank} can be switched to TRUE if we want to print the line number, even if the line is blank.
%    \begin{macrocode}
\newif\iflinenumberLevenifblank
\newif\iflinenumberRevenifblank
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\leftlinenumR}
% \begin{macro}{\rightlinenumR}
% \begin{macro}{\l@dlinenumR}
% \protect\cs{leftlinenumR} and \protect\cs{rightlinenumR} are the macros that are
% called to print the right text's marginal line numbers.
% Much of the
% code for these is common and is maintained in \protect\cs{l@dlinenumR}.
% \changes{v0.3.0}{2005/02/10}{Simplified \protect\cs{leftlinenumR} and
%                \protect\cs{rightlinenumR} by introducing \protect\cs{l@dlinenumR}}
%    \begin{macrocode}
\newcommand*{\leftlinenumR}{%
  \l@dlinenumR%
  \kern\linenumsep%
}%
\newcommand*{\rightlinenumR}{%
  \kern\linenumsep%
  \l@dlinenumR%
}%


\newcommand*{\l@dlinenumR}{%
  \numlabfont%
  \unless\iflinenumannotationotherside%
    \ifdefstring{\Xlinenumannotationposition@side}{before}{%
      \l@wrap@ifnotemptybox{\Xwraplinenumannotation@side}{%
        \csuse{annotR@\the\absline@numR @\the\section@numR}%
        }%
    }{}%
  \fi%
  \linenumrepR{\line@numR}\@Rlineflag%
  \ifsublines@R
    \ifnum\subline@numR>\z@
      \unskip\fullstop\sublinenumrepR{\subline@numR}%
    \fi
  \fi%
  \unless\iflinenumannotationotherside%
    \ifdefstring{\Xlinenumannotationposition@side}{after}{%
      \l@wrap@ifnotemptybox{\Xwraplinenumannotation@side}{%
        \csuse{annotR@\the\absline@numR @\the\section@numR}%
        }%
    }{}%
  \fi%
}%

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\leftlinenumannotationR}
% \begin{macro}{\rightlinenumannotationR}
% \cs{rightlinenumannotationR} and \cs{leftlinenumannotationR} are the same as not suffixed version, but for right side.
%    \begin{macrocode}
\newcommand*{\leftlinenumannotationR}{%
  \l@wrap@ifnotemptybox{\Xwraplinenumannotation@side}{%
    \csuse{annot@\the\absline@numR @\the\section@numR}%
    }%
  \kern\linenumsep%
}%
\newcommand*{\rightlinenumannotationR}{%
  \kern\linenumsep%
  \l@wrap@ifnotemptybox{\Xwraplinenumannotation@side}{%
    \csuse{annot@\the\absline@numR @\the\section@numR}%
  }%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \subsection{Line-number counters and lists}
% \subsubsection{Correspond to those in \macpackage for regular or left text}
% We need another set of counters and lists for the right text,
% corresponding to those in \parpackage for regular or left text.
%
% \begin{macro}{\line@numR}
% \begin{macro}{\subline@numR}
% \begin{macro}{\absline@numR}
% The count \protect\cs{line@numR} stores the line number that is used in
% the right text's marginal line numbering and in notes.
% The count \protect\cs{subline@numR} stores
% a sub-line number that qualifies \protect\cs{line@numR}.
% The count \protect\cs{absline@numR} stores the
% absolute number of lines since the start
% of the right text section: that is, the number we have actually printed,
% no matter what numbers we attached to them.
%
%    \begin{macrocode}
\newcount\line@numR
\newcount\subline@numR
\newcount\absline@numR

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\line@listR}
% \begin{macro}{\insertlines@listR}
% \begin{macro}{\actionlines@listR}
% \begin{macro}{\actions@listR}
% \begin{macro}{\annot@listR}
% Now we can define the list macros that will be created from the
% line-list file.  They are directly analogous to the left text ones.
% The full list of action codes and their meanings is given in the \macpackage
% manual.
%
% Here are the commands to create these lists:
%
%    \begin{macrocode}
\list@create{\line@listR}
\list@create{\insertlines@listR}
\list@create{\actionlines@listR}
\list@create{\actions@listR}
\list@create{\annot@listR}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\page@numR}
% \begin{macro}{\this@section@page@numR}
% The right text page numbers.
%    \begin{macrocode}
\newcount\page@numR
\newcount\this@section@page@numR%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \subsubsection{Specific to \parpackage}
% \begin{macro}{\linesinpar@listL}
% \begin{macro}{\linesinpar@listR}
% \begin{macro}{\maxlinesinpar@list}
% In order to synchronise left and right chunks in parallel processing
% we need to know how many lines are in each left and right text chunk,
% and the maximum of these for each pair of chunks.
%    \begin{macrocode}
\list@create{\linesinpar@listL}
\list@create{\linesinpar@listR}
\list@create{\maxlinesinpar@list}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
%
% \subsection{Reading the line-list file}
%
%
% \begin{macro}{\list@clearing@regR}
% \protect\cs{Clear the right lines for \protect\cs{read@linelist}}
%    \begin{macrocode}
\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}
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@par@sync@option}
% When typesetting parallel pages, \cs{@par@sync@option} check if we have changed the synchronization's option since the last run.
% If true, we just not read the numbered file.
%    \begin{macrocode}
\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%
    }%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\read@linelist}
% \protect\cs{read@linelist}\marg{file} is the control sequence
% that is called by \protect\cs{beginnumbering}
% (via \protect\cs{line@list@stuff}) to open and process a
% line-list file; its argument is the name of the file.
% \label{readlinelist}.
% It is defined only once time in \reledmac.
% \changes{v2.0.0}{2015/07/19}{\protect\cs{read@linelist} is defined only once time in \protect\cs{reledmac}.}
%
% \end{macro}
% \subsection{Commands within the line-list file}
%
% This section defines the commands that can appear within a
% line-list file, except for \protect\cs{@lab} which is in a
% later section among the cross-referencing commands it is
% associated with.
%
% The macros with \verb"action" in their names contain all the code
% that modifies the action-code list.
% \changes{v2.0.0}{2015/07/19}{\protect\cs{@nl} is now defined only in \reledmac.}
% \begin{macro}{\@nl@regR}
% \begin{macro}{\@nl}
% \protect\cs{@nl@regR} is called by \protect\cs{@nl} if we are on a right side.
% It does everything related to the start of a
% new line of numbered text on a right side.
%
%    \begin{macrocode}
\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}


%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\last@page@numR}
% \begin{macro}{\this@section@last@page@numR}
% \begin{macro}{\fix@page}
% \protect\cs{last@page@numR} holds the page number of the last right page.
% \protect\cs{this@section@last@page@numR} holds the page number of the last right page of the current section. Its value is modified globally, contrary to \cs{last@page@numR}.
% Both are modified by \protect\cs{fix@page}, defined by \reledmac.
%
% \changes{v2.0.0}{2105/06/28}{\protect\cs{fix@page} is defined only once in \reledmac}
%
%    \begin{macrocode}
\newcount\last@page@numR
  \last@page@numR=-10000
\newcount\this@section@last@page@numR%
  \this@section@last@page@numR=-10000%

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\@adv}
% The \protect\cs{@adv}\marg{num} macro advances
% the current visible line number by the amount specified as
% its argument. This is used to implement \protect\cs{advanceline}.
% It is defined in \macpackage.
% \changes{v2.0.0}{2015/07/19}{\protect\cs{@adv} defined only in \reledmac.}
% \end{macro}
%
% \begin{macro}{\@set}
% The \protect\cs{@set}\marg{num} macro sets
% the current visible line number to the value specified as
% its argument.  This is used to implement \protect\cs{setline}.
% It is defined in \macpackage.
%
% \changes{v2.0.0}{2015/07/19}{\protect\cs{@set} defined only in \reledmac.}
% \end{macro}
%
% \begin{macro}{\l@d@set}
% The \protect\cs{l@d@set}\marg{num} macro sets
% the line number for the next \cs{pstart}\ldots\ to the value specified as
% its argument.  This is used to implement \protect\cs{setlinenum}.
% It is defined in \macpackage.
% \changes{v2.0.0}{2015/07/19}{\protect\cs{l@d@set} defined only in \reledmac.}

% \end{macro}
%
% \begin{macro}{\page@action}
% \protect\cs{page@action}
% adds an entry to the action-code list to change the page number.
% It is defined in \macpackage.

% \changes{v2.0.0}{2015/07/19}{\protect\cs{page@action} defined only in \reledmac.}
% \end{macro}
%
% \begin{macro}{\set@line@action}
% \protect\cs{set@line@action} adds an entry to the action-code
% list to change the visible line number.
% It is defined in \macpackage.
% \changes{v2.0.0}{2015/07/19}{\protect\cs{set@line@action} defined only in \reledmac.}
% \end{macro}
%
% \begin{macro}{\sub@action}
% \protect\cs{sub@action}
% adds an entry to the action-code list to turn sub-lineation on or
% off, according to the current value of the \protect\cs{ifsublines@} flag.
% It is defined in \macpackage.
%
% \changes{v2.0.0}{2015/07/19}{\protect\cs{sub@action} defined only in \reledmac.}
% \end{macro}
%
% \begin{macro}{\do@lockon}
% \begin{macro}{\do@lockonR}
% \protect\cs{lock@on}
% adds an entry to the action-code list to turn line number
% locking on. The current setting of the sub-lineation flag tells us
% whether this applies to line numbers or sub-line numbers.
% It is defined in \macpackage, however the code specific to right side is defined here, in \protect\cs{do@lockonR}.

% \changes{v2.0.0}{2015/07/19}{\protect\cs{do@lockon} defined only in \reledmac.}
%    \begin{macrocode}
\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}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\lock@off}
% \begin{macro}{\do@lockoff}
% \begin{macro}{\do@lockoffR}
% \begin{macro}{\skip@lockoff}
% \protect\cs{lock@off} adds an entry to the action-code list
% to turn line number locking off.
% It is defined in \macpackage, however the code specific to right side is defined here, in \protect\cs{do@lockoffR}.
% \changes{v2.0.0}{2015/07/19}{\protect\cs{do@lockoff} defined only in \reledmac.}
%    \begin{macrocode}


\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}


%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\n@num}
% \changes{v1.15.0}{2015/04/13}{\protect\cs{n@num} defined only one time for both \Eledmac{} and \Eledpar{}.}
% \end{macro}
%
% \begin{macro}{\@ref}
% \begin{macro}{\@ref@regR}
% \changes{v2.0.0}{2015/07/19}{\protect\cs{@ref} defined only in \reledmac, code specific to right side moved in \protect\cs{ref@regR}.}
% \begin{macro}{\insert@countR}
% \protect\cs{@ref}
% marks the start of a passage, for creation of a footnote reference.
% It takes two arguments:
% \begin{itemize}
% \item \verb"#1", the number of entries to add to \protect\cs{insertlines@list}
% for this reference.
% This value for right text, here and within \protect\cs{edtext},
% which computes it and writes it to the line-list file,
% will be stored in the count \protect\cs{insert@countR}.
%    \begin{macrocode}
\newcount\insert@countR
%    \end{macrocode}
%
% \item \verb"#2", a sequence of other line-list-file commands, executed to
% determine the ending line-number. This may also include other
% \protect\cs{@ref} commands, corresponding to uses of \protect\cs{edtext}
% within the first argument of another instance of \protect\cs{edtext}.
% \end{itemize}
%
% \protect\cs{@ref} itself is defined in \macpackage.
% It calls \protect\cs{ref@reg}  or \protect\cs{ref@regR}, depending weither we are in left or right side.
% Here, we define only \protect\cs{ref@regR}, \protect\cs{ref@reg} is already defined in \macpackage.
%
% The first thing \protect\cs{@ref@regR} itself does is to add the specified number
% of items to the \protect\cs{insertlines@listR} list.
%    \begin{macrocode}
\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
%    \end{macrocode}
%
% Next, process the second argument to determine the page
% and line numbers for the end of this lemma.
% We temporarily equate \protect\cs{@ref} to a different macro that just executes
% its argument, so that nested \protect\cs{@ref} commands are just skipped
% this time. Some other macros need to be temporarily redefined to
% suppress their action.
%    \begin{macrocode}
  \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
%    \end{macrocode}
%
% Now store all the information about the location of the lemma's
% start and end in \protect\cs{line@list@R}.
%    \begin{macrocode}
    \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%
%    \end{macrocode}
% Create a list which will store all the second argument of  each \protect\cs{@sw}
% in this lemma, at this level.
%    \begin{macrocode}
     \expandafter\list@create\expandafter{\csname sw@list@edtext@tmp@\the\@edtext@level\endcsname}%
%    \end{macrocode}
% And now, call \cs{@ref@reg@parseargR}, which can be also called by \cs{@ref@later}
%    \begin{macrocode}
     \@ref@reg@parseR{#2}%
%    \end{macrocode}
% Decrease edtext level counter.
%    \begin{macrocode}
     \global\advance\@edtext@level by -1%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\@ref@reg@parseR}
%    \begin{macrocode}
\newcommand{\@ref@reg@parseR}[1]{%
%    \end{macrocode}
% Declare and init boolean for lemma in this level.
%    \begin{macrocode}
     \providebool{lemmacommand@\the\@edtext@level}%
     \boolfalse{lemmacommand@\the\@edtext@level}%
%    \end{macrocode}
% Execute the second argument of \protect\cs{@ref} again,
% to perform for real all the commands within it.
%    \begin{macrocode}
    #1%
% Now, we store the list of \protect\cs{@sw} of this current \protect\cs{edtext} as an element of
% the global list of list of \protect\cs{@sw} for a \protect\cs{edtext} depth.
%    \begin{macrocode}
    \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%
}%
%    \end{macrocode}

% \end{macro}
% \begin{macro}{\@pend}
% \begin{macro}{\@pendR}
% \protect\cs{@pend}\marg{num} adds its argument to the \protect\cs{linesinpar@listL}
% list, and analogously for \protect\cs{@pendR}. If needed, it resets line number.
% Both  are defined  in \macpackage, but they are empty.
% They are really defined only in \parpackage.
%
%
%    \begin{macrocode}
\renewcommand*{\@pend}[1]{%
  \ifbypstart@%
    \unless\ifinstanza%
      \global\line@num=0%
    \fi%
  \fi%
  \xright@appenditem{#1}\to\linesinpar@listL%
}%
\renewcommand*{\@pendR}[1]{%
  \ifbypstart@R%
    \unless\ifinstanzaR%
      \global\line@numR=0%
    \fi%
  \fi%
  \xright@appenditem{#1}\to\linesinpar@listR%
}%

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@pstart}
% \begin{macro}{\@pstartR}
% \cs{@pstart} and cs{@pstartR} allows us to know, when using \cs{nomaxlines} option, in which page we should start a pstart, and also how many empty lines we should let before starting this pstart at the beginning of the page
%    \begin{macrocode}
\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}%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\@lopL}
% \begin{macro}{\@lopR}
% \protect\cs{@lopL}\marg{num} adds its argument to the \protect\cs{linesonpage@listL}
% list, and analagously for \protect\cs{@lopR}.
% Both  are defined in \macpackage, but they are empty.
% They are really defined only in \parpackage.
%    \begin{macrocode}
\renewcommand*{\@lopL}[1]{%
  \xright@appenditem{#1}\to\linesonpage@listL}
\renewcommand*{\@lopR}[1]{%
  \xright@appenditem{#1}\to\linesonpage@listR}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Writing to the line-list file}
%
% We have now defined all the counters, lists, and commands involved in
% reading the line-list file at the start of a section. Now we will
% cover the commands that \macpackage{} uses within the text of a
% section to write commands out to the line-list.
%
% \begin{macro}{\linenum@outR}
% The file for right texts will be opened on output stream \protect\cs{linenum@outR}.
%    \begin{macrocode}
\newwrite\linenum@outR
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\iffirst@linenum@out@R}
% \begin{macro}{\first@linenum@out@Rtrue}
% \begin{macro}{\first@linenum@out@Rfalse}
% Once any file is opened on this stream, we keep it open forever, or
% else switch to another file that we keep open.
%    \begin{macrocode}
\newif\iffirst@linenum@out@R
  \first@linenum@out@Rtrue
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\line@list@stuffR}
% \begin{macro}{\next@line@list@stuffR}
% This is the right text version of the \protect\cs{line@list@stuff}\marg{file}
% macro. It is called by \protect\cs{beginnumberingR} and performs
% all the line-list operations needed at the start of a section.
% Its argument is the name of the line-list file.
% \changes{v1.10.1}{2015/01/16}{Revert modification of 1.4.2, which makes bugs with numbering. Leave vertical mode to solve spurious space before minipage.}
% \Macpackage and \parpackage can fill the \cs{next@line@list@stuffR} hook between a \cs{endnumberingR} (associated with numbered file $n$) and a \cs{beginnumberingR} (associated with numbered file $n+1$). It allows adding content to the numbered file $n+1R$ and not $nR$.
% \changes{v2.20.0}{2017/08/17}{Add \protect\cs{next@line@list@stuffR} internal hook.}
%    \begin{macrocode}

\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%
}%

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\new@lineL}
% The \protect\cs{new@lineL} macro sends the \protect\cs{@nl} command to the left text
% line-list file, to mark the start of a new text line.
%    \begin{macrocode}
\newcommand*{\new@lineL}{%
  \ifnumberline%
    \write\linenum@out{\string\@nl[\the\@this@c@page][\thepage]}%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\new@lineR}
% The \protect\cs{new@lineR} macro sends the \protect\cs{@nl} command to the right text
% line-list file, to mark the start of a new text line.
%    \begin{macrocode}
\newcommand*{\new@lineR}{%
  \ifnumberline%
    \write\linenum@outR{\string\@nl[\the\@this@c@page][\thepage]}%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\flag@start}
% \begin{macro}{\flag@end}
% We enclose a lemma marked by \protect\cs{edtext} in
% \protect\cs{flag@start} and \protect\cs{flag@end}: these send the \protect\cs{@ref}
% command to the line-list file.
% \changes{v0.3.0}{2005/02/04}{Removed extraneous spaces from\protect\cs{flag@end}}
% \changes{v1.8.2}{2014/08/15}{\protect\cs{flag@start} and \protect\cs{flag@end} are now defined only one time for eledmac and eledpar}
% They are both defined in \macpackage.
%
% \end{macro}
% \end{macro}
%
% \begin{macro}{\startsub}
% \begin{macro}{\endsub}
% \protect\cs{startsub} and \protect\cs{endsub}
% turn sub-lineation on and off, by writing
% appropriate instructions to the line-list file.
% There are both defined in \macpackage.
% \changes{v2.0.0}{2015/07/19}{\protect\cs{startsub} and \protect\cs{endsub} defined only in \reledmac.}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\advanceline}
% You can use \protect\cs{advanceline}\marg{num}
% in running text to advance the current visible
% line-number by a specified value, positive or negative.
% It is defined in \macpackage.
% \changes{v2.0.0}{2015/07/19}{\protect\cs{advanceline}  defined only in \reledmac.}
% \end{macro}
%
% \begin{macro}{\setline}
% You can use \protect\cs{setline}\marg{num}
% in running text (i.e., within \cs{pstart}\ldots\cs{pend}) to set the
% current visible
% line-number to a specified positive value.
% It is defined in \macpackage.
% \changes{v2.0.0}{2015/07/19}{\protect\cs{setline}  defined only in \reledmac.}
%
% \end{macro}
%
% \begin{macro}{\setlinenum}
% You can use \protect\cs{setlinenum}\marg{num}
% before a \protect\cs{pstart} to set the visible line-number to a specified
% positive value. It writes a \protect\cs{l@d@set} command to the line-list file.
% It is defined in \macpackage.
%
% \changes{v2.0.0}{2015/07/19}{\protect\cs{setlinenum}  defined only in \reledmac.}
% \end{macro}
%
% \begin{macro}{\startlock}
% \begin{macro}{\endlock}
% You can use \protect\cs{startlock} or \protect\cs{endlock}
% in running text to start or end line number locking at
% the current line. They decide whether line numbers or sub-line numbers
% are affected, depending on the current state of the sub-lineation flags.
% They are defined in \macpackage.

% \changes{v2.0.0}{2015/07/19}{\protect\cs{startlock} and \protect\cs{endlock}  defined only in \reledmac.}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\skipnumbering}
% \changes{v1.15.0}{2015/04/13}{\protect\cs{skipnumbering} defined only one time for both \Eledmac{} and \Eledpar{}}
% \end{macro}
%
%
% \section{Marking text for notes}
% \label{text}
%
% The \protect\cs{edtext}  macro is used to create all
% footnotes and endnotes,
% as well as to print the portion of the main text to which a given note
% or notes is keyed. The idea is to have that lemma appear only once in
% the \file{.tex} file: all instances of it in the main text and in the
% notes are copied from that one appearance.
%
% \begin{macro}{\critext}
% \begin{macro}{\edtext}
% \changes{v1.3.0}{2012/11/16}{Manage RTL language.}
% \changes{v1.11.0}{2014/01/22}{\protect\cs{critext} and \protect\cs{edtext} are now defined only in eledmac.}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\set@line}
% The \protect\cs{set@line} macro
% is called by \protect\cs{edtext} to put the line-reference field and
% font specifier for the current block of text into \protect\cs{l@d@nums}.
% It is defined in \macpackage.
%
% \changes{v2.0.0}{2015/07/19}{\protect\cs{set@line}  defined only in \reledmac.}
% \end{macro}
% \subsection{Specific hooks and commands for notes}
% The \macpackage \protect\cs{newseries@}  initializes commands which are linked to notes series.
% However, to keep \macpackage as light as possible, it does not define commands which are specific to \parpackage.
% This is what does \protect\cs{newseries@par}. The specific hooks are also defined here.
% \begin{macro}{\newseries@par}
%    \begin{macrocode}
\newcommand{\newseries@par}[1]{%
%    \end{macrocode}
% \subsubsection{Notes to be printed on one side only}
% \Parpackage allows notes to be printed on one side only.
% We need to declare these options.
% We also need box to store temporary the footnote not printed.
% We check the \verb+nofamiliar+ and \verb+nocritical+ \macpackage\ options.
% \changes{v1.16.0}{2015/05/18}{Fix a bug with \protect\cs{onlysideX}.}
%    \begin{macrocode}
    \unless\ifnofamiliar@%
      \csgdef{onlysideX@#1}{}%
      \newnamebox{footins#1@kept}%
    \fi%
    \unless\ifnocritical@%
      \csgdef{Xonlyside@#1}{}%
      \newnamebox{#1footins@kept}%
    \fi%
%    \end{macrocode}
% \subsubsection{Tools specific to familiar footnotes}
%    \begin{macrocode}
  \unless\ifnofamiliar@%
%    \end{macrocode}
% \paragraph{Managing correct number}\label{familiarfootnotenumber}
% One problem with using familiar footnotes in parallel typesetting is the fact that the order of reading notes is not the same as the order they are typeset, because \LaTeX\ reads first all the notes on one side, then all the notes on the other side.
% Then, however, \LaTeX\ alternates between typesetting left-side note and right-side notes.
% Consequently, if we do nothing special, the note numbers are sorted in the reading order, not in the typesetting order.
% So we could obtain something like 1,3,2,5,4.
%
% To prevent this problem, we use a two new counters by  series.
% Every note, in parallel typesetting, has three associated counters.
% \begin{enumerate}
% \item A \LaTeX\ counter \verb+footnoteX+. This the only one manipulated by user, and the only one finally printed.
% \item A \TeX\ counter \verb+footnoteX@reading+. Its value is incremented when reading the \cs{footnoteX} command in left or right side environments. It is used to get the correct footnote number from the \verb+.aux+ file to be typeset in the main text. This counter is already defined in \macpackage, as it is also used for hyperlink.
% \changes{v2.6.2}{2015/11/29}{The \TeX\ counter \protect\cs{footnoteX@reading} is defined in \protect\reledmac.}
% \item A \LaTeX\ counter \verb+footnoteX@typeset+. Its value is increased when inserting footnotes. Its value is directly used in the footnote, and is stored in the \verb+aux+ files to be used on the next run for the main text.
% \end{enumerate}
%
%
%
% So here, we only defined the new counter.
%    \begin{macrocode}
      \newcounter{footnote#1@typeset}%
%    \end{macrocode}
%
% \paragraph{Familiar footnotes without marks}
% The \protect\cs{footnoteXnomk} commands are for notes which are printed on the left side, while they are called in the right side.
% Basically, they set first toggle \protect\cs{nomark@} to true, then call the \protect\cs{footnoteX}.
% and finally add the footnote counter in the footnote counter list.
%
% First, check the \verb+nofamiliar+ option of \macpackage.
%
% So declare the list.
%    \begin{macrocode}
      \expandafter\list@create\csname footnote#1@mk\endcsname%
%    \end{macrocode}
% Then, declare the \protect\cs{footnoteXnomk} command.
%    \begin{macrocode}
      \expandafter\newcommand\csname footnote#1nomk\endcsname[1]{%
%    \end{macrocode}
% First step: just call the normal \protect\cs{footnoteX}, saying that we do not want to print the mark.
%    \begin{macrocode}
         \toggletrue{nomk@}%
         \csuse{footnote#1}{##1}%
         \togglefalse{nomk@}%
%    \end{macrocode}
% Second, and last, step: store the footnote counter in the footnote counters list.
% We use some \protect\cs{let}, because \protect\cs{xright@appenditem} is difficult to use with \protect\cs{expandafter}.
%    \begin{macrocode}
         \letcs{\@tmp}{footnote#1@mk}%
         \numdef\@tmpa{\csuse{c@footnote#1}}%
         \global\xright@appenditem{\@tmpa}\to\@tmp%
         \global\cslet{footnote#1@mk}{\@tmp}%
         \global\protected@csxdef{hr@thefnmark#1}{\noexpand\@tmpa @\the\csname footnote#1@series\endcsname}%
     }%
%    \end{macrocode}
% Then, declare the command which inserts the footnotemark in the right side.
%    \begin{macrocode}
      \expandafter\newcommand\csname footnote#1mk\endcsname{%
%    \end{macrocode}
% Get the first element of the footnote mark list.
% As \protect\cs{gl@p} is difficult to use with dynamic name macro, we use \protect\cs{let} commands.
%    \begin{macrocode}
         \letcs{\@tmp}{footnote#1@mk}%
         \gl@p\@tmp\to\@tmpa%
         \global\cslet{footnote#1@mk}{\@tmp}%
%    \end{macrocode}
% Set the footnotecounter with it.
% For the sake of security, we make a backup of the previous value.
%    \begin{macrocode}
         \letcs{\old@footnote}{c@footnote#1}%
         \setcounter{footnote#1}{\@tmpa}%
%    \end{macrocode}
% Define the footnote mark and print it
%    \begin{macrocode}
         \protected@csxdef{@thefnmark#1}{\csuse{thefootnote#1}}%
         \csuse{@footnotemark#1}%
%    \end{macrocode}
% Restore previous footnote counter and finally add space.
%    \begin{macrocode}
         \setcounter{footnote#1}{\old@footnote}%
         \xspace%
      }%
%    \end{macrocode}
% End of tools specific to familiar notes.
%    \begin{macrocode}
  \fi
%    \end{macrocode}
% End of \protect\cs{newseries@par}.
%    \begin{macrocode}
}%
%    \end{macrocode}
% \end{macro}
% \subsubsection{Get correct footnote number}
% \begin{macro}{\get@familiarfootnote@number}
% \begin{macro}{\save@familiarfootnote@number}
% As users can insert footnotes between two \cs{Pairs} or \cs{Pages} commands, we have to set the \cs+footnoteX@typeset+ counter to the last value of the \verb+footnoteX+ counter at the beginning of these two commands.
%    \begin{macrocode}
\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}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \subsection{Create hooks}
% Read the \macpackage code handbook about \protect\cs{newhookcommand@series}.
% Here, we create hooks which are specific to \parpackage.
%    \begin{macrocode}
\unless\ifnocritical@%
  \newhookcommand@series{Xonlyside}%
\fi%
\unless\ifnofamiliar@%
  \newhookcommand@series{onlysideX}%
\fi


%    \end{macrocode}
% \subsection{Init standards series (A,B,C,D,E,Z)}
% \begin{macro}{\init@series@par}
% \protect\cs{newseries@par} is called by \protect\cs{newseries}.
% However, this last command is called before \parpackage is loaded.
% Thus, we need to initiate a specific series hook for \parpackage.
%    \begin{macrocode}
\newcommand{\init@series@par}{%
  \def\do##1{\newseries@par{##1}}%
  \dolistloop{\@series}%
}%
\init@series@par%
%    \end{macrocode}
% \end{macro}
% \subsection{Tools specific to \LaTeX's classical footnotes}
% As users can use classical footnotes of \LaTeX\ (\cs{footnote})
% in parallel texts, we must integrate the same tools to get correct number as for \macpackage' footnotes (\reff{familiarfootnotenumber}).
% \begin{macro}{\footnote@reading}
% \begin{macro}{\footnote@typeset}
%    \begin{macrocode}
\newcount\footnote@reading%
\newcounter{footnote@typeset}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \section{Pstart numbers dumping and restoration}
% While in \macpackage the footnotes are inserted at the same time as the \protect\cs{pstart}\ldots\protect\cs{pend} are read, in \parpackage they are inserted when the \protect\cs{Columns} or \protect\cs{Pages} commands are called.
% Consequently, if we do nothing, the value of the \verb+PstartL+ and \verb+PstartR+ counters are not the same in the main text and in the notes.
% To solve this problem, we dump the values in two list (one by side) when processing \protect\cs{pstart} and restore these at each \protect\cs{pstart} when calling \protect\cs{Columns} or \protect\cs{Pages}.
% We also dump and restore the value of the booleans \protect\cs{ifnumberpstart} and \protect\cs{ifnumberline}.

% So, first step, creating the lists.
% Here, \enquote{pc} means \enquote{public counters}.
% \begin{macro}{\list@pstartL@pc}
% \begin{macro}{\list@pstartR@pc}
%    \begin{macrocode}
\list@create{\list@pstartL@pc}%
\list@create{\list@pstartR@pc}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% Two commands to dump current pstarts.
% We prefer two commands to one with argument indicating the side,
% because the commands are short, and so we save one test (or a \protect\cs{csname} construction).
% \begin{macro}{\dump@pstartL@pc}
% \begin{macro}{\dump@pstartR@pc}
%    \begin{macrocode}
\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}%
  \global\cslet{linenumannotationotherside@L\the\l@dnumpstartsL}{\iflinenumannotationotherside}%
}%

\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}%
  \global\cslet{linenumannotationotherside@R\the\l@dnumpstartsR}{\iflinenumannotationotherside}%
}%

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\restore@pstartL@pc}
% \begin{macro}{\restore@pstartR@pc}
% And so, the commands to restore them.
%    \begin{macrocode}
\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%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \section{Parallel environments}
%
% The initial set up for parallel processing is deceptively simple.
%
%
% \begin{environment}{pairs}
% \begin{environment}{pages}
% \begin{macro}{chapterinpages}
% The \verb?pairs? environment is for parallel columns and the \verb?pages?
% environment for parallel pages.
%    \begin{macrocode}
\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
}

%    \end{macrocode}
% \begin{macro}{\AtBeginPairs}
% The \protect\cs{AtBeginPairs} macro just define a \protect\cs{at@begin@pairs} macro, called at the beginning of each \verb+pairs+ environments.
%    \begin{macrocode}
\newcommand{\AtBeginPairs}[1]{\gdef\at@begin@pairs{#1}}%
\def\at@begin@pairs{}%

%    \end{macrocode}
% \end{macro}
% \changes{v2.0.0}{2015/07/19}{Deleting the old system of managing parallel chapter, keep only the new one with \protect\cs{patchcmd}.}
% The \verb?pages? environment additionally sets the \enquote{column} widths to the
% \protect\cs{textwidth} (as known at the time the package is called). In this environment, there are two text in parallel on 2 pages.
%    \begin{macrocode}
\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%
}

%    \end{macrocode}
% \end{macro}
% \end{environment}
% \end{environment}
%
%
% \begin{environment}{Leftside}
% Within the \verb?pairs? and \verb?pages? environments the left and
% right hand texts are within \verb?Leftside? and \verb?Rightside?
% environments, respectively. The \verb?Leftside? environment is simple,
% indicating that right text is not within its purview and using some
% particular macros.
% \changes{v0.3.0}{2005/02/10}{Added hooks into Leftside environment}
%    \begin{macrocode}
\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}
%    \end{macrocode}
% \end{environment}
%
% \begin{macro}{\Leftsidehook}
% \begin{macro}{\Leftsidehookend}
% \begin{macro}{\Rightsidehook}
% \begin{macro}{\Rightsidehookend}
% Hooks into the start and end of the {Leftside} and {Rightside}
% environments. These are initially empty.
% \changes{v0.3.0}{2005/02/10}{Added \protect\cs{Leftsidehook}, \protect\cs{Leftsidehookend},
%                            \protect\cs{Rightsidehook} and \protect\cs{Rightsidehookend}}
%    \begin{macrocode}
\newcommand*{\Leftsidehook}{}
\newcommand*{\Leftsidehookend}{}
\newcommand*{\Rightsidehook}{}
\newcommand*{\Rightsidehookend}{}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\Rightpagehook}
% \begin{macro}{\Leftpagehook}
% Hook at the start of Left/Right page, initially empty.
%    \begin{macrocode}
\newcommand*{\Rightpagehook}{}%
\newcommand*{\Leftpagehook}{}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{environment}{Rightside}
% The \verb?Rightside? environment is only slightly more complicated
% than the \verb?Leftside?.
% Apart from indicating that right text is being provided it
% ensures that the right right text code will be used.
%    \begin{macrocode}
\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
}

%    \end{macrocode}
% \end{environment}
%
%
%
% \section{Paragraph decomposition and reassembly}
% \label{paragraph}\relax
%
% In order to be able to count the lines of text and affix line
% numbers, we add an extra stage of processing for each paragraph.
% We send the paragraph into a box
% register, rather than straight onto the vertical list, and when
% the paragraph ends we
% slice the paragraph into its component lines; to each line we
% add any notes or line numbers, add a command to write to the
% line-list, and then at last send the line to the vertical list.
% This section contains all the code for this processing.
%
% \subsection{Boxes, counters, \protect\cs{pstart}
% and \protect\cs{pend}}
%
% \begin{macro}{\num@linesR}
% \begin{macro}{\one@lineR}
% \begin{macro}{\par@lineR}
% Here are numbers and flags that are used internally in the course
% of the paragraph decomposition.
%
% When we first form the paragraph, it goes into a box register,
% \protect\cs{l@dLcolrawbox} or \protect\cs{l@dRcolrawbox} for right text, instead of onto the
% current vertical list.
% The \protect\cs{ifnumberedpar@} flag will be \verb"true" while a paragraph is
% being processed in that way.
% \protect\cs{num@lines(R)} will store the number of lines in the paragraph
% when it is complete. When we chop it up into lines, each line
% in turn goes into the
% \protect\cs{one@line} or \protect\cs{one@lineR} register, and \protect\cs{par@line(R)}
% will be the number
% of that line within the paragraph.
%    \begin{macrocode}
\newcount\num@linesR
\newbox\one@lineR
\newcount\par@lineR
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\pstartL}
% \begin{macro}{\pstartR}
% \changes{v1.1.0}{2012/09/25}{Add \protect\cs{labelpstarttrue} (from eledmac).}
% \changes{v1.1.1}{2012/10/01}{Correct \protect\cs{pstartR} bug introduced by 1.1.}
% \changes{v1.4.3}{2013/10/27}{Spurious spaces in \protect\cs{pstartL} and \protect\cs{pstartR}.}
% \changes{v1.8.0}{2014/08/05}{As in \protect\package{eledmac}, \protect\cs{pendL} and \protect\cs{pendR} can have an optional argument.}
% \protect\cs{pstart} starts the paragraph by
% clearing the \protect\cs{inserts@list} list and other
% relevant variables, and then arranges for the
% subsequent text to go into the appropriate box.
% \protect\cs{pstart} needs to appear at the start of
% every paragraph that is to be numbered.
%
% Beware: everything that occurs between \protect\cs{pstart} and \protect\cs{pend}
% is happening within a group; definitions must be global if you want
% them to survive past the end of the paragraph.
%
% We have to have specific left and right \protect\cs{pstart} when parallel processing;
% among other things because of potential changes in the linewidth.
%
%    \begin{macrocode}

\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%
%    \end{macrocode}
% If this is the first \protect\cs{pstart} in a numbered section, clear any inserts
% and set \protect\cs{ifpst@rtedL} to FALSE.
%    \begin{macrocode}
  \ifpst@rtedL\else%
    \list@clear{\inserts@list}%
    \global\let\next@insert=\empty%
     \global\pst@rtedLtrue%
  \fi%
  \begingroup\everypar{}%
%    \end{macrocode}
% When parallel processing we check that we have not exceeded
% the maximum number of chunks. In any event we grab a box for the
% forthcoming text.
%    \begin{macrocode}
  \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%
%    \end{macrocode}
% We set all the usual interline penalties to zero; this ensures that there will
% be no large interline penalties to prevent us from slicing the
% paragraph into pieces. These penalties revert to the values
% that you set when the group for the \protect\cs{vbox} ends.
%    \begin{macrocode}
  \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%
%    \end{macrocode}
% Dump the optional arguments
%    \begin{macrocode}
  \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%
%    \end{macrocode}
% Let \cs{by@autopar} to FALSE.
%    \begin{macrocode}
  \global\by@autoparfalse%
%    \end{macrocode}
% Gobble following space (automatically done if there is no optional argument)
%    \begin{macrocode}
  \ignorespaces%
  }
%    \end{macrocode}
% The same for right side.
%
%    \begin{macrocode}
\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%
  }
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\pendL}
% \changes{v1.4.3}{2013/10/27}{Spurious spaces in \protect\cs{pendL}.}
% \changes{v1.8.0}{2014/08/05}{As in \protect\package{eledmac}, \protect\cs{pendL} can have an optional argument.}
% \protect\cs{pend} must be used to end a numbered paragraph. Again we need
% a version
% that knows about left parallel texts.
%
%    \begin{macrocode}
\newcommandx*{\pendL}[2][1,2,usedefault]{%
  \ifnumbering \else%
    \led@err@PendNotNumbered%
  \fi%
  \ifnumberedpar@ \else%
    \led@err@PendNoPstart%
  \fi%
%    \end{macrocode}
% We immediately
% call \protect\cs{endgraf} to end the paragraph; this ensures that there will
% be no large interline penalties to prevent us from slicing the
% paragraph into pieces.
%    \begin{macrocode}
  \@at@end@every@pend%
  \endgraf\global\num@lines=\prevgraf\egroup%
  \global\par@line=0%
  \get@firsthalf@antilabe@wd%
%    \end{macrocode}
% End the group that was begun in the \protect\cs{pstart}.
%    \begin{macrocode}
  \endgroup%
  \ignorespaces%
  \@oldnobreak%
  \dump@pstartL@pc%
  \ifnumberpstart%
    \addtocounter{pstartL}{1}%
    \ifcontinuousnumberingwithcolumns%
      \addtocounter{pstart}{1}%
    \fi%
  \fi
  \parledgroup@beforenotes@save{L}%
%    \end{macrocode}
% Dump content of the optional argument.
%    \begin{macrocode}
  \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}%
      }%
    }%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pendR}
% \changes{v1.4.3}{2013/10/27}{Spurious spaces in \protect\cs{pstartR}.}
% \changes{v1.8.0}{2014/08/05}{As in \protect\package{eledmac}, \protect\cs{pendR} can have an optional argument.}
% The version of \protect\cs{pend} needed for right texts.
%
%    \begin{macrocode}
\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%
  \get@firsthalf@antilabe@wd%
  \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}%
        }%
    }%
}

%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\AtEveryPstartCall}
% The \protect\cs{AtEveryPstartCall} argument is called when the \protect\cs{pstartL} or \protect\cs{pstartR} is called.
% That is different of \protect\cs{AtEveryPstart} the argument of which is called when the \protect\cs{pstart}s are printed.
%    \begin{macrocode}
\newcommand{\AtEveryPstartCall}[1]{\gdef\at@every@pstart@call{#1}}%
\gdef\at@every@pstart@call{}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\ifprint@last@after@pendL}
% \begin{macro}{\ifprint@last@after@pendR}
% Two booleans set to true, when the time is to print the last optional argument of a \protect\cs{pend}.
%    \begin{macrocode}
\newif\ifprint@last@after@pendL%
\newif\ifprint@last@after@pendR%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \subsection{Processing one line}
%
% For parallel texts we have to be able to process left and right lines
% independently. For sequential text we happily use the
% original \protect\cs{do@line}. Otherwise \ldots
%
% \begin{macro}{\l@dleftbox}
% \begin{macro}{\l@drightbox}
% A line of left text will be put in the box \protect\cs{l@dleftbox}, and analogously
% for a line of right text.
%    \begin{macrocode}
\newbox\l@dleftbox
\newbox\l@drightbox

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\countLline}
% \begin{macro}{\countRline}
% We need to know the number of lines processed.
%    \begin{macrocode}
\newcount\countLline
  \countLline \z@
\newcount\countRline
  \countRline \z@

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@donereallinesL}
% \begin{macro}{\@donetotallinesL}
% \begin{macro}{\@donereallinesR}
% \begin{macro}{\@donetotallinesR}
% We need to know the number of \enquote{real} lines output (i.e., those that
% have been input by the user), and the total lines output (which includes
% any blank lines output for synchronisation).
%    \begin{macrocode}
\newcount\@donereallinesL
\newcount\@donetotallinesL
\newcount\@donereallinesR
\newcount\@donetotallinesR

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \changes{v0.11.0}{2012/06/11}{Change \protect\cs{do@lineL} and \protect\cs{do@lineR} to allow line numbering by pstart (like in eledmac 0.15).}
% \changes{v1.8.0}{2014/08/05}{Change \protect\cs{do@lineR} and \protect\cs{do@lineR} to allow new sectioning commands.}
% \begin{macro}{\do@lineL}
% \changes{v1.8.1}{2014/08/07}{Fix a bug with critical notes a the beginning of a page, (maybe added by v1.8.0) (?).}
% The \protect\cs{do@lineL} macro is called to
% do all the processing for a single line of left text.
% \changes{v0.3.0}{2005/02/10}{Added \protect\cs{do@lineLhook} to \protect\cs{do@lineL}}
% \changes{v0.3.0}{2005/02/10}{Simplified \protect\cs{do@lineL} by using macros for
%                            some common code}
%    \begin{macrocode}
\newcommand*{\do@lineL}{%
  \letcs{\ifnumberpstart}{numberpstart@L\the\l@dpscL}%
  \letcs{\ifnumberline}{numberline@L\the\l@dpscL}%
  \letcs{\iflinenumannotationotherside}{linenumannotationotherside@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%
}%


%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\print@lineL}
% \protect\cs{print@lineL} is for lines without a sectioning command. See \macpackage definition of \protect\cs{print@line} for handbook.
% \changes{v1.12.0}{2015/02/23}{Compatibility with \LuaLaTeX\ RTL languages.}
%    \begin{macrocode}
\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}}%

%    \end{macrocode}
% \end{macro}
% \begin{macro}{\print@eledsectionL}
% \changes{v1.12.0}{2015/02/23}{Compatibility with \LuaLaTeX\ RTL languages.}
% \changes{v1.12.1}{2015/02/27}{Fix bug with \LuaLaTeX\ RTL \protect\cs{eledsection}.}
% \protect\cs{print@eledsectionL} is for line with macro code.
%    \begin{macrocode}
\def\print@eledsectionL{%%
    \disable@edindex%
    \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%
    \restore@edindex%
}

%    \end{macrocode}
% \end{macro}
% \begin{macro}{\add@apparatusL}
% The \cs{add@apparatusL} macro adds apparatus for the left lines, apparatus is both footnotes and sidenotes.
%    \begin{macrocode}
\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%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\dolineLhook}
% \begin{macro}{\dolineRhook}
% \begin{macro}{\doinsidelineLhook}
% \begin{macro}{\doinsidelineRhook}
% \changes{v1.8.3}{2014/08/31}{Added \protect\cs{dolineLhook}, \protect\cs{dolineRhook}, \protect\cs{doinsidelineLhook} and \protect\cs{doinsidelineRhook}}
% These high-level commands just redefine the low-level commands.
% They have to be used by user, without \protect\cs{makeatletter}.
%    \begin{macrocode}
\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}}%

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \changes{v0.3.0}{2005/02/10}{Added \protect\cs{do@lineLhook} and \protect\cs{do@lineRhook}}
% \changes{v1.4.0}{2013/07/11}{Added \protect\cs{do@insidelineLhook} and \protect\cs{do@insidelineRhook}}
% \begin{macro}{\do@lineLhook}
% \begin{macro}{\do@lineRhook}
% \begin{macro}{\do@insidelineLhook}
% \begin{macro}{\do@insidelineRhook}
% Hooks, initially empty, into the respective \protect\cs{do@line(L/R)} macros.
%    \begin{macrocode}
\newcommand*{\do@lineLhook}{}
\newcommand*{\do@lineRhook}{}
\newcommand*{\do@insidelineLhook}{}
\newcommand*{\do@insidelineRhook}{}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\do@lineR}
% The \protect\cs{do@lineR} macro is called to
% do all the processing for a single line of right text.
% \changes{v0.3.0}{2005/02/10}{Changed \protect\cs{do@lineR} similarly to \protect\cs{do@lineL}}
% \changes{v1.8.1}{2014/08/07}{Fix a bug with critical notes a the beginning of a page, added by v1.8.0 (?).}
%    \begin{macrocode}
\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}%
  \letcs{\iflinenumannotationotherside}{linenumannotationotherside@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%
}


%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\print@lineR}{}
% \begin{macro}{\print@eledsectionR}{}
% \changes{v1.12.0}{2015/02/23}{Compatibility with \LuaLaTeX\ RTL languages.}
\def\print@lineR{%
    \affixpstart@numR%
    \l@dld@ta%
    \add@apparatusR%
    \l@dlsn@te%
    \do@insidelineRhook%
    \csuse{insidethisR@\the\absline@numR @\the\section@numR}%
    \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{%
    \disable@edindex%
    \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%
    \restore@edindex%
}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\add@apparatusR}
% The \cs{add@apparatusR} macro adds apparatus for the right lines, apparatus is both footnotes and sidenotes.
%    \begin{macrocode}
\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%
}%
%    \end{macrocode}
% \end{macro}
% \subsection{Line and page number computation}
%
% \begin{macro}{\getline@numR}
% The \protect\cs{getline@numR} macro
% determines the page and line numbers for the right text line we are about to
% send to the vertical list. The \protect\cs{getline@numL} is the same for left text.
%
%    \begin{macrocode}
\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
}


%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\do@ballastR}
% \relax
% The real work in the line macros above is done in \protect\cs{do@actions}, but
% before we plunge into that, let is get \protect\cs{do@ballastR} out of the
% way.
%    \begin{macrocode}
\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}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\l@dskipversenumberR}
% \begin{macro}{\do@actionsR}
% \begin{macro}{\do@actions@fixedcodeR}
% \begin{macro}{\do@actions@nextR}
%
% The \protect\cs{do@actionsR} macro
% looks at the list of actions to take at particular right text absolute line
% numbers, and does everything that is specified for the current line.
%
% It may call itself recursively and we use tail recursion, via
% \protect\cs{do@actions@nextR} for this.
% \changes{v0.3.0}{2005/02/24}{Used \protect\cs{do@actions@fixedcode} in \protect\cs{do@actionsR}}
% \changes{v1.15.0}{2015/04/13}{Add actions 1008 and 1009}
% \changes{v2.10.0}{2016/06/02}{Add action 1010}
%    \begin{macrocode}

\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%
        \@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}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \subsection{Line number printing}
%
% \begin{macro}{\l@dcalcnum}
% \begin{macro}{\ch@cksub@l@ckR}
% \begin{macro}{\ch@ck@l@ckR}
% \begin{macro}{\f@x@l@cksR}
% \begin{macro}{\affixline@numR}
% \protect\cs{affixline@numR} is the right text version of the
% \protect\cs{affixline@num} macro.
% \changes{v0.3.0}{2005/02/24}{Changed \protect\cs{affixline@numR} to match new eledmac}
% \changes{v0.11.0}{2012/06/11}{Changed \protect\cs{affixline@numR} to allow to disable line numbering (like in eledmac 0.15).}
%    \begin{macrocode}

\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}}}%
          \iflinenumannotationotherside%
            \gdef\l@drd@ta{\rlap{{\rightlinenumannotationR}}}%
          \fi%
        \else
          \gdef\l@drd@ta{\rlap{{\rightlinenumR}}}%
          \iflinenumannotationotherside%
            \gdef\l@dld@ta{\llap{{\leftlinenumannotationR}}}%
          \fi%
        \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 \numexpr\csuse{@page@forlineR@\the\section@numR @\the\absline@numR}+0\relax%
        \fi
        \ifboolexpr{%
           bool {l@dprintingcolumns}%
           and (%
             (test {\ifdefstring{\linenum@OnlyPages@ForColumnsR}{left}}%
             and test {\ifnumodd{\csuse{@page@forlineR@\the\section@numR @\the\absline@numR}+0}}%
             )%
             or%
             (test {\ifdefstring{\linenum@OnlyPages@ForColumnsR}{right}}%
             and not test {\ifnumodd{\csuse{@page@forlineR@\the\section@numR @\the\absline@numR}+0}}%
             )%
           )%
        }%
        {}%
        {%
          \ifodd\@l@dtempcntb%
            \gdef\l@drd@ta{\rlap{{\rightlinenumR}}}%
            \iflinenumannotationotherside%
              \gdef\l@dld@ta{\llap{{\leftlinenumannotationR}}}%
            \fi%
          \else%
            \gdef\l@dld@ta{\llap{{\leftlinenumR}}}%
            \iflinenumannotationotherside%
              \gdef\l@drd@ta{\rlap{{\rightlinenumannotationR}}}%
            \fi%
          \fi%
        }%
      \fi
    \fi
  \fi
  \f@x@l@cksR
\fi
\fi
\fi}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \subsection{Pstart number printing in side}
% The printing of the pstart number is like in \macpackage, with two differences:
%\begin{itemize}
%\item Some commands have versions suffixed by R or L.
%\item The \protect\cs{affixpstart@num} and \protect\cs{affixpstart@numR} commands are called in the \protect\cs{Pages} command. Consequently, the \verb|pstartL| and \verb|pstartR| counters must be reset at the beginning of this command.
%\end{itemize}
% \begin{macro}{\affixpstart@numL}
% \begin{macro}{\affixpstart@numR}
% \begin{macro}{\leftpstartnumR}
% \begin{macro}{\rightpstartnumR}
% \begin{macro}{\leftpstartnumL}
% \begin{macro}{\rightpstartnumL}
% \begin{macro}{\ifpstartnumR}
%    \begin{macrocode}

\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
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \subsection{Add insertions to the vertical list}
%
% \begin{macro}{\inserts@listR}
% \protect\cs{inserts@listR} is the list macro that contains the inserts that
% we save up for one right text paragraph.
%
%    \begin{macrocode}
\list@create{\inserts@listR}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\add@insertsR}
% \begin{macro}{\add@inserts@nextR}
% The right text version.
%    \begin{macrocode}
\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}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Penalties}
%
% \begin{macro}{\add@penaltiesL}
% \begin{macro}{\add@penaltiesR}
% \protect\cs{add@penaltiesL} is
% the last macro used by \protect\cs{do@lineL}. It adds up the club,
% widow, and interline penalties, and puts a single penalty
% of the appropriate size
% back into the paragraph; these penalties get
% removed by the \protect\cs{vsplit} operation. \protect\cs{displaywidowpenalty} and
% \protect\cs{brokenpenalty} are not restored, since we have no easy way to
% find out where we should insert them.
%
% \label{add@penalties}
% In the code below, which is a virtual copy of the original
% \protect\cs{add@penalties}, \protect\cs{num@lines} is the number of lines in the whole
% paragraph, and \protect\cs{par@line} is the line we are working on at the
% moment.  The count \protect\cs{@l@dtempcnta} is used to calculate and
% accumulate the penalty; it is initially set to the value of
% \protect\cs{ballast@count}, which has been worked out in \protect\cs{do@ballast}.
% Finally, the penalty is
% checked to see that it does not go below $-10000$.
% \begin{verbatim}
% \newcommand*{\add@penaltiesR}{\@l@dtempcnta=\ballast@count
%   \ifnum\num@linesR>\@ne
%     \global\advance\par@lineR \@ne
%     \ifnum\par@lineR=\@ne
%       \advance\@l@dtempcnta by \clubpenalty
%     \fi
%     \@l@dtempcntb=\par@lineR \advance\@l@dtempcntb \@ne
%     \ifnum\@l@dtempcntb=\num@linesR
%       \advance\@l@dtempcnta by \widowpenalty
%     \fi
%     \ifnum\par@lineR<\num@linesR
%       \advance\@l@dtempcnta by \interlinepenalty
%     \fi
%   \fi
%     \ifnum\@l@dtempcnta=\z@
%       \relax
%     \else
%       \ifnum\@l@dtempcnta>-10000
%         \penalty\@l@dtempcnta
%       \else
%         \penalty -10000
%       \fi
%     \fi}
% \end{verbatim}
% This is for a single chunk. However, as we are probably dealing
% with several chunks at a time, the above is nor really relevant. Peter Wilson thinks
% that it is likely with parallel text that there is no real need to add
% back any penalties; even if there was, they would have to match across the
% left and right lines. So, Peter Wilson ends up with the following.
%
%    \begin{macrocode}
\newcommand*{\add@penaltiesL}{}
\newcommand*{\add@penaltiesR}{}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Printing leftover notes}
%
% \begin{macro}{\flush@notesR}
% The \protect\cs{flush@notesR}
% macro is called after the entire right text has been sliced up
% and sent on to the vertical list.
%    \begin{macrocode}
\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%
   }{}%
}%


%    \end{macrocode}
% \end{macro}
%
%
% \section{Footnotes}
% \label{footnotes}
%

% \subsection{Footnotes output specific to \protect\cs{Pages}}
% \begin{macro}{\print@Xnotes@forpages}
% \begin{macro}{\restore@Xnotes@settings}
% \begin{macro}{\correct@Xfootins@box}
% \begin{macro}{\print@notesX@forpages}
% \begin{macro}{\restore@notesX@settings}
% \begin{macro}{\correct@footinsX@box}
% \changes{v1.13.1}{2015/03/12}{Correct \protect\cs{correct@footinsX@box} and \protect\cs{correct@Xfootins@box}}
% \changes{v1.13.1}{2015/03/12}{Call \protect\cs{correct@footinsX@box} and \protect\cs{correct@Xfootins@box} directly in \protect\cs{print@notesX@forpages} and \protect\cs{print@Xnotes@forpages}.}
% \changes{v2.11.0}{2016/06/16}{New implementation of \protect\cs{Xonlyside} and \protect\cs{onlysideX} hooks, prevent trouble with vertical spacing.}
% \changes{v2.11.0}{2016/06/16}{Clarification in the handbook about the use of \protect\cs{Xonlyside} and \protect{onlysideX} and error message if mesuse.}
% The \protect\cs{Xonlyside} and \protect\cs{onlysideX} hooks for \protect\cs{Pages}
% allow notes to be printed  either in left or right pages only.
% The implementation of such features is delegated to \protect\cs{print@Xnotes@forpages},
% which replaces \protect\cs{print@Xnotes} inside \protect\cs{Pages}.
% Here is how we proceed\footnote{See \url{http://tex.stackexchange.com/a/230332/7712}.}:
% \begin{itemize}
%    \item If notes are to be printed on both sides, we just proceed the usual way: print the foot starts for the series, then the foot group.
%    \item If notes are to be printed in the left side, we do these prints only for even pages ; if notes are to be printed in the right side, we do these prints only for odd pages.
%    \item However, that is not enough. Because the problem does not only consists in printing notes in any particular page. It is also not to put aside room for notes in the pages where we do not want to print them.
%    To take an example: if some note in the left side is too long by 160pt to be printed in full in the left page, we do not want to put aside 160pt a space for it in the following right page.
%    \item To solve this problem, we change the magnification factor associated with notes before going to the next page.
%    If we start a page where no notes are supposed to be  printed, the magnification counter is set to 0. The dimension associated to footnote is set to \cs{maxdimen}, and so we can keep all the notes we want, without any break inside  We also set the note skip to 0pt. Before starting a new page where these notes are supposed to be printed, we reset these counter and skip to their default values. (About these counter, dimension and skip, read \thetexbook\ p.~122-125).
%    \item In the output macro of the page where notes must NOT be printed, we store the content of the footnote box produced by \TeX\ to a temporary box.
%    \item After going to the next page, before typesetting any thing in this page, we put the content of this temporary box the footnote insert box.
% \end{itemize}
% The code to print critical notes, when processing \protect\cs{Pages}, called in the output routine.
%    \begin{macrocode}
\newcommand\print@Xnotes@forpages[1]{%
%    \end{macrocode}
% First case: notes are for both sides. Just print the note start and the note group
%    \begin{macrocode}
   \ifcsempty{Xonlyside@#1}{%
     \csuse{#1footstart}{#1}%
     \csuse{#1footgroup}{#1}%
   }%
%    \end{macrocode}
% Second case: notes are for  one side only.
% First test if we are in a page where they must be printed.
%    \begin{macrocode}
   {%
     \ifboolexpr{%
       ((test {\ifcsstring{Xonlyside@#1}{L}} and not test{\ifnumodd{\c@page}})%
       or%
       (test {\ifcsstring{Xonlyside@#1}{R}} and test{\ifnumodd{\c@page}}))%
       }%
%    \end{macrocode}
% If we are in a page where notes must be printed, print the notes.
%    \begin{macrocode}
      {%
         \csuse{#1footstart}{#1}%
         \csuse{#1footgroup}{#1}%
%    \end{macrocode}
% Then, set to not to keep room for notes in the next page.
% Also set to that, in the next page, notes are not to be split, using \cs{maxdimen}.
%    \begin{macrocode}
         \global\count\csuse{#1footins}=\z@%
         \global\skip\csuse{#1footins}=\z@%
         \global\dimen\csuse{#1footins}=\maxdimen%
     }%
%    \end{macrocode}
% In case we are on a page where notes must NOT be printed.
% We reset the settings of the notes for one side.
%    \begin{macrocode}
       {%
         \restore@Xnotes@settings{#1}%
       }%
%    \end{macrocode}
% End of \protect\cs{print@Xnotes@forpages}.
%    \begin{macrocode}
     }%
}%
%    \end{macrocode}
% The macro which restore the note settings.
% \#1 = series
%    \begin{macrocode}
\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
}%
%    \end{macrocode}
% And now, the same for familiar footnotes.
%    \begin{macrocode}
\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
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\insert@notes@for@onlyside}
% \cs{insert@notes@for@onlyside} is everytime \cs{Pages}  go to the next side.
% It just reinsert the notes note printed on the previous side because of \protect{Xonlyside} or \cs{onlysideX} setting.
%    \begin{macrocode}
\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}%
}%
%    \end{macrocode}
% \end{macro}
% \subsection{Critical footnote printed in right side}
% \changes{v2.12.0}{2016/07/01}{Add \protect\cs{edtextlater} and \protect\cs{edtextnow}.}
% \begin{macro}{\edtext@later}
% \begin{macro}{\edtext@now}
% \begin{macro}{\edtextlater}
% \begin{macro}{\edtextnow}
% \cs{edtextlater} and \cs{edtextnow} are used to print critical footnotes on the right side, while refering to the text on the left side.
% First, we create two counters, one for \cs{edtextlater} and the other for \cs{edtextnow}.
%    \begin{macrocode}
\newcount\edtext@now%
\newcount\edtext@later%
%    \end{macrocode}
%    \begin{macrocode}
\newcommand{\edtextlater}[2]{%#1 lemma, #2 critical notes
%    \end{macrocode}
% First, increase the \cs{edtext@later} counter.
%    \begin{macrocode}
  \global\advance\edtext@later by \@ne%
%    \end{macrocode}
%    \begin{macrocode}
% As we are in a pseudo-\cs{edtext}, we now need to get the \cs{sameword} data stored in the auxiliary file for this \cs{edtextlater}.
  \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}%
%    \end{macrocode}
% The main feature of \cs{edtextlater} is to create a macro which will be called on the equivalent \cs{edtextnow}.
%    \begin{macrocode}
%
  \csxdef{edtext@later@\the\edtext@later}{%
%    \end{macrocode}
% \cs{edtextnow} will insert a empty \cs{edtext}.
%    \begin{macrocode}
      \noexpand\edtext{%
      }%
%    \end{macrocode}
% With a \cs{lemma} and \cs{linenum} defined by the current \cs{edtextlater}.
% Also with \cs{sameword} data gotten from the current \cs{edtextlater}
%    \begin{macrocode}
      {%
      \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}}%
%    \end{macrocode}
% As the \cs{edtextnow} is generally called on the other side than the corresponding \cs{edtextlater}, we need to store the side for a proper formatting of the footnote. We also need to store the pstartL / pstartR counter.
%    \begin{macrocode}
      \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%
%    \end{macrocode}
% And the footnote command of this \cs{edtextlater}.
%    \begin{macrocode}
      \unexpanded{#2}%
    }%
  }%
%    \end{macrocode}
% And now, we print the current lemma data.
% But we save the beginning and the starting line using the crossref mechanism.
% We also store information in the auxiliary file about the existence of a \cs{edtextlater} and, if required, about the use of a \cs{lemma}
%    \begin{macrocode}
  \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%
%    \end{macrocode}
% We decrease the counter increased at the beginning.
%    \begin{macrocode}
  \advance\@edtext@level by -\@ne%
}%
%    \end{macrocode}
% \cs{edtextnow} just calls the command defined as is, reading the \cs{edtext@later} list.
%    \begin{macrocode}
\newcommand{\edtextnow}[0]{%
  \global\advance\edtext@now by \@ne
  \csuse{edtext@later@\the\edtext@now}%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \section{Cross referencing}
% \label{xref}
%
%
% \begin{macro}{\labelref@listR}
% Set up a new list, \protect\cs{labelref@listR}, to hold the page, line and
% sub-line numbers for each label in right text.
%    \begin{macrocode}
\list@create{\labelref@listR}

%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\edlabel}
%  This command is defined only one time in \macpackage, including features for \parpackage.
% \changes{v1.12.0}{2015/02/23}{\protect\cs{edlabel} is now defined only one time for both eledmac and eledpar}
% \changes{v1.12.0}{2015/02/23}{\protect\cs{edlabel} and \protect\cs{edindex} works now with hyperref when using \protect\package{eledpar}.}
% \end{macro}
%
% \begin{macro}{\l@dmake@labelsR}
% This is the right text version of \protect\cs{l@dmake@labels}, taking account
% of \protect\cs{@Rlineflag}.
% \changes{v2.6.0}{2015/11/13}{\protect\cs{@Rlineflag} is not stored directly after the line number, but as a fith argument of \protect\cs{the@labelX}. Can be retrieved by \protect\cs{xflagref}.}
%
%    \begin{macrocode}
\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{}%
}

%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@lab}
% The \protect\cs{@lab} command, which appears in the \protect\cs{linenum@out} file,
% appends the current values of page, line and sub-line to the
% \protect\cs{labelref@list}. These values are defined by the earlier
% \protect\cs{@page}, \protect\cs{@nl}, and the \protect\cs{sub@on} and \protect\cs{sub@off} commands
% appearing in the \protect\cs{linenum@out} file.
%
% It is defined on \macpackage.
% \changes{v2.0.0}{2015/28/06}{\protect\cs{@lab} defined only in \eledmac.}
% \end{macro}
%
%
% \section{Sidenotes}
%
%    Regular \verb?\marginpar?s do not work inside numbered text --- they
% do not produce any note but do put an extra unnumbered blank line into
% the text.
% \begin{macro}{\sidenote@marginR}
% \begin{macro}{\sidenotemargin*}
% \begin{macro}{\sidenotemarginR}
% \changes{v1.8.0}{2014/08/05}{\protect\cs{sidenotemargin} is now directly defined in \protect\package{eledmac} to be able to manage \protect\package{eledpar}.}
% \changes{v1.8.0}{2014/08/05}{Add \protect\cs{sidenotemargin*}}
% Specifies which margin sidenotes can be in.
%    \begin{macrocode}
\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%

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@morespace@rightnote@leftcolumn}
% \begin{macro}{\@morespace@leftnote@rightcolumn}
% \begin{macro}{\get@sidenote@morespace@columns}
% If we are typesetting parallel columns, we may want a left sidenote called on the right column be put on the left of the page and not on the left of the column,
% and a right sidenote called on the left column be put on the right of the page and not on the right of the column. We store as an option in the \cs{if@sidenotesmarginpage} boolean.
%
% To do it, we need to add spaces, respectively defined on \cs{@morespace@leftnote@rightcolumn} and \cs{@morespace@rightnote@leftcolumn}.
% The \cs{get@sidenote@morespace@columns} calculate there two lengths.
%    \begin{macrocode}
\newdimen\@morespace@leftnote@rightcolumn%
\newdimen\@morespace@rightnote@leftcolumn%



\newcommand{\get@sidenote@morespace@columns}{%
%    \end{macrocode}
% The calculations are made only if \cs{if@sidenotesmarginpage} is TRUE.
%    \begin{macrocode}
  \if@sidenotesmarginpage%
%    \end{macrocode}
% Now, we can calculate \cs{@morespace@leftnote@rightcolumn} and \cs{@morespace@rightnote@leftcolumn}.
%    \begin{macrocode}
    \global\@morespace@leftnote@rightcolumn=\dimexpr\intercolumns@width + \Lcolwidth\relax%
    \global\@morespace@rightnote@leftcolumn=\dimexpr\intercolumns@width + \Rcolwidth\relax%
%    \end{macrocode}
% If \cs{if@sidenotesmarginpage} is False
%    \begin{macrocode}
  \else%
    \global\@morespace@leftnote@rightcolumn=\z@%
    \global\@morespace@rightnote@leftcolumn=\z@%
%    \end{macrocode}
% End of \cs{get@sidenote@morespace@columns}.
%    \begin{macrocode}
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \changes{v1.3.3}{2012/12/19}{Debugging the left notes of the right column.}
% \changes{v1.3.4}{2013/07/03}{Allow use of commands in sidenotes, as introduced by eledmac 1.0.}
% \changes{v1.8.0}{2014/08/05}{\protect\cs{l@dlsnote},\protect\cs{l@drsnote} and \protect\cs{l@dcsnote} defined only one time, in \protect\package{eledmac}. }
% \begin{macro}{\affixside@noteR}
% The right text version of \protect\cs{affixside@note}.
% \changes{v1.1.2}{2012/10/06}{Remove spurious space between line number and line content}
%    \begin{macrocode}
\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%
}

%    \end{macrocode}
% \end{macro}
%
%
% \section{Verse}
%\changes{v0.11.0}{2012/06/11}{New management of hangingsymbol insertion, preventing undesirable insertions.}
%\changes{v0.12.0}{2012/08/03}{New management of hangingsymbol insertion, preventing undesirable insertions.}
% Like in \macpackage, the insertion of hangingsymbol is base on \protect\cs{ifinserthangingsymbol}, and, for the right side, on \protect\cs{ifinserthangingsymbolR}.
% Both commands also include the hanging space, to be sure the \protect\cs{one@line} of hanging lines has the same width that the \protect\cs{one@line} of normal lines and to prevent the column separator from shifting.
% \begin{macro}{\inserthangingsymbolL}
% \begin{macro}{\inserthangingsymbolR}
% \changes{v0.11.0}{2012/06/11}{Prevent the column separator for hanging verse from shifting}
% \changes{v1.4.3}{2013/10/27}{Hanging verse is no longer automatically flush right.}
% \changes{v1.15.0}{2015/04/13}{Prevent more efficiently the column separator from shifting when a verse is hanging}
%    \begin{macrocode}
\newif\ifinserthangingsymbolR
\newcommand{\inserthangingsymbolL}{%
  \ifinserthangingsymbol%
    \ifinstanzaL%
        \@hangingsymbol%
    \fi%
    \ifinastanzaL%
        \@hangingsymbol%
    \fi%
  \fi%
}%
\newcommand{\inserthangingsymbolR}{%
  \ifinserthangingsymbolR%
    \ifinstanzaR%
        \@hangingsymbol%
    \fi%
    \ifinastanzaR%
        \@hangingsymbol%
    \fi%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}

% Before we can define the main stanza macros we need to be able to save
% and reset
% the category code for \&. To save the current value we use
% \verb+\next+ from the \verb+\loop+ macro.
%    \begin{macrocode}
  \chardef\next=\catcode`\&
  \catcode`\&=\active

%    \end{macrocode}
%
%
%
% \begin{environment}{astanza}
% \changes{v1.4.1}{2013/08/16}{Enable the  use of stanzaindentsrepetition within astanza environment.}
% \changes{v1.13.0}{2015/03/06}{Enable the  use of optional argument of \& in astanza environment.}
% This is roughly an environmental form of \cs{stanza}, which treats
% its stanza-like contents as a single chunk.
%
%    \begin{macrocode}
\newenvironmentx{astanza}[2][1,2,usedefault]{%
  \ifledRcol%
    \global\inastanzaRtrue%
  \else%
    \global\inastanzaLtrue%
  \fi%
  \catcode`\&\active
  \global\stanza@count\@ne\stanza@modulo\@ne
  \@advancestanzanumber%
  \newdimen\parindent@beforestanza%
  \parindent@beforestanza=\parindent%Keep in memory the standard \parindent
  \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
  \@insertstanzanumber%
  \let\par\relax\ignorespaces%No paragraph in verses
}{%
  \global\undef\parindent@beforestanza%
}%

%    \end{macrocode}
% \end{environment}
%
% \begin{macro}{\@stopastanza}
% This command is called by \verb+\&+ in \env{astanza} environment.
% It allows optional arguments.
%    \begin{macrocode}
\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]}%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@astanza@line}
% This gets put at the start of each line in the environment. It sets up
% the paragraph style --- each line is treated as a paragraph.
%    \begin{macrocode}
\newcommand*{\@astanza@line}{%
  \stanza@indent%
  \endgraf
  \stanza@hang%
  \ignorespaces}

%    \end{macrocode}
% \end{macro}
%
% Lastly reset the modified category codes.
%    \begin{macrocode}
  \catcode`\&=\next

%    \end{macrocode}
%
% \begin{macro}{\thestanzaL}
% \begin{macro}{\thestanzaR}
% And now, the left and right stanza counter.
%    \begin{macrocode}
\newcounter{stanzaL}
\newcounter{stanzaR}
\renewcommand{\thestanzaL}{%
  \textbf{\arabic{stanzaL}}%
}
\renewcommand{\thestanzaR}{%
  \textbf{\arabic{stanzaR}}%
}
%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \section{Fixing babel and polyglossia}
%
%    With parallel texts there is the possibility that the two sides
% might use different languages via \protect\package{babel}. On the other hand,
% nor \protect\package{babel} nor \protect\package{polyglossia} might not be called at all (even though it might be already
% built into the format).
% \changes{v0.2.0}{2004/12/20}{Added section of babel related code}
%
%    With the normal sequential text each line is initially typeset
% in the current language environment, and then it is output at which
% time its attachments are typeset (in the same language environment.
% In the parallel case lines are typeset in their current language but
% an attachment might be typeset outside the language environment
% of its line if the left and right side languages are different.
% To counter this, we have to make sure that the correct language is
% used at the proper times.
%
% \changes{v1.8.0}{2014/08/05}{Suppress \protect\cs{ifl@dsamelang} which did not work and was not logical, because both columns could have the same language but not the main language of the document.}
%
% \begin{macro}{\l@dchecklang}
% \changes{v1.8.0}{2014/08/05}{Suppress \protect\cs{l@dchecklang} which did not work and was not logical, because both columns could have the same language but not the main language of the document.}
% \end{macro}
% \begin{macro}{\bbl@set@language}
% In \protect\package{babel} the macro \protect\cs{bbl@set@language}\marg{lang} does the work when
% the language \meta{lang} is changed via \protect\cs{selectlanguage}.
% Unfortunately for us, if it is given
% an argument in the form of a control sequence it strips off the \verb?\?
% character rather than expanding the command. We need a version that accepts
% an argument in the form \protect\cs{lang} without it stripping the \verb?\?.
% \changes{v2.0.0}{2015/07/19}{Patch \protect\cs{bbl@set@language} instead of redefining it}
%    \begin{macrocode}
\patchcmd{\bbl@set@language}%
  {\select@language{\languagename}}%
  {\edef\languagename{#1}\select@language{\languagename}}%
  {}%
  {}%

%    \end{macrocode}
% \end{macro}
%
% The rest of the setup has to be postponed until the end of the preamble
% when we know if \protect\package{babel} or \protect\package{polyglossia} have been used or not. However, for now assume
% that it has not been used.
%
% \begin{macro}{\selectlanguage}
% \begin{macro}{\l@duselanguage}
% \begin{macro}{\theledlanguageL}
% \begin{macro}{\theledlanguageR}
% \protect\cs{selectlanguage} is a \verb?babel? command. \protect\cs{theledlanguageL} and
% \protect\cs{theledlanguageR} are the names of the languages of the left and right
% texts. \protect\cs{l@duselanguage} is similar to \protect\cs{selectlanguage}.
%    \begin{macrocode}
\newcommand*{\l@duselanguage}[1]{}
\gdef\theledlanguageL{}
\gdef\theledlanguageR{}

%    \end{macrocode}
%
% Now do the \protect\package{babel} or \protect\package{polyglossia}  fix or, if necessary.
%    \begin{macrocode}
\AtBeginDocument{%
  \@ifpackageloaded{babel}{%
    \@ifundefined{bbl@main@language}{%
%    \end{macrocode}
%  Either \protect\package{babel}   has not been used or it has been used with no
% specified language.
%    \begin{macrocode}
    }{%
%    \end{macrocode}
% Here we deal with the case where babel has been used. \protect\cs{selectlanguage}
% has to be redefined to use our version of \protect\cs{bbl@set@language} and to
% store the left or right language.
%    \begin{macrocode}
    \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}
%    \end{macrocode}
% \protect\cs{l@duselanguage} simply calls the original \protect\cs{selectlanguage} so
% that \protect\cs{theledlanguageL} and \protect\cs{theledlanguageR} are unaltered.
%    \begin{macrocode}
    \renewcommand*{\l@duselanguage}[1]{%
      \let\bbl@savelastskip\relax% Babel 3.61, which provokes spurious vertical space
      \let\bbl@restorelastskip\relax%% Babel 3.61, which provokes spurious vertical space
      \expandafter\l@doldselectlanguage\expandafter{#1}%
    }%
%    \end{macrocode}
% Lastly, initialise the left and right languages to the current \protect\package{babel}
% one.
%    \begin{macrocode}
    \gdef\theledlanguageL{\bbl@main@language}%
    \gdef\theledlanguageR{\bbl@main@language}%
    }%
  }{}%
%    \end{macrocode}
% If use \protect\package{polyglossia}
% \changes{v1.8.0}{2014/08/05}{Correct left/right language setting with polyglossia.}
% \changes{v1.9.0}{2014/09/16}{Debug left/right language switching with polyglossia. Do not write in .aux file when setting left/right lines.}
% \changes{v2.22.4}{2019/11/04}{Provide compatibility with the latest version of polyglossia (v1.45).}
% \changes{v2.23.0}{2020/03/08}{Restore compatibility with versions of polyglossia prior to v1.45.}
% \begin{macrocode}
  \@ifpackageloaded{polyglossia}{%
    \@ifpackagelater{polyglossia}{2024/07/15}{}{\led@err@polyglossiaTooOld}%
      \renewcommand{\l@duselanguage}[1]{%
        \csuse{no\languagename @numbers}%
        \selectlanguage*{#1}%
      }%
      \AddToHook{env/Leftside/begin}{%
        \AddToHookNext{cmd/polyglossia@language@switched/after}{%
          \xdef\theledlanguageL{\languagename}%
        }%
      }%
      \AddToHook{env/Rightside/begin}{%
        \AddToHookNext{cmd/polyglossia@language@switched/after}{%
          \xdef\theledlanguageR{\languagename}%
        }%
      }%
      \xdef\theledlanguageL{\mainlanguagename}%
      \xdef\theledlanguageR{\mainlanguagename}%
%    \end{macrocode}
% That is it.
%    \begin{macrocode}
  }{}%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \section{Counts and boxes for parallel texts}
%
%    In sequential text, each chunk (that enclosed by \protect\cs{pstart} \ldots
% \protect\cs{pend}) is put into a box called \protect\cs{raw@text} and then immediately
% printed, resulting in the box being emptied and ready for the next chunk.
% For parallel processing multiple boxes are needed as printing is delayed.
% We also need extra counters for various things.
%
% \begin{macro}{\maxchunks}
% \begin{macro}{\l@dc@maxchunks}
% The maximum number of chunk pairs before printing has to be called for.
% The default is 5120 chunk pairs.
%    \begin{macrocode}
\newcount\l@dc@maxchunks
\newcommand{\maxchunks}[1]{\l@dc@maxchunks=#1}
  \maxchunks{5120}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\l@dnumpstartsL}
% \begin{macro}{\l@dnumpstartsR}
% The numbers of left and right chunks. \protect\cs{l@dnumpstartsL} is defined
% in \protect\package{eledmac}.
% \changes{v0.3.0}{2005/02/24}{Moved \protect\cs{l@dnumpstartsL} to eledmac}
%    \begin{macrocode}
\newcount\l@dnumpstartsR

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\l@dpscL}
% \begin{macro}{\l@dpscR}
% A couple of scratch counts to count left and right \cs{pstart}, respectively.
%    \begin{macrocode}
\newcount\l@dpscL
\newcount\l@dpscR

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\l@dsetuprawboxes}
% This macro creates \protect\cs{maxchunks} pairs of boxes for left and right
% chunks. The boxes are called \protect\cs{l@dLcolrawbox1}, \protect\cs{l@dLcolrawbox2}, etc.
%    \begin{macrocode}
\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}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\l@dsetupmaxlinecounts}
% \begin{macro}{\l@dzeromaxlinecounts}
% To be able to synchronise left and right texts we need
% to know the maximum number of text lines there are in each pair of chunks.
% \protect\cs{l@dsetupmaxlinecounts} creates \protect\cs{maxchunks} new counts
% called \protect\cs{l@dmaxlinesinpar1}, etc., and
% \protect\cs{l@dzeromaxlinecounts} zeroes all of them.
%    \begin{macrocode}
\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}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% Make sure that all these are set up. This has to be done after the
% user has had an opportunity to change \protect\cs{maxchunks}.
%    \begin{macrocode}
\AtBeginDocument{%
  \l@dsetuprawboxes
  \l@dsetupmaxlinecounts
  \l@dzeromaxlinecounts
  \l@dnumpstartsL=\z@
  \l@dnumpstartsR=\z@
  \l@dpscL=\z@
  \l@dpscR=\z@}

%    \end{macrocode}
% \section{Checking text to be processed}
% \begin{macro}{\if@pstarts}
% \begin{macro}{\@pstartstrue}
% \begin{macro}{\@pstartsfalse}
% \begin{macro}{\check@pstarts}
% \protect\cs{check@pstarts} returns \protect\cs{@pstartstrue} if there are any unprocessed
%  chunks.
%    \begin{macrocode}
\newif\if@pstarts
\newcommand*{\check@pstarts}{%
  \@pstartsfalse
  \ifnum\l@dnumpstartsL>\l@dpscL
    \@pstartstrue
  \else
    \ifnum\l@dnumpstartsR>\l@dpscR
      \@pstartstrue
    \fi
  \fi
}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ifaraw@text}
% \begin{macro}{\araw@texttrue}
% \begin{macro}{\araw@textfalse}
% \begin{macro}{\checkraw@text}
% \protect\cs{checkraw@text} checks whether the current Left or Right box is
% void or not. If one or other is not void it sets \protect\cs{araw@texttrue},
% otherwise both are void and it sets \protect\cs{araw@textfalse}.
%    \begin{macrocode}
\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
}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\@writelinesinparL}
% \begin{macro}{\@writelinesinparR}
% These write the number of text lines in a chunk to the section files,
% and then afterwards zero the counter.
%    \begin{macrocode}
\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@}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@writepageofparL}
% \begin{macro}{\@writepageofparR}
% These write the pages where start the first line of a chunck.
%    \begin{macrocode}
\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%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \section{Parallel columns}
%
% \begin{macro}{\@eledsectionL}
% \begin{macro}{\@eledsectionR}
% The parbox \protect\cs{@eledsectionL} and \protect\cs{@eledsectionR} will keep the sections' title.
%    \begin{macrocode}
\newsavebox{\@eledsectionL}%
\newsavebox{\@eledsectionR}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\Columns}
% \changes{v1.8.0}{2014/07/28}{Modify \protect\cs{Columns} to enable to add section's title.}
% The \protect\cs{Columns} command results in the previous Left and
% Right texts being typeset in matching columns. There should
% be equal numbers of chunks in the left and right texts.
%
% \changes{v1.12.0}{2015/02/23}{Add \protect\cs{l@dprintingcolumnstrue}}
%    \begin{macrocode}
\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
%    \end{macrocode}
% Start a group and zero counters, etc.
%    \begin{macrocode}
  \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%
%    \end{macrocode}
% Check if there are chunks to be processed, and process them
% two by two (left and right pairs).
%    \begin{macrocode}
    \check@pstarts
    \loop\if@pstarts
        \global\pstartnumtrue
        \global\pstartnumRtrue
%    \end{macrocode}
% Increase \protect\cs{l@dpscL} and \protect\cs{l@dpscR} which here count
% the numbers of left and right chunks.
% Increase \cs{pstarts@typeset@L}, which counts the number of \cs{pstart} typeset both in not parallel mode and in the left side of parallel mode.
% Also restore the value of the public pstart counters.
%    \begin{macrocode}
      \global\advance\l@dpscL \@ne
      \global\advance\l@dpscR \@ne
      \global\advance\pstarts@typeset@L\@ne%
      \restore@pstartL@pc%
      \restore@pstartR@pc%
%    \end{macrocode}
% We print the optional argument of \protect\cs{pstart} or the argument of \protect\cs{AtEveryPstart}.
%    \begin{macrocode}
      \Columns@print@before@pstart%
%    \end{macrocode}
% Check if there is text yet to be processed in at least one of
% the two current chunks, and also whether the left and right languages
% are the same
% \changes{v0.2.0}{2004/12/20}{Added \protect\cs{l@dchecklang} and \protect\cs{l@duselanguage}
%                to \protect\cs{Columns}}
% \changes{v1.8.0}{2014/08/05}{Suppress \protect\cs{l@dchecklang} from \protect\cs{Columns}.}
%    \begin{macrocode}
      \checkraw@text
{        \loop\ifaraw@text
%    \end{macrocode}
% Grab the next pair of left and right text lines and output them, swapping
% languages if they differ, adding section title if needed.
%    \begin{macrocode}
            \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}
%    \end{macrocode}
% Having completed a pair of chunks, write the number of lines
% in each chunk to the respective section files.
% Increment pstart counters and reset line numbering if it is by pstart.
% \changes{v0.11.0}{2012/06/11}{Line numbering by pstart.}
%    \begin{macrocode}
      \@writelinesinparL
      \@writelinesinparR
      \check@pstarts
        \ifbypstart@%
           \unless\ifinstanza%
             \write\linenum@out{\string\@set[1]}%
             \resetprevline@%
           \fi%
        \fi
       \ifbypstart@R
           \unless\ifinstanza%
             \write\linenum@outR{\string\@set[1]}%
             \resetprevline@%
          \fi%
        \fi
        \Columns@print@after@pend%
    \repeat
%    \end{macrocode}
% Having output all chunks, make sure all notes have been output,
% then zero counts ready for the next set of texts. The boolean tests for stanza are switched to false.
%    \begin{macrocode}
    \flush@notes
    \flush@notesR
  \endgroup
%    \end{macrocode}
%    \begin{macrocode}
  \global\l@dpscL=\z@
  \global\l@dpscR=\z@
  \global\l@dnumpstartsL=\z@
  \global\l@dnumpstartsR=\z@
  \global\l@dprintingcolumnsfalse%
  \ignorespaces
    \global\instanzaLfalse%
    \global\instanzaRfalse%
  }%
}%

%    \end{macrocode}
% \end{macro}
% \begin{macro}{\print@columnseparator}
% \changes{v1.8.0}{2014/08/05}{Move some code of \protect\cs{Columns} to \protect\cs{print@columnseparator}.}
% \protect\cs{print@columnseparator} prints the column separator, with surrounding spaces (as the user has set them).
% We use the \TeX\ \protect\cs{ifdim} instead of \protect\package{etoolbox}
% to avoid having \protect\cs{hfill} in a \verb+{}+, which deletes some space (but not much).
%    \begin{macrocode}
\def\print@columnseparator{%
  \ifdim\beforecolumnseparator<0pt%
    \hfill%
  \else%
    \hspace{\beforecolumnseparator}%
  \fi%
  \columnseparator%
  \ifdim\aftercolumnseparator<0pt%
    \hfill%
  \else%
    \hspace{\aftercolumnseparator}%
  \fi%
}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\get@intercolumns@width}
% \begin{macro}{\intercolumns@width}
% The \cs{intercolumns@width} is calculated by \cs{get@intercolumns@width}.
% This length depends of many parameters:
% \begin{itemize}
%   \item Columns width;
%   \item columns position;
%   \item columns separator;
%   \item space between columns and columns separator, which can be fixed by user or automatically calculated by \parpackage.
% \end{itemize}
% This length is never used directly, but it is used to calculate some other lengths.
%    \begin{macrocode}
\newdimen\intercolumns@width%
\newcommand{\get@intercolumns@width}{%
%    \begin{macrocode}
  \global\intercolumns@width=\z@%
  \ifdefstring{\columns@position}{C}%
%    \end{macrocode}
% First case, the columns are centered.
%    \begin{macrocode}
  {%
%    \end{macrocode}
% First sub-case, the width between columns is automatically calculated.
%    \begin{macrocode}
    \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%
      }%
      {}%
%    \end{macrocode}
% Second sub-case, the width between column is fully determined by user setting.
%    \begin{macrocode}
    \ifboolexpr{%
      test {\ifdimgreater{\beforecolumnseparator}{\z@}}%
      and test {\ifdimgreater{\aftercolumnseparator}{\z@}}%
    }%
      {%
        \global\intercolumns@width=\dimexpr%
          \columnrulewidth + \beforecolumnseparator + \aftercolumnseparator%
        \relax%
      }%
      {}%
%    \end{macrocode}
% Third sub-case, the width before column separator is determined by user setting, but the width after column separator is automatically calculated.
%    \begin{macrocode}
    \ifboolexpr{%
      test {\ifdimgreater{\beforecolumnseparator}{\z@}}%
      and test {\ifdimless{\aftercolumnseparator}{\z@}}%
    }%
      {%
        \global\intercolumns@width=\dimexpr%
          \columnrulewidth + \beforecolumnseparator +%
          (\textwidth - \Lcolwidth - \Rcolwidth - \columnrulewidth - \beforecolumnseparator) * 1/3%
        \relax%
      }%
      {}%
%    \end{macrocode}
% Fourth and last sub-case, the width before column separator is automatically calculated, but the width after column separator is determined by user setting.
%    \begin{macrocode}
    \ifboolexpr{%
      test {\ifdimless{\beforecolumnseparator}{\z@}}%
      and test {\ifdimgreater{\aftercolumnseparator}{\z@}}%
    }%
      {%
        \global\intercolumns@width=\dimexpr%
          \columnrulewidth + \aftercolumnseparator +%
          (\textwidth - \Lcolwidth - \Rcolwidth - \columnrulewidth - \aftercolumnseparator) * 1/3%
        \relax%
      }%
      {}%
%    \end{macrocode}
% Now, we have finished with the case the columns are centered aligned.
%    \begin{macrocode}
  }%
%    \end{macrocode}
% Other case, the columns are left or right aligned.
%    \begin{macrocode}
  {%
%    \end{macrocode}
% First sub-case, the width between columns is automatically calculated.
%    \begin{macrocode}
    \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%
      }%
      {}%
%    \end{macrocode}
% Second sub-case, the width between column is fully determined by user setting.
%    \begin{macrocode}
    \ifboolexpr{%
      test {\ifdimgreater{\beforecolumnseparator}{\z@}}%
      and test {\ifdimgreater{\aftercolumnseparator}{\z@}}%
    }%
      {%
        \global\intercolumns@width=\dimexpr%
          \columnrulewidth + \beforecolumnseparator + \aftercolumnseparator%
        \relax%
      }%
      {}%
%    \end{macrocode}
% Third sub-case, the width before column separator is determined by user setting, but the width after column separator is automatically calculated.
%    \begin{macrocode}
    \ifboolexpr{%
      test {\ifdimgreater{\beforecolumnseparator}{\z@}}%
      and test {\ifdimless{\aftercolumnseparator}{\z@}}%
    }%
      {%
        \global\intercolumns@width=\dimexpr%
          \columnrulewidth + \beforecolumnseparator +%
          (\textwidth - \Lcolwidth - \Rcolwidth - \columnrulewidth - \beforecolumnseparator) * 1/2%
        \relax%
      }%
      {}%
%    \end{macrocode}
% Fourth and last sub-case, the width before column separator is automatically calculated, but the width after column separator is determined by user setting.
%    \begin{macrocode}
    \ifboolexpr{%
      test {\ifdimless{\beforecolumnseparator}{\z@}}%
      and test {\ifdimgreater{\aftercolumnseparator}{\z@}}%
    }%
      {%
        \global\intercolumns@width=\dimexpr%
          \columnrulewidth + \aftercolumnseparator +%
          (\textwidth - \Lcolwidth - \Rcolwidth - \columnrulewidth - \aftercolumnseparator) * 1/2%
        \relax%
      }%
      {}%
%    \end{macrocode}
% We have finished with the case the columns are left or right aligned.
%    \begin{macrocode}
  }%
%    \end{macrocode}
% End of \cs{get@intercolumns@width}.
%    \begin{macrocode}
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\print@leftcolumn}
% \begin{macro}{\print@rightcolumn}
% \cs{print@leftcolumn} and \cs{print@rightcolumn} print the line number of the left or right column respectively.
% Normally, it is defined by the content of the \env{Leftside} or \env{Rightside} environments.
% But if \cs{movecolumnspositiononrightpage} is set to TRUE, it also depends on the page number.
%    \begin{macrocode}
\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%
    }%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\checkpb@columns}
% \protect\cs{checkpb@columns} prevent or make pagebreaking in columns, depending on the use of \protect\cs{ledpb} or \protect\cs{lednopb}.
%    \begin{macrocode}

\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
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\columnseparator}
% \begin{macro}{\columnrulewidth}
% The separator between line pairs in parallel columns is in the form
% of a vertical rule extending a little below the baseline and with a height
% slightly greater than the \protect\cs{baselineskip}. The width of the rule
% is \protect\cs{columnrulewidth} (initially 0pt so the rule is invisible).
%    \begin{macrocode}
\newcommand*{\columnseparator}{%
  \smash{\rule[-0.2\baselineskip]{\columnrulewidth}{1.05\baselineskip}}}
\newdimen\columnrulewidth
  \columnrulewidth=\z@

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\columnsposition}
% \begin{macro}{\columns@position}
% The position of the \protect\cs{Columns} in a page. Default value is R.
% Stored in \protect\cs{columns@position}.
%    \begin{macrocode}
\newcommand*{\columnsposition}[1]{%
  \xdef\columns@position{#1}%
  }%
\xdef\columns@position{R}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\beforecolumnseparator}
% \begin{macro}{\aftercolumnseparator}
% \protect\cs{beforecolumnseparator} and \protect\cs{aftercolumnseparator} lengths are defined to \verb+-1pt+. If user changes them to a positive length, the lengths are used to define blank spaces before / after the column separator, instead of \protect\cs{hfill}.
%    \begin{macrocode}
\newlength{\beforecolumnseparator}%
\setlength{\beforecolumnseparator}{-2pt}%

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

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{setwidthliketwocolumns}
% \begin{macro}{setpositionliketwocolumns@L}
% \begin{macro}{setnotepositionliketwocolumns@L}
% \begin{macro}{setpositionliketwocolumns@C}
% \begin{macro}{setnotepositionliketwocolumns@C}
% \begin{macro}{setpositionliketwocolumns@R}
% \begin{macro}{setnotepositionliketwocolumns@R}
% The \protect\cs{setwidthliketwocolumns} macro is called in \protect\cs{beginnumbering} in a \textbf{non-parallel}
% typesetting context, to fix the width of the lines to be vertically aligned with parallel columns. It is also called at the beginning of a note's group, if some options are enabled.
% The \protect\cs{setposition\ldots} macros are called in \protect\cs{beginnumbering} in a \textbf{non-parallel} typesetting context to fix the position of the lines.
% The \protect\cs{setnoteposition\ldots} macros are called in \protect\cs{xxxfootstart} in a \textbf{non-parallel} typesetting context to fix the position of the notes block.
% \begin{macrocode}
\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}%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\Columns@print@before@pstart}
% \begin{macro}{\Columns@print@after@pend}
% The \protect\cs{Columns@print@before@pstart} and \protect\cs{Columns@print@after@pend} print the content of the optional argument of \protect\cs{pstart} / \protect\cs{pend}. If this content is not empty, it also print the separator.
%    \begin{macrocode}
\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}%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \section{Parallel pages}
%
% This is considerably more complicated than parallel columns.
%
% \subsection{Specific counters}
% \begin{macro}{\numpagelinesL}
% \begin{macro}{\numpagelinesR}
% \begin{macro}{\l@dminpagelines}
% Counts for the number of lines on a left or right page, and the smaller
% of the number of lines on a pair of facing pages.
%    \begin{macrocode}
\newcount\numpagelinesL
\newcount\numpagelinesR
\newcount\l@dminpagelines

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \subsection{Main macro}
% \begin{macro}{\Pages}
% \changes{v1.8.0}{2014/07/28}{Modify \protect\cs{Pages} to enable to add section's title.}
% \changes{v1.8.3}{2014/08/31}{Debug blank pages when using optional argument in the last \protect\cs{pend}.}
% \changes{v1.10.0}{2015/01/12}{Debug wrong pages splitting when no optional argument is used in last \protect\cs{pend} (bug was added in v.1.8.3).}
% \changes{v1.10.0}{2015/01/12}{Debug wrong parallel pages synchronization when an \protect\cs{edtext} falls across two pages.}
% \changes{v1.13.0}{2015/03/06}{When using shiftedpstarts option, a \protect\cs{l@dleftbox} with a null height will advance the \protect\cs{pagetotal} in any case.}
% \changes{v1.13.1}{2015/03/12}{Prevent false empty page after \protect\cs{Pages} (bug added in 1.13.0)}
% The \protect\cs{Pages} command results in the previous Left and
% Right texts being typeset on matching facing pages. There should
% be equal numbers of chunks in the left and right texts.
%
% \changes{v1.12.0}{2015/02/23}{Add \protect\cs{l@dprintingpagestrue}}
%    \begin{macrocode}
\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%
%    \end{macrocode}
% Get onto an empty even (left) page, then initialise counters, etc.
%    \begin{macrocode}
  \cleartol@devenpage%
  \global\l@dprintingpagestrue%
  \begingroup%
%    \end{macrocode}
% As \protect\cs{Pages} must be called outside of the pages environment, we have to redefine the \protect\cs{Lcolwidth} and \protect\cs{Rcolwidth} lengths, to prevent false overfull hboxes.
% \changes{v1.13.0}{2015/03/06}{Prevent false overfull hboxes when using \protect\cs{Pages} outside of pages environment.}
% \changes{v2.3.0}{2015/09/05}{Fix a bug when calling \protect\cs{Columns} after a \protect\cs{Pages} (bug added in v1.13.0).}
% \changes{v2.17.2}{2017/04/06}{Fix a bug when changing \protect\cs{Lcolwitdth} and \protect\cs{Rcolwitdth} in \protect\env{pages} environment.}
%    \begin{macrocode}
    \Lcolwidth=\Lcolwidth@pages%
    \Rcolwidth=\Rcolwidth@pages%
%    \end{macrocode}
%    \begin{macrocode}
    \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%
%    \end{macrocode}
% The footnotes are printed in a different way from expected in \macpackage, as we may want to print the notes on one side only.
%    \begin{macrocode}
    \let\print@Xnotes\print@Xnotes@forpages%
    \let\print@notesX\print@notesX@forpages%
%    \end{macrocode}
% Check if there are chunks to be processed.
%    \begin{macrocode}
    \check@pstarts%
    \loop\if@pstarts%
%    \end{macrocode}
% Loop over the number of chunks, incrementing the chunk counts
% (\protect\cs{l@dpscL}
% and \protect\cs{l@dpscR} are chunk (box) counts).
%
%    \begin{macrocode}
      \global\advance\l@dpscL \@ne%
      \global\advance\l@dpscR \@ne%
%    \end{macrocode}
% Calculate the maximum number of real text lines in the chunk pair,
% storing the result in the relevant \protect\cs{l@dmaxlinesinpar}.
%    \begin{macrocode}
      \getlinesfromparlistL%
      \getlinesfromparlistR%
      \l@dcalc@maxoftwo{\@cs@linesinparL}{\@cs@linesinparR}%
          {\usenamecount{l@dmaxlinesinpar\the\l@dpscL}}%
      \check@pstarts%
    \repeat%
%    \end{macrocode}
% Zero the counts again, ready for the next bit.
%    \begin{macrocode}
    \global\l@dpscL=\z@%
    \global\l@dpscR=\z@%
%    \end{macrocode}
% Get the number of lines on the first pair of pages and store
% the minimum in \protect\cs{l@dminpagelines}.
%    \begin{macrocode}
    \getlinesfrompagelistL%
    \getlinesfrompagelistR%
    \l@dcalc@minoftwo{\@cs@linesonpageL}{\@cs@linesonpageR}%
        {\l@dminpagelines}%
%    \end{macrocode}
% Now we start processing the left and right chunks (\protect\cs{l@dpscL} and
% \protect\cs{l@dpscR} count the left and right chunks), starting with the first pair.
%    \begin{macrocode}
    \check@pstarts%
    \if@pstarts%
%    \end{macrocode}
% Increment the chunk counts to get the first pair.
% Restore also the value of public pstart counters.
%    \begin{macrocode}
      \global\advance\l@dpscL \@ne%
      \global\advance\l@dpscR \@ne%
      \global\advance\pstarts@typeset@L\@ne%
      \restore@pstartL@pc%
      \restore@pstartR@pc%
%    \end{macrocode}
% We have not processed any lines from these chunks yet, so zero the
% respective line counts.
%    \begin{macrocode}
      \global\@donereallinesL=\z@%
      \global\@donetotallinesL=\z@%
      \global\@donereallinesR=\z@%
      \global\@donetotallinesR=\z@%
%    \end{macrocode}
% Start a loop over the boxes (chunks).
%    \begin{macrocode}
      \checkraw@text%
%    \end{macrocode}
%    \begin{macrocode}
%      \begingroup
{        \loop\ifaraw@text%
%    \end{macrocode}
% See if there is more that can be done for the left page and set up the
% left language.
% \changes{v0.2.0}{2004/12/20}{Added \protect\cs{l@duselanguage} to \protect\cs{Pages}}
%    \begin{macrocode}
          \checkpageL%
          \Leftpagehook%
          \l@duselanguage{\theledlanguageL}%
{            \loop\ifl@dsamepage%
%    \end{macrocode}
% Process the next (left) text line, adding it to the page.
% Eventually, adds the optional argument of pstart.
% \changes{v0.3.0}{2005/02/10}{Added \protect\cs{ledstrutL} to \protect\cs{Pages}}
%    \begin{macrocode}
              \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%
%    \end{macrocode}
% When using shiftedpstarts option, a \protect\cs{l@dleftbox} with a null height is not printed.
% That means we do not insert blank lines at the end of a left chunk lower than the corresponding right chunk.
% However, a \protect\cs{l@dleftbox} with a null height will advance the \protect\cs{pagetotal} in any case.
% Because if we do not do this, the \protect\cs{checkpageL} could let \protect\cs{ifl@pagefull} to false,
% and consequently a \protect\cs{@lopL} equal to 1000 could be written in the numbered file,
% even if all the lines actually needed for the current page have been printed.
% \l@dleftbox
%    \begin{macrocode}
              \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%
%    \end{macrocode}
% Perhaps we have to move to the next (left) box. Check if we have got all
% we can onto the page. If not, repeat for the next line.
% Check if we have to print the optional argument of the last pend.
% Check if the page is full.
% Check if the verse is split in two subsequent pages.
% Check there is any forced page breaks.
% Reset the verse skipnumber boolean
%    \begin{macrocode}
              \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%
%    \end{macrocode}
% That (left) page has been filled. Output the number of real lines
% on the page --- if the page break is because the page has been
% filled with lines, use the actual number, otherwise the page has been
% ended early in order to synchronise with the facing page so use an
% impossibly large number.
%    \begin{macrocode}
            \ifl@dpagefull%
              \@writelinesonpageL{\the\numpagelinesL}%
            \else%
              \@writelinesonpageL{1000}%
            \fi%
%    \end{macrocode}
% Reset to zero the left-page line count,  clear the page to get onto the facing
% (odd, right) page, and reinitialize the accumulated dimension of interline correction for notes in parallel ledgroup.
%    \begin{macrocode}
            \numpagelinesL \z@%
            \parledgroup@correction@notespacing@init%
            \clearl@dleftpage }%
%    \end{macrocode}
% Now do the same for the right text.
% \changes{v0.3.0}{2005/02/10}{Added \protect\cs{ledstrutR} to \protect\cs{Pages}}
%    \begin{macrocode}
          \checkpageR%
          \Rightpagehook%
          \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%
%    \end{macrocode}
% The page is full, so move onto the next (left, odd) page and repeat left
% text processing.
%    \begin{macrocode}
            \clearl@drightpage}%
%    \end{macrocode}
% More to do? If there is we have to get the number of lines for the next
% pair of pages before starting to output them.
% \changes{v0.3.b}{2005/04/08}{Added \protect\cs{l@dminpagelines} calculation
%                             for succeeding page pairs}
%    \begin{macrocode}
          \checkraw@text%
          \ifaraw@text%
            \getlinesfrompagelistL%
            \getlinesfrompagelistR%
            \l@dcalc@minoftwo{\@cs@linesonpageL}{\@cs@linesonpageR}%
                             {\l@dminpagelines}%
          \fi%
        \repeat}%
%    \end{macrocode}
% We have now output the text from all the chunks.
%    \begin{macrocode}
    \fi%
%    \end{macrocode}
% Make sure that there are no inserts hanging around.
%    \begin{macrocode}
    \flush@notes%
    \flush@notesR%
  \endgroup%
%    \end{macrocode}
% Zero counts ready for the next set of left/right text chunks. The boolean tests for stanza are switched to false.
%    \begin{macrocode}
  \global\l@dpscL=\z@%
  \global\l@dpscR=\z@%
  \global\l@dnumpstartsL=\z@%
  \global\l@dnumpstartsR=\z@%
    \global\instanzaLfalse%
    \global\instanzaRfalse%
    \global\inastanzaLfalse%
    \global\inastanzaRfalse%
  \global\l@dprintingpagesfalse%
%    \end{macrocode}
% Check the consistency of \cs{edtext@later} and \cs{edtext@now}
%    \begin{macrocode}
   \ifnum\edtext@later=\edtext@now%
   \else%
     \led@error@edtext@later@now%
   \fi%
   \global\edtext@later=\z@%
   \global\edtext@now=\z@%
%    \end{macrocode}
% Prevent final notes from overlapping the line number
%    \begin{macrocode}
 \finish@Pages@notes%
  \ignorespaces}}%


%    \end{macrocode}
% \end{macro}
%
% \subsection{Ensure all notes are printed at the end of parallel pages}
% \begin{macro}{\finish@Pages@notes}
% This macro ensures that all long notes are printed at the end of \protect\cs{Pages} typesetting, and that there are no more long notes left for the next pages.
%    \begin{macrocode}
\newcommand{\finish@Pages@notes}{%
  \def\do##1{%
%    \end{macrocode}
% First, declare footnote box if there was no previous declared.
% E.g. if familiar or critical notes were disabled by \macpackage's  options.
%    \begin{macrocode}
    \ifnocritical@%
      \global\newnamebox{##1footins}%
    \fi
    \ifnofamiliar@%
      \global\newnamebox{footins##1}%
    \fi
%    \end{macrocode}
% We must also restore the settings for the footnotes in case of using onlyside option.
%    \begin{macrocode}
      \restore@Xnotes@settings{##1}%
      \restore@notesX@settings{##1}%
%    \end{macrocode}
% And now, add a \protect\cs{newpage} if there is no more footnote to print.
%    \begin{macrocode}
    \ifvoid\csuse{##1footins}%
      \ifvoid\csuse{footins##1}\else%
        \newpage\null%
        \listbreak%
      \fi%
    \else%
      \newpage\null%
      \listbreak%
    \fi%
  }%
  \dolistloop{\@series}%
}%
%    \end{macrocode}
% \end{macro}
% \subsection{Struts}
% \begin{macro}{\ledstrutL}
% \begin{macro}{\ledstrutR}
% Struts inserted into leftand right text lines.
% \changes{v0.3.0}{2005/02/10}{Added \protect\cs{ledtrutL} and \protect\cs{ledstrutR}}
% \changes{v2.4.0}{2015/09/29}{Deleted \protect\cs{ledtrutL} and \protect\cs{ledstrutR}}
% \changes{v2.4.0}{2015/09/29}{Fix a bug with dotted letter}
%    \begin{macrocode}
\newcommand*{\ledstrutL}{}
\newcommand*{\ledstrutR}{}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsection{Page clearing}
% \begin{macro}{\cleartoevenpage}
% \begin{macro}{\cleartol@devenpage}
% \protect\cs{cleartoevenpage}, which is defined in the memoir class,
% is like \protect\cs{clear(double)page} except that we
% end up on an even page.
% \protect\cs{cleartol@devenpage} is similar except that it first checks to see
% if it is already on an empty page.
%    \begin{macrocode}
\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%
}%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\clearl@dleftpage}
% \begin{macro}{\clearl@drightpage}
% \protect\cs{clearl@dleftpage} and \protect\cs{clearl@drightpage} get us onto
% an odd and even page, respectively, checking that we end up on
% the subsquent page.
% Both commands use \protect\cs{newpage} and not \protect\cs{clearpage}.
% Because \protect\cs{clearpage} prints all footnotes before the next page, even if it has to add new empty pages, while \protect\cs{newpage} does not.
% And as we want notes started in the left page continue in the right page and \emph{vice-versa}, we must use \protect\cs{newpage} and not \protect\cs{clearpage}
%
% \changes{v1.13.0}{2015/03/06}{Use \protect\cs{newpage} instead of \protect\cs{clearpage}.}
%    \begin{macrocode}
\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}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Lines managing}
% \begin{macro}{\getlinesfromparlistL}
% \begin{macro}{\@cs@linesinparL}
% \begin{macro}{\getlinesfromparlistR}
% \begin{macro}{\@cs@linesinparR}
% \protect\cs{getlinesfromparlistL} gets the next entry from the
% \protect\cs{linesinpar@listL} and puts it into \protect\cs{@cs@linesinparL}; if the
% list is empty, it sets \protect\cs{@cs@linesinparL} to 0. Similarly
% for \protect\cs{getlinesfromparlistR}.
%    \begin{macrocode}
\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}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\getlinesfrompagelistL}
% \begin{macro}{\@cs@linesonpageL}
% \begin{macro}{\getlinesfrompagelistR}
% \begin{macro}{\@cs@linesonpageR}
% \protect\cs{getlinesfrompagelistL} gets the next entry from the
% \protect\cs{linesonpage@listL} and puts it into \protect\cs{@cs@linesonpageL}; if the
% list is empty, it sets \protect\cs{@cs@linesonpageL} to 1000. Similarly
% for \protect\cs{getlinesfrompagelistR}.
%    \begin{macrocode}
\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}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@writelinesonpageL}
% \begin{macro}{\@writelinesonpageR}
% These macros output the number of lines on a page to the section file
% in the form of \protect\cs{@lopL} or \protect\cs{@lopR} macros.
%    \begin{macrocode}
\newcommand*{\@writelinesonpageL}[1]{%
  \edef\next{\write\linenum@out{\string\@lopL{#1}}}%
  \next}
\newcommand*{\@writelinesonpageR}[1]{%
  \edef\next{\write\linenum@outR{\string\@lopR{#1}}}%
  \next}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\l@dcalc@maxoftwo}
% \begin{macro}{\l@dcalc@minoftwo}
% \protect\cs{l@dcalc@maxoftwo}\marg{num}\marg{num}\marg{count} sets \meta{count}
% to the maximum of the two \meta{num}.
%
% Similarly
% \protect\cs{l@dcalc@minoftwo}\marg{num}\marg{num}\marg{count} sets \meta{count}
% to the minimum of the two \meta{num}.
%
%    \begin{macrocode}
\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}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Page break managing}
% \begin{macro}{\ifl@dsamepage}
% \begin{macro}{\l@dsamepagetrue}
% \begin{macro}{\l@dsamepagefalse}
% \begin{macro}{\ifl@dpagefull}
% \begin{macro}{\l@dpagefulltrue}
% \begin{macro}{\l@dpagefullfalse}
% \begin{macro}{\checkpageL}
% \begin{macro}{\checkpageR}
% \protect\cs{checkpageL} tests if the space and lines already taken on the page by
% text and footnotes is less than the constraints. If so, then
% \protect\cs{ifl@dpagefull} is set FALSE and \protect\cs{ifl@dsamepage} is set TRUE.
% If the page is spatially full
% then \protect\cs{ifl@dpagefull} is set TRUE and \protect\cs{ifl@dsamepage} is set FALSE.
% If it is not spatially full but the maximum number of lines have been
% output then both \protect\cs{ifl@dpagefull} and \protect\cs{ifl@dsamepage}
% are set FALSE.
%
%    \begin{macrocode}
\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%
  }%

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\checkpbL}
% \begin{macro}{\checkpbR}
% \protect\cs{checkpbL} and \protect\cs{checkpbR} are called after each line is printed, and after the page is checked. These commands correct page breaks depending on \protect\cs{ledpb} and \protect\cs{lednopb}.
%    \begin{macrocode}
\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}{}
   }{}
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\checkverseL}
% \begin{macro}{\checkverseR}
% \protect\cs{checkverseL} and \protect\cs{checkverseR} are called after each line is printed.
% They prevent page break inside line of verse.
%    \begin{macrocode}
\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%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\setgoalfraction}
% \begin{macro}{\ledthegoal}
% \begin{macro}{\goalfraction}
% \begin{macro}{\check@goal}
% \protect\cs{ledthegoal} is the amount of space allowed to taken by text and
% footnotes on a page before a forced pagebreak. This can be controlled via
% \protect\cs{@goalfraction}. \protect\cs{ledthegoal} is calculated via \protect\cs{check@goal}.
%    \begin{macrocode}
\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}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\ifwrittenlinesL}
% \begin{macro}{\ifwrittenlinesL}
% Booleans for whether line data has been written to the section file.
%    \begin{macrocode}
\newif\ifwrittenlinesL
\newif\ifwrittenlinesR

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{Getting boxes content}
% \begin{macro}{\if@getnextbox}
% The \cs{if@getnextbox} boolean is switched to true if we can get the next chunk in a page after finished previous chunk.
% That is:
% \begin{itemize}
%   \item If we use the \option{nosyncpstarts} option, in any case
%   \item If we do not use it, only when the number or real or blank line of the current chunk is equal or greater to the maximum number of line in the current pair of chunks.
% \end{itemize}
%     \begin{macrocode}
\newif\if@getnextbox%
%     \end{macrocode}
% \end{macro}
% \begin{macro}{\get@nextboxL}
% \begin{macro}{\get@nextboxR}
% \changes{v0.11.0}{2012/06/11}{Change \protect\cs{get@nextboxL} and \protect\cs{get@nextboxR} to allow to disable line numbering (like in eledmac 0.15).}
% If the current box is not empty (i.e., still contains some lines)
% nothing is done. Otherwise if and only if a synchronisation point is
% reached the next box is started.
%
%    \begin{macrocode}
\newcommand*{\get@nextboxL}{%
  \ifvbox\namebox{l@dLcolrawbox\the\l@dpscL}% box is not empty
%    \end{macrocode}
% The current box is not empty; do nothing.
%    \begin{macrocode}
  \else%                                      box is empty
%    \end{macrocode}
% The box is empty.
% By default, we can get the next box
%    \begin{macrocode}
    \@getnextboxtrue%Should be local, but be cautious
%    \end{macrocode}
% But not when sufficient lines for this page have been generated (except when we don't do any synchronization whatsoever).
% output.
%    \begin{macrocode}
    \ifnum\usenamecount{l@dmaxlinesinpar\the\l@dpscL}>\@donetotallinesL
      \parledgroup@notes@endL%
      \unless\ifnosyncpstarts%
        \@getnextboxfalse%
%     \end{macrocode}
%  If we use the nomaxlines option, we will start at new page, but we take count of the lines to be typeset for the actual right chunk on the right page, before starting new chunk on the left page.
%     \begin{macrocode}
        \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%
%    \end{macrocode}
% Sufficient lines have been output.
%    \begin{macrocode}
    \if@getnextbox%
      \ifnum\usenamecount{l@dmaxlinesinpar\the\l@dpscL}=\@donetotallinesL
        \parledgroup@notes@endL
      \fi
      \ifwrittenlinesL\else
%    \end{macrocode}
% Write out the number of lines done, and set the boolean so this is only
% done once.
%    \begin{macrocode}
        \@writelinesinparL
        \writtenlinesLtrue
      \fi
      \ifnum\l@dnumpstartsL>\l@dpscL
%    \end{macrocode}
% \changes{v0.11.0}{2012/06/11}{Pstart number can be printed in side}
% There are still unprocessed boxes. Recalculate the maximum number of
% lines needed, and move onto the next box (by incrementing \protect\cs{l@dpscL}). If needed, restart the line numbering.
%    \begin{macrocode}
        \writtenlinesLfalse
         \ifbypstart@
            \global\line@num=0%
            \resetprevline@%
          \fi
% Add the content of the optional argument of the previous \protect\cs{pend}.
%    \begin{macrocode}
         \csuse{after@pendL@\the\l@dpscL}%
         \global\csundef{after@pendL@\the\l@dpscL}%
%    \end{macrocode}
% Check the number of lines
%    \begin{macrocode}
        \l@dcalc@maxoftwo{\the\usenamecount{l@dmaxlinesinpar\the\l@dpscL}}%
                         {\the\@donetotallinesL}%
                         {\usenamecount{l@dmaxlinesinpar\the\l@dpscL}}%
        \global\@donetotallinesL \z@
%    \end{macrocode}
% Go to the next pstart
%    \begin{macrocode}
        \global\advance\l@dpscL \@ne
        \global\advance\pstarts@typeset@L\@ne%
        \global\pstartnumtrue%
        \restore@pstartL@pc%
%    \end{macrocode}
% Add notes of parallel ledgroup.
%    \begin{macrocode}
        \parledgroup@notes@endL
        \parledgroup@correction@notespacing@final{L}
      \else
%    \end{macrocode}
%    \begin{macrocode}
        \print@last@after@pendLtrue%
      \fi
    \fi
  \fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\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
          \unless\ifinstanzaR%
             \global\line@numR=0%
             \resetprevline@%
          \fi%
        \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}

%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \section{The \option{mainmatter} option of \cs{Pages}}
% The optional argument of \cs{Pages} could be equal to \verb+mainmatter+.
% In this case the boolean \cs{ifPages@mainmatter} is set to true, and some special things are done in \cs{Pages@mainmatter}, called by \cs{cleartol@devenpage}.
% \begin{macro}{\ifPages@mainmatter}
% \begin{macro}{\Pages@mainmatter}
%    \begin{macrocode}
\newif\ifPages@mainmatter
\newcommand{\Pages@mainmatter}{%
    \ifPages@mainmatter%
      \pagenumbering{arabic}%
      \addtocounter{page}{1}%
      \addtocounter{par@page}{-1}%
      \patchcmd{\thepage}{page}{par@page}{}{}%
    \fi%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \section{Sections' titles' commands}
% As switching from left to right pages does not clear the page since v1.13.0,
% but only creates new pages, no \verb+\vbox{}+ is inserted, and consequently parallel chapters are mis-aligned.
%
% So we patch the \protect\cs{chapter} command in order to prevent this problem.
% \begin{macro}{\chapter}
%    \begin{macrocode}
\pretocmd{\chapter}{%
  \ifl@dprintingpages%
    \vbox{}%
  \fi%
  }%
  {}%
  {}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\eledsectnotoc}
% \protect\cs{eledsectnotoc} just saves its content \protect\cs{@eledsectnotoc}, which will be tested where sectioning commands will be printed.
%    \begin{macrocode}
\newcommand{\eledsectnotoc}[1]{\xdef\@eledsectnotoc{#1}}
\eledsectnotoc{R}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\eledsectmark}
% \protect\cs{eledsectmark} just saves its content \protect\cs{@eledsectmark}, which will be tested where sectioning commands will be printed.
%    \begin{macrocode}
\newcommand{\eledsectmark}[1]{\xdef\@eledsectmark{#1}}
\eledsectmark{L}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\eledsection@correcting@skip}
% Because the vertical correction needed after inserting a title in parallel depends whether we are in parallel columns or parallel pages, we stock its length in \protect\cs{eledsection@correcting@skip}.
%    \begin{macrocode}
\newskip\eledsection@correcting@skip
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\eled@sectioningR@out}
% We save the sectioning commands of the right side in the \protect\cs{eled@sectioningR@out} file.
%    \begin{macrocode}
\newwrite\eled@sectioningR@out
%    \end{macrocode}
% \end{macro}
% \section{Page break/no page break, depending on the specific line}
% We need to adapt the macro of the homonym section of eledmac to eledpar.
% \begin{macro}{\prev@pbR}
% \begin{macro}{\prev@nopbR}
% The \protect\cs{l@prev@pbR} macro is a \protect\package{etoolbox}'s list, which contains the lines in which page breaks occur (before or after).
% The \protect\cs{l@prev@nopbR} macro is a \protect\package{etoolbox} list, which contains the lines in which NO page breaks occur (before or after).
%    \begin{macrocode}
\def\l@prev@pbR{}
\def\l@prev@nopbR{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\ledpbR}
% \begin{macro}{\ledpbnumR}
% \begin{macro}{\lednopbnum}
% \begin{macro}{\lednopbnumR}
% The \protect\cs{ledpbR} macro writes the call to \protect\cs{led@pbR} in line-list file.
% The \protect\cs{ledpbnumR} macro writes the call to \protect\cs{led@pbnumR} in line-list file.
% The \protect\cs{lednopbR} macro writes the call to \protect\cs{led@nopbR} in line-list file.
% The \protect\cs{lednopbnumR} macro writes the call to \protect\cs{led@nopbnumR} in line-list file.
%    \begin{macrocode}
\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}}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\led@pbR}
% \begin{macro}{\led@pbnumR}
% \begin{macro}{\led@nopbR}
% \begin{macro}{\led@nopbnumR}
% The \protect\cs{led@pbR} add the absolute line number in the \protect\cs{prev@pbR} list.
% The \protect\cs{led@pbnumR} add the argument in the \protect\cs{prev@pbR} list.
% The \protect\cs{led@nopbR} add the absolute line number in the \protect\cs{prev@nopbR} list.
% The \protect\cs{led@nopbnumR} add the argument in the \protect\cs{prev@nopbR} list.
%    \begin{macrocode}
\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}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \section{Parallel ledgroup}
% \begin{macro}{\parledgroup@}
% \begin{macro}{\parledgroupseries@}
% \begin{macro}{\parledgrouptype@}
% The marks \protect\cs{parledgroup@} contains information about the beginnings and endings of notes in a parallel ledgroup.
% \protect\cs{parledgroup@series} contains the footnote series.
% \protect\cs{parledgroup@type} contains the type of the footnote: critical (Xfootnote) or familiar (footnoteX).
%    \begin{macrocode}
\newmarks\parledgroup@
\newmarks\parledgroup@series
\newmarks\parledgroup@type
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\parledgroup@notes@startL}
% \begin{macro}{\parledgroup@notes@startR}
% \protect\cs{parledgroup@notes@startL} and \protect\cs{parledgroup@notes@startR} are used to mark the beginning of a note series in a parallel ledgroup.
%    \begin{macrocode}
\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}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\parledgroup@notes@startL}
% \begin{macro}{\parledgroup@notes@startR}
% \protect\cs{parledgroup@notes@endL} and \protect\cs{parledgroup@notes@endR} are used to mark the end of a note series in a parallel ledgroup.
%    \begin{macrocode}
\newcommand{\parledgroup@notes@endL}{%
  \global\ledgroupnotesL@false%
}
\newcommand{\parledgroup@notes@endR}{%
  \global\ledgroupnotesR@false%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\insert@noterule@ledgroup}
% A \protect\cs{vskip} is not used when the boxes are constructed. So we insert it before ledgroup note series when parallel lines are constructed.
% This is the goal of \protect\cs{insert@noterule@ledgroup}
%    \begin{macrocode}
\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
           }{}
        }
    {}
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@parledgroupnotespacing}
% \protect\cs{@parledgroupnotespacing} can be redefined by the user to change the interline spacing of ledgroup notes.
%    \begin{macrocode}
\newcommand{\setparledgroupnotespacing}[1]{\gdef\@parledgroupnotespacing{#1}}
\newcommand{\@parledgroupnotespacing}{}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\parledgroup@notespacing@correction}
% \begin{macro}{\parledgroup@notespacing@set@correction}
% \protect\cs{parledgroup@notespacing@correction} is the difference between a normal line skip and a line skip in a note. It is set by \protect\cs{parledgroup@notespacing@set@correction}, called at the beginning of \protect\cs{Pages}.
%    \begin{macrocode}
\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}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\parledgroup@correction@notespacing@init}
% \protect\cs{parledgroup@correction@notespacing@init} sets the value of accumulated corrections of note spacing to 0~pt.
% It is called at the beginning of each pages AND at the end of each ledgroup.
%    \begin{macrocode}
\newcommand{\parledgroup@correction@notespacing@init}{
  \dimdef{\parledgroup@notespacing@correction@accumulated}{0pt}
  \dimdef{\parledgroup@notespacing@correction@modulo}{0pt}
}
\parledgroup@correction@notespacing@init
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\parledgroup@correction@notespacing@final}
% \protect\cs{parledgroup@correction@notespacing@final} adds the total space deleted because of correction for notes, in a parallel ledgroup.
% It also adds the space needed by the other side spaces between note rules and notes.  It is called after the print of each pstart/pend.
%    \begin{macrocode}
\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
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\parledgroup@correction@notespacing}
% \protect\cs{parledgroup@correction@notespacing} is used before each printed line.
% If it is a line of notes in parallel ledgroup, the space \protect\cs{parledgroup@notespacing@correction} is decreased, to make interline space correct.
% The decreased space is added to \protect\cs{parledgroup@notespacing@correction@accumulated} and \protect\cs{parledgroup@notespacing@correction@modulo}.
% If \protect\cs{parledgroup@notespacing@correction@modulo} is equal or greater than \protect\cs{baselineskip}:
% \begin{itemize}
%    \item It is decreased by \protect\cs{baselineskip}.
%    \item The total of line number in the current page is decreased by one.
% \end{itemize}
% For example, suppose an normal interline of 24~pt and interline for note of 12~pt.
% That means that the two lines of notes take the place of one normal line.  For every two lines of notes, the line total for the current place is decreased by one.
%    \begin{macrocode}{}
\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%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\parledgroup@beforenotesL}
% \begin{macro}{\parledgroup@beforenotesR}
% \protect\cs{parledgroup@beforenotesL} and \protect\cs{parledgroup@beforenotesR} store the total of space before notes in the current parallel ledgroup.
%    \begin{macrocode}
\dimdef\parledgroup@beforenotesL{0pt}
\dimdef\parledgroup@beforenotesR{0pt}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\parledgroup@beforenotes@save}
% The macro \protect\cs{parledgroup@beforenotes@save} dumps the space before notes of the current parallel ledgroup in a macro named with the current pstart number.
%    \begin{macrocode}
\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
}
%    \end{macrocode}
% \end{macro}


% \section{Compatibility with \eledmac}
%
% Here, we define some command for the \verb+eledmac-compat+ option.
%
%    \begin{macrocode}
\ifeledmaccompat@%


  \unless\ifnocritical@
  \let\onlyXside\Xonlyside
  \fi
\fi
%    \end{macrocode}
% \section{The End}\label{end}
%
%
%</code>
%
% \newpage
% \appendix
% \clearpage
%
% \let\oldthesection\thesection
% \renewcommand{\thesection}{Appendix \oldthesection}
% \renewcommand{\thesubsection}{\oldthesection.\arabic{subsection}}
% \section{Some things to do when changing version}
% \input{doc-include/migrate-par.dtx}
% \bibliographystyle{alpha}
% \begin{thebibliography}{WWW99}
% \addcontentsline{toc}{section}{References}
% \bibitem[LW90]{EDMACTUG}
% John Lavagnino and Dominik Wujastyk.
% \newblock \enquote{An overview of \edmac: a \textsc{Plain} TeX format for
%            critical editions}.
% \newblock \emph{TUGboat}, \textbf{11}, 4, pp. 623--643, November 1990.
% \newblock (Code available from CTAN in
%            \texttt{macros/plain/contrib/edmac})
%
%
% \bibitem[Wil02]{MEMOIR}
% Peter Wilson.
% \newblock \emph{The \protect\package{memoir} class for configurable typesetting}.
% \newblock November 2002.
% \newblock (Available from CTAN in
%            \texttt{macros/latex/contrib/memoir})
%
% \bibitem[Wil04]{ELEDMAC}
% Peter Wilson and Maïeul Rouquette.
% \newblock \emph{\protect\package{eledmac} A presumptuous attempt to port
%            \protect\package{EDMAC},\protect\package{TABMAC} and \protect\package{EDSTANZA} to
%             LaTeX}.
% \newblock December 2004.
% \newblock (Available from CTAN in
%            \texttt{macros/latex/contrib/eledmac})
%
% \end{thebibliography}
%
% \Finale
% \phantomsection
% \addcontentsline{toc}{section}{Index}
% \PrintIndex
%
% \phantomsection
% \addcontentsline{toc}{section}{Change History}
% \PrintChanges
% \endinput
\endinput

%% \CharacterTabl
%%   Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
