diff options
author | Karl Berry <karl@freefriends.org> | 2014-08-06 22:49:21 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-08-06 22:49:21 +0000 |
commit | 6dbec9cf98c5cc99c45848bbb37a207c2ae21160 (patch) | |
tree | 9a852286da25707be4379a9c2170ffe30783b8be /Master/texmf-dist/tex/latex/eledmac/eledmac.sty | |
parent | ff1845c8557690d905ecb126d40c90e611602de5 (diff) |
eledmac (6aug14)
git-svn-id: svn://tug.org/texlive/trunk@34854 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/eledmac/eledmac.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/eledmac/eledmac.sty | 1040 |
1 files changed, 835 insertions, 205 deletions
diff --git a/Master/texmf-dist/tex/latex/eledmac/eledmac.sty b/Master/texmf-dist/tex/latex/eledmac/eledmac.sty index 60bf7019004..6c10b8364a8 100644 --- a/Master/texmf-dist/tex/latex/eledmac/eledmac.sty +++ b/Master/texmf-dist/tex/latex/eledmac/eledmac.sty @@ -23,8 +23,9 @@ %% This work consists of the files listed in the README file. + \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{eledmac}[2014/05/29 v1.11.1 LaTeX port of EDMAC] +\ProvidesPackage{eledmac}[2014/08/05 v1.12.0 LaTeX port of EDMAC]% \newif\ifledfinal \newif\ifparapparatus@ \newif\ifnoquotation@ @@ -47,6 +48,7 @@ \RequirePackage{suffix} \RequirePackage{xstring} \RequirePackage{ifluatex} +\RequirePackage{ragged2e} \ifcsdef{if@RTL}{}{\newif\if@RTL} \ifledfinal \newcommand*{\showlemma}[1]{#1} @@ -151,6 +153,7 @@ \pst@rtedLfalse \newcount\l@dnumpstartsL \newif\ifledRcol +\newif\ifledRcol@ \newif\ifnumberingR \newcommand*{\beginnumbering}{% \ifnumbering @@ -164,8 +167,16 @@ \line@list@stuff{\jobname.\extensionchars\the\section@num}% \l@dend@stuff \setcounter{pstart}{1} - \ifl@dpairing\else\begingroup\fi - \initnumbering@sectcmd + \ifl@dpairing + \global\l@dnumpstartsL \z@ + \global\pst@rtedLfalse + \else + \begingroup + \initnumbering@sectcmd + \fi + \gdef\eled@sections@@{} + \makeatletter\InputIfFileExists{\jobname.eledsec\the\section@num}{}{}\makeatother + \immediate\openout\eled@sectioning@out=\jobname.eledsec\the\section@num\relax } \newcommand*{\initnumbering@reg}{% \global\pst@rtedLfalse @@ -185,112 +196,6 @@ \resetprevpage@num } -\newcommand{\initnumbering@sectcmd}{ - \newcommand{\ledsection}[2][]{% - \leavevmode\pend\vspace{3.5ex \@plus 1ex \@minus .2ex}\ifl@dpairing\else\skipnumbering\fi%% - \pstart% - \leavevmode\ifledsecnolinenumber\skipnumbering\fi\section[##1]{##2}\leavevmode\vspace{2.3ex \@plus.2ex}\skipnumbering\pend% - \vspace{-2\parskip}\vspace{-2\baselineskip}% - \ifautopar\else\pstart\fi - } - \WithSuffix\newcommand\ledsection*[1]{% - \leavevmode\pend\vspace{3.5ex \@plus 1ex \@minus .2ex}\ifl@dpairing\else\skipnumbering\fi% - \pstart% - \leavevmode\ifledsecnolinenumber\skipnumbering\fi\section*{##1}\leavevmode\vspace{2.3ex \@plus.2ex}\skipnumbering\pend% - \vspace{-2\parskip}\vspace{-2\baselineskip}% - \ifautopar\else\pstart\fi - } - \newcommand{\ledsubsection}[2][]{% - \leavevmode\pend\vspace{3.5ex \@plus 1ex \@minus .2ex}\ifl@dpairing\else\skipnumbering\fi% - \pstart% - \leavevmode\ifledsecnolinenumber\skipnumbering\fi\subsection[##1]{##2}\leavevmode\vspace{1.5ex \@plus .2ex}\skipnumbering\pend% - \vspace{-2\parskip}\vspace{-2\baselineskip}% - \ifautopar\else\pstart\fi - } - \WithSuffix\newcommand\ledsubsection*[1]{% - \leavevmode\pend\vspace{3.5ex \@plus 1ex \@minus .2ex}\ifl@dpairing\else\skipnumbering\fi% - \pstart% - \leavevmode\ifledsecnolinenumber\skipnumbering\fi\subsection*{##1}\leavevmode\vspace{1.5ex \@plus .2ex}\skipnumbering\pend% - \vspace{-2\parskip}\vspace{-2\baselineskip}% - \ifautopar\else\pstart\fi - } - \newcommand{\ledsubsubsection}[2][]{% - \leavevmode\pend\vspace{3.5ex \@plus 1ex \@minus .2ex}\ifl@dpairing\else\skipnumbering\fi% - \pstart% - \leavevmode\ifledsecnolinenumber\skipnumbering\fi\subsubsection[##1]{##2}\leavevmode\vspace{1.5ex \@plus .2ex}\skipnumbering\pend% - \vspace{-2\parskip}\vspace{-2\baselineskip}% - \ifautopar\else\pstart\fi - } - \WithSuffix\newcommand\ledsubsubsection*[1]{% - \leavevmode\pend\vspace{3.5ex \@plus 1ex \@minus .2ex}\ifl@dpairing\else\skipnumbering\fi% - \pstart% - \leavevmode\ifledsecnolinenumber\skipnumbering\fi\subsubsection*{##1}\leavevmode\vspace{1.5ex \@plus .2ex}\skipnumbering\pend% - \vspace{-2\parskip}\vspace{-2\baselineskip}% - \ifautopar\else\pstart\fi - } - \newcommand\ledchapter[2][]{\ifl@dmemoir\gdef\ch@pt@c{##1}\fi~\pend\skipnumbering\pstart\chapter[##1]{##2}\pend\pstart} - \WithSuffix\newcommand\ledchapter*[1]{~\pend\skipnumbering\pstart\chapter*{##1}\pend\pstart} - \patchcmd{\@makeschapterhead}{1\par}{1}{}{} - \pretocmd{\@makeschapterhead}{\par}{}{} - \apptocmd{\@makeschapterhead}{\par}{}{} - \patchcmd{\@makeschapterhead}{\vskip 40\p@}{}{}{} - \patchcmd{\@makechapterhead}{1\par}{1}{}{} - \pretocmd{\@makechapterhead}{\par}{}{} - \apptocmd{\@makechapterhead}{\par}{}{} - \patchcmd{\@makechapterhead}{\vskip 40\p@}{}{}{} - \apptocmd{\@chapter}{\par\leavevmode\vspace{40 \p@}\skipnumbering}{}{} - \apptocmd{\@schapter}{\par\leavevmode\vspace{40 \p@}\skipnumbering}{}{} - \newcommand\beforeledchapter{\pend\cleardoublepage\pstart} - \patchcmd{\chapter}{\cleardoublepage}{\relax}{}{} - \patchcmd{\chapter}{\clearpage}{\relax}{}{} - \ifnoquotation@\else - \renewcommand{\quotation}{\par\leavevmode% - \parindent=1.5em% - \skipnumbering% - \ifautopar% - \vskip-\parskip% - \else% - \vskip\topsep% - \fi% - \global\leftskip=\leftmargin% - \global\rightskip=\leftmargin% - } - \renewcommand{\endquotation}{\par% - \global\leftskip=0pt% - \global\rightskip=0pt% - \leavevmode% - \skipnumbering% - \ifautopar% - \vskip-\parskip% - \else% - \vskip\topsep% - \fi% - } - \renewcommand{\quote}{\par\leavevmode% - \parindent=0pt% - \skipnumbering% - \ifautopar% - \vskip-\parskip% - \else% - \vskip\topsep% - \fi% - \global\leftskip=\leftmargin% - \global\rightskip=\leftmargin% - } - \renewcommand{\endquote}{\par% - \global\leftskip=0pt% - \global\rightskip=0pt% - \leavevmode% - \skipnumbering% - \ifautopar% - \vskip-\parskip% - \else% - \vskip\topsep% - \fi% - } - \fi -} -\newcommand{\ledsectnotoc}{\let\addcontentsline\@gobblethree} \def\endnumbering{% \ifnumbering \global\numberingfalse @@ -311,7 +216,12 @@ \else \led@err@NumberingNotStarted \fi - \autoparfalse\ifl@dpairing\else\endgroup\fi} + \autoparfalse + \immediate\closeout\eled@sectioning@out + \ifl@dpairing\else + \endgroup + \fi +} \newcommand{\pausenumbering}{% \ifautopar\global\autopar@pausetrue\fi% \endnumbering\global\numberingtrue} @@ -324,6 +234,7 @@ \line@list@stuff{\jobname.\extensionchars\the\section@num}% \l@dend@stuff \begingroup + \initnumbering@sectcmd \else \led@err@NumberingShouldHaveStarted \endnumbering @@ -532,10 +443,10 @@ \begingroup}% } -\newcommand{\@l}[2]{% +\newcommand{\@nl}[2]{% \fix@page{#1}% - \@l@reg} -\newcommand*{\@l@reg}{% + \@nl@reg} +\newcommand*{\@nl@reg}{% \ifx\l@dchset@num\relax \else \advance\absline@num \@ne \set@line@action @@ -769,27 +680,25 @@ {\xifinlistcs{\the\absline@num}{l@prev@nopb}% {\xifinlistcs{\the\absline@num}{normal@page@break}% {\numgdef{\@next@page}{\thepage+1}% - \write\linenum@out{\string\@l[\@next@page][\@next@page]}% + \write\linenum@out{\string\@nl[\@next@page][\@next@page]}% }% - {\write\linenum@out{\string\@l[\the\c@page][\thepage]}}% + {\write\linenum@out{\string\@nl[\the\c@page][\thepage]}}% }% - {\write\linenum@out{\string\@l[\the\c@page][\thepage]}}}% + {\write\linenum@out{\string\@nl[\the\c@page][\thepage]}}}% {}% \IfStrEq{\led@pb@setting}{before}% - {% -\numdef{\next@absline}{\the\absline@num+1}% -\xifinlistcs{\next@absline}{l@prev@nopb}% - {\xifinlistcs{\the\absline@num}{normal@page@break}% - {% - \numgdef{\nc@page}{\c@page+1}% - \write\linenum@out{\string\@l[\nc@page][\nc@page]}% + {\numdef{\next@absline}{\the\absline@num+1}% + \xifinlistcs{\next@absline}{l@prev@nopb}% + {\xifinlistcs{\the\absline@num}{normal@page@break}% + {\numgdef{\nc@page}{\c@page+1}% + \write\linenum@out{\string\@nl[\nc@page][\nc@page]}% + }% + {\write\linenum@out{\string\n@l[\the\c@page][\thepage]}}% + }% + {\write\linenum@out{\string\@nl[\the\c@page][\thepage]}}% }% - {\write\linenum@out{\string\@l[\the\c@page][\thepage]}}% - }% - {\write\linenum@out{\string\@l[\the\c@page][\thepage]}}% -}% - {}% - \IfStrEqCase{\led@pb@setting}{{before}{\relax}{after}{\relax}}[\write\linenum@out{\string\@l[\the\c@page][\thepage]}]% + {}% + \IfStrEqCase{\led@pb@setting}{{before}{\relax}{after}{\relax}}[\write\linenum@out{\string\@nl[\the\c@page][\thepage]}]% } \newcommand*{\flag@start}{% @@ -938,14 +847,15 @@ \numberpstartfalse \newif\iflabelpstart \labelpstartfalse -\newcommand*{\pstart}{% -\if@nobreak% - \let\@oldnobreak\@nobreaktrue% -\else% - \let\@oldnobreak\@nobreakfalse% -\fi% -\@nobreaktrue% -\ifnumbering \else% +\newcommandx*{\pstart}[1][1]{% + \ifstrempty{#1}{}{\noindent#1}% + \if@nobreak% + \let\@oldnobreak\@nobreaktrue% + \else% + \let\@oldnobreak\@nobreakfalse% + \fi% + \@nobreaktrue% + \ifnumbering \else% \led@err@PstartNotNumbered% \beginnumbering% \fi% @@ -956,6 +866,7 @@ \list@clear{\inserts@list}% \global\let\next@insert=\empty% \begingroup\normal@pars% + \global\advance \l@dnumpstartsL\@ne \global\setbox\raw@text=\vbox\bgroup% \ifautopar\else% \ifnumberpstart% @@ -968,9 +879,10 @@ \fi% \numberedpar@true% \iflabelpstart\protected@edef\@currentlabel% - {\p@pstart\thepstart}\fi% + {\p@pstart\thepstart} + \fi% } -\newcommand*{\pend}{\ifnumbering \else% +\newcommandx*{\pend}[1][1]{\ifnumbering \else% \led@err@PendNotNumbered% \fi% \ifnumberedpar@ \else% @@ -994,7 +906,9 @@ \pstartnumtrue% \fi% \@oldnobreak% - \addtocounter{pstart}{1}} + \addtocounter{pstart}{1}% + \ifstrempty{#1}{}{\noindent#1}% +} \newcommand*{\l@dzeropenalties}{% \brokenpenalty \z@ \clubpenalty \z@ @@ -1041,19 +955,43 @@ \fi \check@pb@in@verse \affixline@num - \affixpstart@num - \hb@xt@ \linewidth{\do@insidelinehook\l@dld@ta\add@inserts\affixside@note - \l@dlsn@te - {\ledllfill\hb@xt@ \wd\one@line{\new@line\inserthangingsymbol\l@dunhbox@line{\one@line}}\ledrlfill\l@drd@ta% - \l@drsn@te - }} + \add@inserts\affixside@note + \xifinlist{\the\l@dnumpstartsL}{\eled@sections@@}% + {\print@eledsection}% + {\print@line}% \IfStrEq{\led@pb@setting}{after}{\led@check@pb\led@check@nopb}{} }% +\def\print@line{ + \affixpstart@num% + \hb@xt@ \linewidth{\do@insidelinehook\l@dld@ta + \l@dlsn@te + {\ledllfill\hb@xt@ \wd\one@line{\new@line\inserthangingsymbol \l@dunhbox@line{\one@line}}\ledrlfill\l@drd@ta% + \l@drsn@te + }}% +} +\def\print@eledsection{% + \numdef{\temp@}{\l@dnumpstartsL-1}% + \xifinlist{\temp@}{\eled@sections@@}{\@nobreaktrue}{\@nobreakfalse}% + \@eled@sectioningtrue% + \csuse{eled@sectioning@\the\l@dnumpstartsL}% + \@eled@sectioningfalse% + \global\csundef{eled@sectioning@\the\l@dnumpstartsL}% + \if@RTL% + \hspace{-\paperwidth}% + {\hbox{\l@dunhbox@line{\one@line}}\new@line}% + \else% + \hspace{\paperwidth}% + {\new@line \hbox{\l@dunhbox@line{\one@line}}}% + \fi% + \vskip-\baselineskip% +} \newcommand*{\do@linehook}{} \newcommand*{\do@insidelinehook}{} \newcommand*{\l@demptyd@ta}{% \gdef\l@dld@ta{}% \gdef\l@drd@ta{}% + \gdef\l@dcsnotetext@l{}% + \gdef\l@dcsnotetext@r{}% \gdef\l@dcsnotetext{}} \newcommand{\l@dlsn@te}{% @@ -1556,7 +1494,9 @@ }% \vskip\skip\csname #1footins\endcsname% \leftskip0pt \rightskip0pt - \csname #1footnoterule\endcsname\noindent\leavevmode} + \csname #1footnoterule\endcsname% + \vskip\csuse{afterXrule@#1}% + \noindent\leavevmode} \let\normalfootnoterule=\footnoterule \newcommand*{\normalfootgroup}[1]{{\csuse{Xnotefontsize@#1}\noindent\csuse{txtbeforeXnotes@#1}}\unvbox\csname #1footins\endcsname} @@ -1571,9 +1511,11 @@ \ifl@dpairing% \else% \@nameuse{#1footnoterule}% + \vskip\csuse{afterXrule@#1}% \fi% \else% \@nameuse{#1footnoterule}% + \vskip\csuse{afterXrule@#1}% \fi% \setlength{\parindent}{0pt} {\csuse{Xnotefontsize@#1}\csuse{txtbeforeXnotes@#1}} @@ -1615,10 +1557,14 @@ \expandafter\let\csname #1footfmt\endcsname=\parafootfmt \expandafter\let\csname #1footgroup\endcsname=\para@footgroup \count\csname #1footins\endcsname=1000 + \dimen\csname #1footins\endcsname=\csuse{maxhXnotes@#1} + \skip\csname #1footins\endcsname=\csuse{beforeXnotes@#1} \para@footsetup{#1} \expandafter\let\csname mpv#1footnote\endcsname=\mppara@vfootnote \expandafter\let\csname mp#1footgroup\endcsname=\mppara@footgroup \count\csname mp#1footins\endcsname=1000 + \dimen\csname mp#1footins\endcsname=\csuse{maxhXnotes@#1} + \skip\csname mp#1footins\endcsname=\csuse{beforeXnotes@#1} } \providecommand{\footfudgefiddle}{64} \newcommand*{\para@footsetup}[1]{{\csuse{Xnotefontsize@#1} @@ -1638,7 +1584,9 @@ {}% }% \vskip\skip\csname #1footins\endcsname% - \csname #1footnoterule\endcsname\noindent\leavevmode} + \csname #1footnoterule\endcsname% + \vskip\csuse{afterXrule@#1}% + \noindent\leavevmode} \newcommand*{\para@vfootnote}[2]{% \insert\csname #1footins\endcsname \bgroup @@ -1690,6 +1638,8 @@ #3\penalty-10 } \newcommand*{\para@footgroup}[1]{% \unvbox\csname #1footins\endcsname + \ifcsstring{Xragged@#1}{L}{\RaggedLeft}{}% + \ifcsstring{Xragged@#1}{R}{\RaggedRight}{}% \makehboxofhboxes \setbox0=\hbox{{\csuse{Xnotefontsize@#1}\csuse{txtbeforeXnotes@#1}}\unhbox0 \removehboxes}% \csuse{Xnotefontsize@#1} @@ -1706,11 +1656,15 @@ \ifl@dpairing% \else% \@nameuse{#1footnoterule}% + \vskip\csuse{afterXrule@#1}% \fi% \else% \@nameuse{#1footnoterule}% + \vskip\csuse{afterXrule@#1}% \fi% \unvbox\csname mp#1footins\endcsname + \ifcsstring{Xragged@#1}{L}{\RaggedLeft}{}% + \ifcsstring{Xragged@#1}{R}{\RaggedRight}{}% \makehboxofhboxes \setbox0=\hbox{{\csuse{Xnotefontsize@#1}\csuse{txtbeforeXnotes@#1}}\unhbox0 \removehboxes}% \csuse{Xnotefontsize@#1} @@ -1806,9 +1760,11 @@ \ifl@dpairing% \else% \@nameuse{#1footnoterule}% + \vskip\csuse{afterXrule@#1}% \fi% \else% \@nameuse{#1footnoterule}% + \vskip\csuse{afterXrule@#1}% \fi% {\csuse{Xnotefontsize@#1}\noindent\csuse{txtbeforeXnotes@#1}}\par \splittopskip=\ht\strutbox @@ -1868,9 +1824,11 @@ \ifl@dpairing% \else% \@nameuse{#1footnoterule}% + \vskip\csuse{afterXrule@#1}% \fi% \else% \@nameuse{#1footnoterule}% + \vskip\csuse{afterXrule@#1}% \fi% {\csuse{Xnotefontsize@#1}\noindent\csuse{txtbeforeXnotes@#1}}\par \splittopskip=\ht\strutbox @@ -1984,7 +1942,8 @@ \vskip\skip\csname footins#1\endcsname% \leftskip=\z@ \rightskip=\z@ - \@nameuse{footnoterule#1}} + \@nameuse{footnoterule#1}% + \vskip\csuse{afterruleX@#1}} \let\normalfootnoteruleX=\footnoterule @@ -2002,9 +1961,11 @@ \ifl@dpairing% \else% \@nameuse{footnoterule#1}% + \vskip\csuse{afterruleX@#1}% \fi% \else% \@nameuse{footnoterule#1}% + \vskip\csuse{afterruleX@#1}% \fi% \unvbox\@nameuse{mpfootins#1}} @@ -2102,9 +2063,11 @@ \ifl@dpairing% \else% \@nameuse{footnoterule#1}% + \vskip\csuse{afterruleX@#1}% \fi% \else% \@nameuse{footnoterule#1}% + \vskip\csuse{afterruleX@#1}% \fi% \splittopskip=\ht\strutbox \expandafter @@ -2163,9 +2126,11 @@ \ifl@dpairing% \else% \@nameuse{footnoterule#1}% + \vskip\csuse{afterruleX@#1}% \fi% \else% \@nameuse{footnoterule#1}% + \vskip\csuse{afterruleX@#1}% \fi% \splittopskip=\ht\strutbox \expandafter @@ -2180,9 +2145,13 @@ \expandafter\let\csname footgroup#1\endcsname=\para@footgroupX \expandafter\let\csname footnoterule#1\endcsname=\normalfootnoteruleX \count\csname footins#1\endcsname=1000 + \dimen\csname footins#1\endcsname=\csuse{maxhnotesX@#1} + \skip\csname footins#1\endcsname=\csuse{beforenotesX@#1} \expandafter\let\csname mpvfootnote#1\endcsname=\mppara@vfootnoteX \expandafter\let\csname mpfootgroup#1\endcsname=\mppara@footgroupX \count\csname mpfootins#1\endcsname=1000 + \dimen\csname mpfootins#1\endcsname=\csuse{maxhnotesX@#1} + \skip\csname mpfootins#1\endcsname=\csuse{beforenotesX@#1} \para@footsetupX{#1}} \newcommand*{\para@footsetupX}[1]{{\csuse{notefontsizeX@#1} @@ -2205,7 +2174,9 @@ \rightskip=\z@ \parindent=\z@ \vskip\skip\@nameuse{footins#1}% - \@nameuse{footnoterule#1}} + \@nameuse{footnoterule#1}% + \vskip\csuse{afterruleX@#1}% + } \newcommand*{\para@vfootnoteX}[2]{% \insert\csname footins#1\endcsname @@ -2246,6 +2217,8 @@ \newcommand*{\para@footgroupX}[1]{% \unvbox\csname footins#1\endcsname + \ifcsstring{raggedX@#1}{L}{\RaggedLeft}{}% + \ifcsstring{raggedX@#1}{R}{\RaggedRight}{}% \makehboxofhboxes \setbox0=\hbox{\unhbox0 \removehboxes}% \csuse{notefontsizeX@#1} @@ -2262,11 +2235,15 @@ \ifl@dpairing% \else% \@nameuse{footnoterule#1}% + \vskip\csuse{afterruleX@#1}% \fi% \else% \@nameuse{footnoterule#1}% + \vskip\csuse{afterruleX@#1}% \fi% \unvbox\csname mpfootins#1\endcsname + \ifcsstring{raggedX@#1}{L}{\RaggedLeft}{}% + \ifcsstring{raggedX@#1}{R}{\RaggedRight}{}% \makehboxofhboxes \setbox0=\hbox{\unhbox0 \removehboxes}% \csuse{notefontsizeX@#1} @@ -2375,10 +2352,12 @@ \newcommand{\newseries@}[1]{ \xifinlist{#1}{\@series}{\eledmac@warning{Series #1 is still existing !}} {% -\newtoggle{Xlemmadisablefontselection@#1} -\newtoggle{Xendlemmadisablefontselection@#1} + \newtoggle{Xlemmadisablefontselection@#1} + \newtoggle{Xendlemmadisablefontselection@#1} \csgdef{Xhangindent@#1}{0pt}% - \csgdef{hangindentX@#1}{0pt} + \csgdef{hangindentX@#1}{0pt}% + \csgdef{Xragged@#1}{}% + \csgdef{raggedX@#1}{}% \csgdef{hsizetwocol@#1}{0.45 \hsize}% \csgdef{hsizetwocolX@#1}{0.45 \hsize}% \csgdef{hsizethreecol@#1}{.3 \hsize}% @@ -2414,6 +2393,8 @@ \csgdef{parafootsep@#1}{\parafootftmsep}% \csgdef{beforeXnotes@#1}{1.2em \@plus .6em \@minus .6em} \csgdef{beforenotesX@#1}{1.2em \@plus .6em \@minus .6em} + \csgdef{afterXrule@#1}{0pt} + \csgdef{afterruleX@#1}{0pt} \csgdef{txtbeforeXnotes@#1}{} \csgdef{maxhnotesX@#1}{\ledfootinsdim}% \csgdef{maxhXnotes@#1}{\ledfootinsdim} @@ -2538,6 +2519,10 @@ \newhookcommand@series{hangindentX} +\newhookcommand@series{Xragged} + +\newhookcommand@series{raggedX} + \newhookcommand@series{hsizetwocol} \newhookcommand@series{hsizethreecol} @@ -2594,6 +2579,10 @@ \newhookcommand@series{txtbeforeXnotes} +\newhookcommand@series{afterruleX} + +\newhookcommand@series{afterXrule} + \newcommand{\newhookcommand@series@reload}[1]{% \global\expandafter\newcommand\expandafter*\csname #1\endcsname[2][]{% \csuse{setcommand@series}{##1}{#1}{##2}[reload] @@ -2890,6 +2879,7 @@ \fi \protected@write\@auxout{}% {\string\l@dmake@labels\space\thepage|\label@refs|\the\c@pstart|{#1}}% + \ifcsdef{hypertarget}{\hypertarget{#1}{}}{}% \@esphack} \newcounter{line}% @@ -2923,17 +2913,23 @@ {\linenumrep{\line@num}|% \ifsublines@ \sublinenumrep{\subline@num}\else 0\fi}\to\labelref@list} -\newcommand*{\edpageref}[1]{\l@dref@undefined{#1}\l@dgetref@num{1}{#1}} +\newcommand{\wrap@edcrossref}[2]{% + \ifdef{\hyperlink}% + {\hyperlink{#1}{#2}}% + {#2} +} +\newcommand*{\edpageref}[1]{\l@dref@undefined{#1}\wrap@edcrossref{#1}{\l@dgetref@num{1}{#1}}} \newcommand*{\xpageref}[1]{\l@dgetref@num{1}{#1}} -\newcommand*{\lineref}[1]{\l@dref@undefined{#1}\l@dgetref@num{2}{#1}} +\newcommand*{\lineref}[1]{\l@dref@undefined{#1}\wrap@edcrossref{#1}{\l@dgetref@num{2}{#1}}} \newcommand*{\xlineref}[1]{\l@dgetref@num{2}{#1}} -\newcommand*{\sublineref}[1]{\l@dref@undefined{#1}\l@dgetref@num{3}{#1}} +\newcommand*{\sublineref}[1]{\l@dref@undefined{#1}\wrap@edcrossref{#1}{\l@dgetref@num{3}{#1}}} \newcommand*{\xsublineref}[1]{\l@dgetref@num{3}{#1}} -\newcommand*{\pstartref}[1]{\l@dref@undefined{#1}\l@dgetref@num{4}{#1}} +\newcommand*{\pstartref}[1]{\l@dref@undefined{#1}\wrap@edcrossref{#1}{\l@dgetref@num{4}{#1}}} \newcommand*{\xpstartref}[1]{\l@dgetref@num{4}{#1}} + \newcommand*{\l@dref@undefined}[1]{% \expandafter\ifx\csname the@label#1\endcsname\relax \led@warn@RefUndefined{#1}% @@ -2986,7 +2982,11 @@ \newcommand*{\sidenotemargin}[1]{{% \l@dgetsidenote@margin{#1}% \ifnum\@l@dtempcntb>\m@ne - \global\sidenote@margin=\@l@dtempcntb + \ifledRcol + \global\sidenote@marginR=\@l@dtempcntb + \else + \global\sidenote@margin=\@l@dtempcntb + \fi \fi}} \newcommand*{\l@dgetsidenote@margin}[1]{% \def\@tempa{#1}\def\@tempb{left}% @@ -3025,36 +3025,108 @@ \newcommand*{\ledleftnote}[1]{\edtext{}{\l@dlsnote{#1}}} \newcommand*{\ledrightnote}[1]{\edtext{}{\l@drsnote{#1}}} -\newcommand*{\ledsidenote}[1]{\edtext{}{\l@dcsnote{#1}}} +\newcommand*{\ledinnernote}[1]{% + \ifodd\page@num% + \ledleftnote{#1}% + \else% + \ledrightnote{#1}% + \fi% +} + +\newcommand*{\ledouternote}[1]{% + \ifodd\page@num% + \ledrightnote{#1}% + \else% + \ledleftnote{#1}% + \fi% +} + +\newcommand*{\ledsidenote}[1]{\edtext{}{\l@dcsnote{#1}}} \newif\ifrightnoteup \rightnoteuptrue + \newcommand*{\l@dlsnote}[1]{% \begingroup% \newcommand{\content}{#1}% \ifnumberedpar@ - \xright@appenditem{\noexpand\vl@dlsnote{\csexpandonce{content}}}% - \to\inserts@list - \global\advance\insert@count \@ne + \ifledRcol% + \xright@appenditem{\noexpand\vl@dlsnote{\csexpandonce{content}}}% + \to\inserts@listR + \global\advance\insert@countR \@ne% + \else% + \xright@appenditem{\noexpand\vl@dlsnote{\csexpandonce{content}}}% + \to\inserts@list + \global\advance\insert@count \@ne% + \fi \fi\ignorespaces\endgroup} + \newcommand*{\l@drsnote}[1]{% \begingroup% \newcommand{\content}{#1}% \ifnumberedpar@ - \xright@appenditem{\noexpand\vl@drsnote{\csexpandonce{content}}}% - \to\inserts@list - \global\advance\insert@count \@ne + \ifledRcol% + \xright@appenditem{\noexpand\vl@drsnote{\csexpandonce{content}}}% + \to\inserts@listR + \global\advance\insert@countR \@ne% + \else% + \xright@appenditem{\noexpand\vl@drsnote{\csexpandonce{content}}}% + \to\inserts@list + \global\advance\insert@count \@ne% + \fi \fi\ignorespaces\endgroup} -\newcommand*{\l@dcsnote}[1]{\begingroup% + +\newcommand*{\l@dcsnote}[1]{% + \begingroup% \newcommand{\content}{#1}% \ifnumberedpar@ - \xright@appenditem{\noexpand\vl@dcsnote{\csexpandonce{content}}}% - \to\inserts@list - \global\advance\insert@count \@ne + \ifledRcol% + \xright@appenditem{\noexpand\vl@dcsnote{\csexpandonce{content}}}% + \to\inserts@listR + \global\advance\insert@countR \@ne% + \else% + \xright@appenditem{\noexpand\vl@dcsnote{\csexpandonce{content}}}% + \to\inserts@list + \global\advance\insert@count \@ne% + \fi \fi\ignorespaces\endgroup} -\newcommand*{\vl@dlsnote}[1]{\setl@dlp@rbox{#1}} -\newcommand*{\vl@drsnote}[1]{\setl@drp@rbox{#1}} +\newcommand*{\vl@dlsnote}[1]{% + \ifledRcol@% + \@l@dtempcntb=\sidenote@marginR% + \ifnum\@l@dtempcntb>\@ne% + \advance\@l@dtempcntb by\page@numR% + \fi% + \else% + \@l@dtempcntb=\sidenote@margin% + \ifnum\@l@dtempcntb>\@ne% + \advance\@l@dtempcntb by\page@num% + \fi% + \fi% + \ifodd\@l@dtempcntb% + \listgadd{\l@dcsnotetext@l}{#1}% + \else% + \listgadd{\l@dcsnotetext}{#1}% + \fi +} +\newcommand*{\vl@drsnote}[1]{% + \ifledRcol@% + \@l@dtempcntb=\sidenote@marginR% + \ifnum\@l@dtempcntb>\@ne% + \advance\@l@dtempcntb by\page@numR% + \fi% + \else% + \@l@dtempcntb=\sidenote@margin% + \ifnum\@l@dtempcntb>\@ne% + \advance\@l@dtempcntb by\page@num% + \fi% + \fi% + \ifodd\@l@dtempcntb% + \listgadd{\l@dcsnotetext}{#1}% + \else% + \listgadd{\l@dcsnotetext@r}{#1}% + \fi% +} \newcommand*{\vl@dcsnote}[1]{\listgadd{\l@dcsnotetext}{#1}} \newcommand*{\setl@dlp@rbox}[1]{% @@ -3104,21 +3176,32 @@ \fi% \ifodd\@l@dtempcntb% \setl@drp@rbox{\sidenotecontent@}% + \gdef\sidenotecontent@{}% + \numdef{\itemcount@}{0}% + \dolistloop{\l@dcsnotetext@l}% + \ifnumgreater{\itemcount@}{1}{\eledmac@warning{\itemcount@\space leftnotes on line \the\line@num\space p. \the\page@num,}}{}% + \setl@dlp@rbox{\sidenotecontent@}% \else% \setl@dlp@rbox{\sidenotecontent@}% + \gdef\sidenotecontent@{}% + \numdef{\itemcount@}{0}% + \dolistloop{\l@dcsnotetext@r}% + \ifnumgreater{\itemcount@}{1}{\eledmac@warning{\itemcount@\space rightnotes on line \the\line@num\space p. \the\page@num,}}{}% + \setl@drp@rbox{\sidenotecontent@}% \fi% \fi% -\fi} + \fi% +} \newcommand*{\l@dfeetbeginmini}{\l@dedbeginmini\l@dfambeginmini} \newcommand*{\l@dfeetendmini}{% -\IfStrEq{critical-familiar}{\@mpfnpos}% -{\l@dedendmini\l@dfamendmini}% -{% -\IfStrEq{familiar-critical}{\@mpfnpos}% -{\l@dfamendmini\l@dedendmini}% -{\l@dedendmini\l@dfamendmini}% -}% -}% + \IfStrEq{critical-familiar}{\@mpfnpos}% + {\l@dedendmini\l@dfamendmini}% + {% + \IfStrEq{familiar-critical}{\@mpfnpos}% + {\l@dfamendmini\l@dedendmini}% + {\l@dedendmini\l@dfamendmini}% + }% + }% \newcommand*{\l@dedbeginmini}{% \def\do##1{\csletcs{v##1footnote}{mpv##1footnote}}% \dolistloop{\@series}% @@ -3241,6 +3324,13 @@ \newif\ifledgroupnotesL@ \newif\ifledgroupnotesR@ +\newif\ifeledmac@after@imakeidx@ +\@ifpackageloaded{imakeidx}{\eledmac@after@imakeidx@true}{} +\AtBeginDocument{% + \ifeledmac@after@imakeidx@\else% + \@ifpackageloaded{imakeidx}{\eledmac@error{Imakeidx must be loaded before eledmac.}}{}% + \fi +} \newcommand{\pagelinesep}{-} \newcommand{\edindexlab}{$&} \newcounter{labidx} @@ -3250,7 +3340,7 @@ \edlabel{\edindexlab\thelabidx}} \newcommand{\thepageline}{% - \thepage\pagelinesep\lineref{\edindexlab\thelabidx}} + \thepage\pagelinesep\xlineref{\edindexlab\thelabidx}} \newcommand{\thestartpageline}{\l@dparsedstartpage\pagelinesep\l@dparsedstartline} \newcommand{\theendpageline}{\l@dparsedendpage\pagelinesep\l@dparsedendline} \newif\if@edindex@fornote@ @@ -3258,7 +3348,21 @@ \l@dp@rsefootspec#1|% \@edindex@fornote@true } -\def\get@index@command#1|#2{\gdef\@index@command{#2}\gdef\@index@txt{#1}} +\def\get@index@command#1|#2+{% + \gdef\@index@txt{#1}% + \gdef\@index@command{#2}% + \xdef\@index@parenthesis{}% + \IfBeginWith{\@index@command}{(}{% + \StrGobbleLeft{\@index@command}{1}[\@index@command@]% + \global\let\@index@command\@index@command@% + \xdef\@index@parenthesis{(}% + }{}% + \IfBeginWith{\@index@command}{)}{% + \StrGobbleLeft{\@index@command}{1}[\@index@command@]% + \global\let\@index@command\@index@command@% + \xdef\@index@parenthesis{)}% + }{}% +} \newcommand{\ledinnote}[2]{\csuse{#1}{#2\emph{n}}} \newcommand{\ledinnotehyperpage}[2]{\csuse{#1}{\hyperpage{#2}\emph{n}}} \@ifclassloaded{memoir}{% @@ -3326,18 +3430,19 @@ \@sanitize \@wredindex}}{}{} \newcommand{\edindex}[1]{\@bsphack\@esphack} - \newcommandx{\@wredindex}[2][1=\jobname,usedefault]{%#1 = the index name, #2 = the text + \newcommandx{\@wredindex}[2][1=\expandonce\jobname,usedefault]{%#1 = the index name, #2 = the text \ifl@imakeidx% \if@edindex@fornote@% - \IfSubStr[1]{#2}{|}{\get@index@command#2}{\get@index@command#2|}% + \IfSubStr[1]{#2}{|}{\get@index@command#2+}{\get@index@command#2|+}% \expandafter\imki@wrindexentry{#1}{\@index@txt|(ledinnote{\@index@command}}{\thestartpageline}% \expandafter\imki@wrindexentry{#1}{\@index@txt|)ledinnote{\@index@command}}{\theendpageline}% \else% - \imki@wrindexentry{#1}{#2}{\thepageline}% + \get@edindex@hyperref{#2}% + \imki@wrindexentry{#1}{\@index@txt\@edindex@hyperref}{\thepageline}% \fi% \else% \if@edindex@fornote@% - \IfSubStr[1]{#2}{|}{\get@index@command#2}{\get@index@command#2|}% + \IfSubStr[1]{#2}{|}{\get@index@command#2+}{\get@index@command#2|+}% \expandafter\protected@write\@indexfile{}% {\string\indexentry{\@index@txt|(ledinnote{\@index@command}}{\thestartpageline} }% @@ -3354,10 +3459,27 @@ \@esphack} } +\newcommand{\hyperlinkformat}[3]{% + \ifstrempty{#1}% + {\hyperlink{#2}{#3}}% + {\csuse{#1}{\hyperlink{#2}{#3}}% + }} +\newcommand{\get@edindex@hyperref}[1]{% + \ifcsdef{hyperlink}% + {\IfSubStr{#1}{|}% + {\get@index@command#1+% + \gdef\@edindex@hyperref{|\@index@parenthesis % + hyperlinkformat{\@index@command} + {\edindexlab\thelabidx}}}% + {\get@index@command#1|+ + \gdef\@edindex@hyperref{|hyperlink{\edindexlab\thelabidx}}}% + }% + {\gdef\@edindex@hyperref{}}% +} \AtBeginDocument{\@ifpackageloaded{hyperref}{}{% \def\l@d@@wrindexhyp#1||\\{% \ifshowindexmark\@showidx{#1}\fi - \IfSubStr[1]{#1}{|}{\get@index@command#1}{\get@index@command#1|}% + \IfSubStr[1]{#1}{|}{\get@index@command#1+}{\get@index@command#1|+}% \if@edindex@fornote@% \protected@write\@auxout{}% {\string\@@wrindexm@m{\@idxfile}{\@index@txt|(ledinnote{\@index@command}}{\thestartpageline}}% @@ -3446,7 +3568,7 @@ \stanza@modulo\@ne \fi } -\def\stanza@line{ +\newcommandx{\stanza@line}[1][1]{ \ifnum\value{stanzaindentsrepetition}=0 \parindent=\csname sza@\number\stanza@count @\endcsname\stanzaindentbase @@ -3455,7 +3577,7 @@ @\endcsname\stanzaindentbase \managestanza@modulo \fi - \pstart\stanza@hang\ignorespaces} + \pstart[#1]\stanza@hang\ignorespaces} \xdef\stanza@hang{\noexpand\leavevmode\noexpand\startlock \hangindent\expandafter \noexpand\csname sza@0@\endcsname\stanzaindentbase @@ -3465,26 +3587,41 @@ \penalty\fi\count@} \let\startstanzahook\relax \let\endstanzaextra\relax -\xdef\stanza{\noexpand\instanzatrue\expandafter - \begingroup\startstanzahook% - \catcode`\noexpand\&\active% - \global\stanza@count\@ne\stanza@modulo\@ne - \noexpand\ifnum\expandafter\noexpand - \csname sza@0@\endcsname=\z@\let\noexpand\stanza@hang\relax - \let\noexpand\endlock\relax\noexpand\else\interlinepenalty - \@M\rightskip\z@ plus 1fil\relax\noexpand\fi\noexpand\ifnum - \expandafter\noexpand\csname szp@0@\endcsname=\z@ - \let\noexpand\sza@penalty\relax\noexpand\fi% +\xdef\@startstanza[#1]{% + \noexpand\instanzatrue\expandafter + \begingroup\startstanzahook% + \catcode`\noexpand\&\active% + \global\stanza@count\@ne\stanza@modulo\@ne + \noexpand\ifnum\expandafter\noexpand + \csname sza@0@\endcsname=\z@\let\noexpand\stanza@hang\relax + \let\noexpand\endlock\relax\noexpand\else\interlinepenalty + \@M\rightskip\z@ plus 1fil\relax\noexpand\fi\noexpand\ifnum + \expandafter\noexpand\csname szp@0@\endcsname=\z@ + \let\noexpand\sza@penalty\relax\noexpand\fi% \def\noexpand\falseverse{% + \noexpand\eledmac@warning{\string\falseverse\space deprecated. Look at \string\newverse\space instead.} \global\advance\stanza@modulo-\@ne% \global\advance\stanza@count-\@ne% \relax\noexpand&\leavevmode\skipnumbering} - \def\noexpand&{% - \noexpand\endlock\noexpand\pend\noexpand\sza@penalty\global% - \advance\stanza@count\@ne\noexpand\stanza@line}% - \def\noexpand% - \&{\noexpand\endlock\noexpand\pend\endgroup\noexpand\instanzafalse\expandafter\endstanzaextra}% - \noexpand\stanza@line} + \def\noexpand&{% + \noexpand\newverse[][]}% + \def\noexpand\&{\noexpand\@stopstanza}% + \noexpand\stanza@line[#1]} + +\newcommandx{\stanza}[1][1,usedefault]{\@startstanza[#1]} + +\newcommandx{\@stopstanza}[1][1,usedefault]{% + \endlock% + \pend[#1]% + \endgroup% + \instanzafalse% + \endstanzaextra% +} + +\newcommandx*{\newverse}[2][1,2,usedefault]{% + \endlock\pend[#1]\sza@penalty\global% + \advance\stanza@count\@ne\stanza@line[#2]% + } \newcommand*{\flagstanza}[2][\stanzaindentbase]{% \hskip -#1\llap{#2}\hskip #1\ignorespaces} @@ -4107,6 +4244,499 @@ \usingedtext +\newcommand{\initnumbering@sectcmd}{ + \newcommand{\ledsection}[2][]{\eledmac@warning{\string\ledsection\space deprecated}% + \leavevmode\pend\vspace{3.5ex \@plus 1ex \@minus .2ex}\ifl@dpairing\else\skipnumbering\fi%% + \pstart% + \leavevmode\ifledsecnolinenumber\skipnumbering\fi\section[##1]{##2}\leavevmode\vspace{2.3ex \@plus.2ex}\skipnumbering\pend% + \vspace{-2\parskip}\vspace{-2\baselineskip}% + \ifautopar\else\pstart\fi + } + \WithSuffix\newcommand\ledsection*[1]{\eledmac@warning{\string\ledsection*\space deprecated}% + \leavevmode\pend\vspace{3.5ex \@plus 1ex \@minus .2ex}\ifl@dpairing\else\skipnumbering\fi% + \pstart% + \leavevmode\ifledsecnolinenumber\skipnumbering\fi\section*{##1}\leavevmode\vspace{2.3ex \@plus.2ex}\skipnumbering\pend% + \vspace{-2\parskip}\vspace{-2\baselineskip}% + \ifautopar\else\pstart\fi + } + \newcommand{\ledsubsection}[2][]{\eledmac@warning{\string\ledsubsection*\space deprecated}% + \leavevmode\pend\vspace{3.5ex \@plus 1ex \@minus .2ex}\ifl@dpairing\else\skipnumbering\fi% + \pstart% + \leavevmode\ifledsecnolinenumber\skipnumbering\fi\subsection[##1]{##2}\leavevmode\vspace{1.5ex \@plus .2ex}\skipnumbering\pend% + \vspace{-2\parskip}\vspace{-2\baselineskip}% + \ifautopar\else\pstart\fi + } + \WithSuffix\newcommand\ledsubsection*[1]{\eledmac@warning{\string\ledsubsection*\space deprecated}% + \leavevmode\pend\vspace{3.5ex \@plus 1ex \@minus .2ex}\ifl@dpairing\else\skipnumbering\fi% + \pstart% + \leavevmode\ifledsecnolinenumber\skipnumbering\fi\subsection*{##1}\leavevmode\vspace{1.5ex \@plus .2ex}\skipnumbering\pend% + \vspace{-2\parskip}\vspace{-2\baselineskip}% + \ifautopar\else\pstart\fi + } + \newcommand{\ledsubsubsection}[2][]{\eledmac@warning{\string\ledsubsubsection*\space deprecated}% + \leavevmode\pend\vspace{3.5ex \@plus 1ex \@minus .2ex}\ifl@dpairing\else\skipnumbering\fi% + \pstart% + \leavevmode\ifledsecnolinenumber\skipnumbering\fi\subsubsection[##1]{##2}\leavevmode\vspace{1.5ex \@plus .2ex}\skipnumbering\pend% + \vspace{-2\parskip}\vspace{-2\baselineskip}% + \ifautopar\else\pstart\fi + } + \WithSuffix\newcommand\ledsubsubsection*[1]{\eledmac@warning{\string\ledsubsubsection*\space deprecated}% + \leavevmode\pend\vspace{3.5ex \@plus 1ex \@minus .2ex}\ifl@dpairing\else\skipnumbering\fi% + \pstart% + \leavevmode\ifledsecnolinenumber\skipnumbering\fi\subsubsection*{##1}\leavevmode\vspace{1.5ex \@plus .2ex}\skipnumbering\pend% + \vspace{-2\parskip}\vspace{-2\baselineskip}% + \ifautopar\else\pstart\fi + } + \newcommand\ledchapter[2][]{% + \eledmac@warning{\string\ledchapter\space deprecated}% + \ifl@dmemoir% + \gdef\ch@pt@c{##1}% + \fi% + ~\pend\skipnumbering% + \pstart% + \@patchforledchapter\chapter[##1]{##2}% + \pend\pstart} + \WithSuffix\newcommand\ledchapter*[1]{% + \eledmac@warning{\string\ledchapter*\space deprecated}% + ~\pend\skipnumbering% + \pstart% + \@patchforledchapter\chapter*{##1}\pend% + \pstart} + \def\@patchforledchapter{ + \patchcmd{\@makeschapterhead}{1\par}{1}{}{} + \pretocmd{\@makeschapterhead}{\par}{}{} + \apptocmd{\@makeschapterhead}{\par}{}{} + \patchcmd{\@makeschapterhead}{\vskip 40\p@}{}{}{} + \patchcmd{\@makechapterhead}{1\par}{1}{}{} + \pretocmd{\@makechapterhead}{\par}{}{} + \apptocmd{\@makechapterhead}{\par}{}{} + \patchcmd{\@makechapterhead}{\vskip 40\p@}{}{}{} + \apptocmd{\@chapter}{\par\leavevmode\vspace{40 \p@}\skipnumbering}{}{} + \apptocmd{\@schapter}{\par\leavevmode\vspace{40 \p@}\skipnumbering}{}{} + \newcommand\beforeledchapter{\pend\cleardoublepage\pstart} + \patchcmd{\chapter}{\cleardoublepage}{\relax}{}{} + \patchcmd{\chapter}{\clearpage}{\relax}{}{} + } + \ifnoquotation@\else + \renewcommand{\quotation}{\par\leavevmode% + \parindent=1.5em% + \skipnumbering% + \ifautopar% + \vskip-\parskip% + \else% + \vskip\topsep% + \fi% + \global\leftskip=\leftmargin% + \global\rightskip=\leftmargin% + } + \renewcommand{\endquotation}{\par% + \global\leftskip=0pt% + \global\rightskip=0pt% + \leavevmode% + \skipnumbering% + \ifautopar% + \vskip-\parskip% + \else% + \vskip\topsep% + \fi% + } + \renewcommand{\quote}{\par\leavevmode% + \parindent=0pt% + \skipnumbering% + \ifautopar% + \vskip-\parskip% + \else% + \vskip\topsep% + \fi% + \global\leftskip=\leftmargin% + \global\rightskip=\leftmargin% + } + \renewcommand{\endquote}{\par% + \global\leftskip=0pt% + \global\rightskip=0pt% + \leavevmode% + \skipnumbering% + \ifautopar% + \vskip-\parskip% + \else% + \vskip\topsep% + \fi% + } + \fi +} +\newcommand{\ledsectnotoc}{\let\addcontentsline\@gobblethree} +\newcommand{\ledsectnomark}{% + \let\chaptermark\@gobble% + \let\sectionmark\@gobble% + \let\subsectionmark\@gobble% +} +\ifl@dmemoir + \newcommand\beforeeledchapter{\clearforchapter} +\else + \newcommand\beforeeledchapter{\if@openright\cleardoublepage\else\clearpage\fi} +\fi +\newif\if@eled@sectioning +\def\print@rightmargin@eledsection{% + \if@eled@sectioning% + \begingroup% + \if@RTL% + \let\llap\rlap% + \let\leftlinenum\rightlinenum% + \let\leftlinenumR\rightlinenumR% + \let\l@drd@ta\l@dld@ta% + \let\l@drsn@te\l@dlsn@te% + \fi% + \hfill\l@drd@ta \csuse{LR}{\l@drsn@te}% + \endgroup% + \fi% +}% + +\def\print@leftmargin@eledsection{% + \if@eled@sectioning% + \leavevmode% + \begingroup% + \if@RTL% + \let\rlap\llap% + \let\rightlinenum\leftlinenum% + \let\rightlinenumR\leftlinenumR% + \let\l@dld@ta\l@drd@ta% + \let\l@dlsn@te\l@drsn@te% + \fi% + \l@dld@ta\csuse{LR}{\l@dlsn@te}% + \endgroup% + \fi% +}% + +\catcode`\#=12 % Space NEEDS by \catcode +\AtBeginDocument{% +\patchcmd{\chapter}{\clearforchapter}{% + \ifnumbering\else% + \clearforchapter + \fi% + } + {} + {} + +\pretocmd{\M@sect} + {\let\old@edtext=\edtext% + \let\edtext=\dummy@edtext% + } + {} + {} + +\apptocmd{\M@sect} + {\let\edtext=\old@edtext} + {} + {} + +\patchcmd{\M@sect} + { #9} + { #9% + \print@rightmargin@eledsection% + } + {} + {} + +\patchcmd{\M@sect} + {\hskip #3\relax} + {\hskip #3\relax% + \print@leftmargin@eledsection% + } + {} + {} + +\pretocmd{\@mem@old@ssect} + {\let\old@edtext=\edtext% + \let\edtext=\dummy@edtext% + } + {} + {} + +\apptocmd{\@mem@old@ssect} + {\let\edtext=\old@edtext} + {} + {} + +\patchcmd{\@mem@old@ssect} + {#5} + {#5% + \print@leftmargin@eledsection% + } + {} + {} + +\patchcmd{\@mem@old@ssect} + {\hskip #1} + {\hskip #1% + \print@rightmargin@eledsection% + } + {} + {} + +\patchcmd{\chapter}{\if@openright\cleardoublepage\else\clearpage\fi}{% + \if@eled@sectioning\else% + \leavevmode\if@openright\cleardoublepage\else\clearpage\fi%No clearpage inside a \eledsection : will make the critical notes not in the same page than title. + \fi% + }% + {}% + {}% + +\patchcmd{\@makechapterhead} + {#1} + {\print@leftmargin@eledsection% + #1% + \print@rightmargin@eledsection% + } + {} + {} + +\patchcmd{\@makechapterhead}% For BIDI + {\if@RTL\raggedleft\else\raggedright\fi}% + {\if@eled@sectioning\else% + \if@RTL\raggedleft\else\raggedright\fi% + \fi% + }% + {}% + {}% + +\patchcmd{\@makeschapterhead} + {#1} + {\print@leftmargin@eledsection% + #1% + \print@rightmargin@eledsection% + } + {} + {} + +\pretocmd{\@sect} + {\let\old@edtext=\edtext + \let\edtext=\dummy@edtext% + } + {} + {} + +\apptocmd{\@sect} + {\let\edtext=\old@edtext} + {} + {} + +\patchcmd{\@sect} + {#8} + {#8% + \print@rightmargin@eledsection% + } + {} + {} + +\patchcmd{\@sect} + {\hskip #3\relax} + {\hskip #3\relax% + \print@leftmargin@eledsection% + } + {} + {} + +\pretocmd{\@ssect} + {\let\old@edtext=\edtext% + \let\edtext=\dummy@edtext% + } + {} + {} + +\apptocmd{\@ssect} + {\let\edtext=\old@edtext} + {} + {} + +\patchcmd{\@ssect} + {#5} + {#5% + \print@rightmargin@eledsection% + } + {} + {} + +\patchcmd{\@ssect} + {\hskip #1} + {\hskip #1% + \print@leftmargin@eledsection% + } + {} + {} +}% +\catcode`\#=6 %Space NEEDS by \catcode +\newwrite\eled@sectioning@out +\newcommand{\eledchapter}[2][]{% + #2% + \ifledRcol% + \immediate\write\eled@sectioningR@out{% + \string\eled@chapter{#1}{\unexpanded{#2}}{\the\l@dnumpstartsR}{}{R} + }% + \else% + \immediate\write\eled@sectioning@out{% + \string\eled@chapter{#1}{\unexpanded{#2}}{\the\l@dnumpstartsL}{}{} + }% + \fi% +} + +\newcommand{\eledsection}[2][]{% + #2% + \ifledRcol% + \immediate\write\eled@sectioningR@out{% + \string\eled@section{#1}{\unexpanded{#2}}{\the\l@dnumpstartsR}{}{R} + }% + \else% + \immediate\write\eled@sectioning@out{% + \string\eled@section{#1}{\unexpanded{#2}}{\the\l@dnumpstartsL}{}{} + }% + \fi% +} + +\newcommand{\eledsubsection}[2][]{% + #2% + \ifledRcol% + \immediate\write\eled@sectioningR@out{% + \string\eled@subsection{#1}{\unexpanded{#2}}{\the\l@dnumpstartsR}{}{R} + }% + \else% + \immediate\write\eled@sectioning@out{% + \string\eled@subsection{#1}{\unexpanded{#2}}{\the\l@dnumpstartsL}{}{} + }% + \fi% +} +\newcommand{\eledsubsubsection}[2][]{% + #2% + \ifledRcol% + \immediate\write\eled@sectioningR@out{% + \string\eled@subsubsection{#1}{\unexpanded{#2}}{\the\l@dnumpstartsR}{}{R} + }% + \else% + \immediate\write\eled@sectioning@out{% + \string\eled@subsubsection{#1}{\unexpanded{#2}}{\the\l@dnumpstartsL}{}{} + }% + \fi% +} + +\WithSuffix\newcommand\eledchapter*[2][]{% + #2% + \ifledRcol% + \immediate\write\eled@sectioningR@out{% + \string\eled@chapter{#1}{\unexpanded{#2}}{\the\l@dnumpstartsR}{*}{R} + }% + \else% + \immediate\write\eled@sectioning@out{% + \string\eled@chapter{#1}{\unexpanded{#2}}{\the\l@dnumpstartsL}{*}{} + }% + \fi% +} + +\WithSuffix\newcommand\eledsection*[2][]{% + #2% + \ifledRcol% + \immediate\write\eled@sectioningR@out{% + \string\eled@section{#1}{\unexpanded{#2}}{\the\l@dnumpstartsR}{*}{R} + }% + \else% + \immediate\write\eled@sectioning@out{% + \string\eled@section{#1}{\unexpanded{#2}}{\the\l@dnumpstartsL}{*}{} + }% + \fi% +} + +\WithSuffix\newcommand\eledsubsection*[2][]{% + #2% + \ifledRcol% + \immediate\write\eled@sectioningR@out{% + \string\eled@subsection{#1}{\unexpanded{#2}}{\the\l@dnumpstartsR}{*}{R} + }% + \else% + \immediate\write\eled@sectioning@out{% + \string\eled@subsection{#1}{\unexpanded{#2}}{\the\l@dnumpstartsL}{*}{} + }% + \fi% +} + +\WithSuffix\newcommand\eledsubsubsection*[2][]{% + #2% + \ifledRcol% + \immediate\write\eled@sectioningR@out{% + \string\eled@subsubsection{#1}{\unexpanded{#2}}{\the\l@dnumpstartsR}{*}{R} + }% + \else% + \immediate\write\eled@sectioning@out{% + \string\eled@subsubsection{#1}{\unexpanded{#2}}{\the\l@dnumpstartsL}{*}{} + }% + \fi% +} +\def\eled@chapter#1#2#3#4#5{% + \ifstrempty{#4}% + {% + \ifstrempty{#1}% + {% + \global\csdef{eled@sectioning@#3#5}{\let\edtext=\dummy@edtext\chapter{#2}}% + \global\csdef{eled@sectmark@#3#5}{\let\edtext=\dummy@edtext{}\chaptermark{#2}}% + }%Need for \pairs, because of using parbox. + {% + \global\csdef{eled@sectioning@#3#5}{\let\edtext=\dummy@edtext\chapter[#1]{#2}}% + \global\csdef{eled@sectmark@#3#5}{\let\edtext=\dummy@edtext{}\chaptermark{#2}}%Need for \pairs, because of using parbox. + }% + }% + {% + \ifstrempty{#1}% + {\global\csdef{eled@sectioning@#3#5}{\let\edtext=\dummy@edtext\chapter*{#2}}} + {\global\csdef{eled@sectioning@#3#5}{\let\edtext=\dummy@edtext\chapter*[#1]{#2}}}%Bug in LaTeX! + }% + \listcsgadd{eled@sections#5@@}{#3}% + } +\def\eled@section#1#2#3#4#5{% + \ifstrempty{#4}% + {\ifstrempty{#1}% + {% + \global\csdef{eled@sectioning@#3#5}{\section{#2}}% + \global\csdef{eled@sectmark@#3#5}{\let\edtext=\dummy@edtext{}\sectionmark{#2}}%Need for \pairs, because of using parbox. + }% + {% + \global\csdef{eled@sectioning@#3#5}{\section[#1]{#2}}% + \global\csdef{eled@sectmark@#3#5}{\let\edtext=\dummy@edtext{}\sectionmark{#1}}%Need for \pairs, because of using parbox. + }% + }% + {\ifstrempty{#1}% + {\global\csdef{eled@sectioning@#3#5}{\section*{#2}}}% + {\global\csdef{eled@sectioning@#3#5}{\section*[#1]{#2}}}%Bug in LaTeX! + } + \listcsgadd{eled@sections#5@@}{#3}% + } +\def\eled@subsection#1#2#3#4#5{% + \ifstrempty{#4}% + {\ifstrempty{#1}% + {% + \global\csdef{eled@sectioning@#3#5}{\subsection{#2}}% + \global\csdef{eled@sectmark@#3#5}{\let\edtext=\dummy@edtext{}\csuse{subsectionmark}{#2}}%Need for \pairs, because of using parbox. \csuse in case of \subsectionmark is not defined (book) + }% + {% + \global\csdef{eled@sectioning@#3#5}{\subsection[#1]{#2}}% + \global\csdef{eled@sectmark@#3#5}{\let\edtext=\dummy@edtext{}\csuse{subsectionmark}{#1}}%Need for \pairs, because of using parbox. \csuse in case of \subsectionmark is not defined (book) + }% + }% + {\ifstrempty{#1}% + {\global\csdef{eled@sectioning@#3#5}{\subsection*{#2}}}% + {\global\csdef{eled@sectioning@#3#5}{\subsection*[#1]{#2}}}%Bug in LaTeX! + } + \listcsgadd{eled@sections#5@@}{#3}% + } +\def\eled@subsubsection#1#2#3#4#5{% + \ifstrempty{#4}% + {\ifstrempty{#1}% + {\global\csdef{eled@sectioning@#3#5}{\subsubsection{#2}}}% + {\global\csdef{eled@sectioning@#3#5}{\subsubsection[#1]{#2}}}% + }% + {\ifstrempty{#1}% + {\global\csdef{eled@sectioning@#3#5}{\subsubsection*{#2}}}% + {\global\csdef{eled@sectioning@#3#5}{\subsubsection*[#1]{#2}}}%Bug in LaTeX! + } + \listcsgadd{eled@sections#5@@}{#3}% + } + \def\normal@page@break{} \def\l@prev@pb{} \def\l@prev@nopb{} |