From 0f2554e35190347cfcf957be9952a319ce4a1b16 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Sun, 22 May 2022 20:24:55 +0000
Subject: bidi (22may22)

git-svn-id: svn://tug.org/texlive/trunk@63370 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/source/xelatex/bidi/bidi.dtx | 2156 ++++++++++++++----------
 1 file changed, 1223 insertions(+), 933 deletions(-)

(limited to 'Master/texmf-dist/source/xelatex/bidi/bidi.dtx')

diff --git a/Master/texmf-dist/source/xelatex/bidi/bidi.dtx b/Master/texmf-dist/source/xelatex/bidi/bidi.dtx
index 2814a223346..4b48ad45ea9 100644
--- a/Master/texmf-dist/source/xelatex/bidi/bidi.dtx
+++ b/Master/texmf-dist/source/xelatex/bidi/bidi.dtx
@@ -5,7 +5,7 @@
 %<*readme>
 ___________________
 The bidi package
-v36.8
+v36.9
 
 This package provides a convenient interface for typesetting
 bidirectional texts in Plain TeX and LaTeX, using XeTeX engine.
@@ -30,7 +30,7 @@ The announcements for the new releases of the package will
 also appear in the Discussions space under the Announcements
 category.
   
-Current version release date: 2022/05/20
+Current version release date: 2022/05/22
 
 ___________________________________________
 Vafa Khalighi
@@ -179,7 +179,6 @@ by Vafa Khalighi.
 \generate{\file{rotating-xetex-bidi.def}{\from{\jobname.dtx}{table,rotating-xetex-bidi.def}}}
 \generate{\file{scrartcl-xetex-bidi.def}{\from{\jobname.dtx}{table,scrartcl-xetex-bidi.def}}}
 \generate{\file{scrbook-xetex-bidi.def}{\from{\jobname.dtx}{table,scrbook-xetex-bidi.def}}}
-\generate{\file{scrlettr-xetex-bidi.def}{\from{\jobname.dtx}{table,scrlettr-xetex-bidi.def}}}
 \generate{\file{scrreprt-xetex-bidi.def}{\from{\jobname.dtx}{table,scrreprt-xetex-bidi.def}}}
 \generate{\file{sidecap-xetex-bidi.def}{\from{\jobname.dtx}{table,sidecap-xetex-bidi.def}}}
 \generate{\file{soul-xetex-bidi.def}{\from{\jobname.dtx}{table,soul-xetex-bidi.def}}}
@@ -235,7 +234,7 @@ by Vafa Khalighi.
 \documentclass{ltxdoc}
 \input{bidi-doc-preamble.ltx}
 \hypersetup{%
-  pdftitle={Source documentation for version 36.8 of the bidi
+  pdftitle={Source documentation for version 36.9 of the bidi
                 package}%
 }
 \EnableCrossrefs
@@ -254,7 +253,7 @@ by Vafa Khalighi.
 % \GetFileInfo{\jobname.dtx}
 % \title{\textcolor{blue!65!black}{\Huge The \textsf{bidi} \textit{Package}}\\
 %\LARGE Bidirectional typesetting in plain \TeX{} and \LaTeX, using \XeTeX{} engine\\[5pt]
-%\large Source documentation for \textcolor{blue!65!black}{version 36.8}}
+%\large Source documentation for \textcolor{blue!65!black}{version 36.9}}
 % \author{Vafa Khalighi\thanks{Thanks to the bidi-tex GitHub organization consisted of David Carlisle and other members of the  {\LaTeX} team to maintain the package in the period 2018--2020.}}
 %\setcounter{page}{0}
 %\thispagestyle{empty}
@@ -264,7 +263,7 @@ by Vafa Khalighi.
 %\textcolor{blue!65!black}{\Huge The \textsf{bidi} \textit{Package}}
 %
 %\Large
-%Source documentation for \textcolor{blue!65!black}{version 36.8}}
+%Source documentation for \textcolor{blue!65!black}{version 36.9}}
 %
 %\vskip 0pt plus 3fill
 %\textit{\large to my Master, \textbf{Ferdowsi The Great}}
@@ -313,7 +312,7 @@ by Vafa Khalighi.
 %\iffalse
 %<*table>
 %\fi
-%% \CheckSum{50563}
+%% \CheckSum{50672}
 %% \CharacterTable
 %%  {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
@@ -1933,8 +1932,8 @@ by Vafa Khalighi.
 % \section{File \texttt{bidi.sty}}
 %    \begin{macrocode}
 \NeedsTeXFormat{LaTeX2e}
-\def\bididate{2022/05/20}
-\def\bidi@version{36.8}
+\def\bididate{2022/05/22}
+\def\bidi@version{36.9}
 \ProvidesPackage{bidi}[\bididate\space v\bidi@version\space
 Bidirectional typesetting in plain TeX and LaTeX]
 \edef\@bidi@info{****************************************************^^J%
@@ -2022,7 +2021,7 @@ Bidirectional typesetting in plain TeX and LaTeX]
 }
 \newcommand*{\@bidi@pdfcustomproperties}{%
   This is the bidi package, Version \bidi@version,
-  Released May 20, 2022. 
+  Released May 22, 2022. 
 }
 \@RTLmainfalse
 \AtBeginDocument{%
@@ -2265,9 +2264,9 @@ Bidirectional typesetting in plain TeX and LaTeX]
 %\fi
 % \section{File \texttt{bidi.tex}}
 %    \begin{macrocode}
-\def\bididate{2022/05/20}
+\def\bididate{2022/05/22}
 \catcode`@=11
-\def\bidi@version{36.8}
+\def\bidi@version{36.9}
 \let \protect \relax
 \newlinechar`\^^J
 \edef\@bidi@info{****************************************************^^J%
@@ -2369,7 +2368,7 @@ Bidirectional typesetting in plain TeX and LaTeX]
 }
 \def\@bidi@pdfcustomproperties{%
   This is the bidi package, Version \bidi@version,
-  Released May 20, 2022. 
+  Released May 22, 2022. 
 }
 \def\bidi@pdfm@mark{%
   \special{pdf:%
@@ -18286,7 +18285,7 @@ to\rtside{\box\bslice\hfil}}
 %\fi
 % \section{File \texttt{scrartcl-xetex-bidi.def}}
 %    \begin{macrocode}
-\ProvidesFile{scrartcl-xetex-bidi.def}[2017/06/09 v1.1 bidi adaptations for scrartcl class for XeTeX engine]
+\ProvidesFile{scrartcl-xetex-bidi.def}[2022/05/22 v1.2 bidi adaptations for scrartcl class for XeTeX engine]
 \newcommand{\scr@saved@LTRfootnotetext}{}
 \newcommand{\scr@saved@RTLfootnotetext}{}
 \let\scr@saved@footnotetext\@footnotetext
@@ -18305,28 +18304,68 @@ to\rtside{\box\bslice\hfil}}
   \csname FN@mf@prepare\endcsname
 }
 \renewcommand\deffootnote[4][]{%
-  \long\def\@makefntext##1{%
-    \setlength{\@tempdimc}{#3}%
-    \def\@tempa{#1}\ifx\@tempa\@empty
-      \@setpar{\@@par
-        \@tempdima = \hsize
-        \addtolength{\@tempdima}{-#2}%
-        \if@RTL\parshape \@ne 0pt \@tempdima\else\parshape \@ne #2 \@tempdima\fi}%
-    \else
-      \addtolength{\@tempdimc}{#2}%
-      \addtolength{\@tempdimc}{-#1}%
-      \@setpar{\@@par
-        \@tempdima = \hsize
-        \addtolength{\@tempdima}{-#1}%
-        \@tempdimb = \hsize
-        \addtolength{\@tempdimb}{-#2}%
-        \if@RTL\parshape \tw@ 0pt \@tempdima 0pt \@tempdimb\else\parshape \tw@ #1 \@tempdima #2 \@tempdimb\fi
+  \expandafter\ifnum\scr@v@is@ge{3.22}\relax
+    \long\def\@makefntext##1{%
+      \ExecuteDoHook{footnote/text/begin}%
+      \raggedfootnote
+      \if@RTL
+        \rightskip
+      \else
+        \leftskip 
+      \fi 
+      #2
+      \l@addto@macro\@trivlist{%
+        \ifnum\@listdepth=\@ne
+          \if@RTL
+            \advance\rightmargin #2\relax
+          \else
+            \advance\leftmargin #2\relax
+          \fi
+        \fi
       }%
-    \fi
-    \par
-    \parindent\@tempdimc\noindent
-    \ftn@font\hbox to \z@{\hss\@@makefnmark}##1%
-  }%
+      \parindent #3\noindent
+      \IfArgIsEmpty{#1}{}{%
+        \hskip \dimexpr #1-#2\relax
+      }%
+      \ftn@font\hbox to \z@{\hss\@@makefnmark}##1%
+      \ExecuteDoHook{footnote/text/end}%
+    }%
+  \else
+    \ClassInfo{\KOMAClassName}{%
+      Using old \string\@makefntext\space due to compatibility
+      level\MessageBreak
+      less than 3.22}%
+    \long\def\@makefntext##1{%
+      \setlength{\@tempdimc}{#3}%
+      \def\@tempa{#1}\ifx\@tempa\@empty
+        \@setpar{\@@par
+          \@tempdima = \hsize
+          \addtolength{\@tempdima}{-#2}%
+          \if@RTL
+            \parshape \@ne \z@ \@tempdima
+          \else
+            \parshape \@ne #2 \@tempdima
+          \fi}%
+      \else
+        \addtolength{\@tempdimc}{#2}%
+        \addtolength{\@tempdimc}{-#1}%
+        \@setpar{\@@par
+          \@tempdima = \hsize
+          \addtolength{\@tempdima}{-#1}%
+          \@tempdimb = \hsize
+          \addtolength{\@tempdimb}{-#2}%
+           \if@RTL
+             \parshape \tw@ \z@ \@tempdima \z@ \@tempdimb
+           \else
+             \parshape \tw@ #1 \@tempdima #2 \@tempdimb
+           \fi
+        }%
+      \fi
+      \par
+      \parindent\@tempdimc\noindent
+      \ftn@font\hbox to \z@{\hss\@@makefnmark}##1%
+    }%
+  \fi
   \def\@@makefnmark{\hbox{\ftnm@font{#4}}}%
 }
 \deffootnote[1em]{1.5em}{1em}{\textsuperscript{\thefootnotemark}}
@@ -18345,11 +18384,48 @@ to\rtside{\box\bslice\hfil}}
       \hbox to \columnwidth{\hskip \dimexpr\columnwidth-\ftn@rule@width\relax  \leavevmode\leaders\hrule\@height\ftn@rule@height\hfill\kern\z@}}}%
   \kern 2.6\p@} 
 \renewcommand*\maketitle[1][1]{%
+  \expandafter\ifnum \csname scr@v@3.12\endcsname>\scr@compatibility\relax
+  \else
+    \def\and{%
+      \end{tabular}%
+      \hskip 1em \@plus.17fil%
+      \begin{tabular}[t]{c}%
+    }%
+  \fi
   \if@titlepage
     \begin{titlepage}
       \setcounter{page}{%
         #1%
       }%
+      \if@titlepageiscoverpage
+        \edef\titlepage@restore{%
+          \noexpand\endgroup
+          \noexpand\global\noexpand\@colht\the\@colht
+          \noexpand\global\noexpand\@colroom\the\@colroom
+          \noexpand\global\vsize\the\vsize
+          \noexpand\global\noexpand\@titlepageiscoverpagefalse
+          \noexpand\let\noexpand\titlepage@restore\noexpand\relax
+        }%
+        \begingroup
+        \topmargin=\dimexpr \coverpagetopmargin-1in\relax
+        \oddsidemargin=\dimexpr \coverpageleftmargin-1in\relax
+        \evensidemargin=\dimexpr \coverpageleftmargin-1in\relax
+        \textwidth=\dimexpr
+        \paperwidth-\coverpageleftmargin-\coverpagerightmargin\relax
+        \textheight=\dimexpr
+        \paperheight-\coverpagetopmargin-\coverpagebottommargin\relax
+        \headheight=0pt
+        \headsep=0pt
+        \footskip=\baselineskip
+        \@colht=\textheight
+        \@colroom=\textheight
+        \vsize=\textheight
+        \columnwidth=\textwidth
+        \hsize=\columnwidth
+        \linewidth=\hsize
+      \else
+        \let\titlepage@restore\relax
+      \fi
       \let\footnotesize\small
       \let\right@footnoterule\relax
       \let\left@footnoterule\relax
@@ -18360,54 +18436,97 @@ to\rtside{\box\bslice\hfil}}
       \renewcommand*\thefootnote{\@fnsymbol\c@footnote}%
       \let\@oldmakefnmark\@makefnmark
       \renewcommand*{\@makefnmark}{\rlap\@oldmakefnmark}%
-      \ifx\@extratitle\@empty \else
-        \noindent\@extratitle\next@tpage\cleardoubleemptypage
-        \thispagestyle{empty}%
+      \ifx\@extratitle\@empty
+        \ifx\@frontispiece\@empty
+        \else
+          \if@twoside\mbox{}\next@tpage\fi
+          \noindent\@frontispiece\next@tdpage
+        \fi
+      \else
+        \noindent\@extratitle
+        \ifx\@frontispiece\@empty
+        \else
+          \next@tpage
+          \noindent\@frontispiece
+        \fi
+        \next@tdpage
       \fi
       \setparsizes{\z@}{\z@}{\z@\@plus 1fil}\par@updaterelative
       \ifx\@titlehead\@empty \else
         \begin{minipage}[t]{\textwidth}%
-        \@titlehead
+          \usekomafont{titlehead}{\@titlehead\par}%
         \end{minipage}\par
       \fi
       \null\vfill
       \begin{center}
         \ifx\@subject\@empty \else
-          {\subject@font \@subject \par}%
+          {\usekomafont{subject}{\@subject\par}}%
           \vskip 3em
         \fi
-        {\titlefont\huge \@title\par}%
+        {\usekomafont{title}{\huge \@title\par}}%
         \vskip 1em
-        {\ifx\@subtitle\@empty\else\usekomafont{subtitle}\@subtitle\par\fi}%
+        {\ifx\@subtitle\@empty\else\usekomafont{subtitle}{\@subtitle\par}\fi}%
         \vskip 2em
-        {\Large \lineskip 0.75em
-          \begin{tabular}[t]{c}
-            \@author
-          \end{tabular}\par
+        {%
+          \usekomafont{author}{%
+            \lineskip 0.75em
+            \begin{tabular}[t]{c}
+              \@author
+            \end{tabular}\par
+          }%
         }%
         \vskip 1.5em
-        {\Large \@date \par}%
+        {\usekomafont{date}{\@date \par}}%
         \vskip \z@ \@plus3fill
-        {\Large \@publishers \par}%
+        {\usekomafont{publishers}{\@publishers \par}}%
         \vskip 3em
       \end{center}\par
-      \@thanks
+      \@thanks\global\let\@thanks\@empty
       \vfill\null
-      \if@twoside\next@tpage
-        \begin{minipage}[t]{\textwidth}
-          \@uppertitleback
-        \end{minipage}\par
-        \vfill
-        \begin{minipage}[b]{\textwidth}
-          \@lowertitleback
-        \end{minipage}
+      \if@twoside
+        \@tempswatrue
+        \expandafter\ifnum \@nameuse{scr@v@3.12}>\scr@compatibility\relax
+        \else
+          \ifx\@uppertitleback\@empty\ifx\@lowertitleback\@empty
+            \@tempswafalse
+          \fi\fi
+        \fi
+        \if@tempswa
+          \next@tpage
+          \begin{minipage}[t]{\textwidth}
+            \@uppertitleback
+          \end{minipage}\par
+          \vfill
+          \begin{minipage}[b]{\textwidth}
+            \@lowertitleback
+          \end{minipage}\par
+          \@thanks\global\let\@thanks\@empty
+        \fi
+      \else
+        \ifx\@uppertitleback\@empty\else
+          \ClassWarning{\KOMAClassName}{%
+            non empty \string\uppertitleback\space ignored
+            by \string\maketitle\MessageBreak
+            in `twoside=false' mode%
+          }%
+        \fi
+        \ifx\@lowertitleback\@empty\else
+          \ClassWarning{\KOMAClassName}{%
+            non empty \string\lowertitleback\space ignored
+            by \string\maketitle\MessageBreak
+            in `twoside=false' mode%
+          }%
+        \fi
       \fi
-      \ifx\@dedication\@empty \else
-        \next@tpage\null\vfill
-        {\centering \Large \@dedication \par}%
+      \ifx\@dedication\@empty
+      \else
+        \next@tdpage\null\vfill
+        {\centering\usekomafont{dedication}{\@dedication \par}}%
         \vskip \z@ \@plus3fill
-        \if@twoside \next@tpage\cleardoubleemptypage \fi
+        \@thanks\global\let\@thanks\@empty
+        \cleardoubleemptypage
       \fi
+      \ifx\titlepage@restore\relax\else\clearpage\titlepage@restore\fi
     \end{titlepage}
   \else
     \par
@@ -18415,101 +18534,111 @@ to\rtside{\box\bslice\hfil}}
     #1%
     \relax\ifnum\@tempcnta=1\else
       \ClassWarning{\KOMAClassName}{%
-        Optional argument of \string\maketitle\space ignored
-        at\MessageBreak
-        notitlepage-mode%
+        Optional argument of \string\maketitle\space ignored\MessageBreak
+        in `titlepage=false' mode%
+      }%
+    \fi
+    \ifx\@uppertitleback\@empty\else
+      \ClassWarning{\KOMAClassName}{%
+        non empty \string\uppertitleback\space ignored
+        by \string\maketitle\MessageBreak
+        in `titlepage=false' mode%
+      }%
+    \fi
+    \ifx\@lowertitleback\@empty\else
+      \ClassWarning{\KOMAClassName}{%
+        non empty \string\lowertitleback\space ignored
+        by \string\maketitle\MessageBreak
+        in `titlepage=false' mode%
       }%
     \fi
     \begingroup
+      \let\titlepage@restore\relax
       \renewcommand*\thefootnote{\@fnsymbol\c@footnote}%
       \let\@oldmakefnmark\@makefnmark
-      \renewcommand*{\@makefnmark}{\rlap\@oldmakefnmark}
+      \renewcommand*{\@makefnmark}{\rlap\@oldmakefnmark}%
+      \next@tdpage
       \if@twocolumn
         \ifnum \col@number=\@ne
+          \ifx\@extratitle\@empty
+            \ifx\@frontispiece\@empty\else\if@twoside\mbox{}\fi\fi
+          \else
+            \@makeextratitle
+          \fi
+          \ifx\@frontispiece\@empty
+            \ifx\@extratitle\@empty\else\next@tdpage\fi
+          \else
+            \next@tpage
+            \@makefrontispiece
+            \next@tdpage
+          \fi
           \@maketitle
         \else
+          \ifx\@extratitle\@empty
+            \ifx\@frontispiece\@empty\else\if@twoside\mbox{}\fi\fi
+          \else
+            \twocolumn[\@makeextratitle]%
+          \fi
+          \ifx\@frontispiece\@empty
+            \ifx\@extratitle\@empty\else\next@tdpage\fi
+          \else
+            \next@tpage
+            \twocolumn[\@makefrontispiece]%
+            \next@tdpage
+          \fi
           \twocolumn[\@maketitle]%
         \fi
       \else
-        \newpage
-        \global\@topnum\z@
+        \ifx\@extratitle\@empty
+          \ifx\@frontispiece\@empty\else \mbox{}\fi
+        \else
+          \@makeextratitle
+        \fi
+        \ifx\@frontispiece\@empty
+          \ifx\@extratitle\@empty\else\next@tdpage\fi
+        \else
+          \next@tpage
+          \@makefrontispiece
+          \next@tdpage
+        \fi
         \@maketitle
       \fi
-      \thispagestyle{\titlepagestyle}\@thanks
+      \ifx\titlepagestyle\@empty\else\thispagestyle{\titlepagestyle}\fi
+      \@thanks\global\let\@thanks\@empty
     \endgroup
   \fi
   \setcounter{footnote}{0}%
-  \let\thanks\relax
-  \let\LTRthanks\relax
-  \let\RTLthanks\relax
-  \let\maketitle\relax
-  \let\@maketitle\relax
-  \global\let\@thanks\@empty
-  \global\let\@author\@empty
-  \global\let\@date\@empty
-  \global\let\@title\@empty
-  \global\let\@subtitle\@empty
-  \global\let\@extratitle\@empty
-  \global\let\@titlehead\@empty
-  \global\let\@subject\@empty
-  \global\let\@publishers\@empty
-  \global\let\@uppertitleback\@empty
-  \global\let\@lowertitleback\@empty
-  \global\let\@dedication\@empty
-  \global\let\author\relax
-  \global\let\title\relax
-  \global\let\extratitle\relax
-  \global\let\titlehead\relax
-  \global\let\subject\relax
-  \global\let\publishers\relax
-  \global\let\uppertitleback\relax
-  \global\let\lowertitleback\relax
-  \global\let\dedication\relax
-  \global\let\date\relax
-  \global\let\and\relax
-}%
-\renewcommand*{\@maketitle}{%
-  \clearpage
-  \let\footnote\thanks
-  \let\LTRfootnote\LTRthanks
-  \let\RTLfootnote\RTLthanks
-  \ifx\@extratitle\@empty \else
-    \noindent\@extratitle \next@tpage \if@twoside \null\next@tpage \fi
+  \expandafter\ifnum \csname scr@v@3.12\endcsname>\scr@compatibility\relax
+    \let\thanks\relax
+    \let\LTRthanks\relax
+    \let\RTLthanks\relax
+    \let\maketitle\relax
+    \let\@maketitle\relax
+    \global\let\@thanks\@empty
+    \global\let\@author\@empty
+    \global\let\@date\@empty
+    \global\let\@title\@empty
+    \global\let\@subtitle\@empty
+    \global\let\@extratitle\@empty
+    \global\let\@frontispiece\@empty
+    \global\let\@titlehead\@empty
+    \global\let\@subject\@empty
+    \global\let\@publishers\@empty
+    \global\let\@uppertitleback\@empty
+    \global\let\@lowertitleback\@empty
+    \global\let\@dedication\@empty
+    \global\let\author\relax
+    \global\let\title\relax
+    \global\let\extratitle\relax
+    \global\let\titlehead\relax
+    \global\let\subject\relax
+    \global\let\publishers\relax
+    \global\let\uppertitleback\relax
+    \global\let\lowertitleback\relax
+    \global\let\dedication\relax
+    \global\let\date\relax
   \fi
-  \setparsizes{\z@}{\z@}{\z@\@plus 1fil}\par@updaterelative
-  \ifx\@titlehead\@empty \else
-    \begin{minipage}[t]{\textwidth}
-      \@titlehead
-    \end{minipage}\par
-  \fi
-  \null
-  \vskip 2em%
-  \begin{center}%
-    \ifx\@subject\@empty \else
-      {\subject@font \@subject \par}
-      \vskip 1.5em
-    \fi
-    {\titlefont\huge \@title \par}%
-    \vskip .5em
-    {\ifx\@subtitle\@empty\else\usekomafont{subtitle}\@subtitle\par\fi}%
-    \vskip 1em
-    {\Large
-      \lineskip .5em%
-      \begin{tabular}[t]{c}
-        \@author
-      \end{tabular}\par
-    }%
-    \vskip 1em%
-    {\Large \@date \par}%
-    \vskip \z@ \@plus 1em
-    {\Large \@publishers \par}
-    \ifx\@dedication\@empty \else
-      \vskip 2em
-      {\Large \@dedication \par}
-    \fi
-  \end{center}%
-  \par
-  \vskip 2em
+  \global\let\and\relax
 }%
 \def\raggedsection{\if@RTL\raggedleft\else\raggedright\fi}
 \def\raggedpart{\if@RTL\raggedleft\else\raggedright\fi}
@@ -18587,16 +18716,6 @@ to\rtside{\box\bslice\hfil}}
   \fi
   \bib@endhook
 }
-\renewcommand*\left@footnoterule{%
-  \kern-3\p@
-  \ifx\@textbottom\relax\else\vskip \z@ \@plus.05fil\fi
-  \hrule\@width.4\columnwidth
-  \kern 2.6\p@}
-\renewcommand*\right@footnoterule{%
-  \kern-3\p@
-  \ifx\@textbottom\relax\else\vskip \z@ \@plus.05fil\fi
-  \hbox to \columnwidth{\hskip .6\columnwidth \hrulefill }
-  \kern2.6\p@}
 \renewcommand*{\raggeddictum}{\if@RTL\raggedright\else\raggedleft\fi}
 \renewcommand*{\raggeddictumtext}{\if@RTL\raggedleft\else\raggedright\fi}
 \renewcommand*{\raggeddictumauthor}{\if@RTL\raggedright\else\raggedleft\fi}
@@ -18605,76 +18724,61 @@ to\rtside{\box\bslice\hfil}}
 }
 \renewcommand{\@@makecaption}[3]{%
   \cap@margin
-  \ifonelinecaptions
-    \@tempcnta=\value{mpfootnote}\@tempcntb=\value{footnote}%
-    \let\scr@tmp@footnotetext=\@footnotetext
-    \let\@footnotetext=\@gobble
-    \let\scr@tmp@LTRfootnotetext=\@LTRfootnotetext
-    \let\@LTRfootnotetext=\@gobble
-    \let\scr@tmp@RTLfootnotetext=\@RTLfootnotetext
-    \let\@RTLfootnotetext=\@gobble
-    \sbox\@tempboxa{%
-      {\capfont{\strut\ignorespaces
-        #1{{\caplabelfont{#2\captionformat}}}%
-        #3\unskip\strut}}%
-    }%
-    \let\@footnotetext=\scr@tmp@footnotetext
-    \let\scr@tmp@footnotetext=\undefined
-    \let\@LTRfootnotetext=\scr@tmp@LTRfootnotetext
-    \let\scr@tmp@LTRfootnotetext=\undefined
-    \let\@RTLfootnotetext=\scr@tmp@RTLfootnotetext
-    \let\scr@tmp@RTLfootnotetext=\undefined
-    \setcounter{footnote}{\@tempcntb}%
-    \setcounter{mpfootnote}{\@tempcnta}%
-  \else
-    \sbox\@tempboxa{\hspace*{2\cap@width}}%
-  \fi
-  \begingroup%
-    \setlength{\@tempdima}{\cap@width}%
-    \ifdim \wd\@tempboxa >\@tempdima
-      \hb@xt@\hsize{%
-        \setbox\@tempboxa\vbox{\hsize=\cap@width
-          \ifdofullc@p
-            {\capfont{\@hangfrom{\scr@smashdp{\strut\ignorespaces
-                  #1{{\caplabelfont{#2\captionformat}}}}}%
-              {#3\unskip\strut\par}}}%
-          \else%
-            \ifdim\cap@indent<\z@
-              {\capfont{\strut\ignorespaces
-                #1{{\caplabelfont{#2\captionformat\par}}}%
-                \noindent\hspace*{-\cap@indent}#3\unskip\strut\par}}%
-            \else%
-              \if@capbreak
-                {\capfont{\strut\ignorespaces
-                  #1{{\caplabelfont{#2\captionformat\par}}}%
-                  \noindent\@hangfrom{\hspace*{\cap@indent}}{#3\par}}}%
-              \else
-                {\capfont{\@hangfrom{\scr@smashdp\strut\hspace*{\cap@indent}}%
-                  {\hspace{-\cap@indent}\scr@smashdp{\ignorespaces#1%
-                    {{\caplabelfont{#2\captionformat}}}}#3\unskip\strut\par}}}%
-              \fi
-            \fi
-          \fi
+  \begingroup
+    \ifonelinecaptions
+      \def\stepcounter##1{\advance\value{##1}\@ne}%
+      \let\refstepcounter\stepcounter
+      \let\label\@gobble
+      \let\@footnotetext=\@gobble
+      \let\@LTRfootnotetext=\@gobble
+      \let\@RTLfootnotetext=\@gobble
+      \let\hypertarget\@gobbletwo
+      \edef\@xnewline{%
+        \unexpanded{\ClassInfo{\KOMAClassName}{%
+            Workaround for not recommended usage of \string\\ or\MessageBreak
+            \string\newline in caption text
+          }%
+          \hspace*{\linewidth}\hspace{1sp}%
         }%
-        \setlength{\@tempdima}{\ht\@tempboxa}%
-        \addtolength{\@tempdima}{\dp\@tempboxa}%
-        \addtolength{\@tempdima}{-\ht\strutbox}%
-        \ht\@tempboxa\ht\strutbox
-        \dp\@tempboxa\@tempdima
-        \strut\cap@left
-        \box\@tempboxa
-        \cap@right\strut
+        \unexpanded\expandafter{\@xnewline}%
       }%
-    \else
-      \global \@minipagefalse
-      \sbox\@tempboxa{%
-        {\capfont{\scr@smashdp{\strut\ignorespaces
-          #1{{\caplabelfont{#2\captionformat}}}}%
-          #3}}%
+      \edef\@xcentercr{%
+        \unexpanded{\ClassInfo{\KOMAClassName}{%
+            Workaround for not recommended usage of \string\\ or\MessageBreak
+            \string\newline in caption text
+          }%
+          \hspace*{\linewidth}\hspace{1sp}%
+        }%
+        \unexpanded\expandafter{\@xcentercr}%
       }%
-      {\capfont{\hb@xt@\hsize{\strut\cap@left\if@RTL\beginR\fi\box\@tempboxa\if@RTL\endR\fi\cap@right\strut}}}%
+      \settowidth{\@tempdima}{\scr@@makesinglelinecaption{#1}{#2}{#3}}%
+      \ifdim\@tempdima>\cap@width
+        \aftergroup\scr@makemultilinecaption
+      \else
+        \aftergroup\scr@makesinglelinecaption
+      \fi
+    \else
+      \aftergroup\scr@makemultilinecaption
     \fi
   \endgroup
+  {#1}{#2}{#3}%
+}
+\renewcommand{\scr@makesinglelinecaption}[3]{%
+  {%
+    \usefontofkomafont{caption}{%
+      \hb@xt@\hsize{%
+        \cap@left
+        \if@RTL
+          \beginR
+        \fi
+        \scr@@makesinglelinecaption{#1}{#2}{#3}%
+        \if@RTL
+          \endR
+        \fi
+        \cap@right
+      }\par\kern\dp\strutbox%
+    }%
+  }\kern-\dp\strutbox
 }
 \renewcommand{\@makecaption}[2]{%
   \if@captionabove
@@ -18689,10 +18793,8 @@ to\rtside{\box\bslice\hfil}}
     \vskip\belowcaptionskip
   \fi
 }
+
 \bidi@AfterFile{longtable-xetex-bidi.def}{%
-  \@ifpackageloaded{caption2}{\@komalongtablefalse
-    \scr@caption@before@longtable@warning{caption2}%
-  }{}%
   \if@komalongtable
     \renewcommand{\LT@makecaption}[3]{%
       \noalign{%
@@ -18704,6 +18806,7 @@ to\rtside{\box\bslice\hfil}}
       }%
       \LT@mcol\LT@cols c{%
         \hbox to\z@{\hss\parbox[t]\linewidth{%
+            \def\@captype{table}%
             \@@makecaption{#1}{#2}{#3}%
             \endgraf
             \if@captionabove
@@ -18755,12 +18858,11 @@ to\rtside{\box\bslice\hfil}}
   \expandafter\renewcommand%
   \csname scr@tso@#1@linefill\endcsname{%
     \if@sectionentrywithdots
-      \TOCLineLeaderFill\relax
+      {\usekomafont{sectionentrydots}{\TOCLineLeaderFill}}\relax
     \else
       \hfill
     \fi
   }%
-  % F^^fcr die Eintr^^e4ge die Schrift von Element sectionentry verwenden.
   \expandafter\renewcommand%
   \csname scr@tso@#1@entryformat\endcsname{\usekomafont{sectionentry}}%
   \expandafter\renewcommand%
@@ -18777,14 +18879,6 @@ to\rtside{\box\bslice\hfil}}
 
 \CloneTOCEntryStyle{subsection}{default}
 
-\DeclareSectionCommand[%
-  style=part,%
-  level=\z@,%
-  tocstyle=part,%
-  toclevel=\m@ne,%
-  tocindent=\z@,%
-  tocnumwidth=2em%
-]{part}
 \DeclareSectionCommand[%
   style=section,%
   level=1,%
@@ -18795,6 +18889,14 @@ to\rtside{\box\bslice\hfil}}
   tocindent=0pt,%
   tocnumwidth=1.5em%
 ]{section}
+\DeclareSectionCommand[%
+  style=part,%
+  level=\z@,%
+  tocstyle=part,%
+  toclevel=\m@ne,%
+  tocindent=\z@,%
+  tocnumwidth=2em%
+]{part}
 \DeclareSectionCommand[%
   style=section,%
   level=2,%
@@ -18822,6 +18924,7 @@ to\rtside{\box\bslice\hfil}}
   beforeskip=3.25ex \@plus1ex \@minus.2ex,%
   afterskip=-1em,%
   tocstyle=subsection,%
+  tocindentfollows=subsubsection,%
   tocindent=7.0em,%
   tocnumwidth=4.1em%
 ]{paragraph}
@@ -18842,7 +18945,7 @@ to\rtside{\box\bslice\hfil}}
 %\fi
 % \section{File \texttt{scrbook-xetex-bidi.def}}
 %    \begin{macrocode}
-\ProvidesFile{scrbook-xetex-bidi.def}[2017/06/09 v1.1 bidi adaptations for scrbook class for XeTeX engine]
+\ProvidesFile{scrbook-xetex-bidi.def}[2022/05/22 v1.2 bidi adaptations for scrbook class for XeTeX engine]
 \newcommand{\scr@saved@LTRfootnotetext}{}
 \newcommand{\scr@saved@RTLfootnotetext}{}
 \let\scr@saved@footnotetext\@footnotetext
@@ -18861,28 +18964,69 @@ to\rtside{\box\bslice\hfil}}
   \csname FN@mf@prepare\endcsname
 }
 \renewcommand\deffootnote[4][]{%
-  \long\def\@makefntext##1{%
-    \setlength{\@tempdimc}{#3}%
-    \def\@tempa{#1}\ifx\@tempa\@empty
-      \@setpar{\@@par
-        \@tempdima = \hsize
-        \addtolength{\@tempdima}{-#2}%
-        \if@RTL\parshape \@ne 0pt \@tempdima\else\parshape \@ne #2 \@tempdima\fi}%
-    \else
-      \addtolength{\@tempdimc}{#2}%
-      \addtolength{\@tempdimc}{-#1}%
-      \@setpar{\@@par
-        \@tempdima = \hsize
-        \addtolength{\@tempdima}{-#1}%
-        \@tempdimb = \hsize
-        \addtolength{\@tempdimb}{-#2}%
-        \if@RTL\parshape \tw@ 0pt \@tempdima 0pt \@tempdimb\else\parshape \tw@ #1 \@tempdima #2 \@tempdimb\fi
+  \expandafter\ifnum\scr@v@is@ge{3.22}\relax
+    \long\def\@makefntext##1{%
+      \ExecuteDoHook{footnote/text/begin}%
+      \raggedfootnote
+      \if@RTL
+        \rightskip
+      \else
+        \leftskip
+      \fi
+      #2
+      \l@addto@macro\@trivlist{%
+        \ifnum\@listdepth=\@ne\advance
+          \if@RTL
+            \rightmargin #2\relax
+          \else
+            \leftmargin #2\relax
+          \fi
+        \fi
       }%
-    \fi
-    \par
-    \parindent\@tempdimc\noindent
-    \ftn@font\hbox to \z@{\hss\@@makefnmark}##1%
-  }%
+      \parindent #3\noindent
+      \IfArgIsEmpty{#1}{}{%
+        \hskip \dimexpr #1-#2\relax
+      }%
+      \ftn@font\hbox to \z@{\hss\@@makefnmark}##1%
+      \ExecuteDoHook{footnote/text/end}%
+    }%
+  \else
+    \ClassInfo{\KOMAClassName}{%
+      Using old \string\@makefntext\space due to compatibility
+      level\MessageBreak
+      less than 3.22}%
+    \long\def\@makefntext##1{%
+      \setlength{\@tempdimc}{#3}%
+      \def\@tempa{#1}\ifx\@tempa\@empty
+        \@setpar{\@@par
+          \@tempdima = \hsize
+          \addtolength{\@tempdima}{-#2}%
+          \if@RTL
+            \parshape \@ne \z@ \@tempdima
+          \else
+            \parshape \@ne #2 \@tempdima
+          \fi
+          }%
+      \else
+        \addtolength{\@tempdimc}{#2}%
+        \addtolength{\@tempdimc}{-#1}%
+        \@setpar{\@@par
+          \@tempdima = \hsize
+          \addtolength{\@tempdima}{-#1}%
+          \@tempdimb = \hsize
+          \addtolength{\@tempdimb}{-#2}%
+          \if@RTL
+            \parshape \tw@ \z@ \@tempdima \z@ \@tempdimb
+          \else
+            \parshape \tw@ #1 \@tempdima #2 \@tempdimb
+          \fi
+        }%
+      \fi
+      \par
+      \parindent\@tempdimc\noindent
+      \ftn@font\hbox to \z@{\hss\@@makefnmark}##1%
+    }%
+  \fi
   \def\@@makefnmark{\hbox{\ftnm@font{#4}}}%
 }
 \deffootnote[1em]{1.5em}{1em}{\textsuperscript{\thefootnotemark}}
@@ -18901,11 +19045,48 @@ to\rtside{\box\bslice\hfil}}
       \hbox to \columnwidth{\hskip \dimexpr\columnwidth-\ftn@rule@width\relax  \leavevmode\leaders\hrule\@height\ftn@rule@height\hfill\kern\z@}}}%
   \kern 2.6\p@} 
 \renewcommand*\maketitle[1][1]{%
+  \expandafter\ifnum \csname scr@v@3.12\endcsname>\scr@compatibility\relax
+  \else
+    \def\and{%
+      \end{tabular}%
+      \hskip 1em \@plus.17fil%
+      \begin{tabular}[t]{c}%
+    }%
+  \fi
   \if@titlepage
     \begin{titlepage}
       \setcounter{page}{%
         #1%
       }%
+      \if@titlepageiscoverpage
+        \edef\titlepage@restore{%
+          \noexpand\endgroup
+          \noexpand\global\noexpand\@colht\the\@colht
+          \noexpand\global\noexpand\@colroom\the\@colroom
+          \noexpand\global\vsize\the\vsize
+          \noexpand\global\noexpand\@titlepageiscoverpagefalse
+          \noexpand\let\noexpand\titlepage@restore\noexpand\relax
+        }%
+        \begingroup
+        \topmargin=\dimexpr \coverpagetopmargin-1in\relax
+        \oddsidemargin=\dimexpr \coverpageleftmargin-1in\relax
+        \evensidemargin=\dimexpr \coverpageleftmargin-1in\relax
+        \textwidth=\dimexpr
+        \paperwidth-\coverpageleftmargin-\coverpagerightmargin\relax
+        \textheight=\dimexpr
+        \paperheight-\coverpagetopmargin-\coverpagebottommargin\relax
+        \headheight=0pt
+        \headsep=0pt
+        \footskip=\baselineskip
+        \@colht=\textheight
+        \@colroom=\textheight
+        \vsize=\textheight
+        \columnwidth=\textwidth
+        \hsize=\columnwidth
+        \linewidth=\hsize
+      \else
+        \let\titlepage@restore\relax
+      \fi
       \let\footnotesize\small
       \let\right@footnoterule\relax
       \let\left@footnoterule\relax
@@ -18916,54 +19097,97 @@ to\rtside{\box\bslice\hfil}}
       \renewcommand*\thefootnote{\@fnsymbol\c@footnote}%
       \let\@oldmakefnmark\@makefnmark
       \renewcommand*{\@makefnmark}{\rlap\@oldmakefnmark}%
-      \ifx\@extratitle\@empty \else
-        \noindent\@extratitle\next@tpage\cleardoubleemptypage
-        \thispagestyle{empty}%
+      \ifx\@extratitle\@empty
+        \ifx\@frontispiece\@empty
+        \else
+          \if@twoside\mbox{}\next@tpage\fi
+          \noindent\@frontispiece\next@tdpage
+        \fi
+      \else
+        \noindent\@extratitle
+        \ifx\@frontispiece\@empty
+        \else
+          \next@tpage
+          \noindent\@frontispiece
+        \fi
+        \next@tdpage
       \fi
       \setparsizes{\z@}{\z@}{\z@\@plus 1fil}\par@updaterelative
       \ifx\@titlehead\@empty \else
         \begin{minipage}[t]{\textwidth}%
-        \@titlehead
+          \usekomafont{titlehead}{\@titlehead\par}%
         \end{minipage}\par
       \fi
       \null\vfill
       \begin{center}
         \ifx\@subject\@empty \else
-          {\subject@font \@subject \par}%
+          {\usekomafont{subject}{\@subject\par}}%
           \vskip 3em
         \fi
-        {\titlefont\huge \@title\par}%
+        {\usekomafont{title}{\huge \@title\par}}%
         \vskip 1em
-        {\ifx\@subtitle\@empty\else\usekomafont{subtitle}\@subtitle\par\fi}%
+        {\ifx\@subtitle\@empty\else\usekomafont{subtitle}{\@subtitle\par}\fi}%
         \vskip 2em
-        {\Large \lineskip 0.75em
-          \begin{tabular}[t]{c}
-            \@author
-          \end{tabular}\par
+        {%
+          \usekomafont{author}{%
+            \lineskip 0.75em
+            \begin{tabular}[t]{c}
+              \@author
+            \end{tabular}\par
+          }%
         }%
         \vskip 1.5em
-        {\Large \@date \par}%
+        {\usekomafont{date}{\@date \par}}%
         \vskip \z@ \@plus3fill
-        {\Large \@publishers \par}%
+        {\usekomafont{publishers}{\@publishers \par}}%
         \vskip 3em
       \end{center}\par
-      \@thanks
+      \@thanks\global\let\@thanks\@empty
       \vfill\null
-      \if@twoside\next@tpage
-        \begin{minipage}[t]{\textwidth}
-          \@uppertitleback
-        \end{minipage}\par
-        \vfill
-        \begin{minipage}[b]{\textwidth}
-          \@lowertitleback
-        \end{minipage}
+      \if@twoside
+        \@tempswatrue
+        \expandafter\ifnum \@nameuse{scr@v@3.12}>\scr@compatibility\relax
+        \else
+          \ifx\@uppertitleback\@empty\ifx\@lowertitleback\@empty
+            \@tempswafalse
+          \fi\fi
+        \fi
+        \if@tempswa
+          \next@tpage
+          \begin{minipage}[t]{\textwidth}
+            \@uppertitleback
+          \end{minipage}\par
+          \vfill
+          \begin{minipage}[b]{\textwidth}
+            \@lowertitleback
+          \end{minipage}\par
+          \@thanks\global\let\@thanks\@empty
+        \fi
+      \else
+        \ifx\@uppertitleback\@empty\else
+          \ClassWarning{\KOMAClassName}{%
+            non empty \string\uppertitleback\space ignored
+            by \string\maketitle\MessageBreak
+            in `twoside=false' mode%
+          }%
+        \fi
+        \ifx\@lowertitleback\@empty\else
+          \ClassWarning{\KOMAClassName}{%
+            non empty \string\lowertitleback\space ignored
+            by \string\maketitle\MessageBreak
+            in `twoside=false' mode%
+          }%
+        \fi
       \fi
-      \ifx\@dedication\@empty \else
-        \next@tpage\null\vfill
-        {\centering \Large \@dedication \par}%
+      \ifx\@dedication\@empty
+      \else
+        \next@tdpage\null\vfill
+        {\centering\usekomafont{dedication}{\@dedication \par}}%
         \vskip \z@ \@plus3fill
-        \if@twoside \next@tpage\cleardoubleemptypage \fi
+        \@thanks\global\let\@thanks\@empty
+        \cleardoubleemptypage
       \fi
+      \ifx\titlepage@restore\relax\else\clearpage\titlepage@restore\fi
     \end{titlepage}
   \else
     \par
@@ -18971,106 +19195,116 @@ to\rtside{\box\bslice\hfil}}
     #1%
     \relax\ifnum\@tempcnta=1\else
       \ClassWarning{\KOMAClassName}{%
-        Optional argument of \string\maketitle\space ignored
-        at\MessageBreak
-        notitlepage-mode%
+        Optional argument of \string\maketitle\space ignored\MessageBreak
+        in `titlepage=false' mode%
+      }%
+    \fi
+    \ifx\@uppertitleback\@empty\else
+      \ClassWarning{\KOMAClassName}{%
+        non empty \string\uppertitleback\space ignored
+        by \string\maketitle\MessageBreak
+        in `titlepage=false' mode%
+      }%
+    \fi
+    \ifx\@lowertitleback\@empty\else
+      \ClassWarning{\KOMAClassName}{%
+        non empty \string\lowertitleback\space ignored
+        by \string\maketitle\MessageBreak
+        in `titlepage=false' mode%
       }%
     \fi
     \begingroup
+      \let\titlepage@restore\relax
       \renewcommand*\thefootnote{\@fnsymbol\c@footnote}%
       \let\@oldmakefnmark\@makefnmark
-      \renewcommand*{\@makefnmark}{\rlap\@oldmakefnmark}
+      \renewcommand*{\@makefnmark}{\rlap\@oldmakefnmark}%
+      \next@tdpage
       \if@twocolumn
         \ifnum \col@number=\@ne
+          \ifx\@extratitle\@empty
+            \ifx\@frontispiece\@empty\else\if@twoside\mbox{}\fi\fi
+          \else
+            \@makeextratitle
+          \fi
+          \ifx\@frontispiece\@empty
+            \ifx\@extratitle\@empty\else\next@tdpage\fi
+          \else
+            \next@tpage
+            \@makefrontispiece
+            \next@tdpage
+          \fi
           \@maketitle
         \else
+          \ifx\@extratitle\@empty
+            \ifx\@frontispiece\@empty\else\if@twoside\mbox{}\fi\fi
+          \else
+            \twocolumn[\@makeextratitle]%
+          \fi
+          \ifx\@frontispiece\@empty
+            \ifx\@extratitle\@empty\else\next@tdpage\fi
+          \else
+            \next@tpage
+            \twocolumn[\@makefrontispiece]%
+            \next@tdpage
+          \fi
           \twocolumn[\@maketitle]%
         \fi
       \else
-        \newpage
-        \global\@topnum\z@
+        \ifx\@extratitle\@empty
+          \ifx\@frontispiece\@empty\else \mbox{}\fi
+        \else
+          \@makeextratitle
+        \fi
+        \ifx\@frontispiece\@empty
+          \ifx\@extratitle\@empty\else\next@tdpage\fi
+        \else
+          \next@tpage
+          \@makefrontispiece
+          \next@tdpage
+        \fi
         \@maketitle
       \fi
-      \thispagestyle{\titlepagestyle}\@thanks
+      \ifx\titlepagestyle\@empty\else\thispagestyle{\titlepagestyle}\fi
+      \@thanks\global\let\@thanks\@empty
     \endgroup
   \fi
   \setcounter{footnote}{0}%
-  \let\thanks\relax
-  \let\LTRthanks\relax
-  \let\RTLthanks\relax
-  \let\maketitle\relax
-  \let\@maketitle\relax
-  \global\let\@thanks\@empty
-  \global\let\@author\@empty
-  \global\let\@date\@empty
-  \global\let\@title\@empty
-  \global\let\@subtitle\@empty
-  \global\let\@extratitle\@empty
-  \global\let\@titlehead\@empty
-  \global\let\@subject\@empty
-  \global\let\@publishers\@empty
-  \global\let\@uppertitleback\@empty
-  \global\let\@lowertitleback\@empty
-  \global\let\@dedication\@empty
-  \global\let\author\relax
-  \global\let\title\relax
-  \global\let\extratitle\relax
-  \global\let\titlehead\relax
-  \global\let\subject\relax
-  \global\let\publishers\relax
-  \global\let\uppertitleback\relax
-  \global\let\lowertitleback\relax
-  \global\let\dedication\relax
-  \global\let\date\relax
-  \global\let\and\relax
-}%
-\renewcommand*{\@maketitle}{%
-  \clearpage
-  \let\footnote\thanks
-  \let\LTRfootnote\LTRthanks
-  \let\RTLfootnote\RTLthanks
-  \ifx\@extratitle\@empty \else
-    \noindent\@extratitle \next@tpage \if@twoside \null\next@tpage \fi
-  \fi
-  \setparsizes{\z@}{\z@}{\z@\@plus 1fil}\par@updaterelative
-  \ifx\@titlehead\@empty \else
-    \begin{minipage}[t]{\textwidth}
-      \@titlehead
-    \end{minipage}\par
+  \expandafter\ifnum \csname scr@v@3.12\endcsname>\scr@compatibility\relax
+    \let\thanks\relax
+    \let\LTRthanks\relax
+    \let\RTLthanks\relax
+    \let\maketitle\relax
+    \let\@maketitle\relax
+    \global\let\@thanks\@empty
+    \global\let\@author\@empty
+    \global\let\@date\@empty
+    \global\let\@title\@empty
+    \global\let\@subtitle\@empty
+    \global\let\@extratitle\@empty
+    \global\let\@frontispiece\@empty
+    \global\let\@titlehead\@empty
+    \global\let\@subject\@empty
+    \global\let\@publishers\@empty
+    \global\let\@uppertitleback\@empty
+    \global\let\@lowertitleback\@empty
+    \global\let\@dedication\@empty
+    \global\let\author\relax
+    \global\let\title\relax
+    \global\let\extratitle\relax
+    \global\let\titlehead\relax
+    \global\let\subject\relax
+    \global\let\publishers\relax
+    \global\let\uppertitleback\relax
+    \global\let\lowertitleback\relax
+    \global\let\dedication\relax
+    \global\let\date\relax
   \fi
-  \null
-  \vskip 2em%
-  \begin{center}%
-    \ifx\@subject\@empty \else
-      {\subject@font \@subject \par}
-      \vskip 1.5em
-    \fi
-    {\titlefont\huge \@title \par}%
-    \vskip .5em
-    {\ifx\@subtitle\@empty\else\usekomafont{subtitle}\@subtitle\par\fi}%
-    \vskip 1em
-    {\Large
-      \lineskip .5em%
-      \begin{tabular}[t]{c}
-        \@author
-      \end{tabular}\par
-    }%
-    \vskip 1em%
-    {\Large \@date \par}%
-    \vskip \z@ \@plus 1em
-    {\Large \@publishers \par}
-    \ifx\@dedication\@empty \else
-      \vskip 2em
-      {\Large \@dedication \par}
-    \fi
-  \end{center}%
-  \par
-  \vskip 2em
+  \global\let\and\relax
 }%
 \def\raggedsection{\if@RTL\raggedleft\else\raggedright\fi}
 \renewcommand*\autodot{\if@altsecnumformat\@SepMark\fi}
 \renewcommand*\thesection{%
-  \ifnum \scr@compatibility>\@nameuse{scr@v@2.97d}\relax
+  \expandafter\ifnum\scr@v@is@gt{2.97d}%
     \if@mainmatter\thechapter\@SepMark\fi
   \else
   \thechapter\@SepMark%
@@ -19085,27 +19319,17 @@ to\rtside{\box\bslice\hfil}}
 \renewcommand*{\thesubparagraph}{%
   \theparagraph\@SepMark\@arabic\c@subparagraph
 }
-\renewcommand*\thefigure{%
-  \ifnum \scr@compatibility>\@nameuse{scr@v@2.97d}\relax
-    \if@mainmatter\thechapter\@SepMark\fi
-  \else
-  \thechapter\@SepMark%
-  \fi
-  \@arabic\c@figure
-}
-\renewcommand*\thetable{%
-  \ifnum \scr@compatibility>\@nameuse{scr@v@2.97d}\relax
-    \if@mainmatter\thechapter\@SepMark\fi
-  \else
-  \thechapter\@SepMark%
-  \fi
-  \@arabic\c@table
-}
-\renewcommand*\theequation{%
-  \ifnum \scr@compatibility>\@nameuse{scr@v@2.97d}\relax
+\expandafter\ifnum\scr@v@is@le{2.97d}%
+  \renewcommand*\thefigure{\thechapter\@SepMark\@arabic\c@figure}
+\fi
+\expandafter\ifnum\scr@v@is@le{2.97d}%
+  \renewcommand*\thetable{\thechapter\@SepMark\@arabic\c@table}
+\fi
+\renewcommand*{\theequation}{%
+  \expandafter\ifnum\scr@v@is@gt{2.97d}%
     \if@mainmatter\thechapter\@SepMark\fi
   \else
-  \thechapter\@SepMark%
+    \thechapter\@SepMark%
   \fi
   \@arabic\c@equation
 }
@@ -19174,16 +19398,6 @@ to\rtside{\box\bslice\hfil}}
   \fi
   \bib@endhook
 }
-\renewcommand*\left@footnoterule{%
-  \kern-3\p@
-  \ifx\@textbottom\relax\else\vskip \z@ \@plus.05fil\fi
-  \hrule\@width.4\columnwidth
-  \kern 2.6\p@}
-\renewcommand*\right@footnoterule{%
-  \kern-3\p@
-  \ifx\@textbottom\relax\else\vskip \z@ \@plus.05fil\fi
-  \hbox to \columnwidth{\hskip .6\columnwidth \hrulefill }
-  \kern2.6\p@}
 \renewcommand*{\raggeddictum}{\if@RTL\raggedright\else\raggedleft\fi}
 \renewcommand*{\raggeddictumtext}{\if@RTL\raggedleft\else\raggedright\fi}
 \renewcommand*{\raggeddictumauthor}{\if@RTL\raggedright\else\raggedleft\fi}
@@ -19192,76 +19406,61 @@ to\rtside{\box\bslice\hfil}}
 }
 \renewcommand{\@@makecaption}[3]{%
   \cap@margin
-  \ifonelinecaptions
-    \@tempcnta=\value{mpfootnote}\@tempcntb=\value{footnote}%
-    \let\scr@tmp@footnotetext=\@footnotetext
-    \let\@footnotetext=\@gobble
-    \let\scr@tmp@LTRfootnotetext=\@LTRfootnotetext
-    \let\@LTRfootnotetext=\@gobble
-    \let\scr@tmp@RTLfootnotetext=\@RTLfootnotetext
-    \let\@RTLfootnotetext=\@gobble
-    \sbox\@tempboxa{%
-      {\capfont{\strut\ignorespaces
-        #1{{\caplabelfont{#2\captionformat}}}%
-        #3\unskip\strut}}%
-    }%
-    \let\@footnotetext=\scr@tmp@footnotetext
-    \let\scr@tmp@footnotetext=\undefined
-    \let\@LTRfootnotetext=\scr@tmp@LTRfootnotetext
-    \let\scr@tmp@LTRfootnotetext=\undefined
-    \let\@RTLfootnotetext=\scr@tmp@RTLfootnotetext
-    \let\scr@tmp@RTLfootnotetext=\undefined
-    \setcounter{footnote}{\@tempcntb}%
-    \setcounter{mpfootnote}{\@tempcnta}%
-  \else
-    \sbox\@tempboxa{\hspace*{2\cap@width}}%
-  \fi
-  \begingroup%
-    \setlength{\@tempdima}{\cap@width}%
-    \ifdim \wd\@tempboxa >\@tempdima
-      \hb@xt@\hsize{%
-        \setbox\@tempboxa\vbox{\hsize=\cap@width
-          \ifdofullc@p
-            {\capfont{\@hangfrom{\scr@smashdp{\strut\ignorespaces
-                  #1{{\caplabelfont{#2\captionformat}}}}}%
-              {#3\unskip\strut\par}}}%
-          \else%
-            \ifdim\cap@indent<\z@
-              {\capfont{\strut\ignorespaces
-                #1{{\caplabelfont{#2\captionformat\par}}}%
-                \noindent\hspace*{-\cap@indent}#3\unskip\strut\par}}%
-            \else%
-              \if@capbreak
-                {\capfont{\strut\ignorespaces
-                  #1{{\caplabelfont{#2\captionformat\par}}}%
-                  \noindent\@hangfrom{\hspace*{\cap@indent}}{#3\par}}}%
-              \else
-                {\capfont{\@hangfrom{\scr@smashdp\strut\hspace*{\cap@indent}}%
-                  {\hspace{-\cap@indent}\scr@smashdp{\ignorespaces#1%
-                    {{\caplabelfont{#2\captionformat}}}}#3\unskip\strut\par}}}%
-              \fi
-            \fi
-          \fi
+  \begingroup
+    \ifonelinecaptions
+      \def\stepcounter##1{\advance\value{##1}\@ne}%
+      \let\refstepcounter\stepcounter
+      \let\label\@gobble
+      \let\@footnotetext=\@gobble
+      \let\@LTRfootnotetext=\@gobble
+      \let\@RTLfootnotetext=\@gobble
+      \let\hypertarget\@gobbletwo
+      \edef\@xnewline{%
+        \unexpanded{\ClassInfo{\KOMAClassName}{%
+            Workaround for not recommended usage of \string\\ or\MessageBreak
+            \string\newline in caption text
+          }%
+          \hspace*{\linewidth}\hspace{1sp}%
         }%
-        \setlength{\@tempdima}{\ht\@tempboxa}%
-        \addtolength{\@tempdima}{\dp\@tempboxa}%
-        \addtolength{\@tempdima}{-\ht\strutbox}%
-        \ht\@tempboxa\ht\strutbox
-        \dp\@tempboxa\@tempdima
-        \strut\cap@left
-        \box\@tempboxa
-        \cap@right\strut
+        \unexpanded\expandafter{\@xnewline}%
       }%
-    \else
-      \global \@minipagefalse
-      \sbox\@tempboxa{%
-        {\capfont{\scr@smashdp{\strut\ignorespaces
-          #1{{\caplabelfont{#2\captionformat}}}}%
-          #3}}%
+      \edef\@xcentercr{%
+        \unexpanded{\ClassInfo{\KOMAClassName}{%
+            Workaround for not recommended usage of \string\\ or\MessageBreak
+            \string\newline in caption text
+          }%
+          \hspace*{\linewidth}\hspace{1sp}%
+        }%
+        \unexpanded\expandafter{\@xcentercr}%
       }%
-      {\capfont{\hb@xt@\hsize{\strut\cap@left\if@RTL\beginR\fi\box\@tempboxa\if@RTL\endR\fi\cap@right\strut}}}%
+      \settowidth{\@tempdima}{\scr@@makesinglelinecaption{#1}{#2}{#3}}%
+      \ifdim\@tempdima>\cap@width
+        \aftergroup\scr@makemultilinecaption
+      \else
+        \aftergroup\scr@makesinglelinecaption
+      \fi
+    \else
+      \aftergroup\scr@makemultilinecaption
     \fi
   \endgroup
+  {#1}{#2}{#3}%
+}
+\renewcommand{\scr@makesinglelinecaption}[3]{%
+  {%
+    \usefontofkomafont{caption}{%
+      \hb@xt@\hsize{%
+        \cap@left
+        \if@RTL
+          \beginR
+        \fi
+        \scr@@makesinglelinecaption{#1}{#2}{#3}%
+        \if@RTL
+          \endR
+        \fi
+        \cap@right
+      }\par\kern\dp\strutbox%
+    }%
+  }\kern-\dp\strutbox
 }
 \renewcommand{\@makecaption}[2]{%
   \if@captionabove
@@ -19277,9 +19476,6 @@ to\rtside{\box\bslice\hfil}}
   \fi
 }
 \bidi@AfterFile{longtable-xetex-bidi.def}{%
-  \@ifpackageloaded{caption2}{\@komalongtablefalse
-    \scr@caption@before@longtable@warning{caption2}%
-  }{}%
   \if@komalongtable
     \renewcommand{\LT@makecaption}[3]{%
       \noalign{%
@@ -19291,6 +19487,7 @@ to\rtside{\box\bslice\hfil}}
       }%
       \LT@mcol\LT@cols c{%
         \hbox to\z@{\hss\parbox[t]\linewidth{%
+            \def\@captype{table}%
             \@@makecaption{#1}{#2}{#3}%
             \endgraf
             \if@captionabove
@@ -19342,7 +19539,7 @@ to\rtside{\box\bslice\hfil}}
   \expandafter\renewcommand%
   \csname scr@tso@#1@linefill\endcsname{%
     \if@chapterentrywithdots
-      \TOCLineLeaderFill\relax
+      {\usekomafont{chapterentrydots}{\TOCLineLeaderFill}}\relax
     \else
       \hfill
     \fi
@@ -19357,22 +19554,13 @@ to\rtside{\box\bslice\hfil}}
 }
 
 \CloneTOCEntryStyle{tocline}{section}
-\TOCEntryStyleStartInitCode{section}{%
-  \expandafter\renewcommand%
-  \csname scr@tso@#1@linefill\endcsname{\TOCLineLeaderFill\relax}%
-}
-
-\CloneTOCEntryStyle{section}{default}
-
-\DeclareSectionCommand[%
-  style=part,%
-  level=\m@ne,%
-  pagestyle=plain,%
-  tocstyle=part,%
-  toclevel=\m@ne,%
-  tocindent=\z@,%
-  tocnumwidth=2em%
-]{part}
+\TOCEntryStyleStartInitCode{section}{%
+  \expandafter\renewcommand%
+  \csname scr@tso@#1@linefill\endcsname{\TOCLineLeaderFill\relax}%
+}
+
+\CloneTOCEntryStyle{section}{default}
+
 \DeclareSectionCommand[%
   style=chapter,%
   level=\z@,%
@@ -19388,9 +19576,19 @@ to\rtside{\box\bslice\hfil}}
   beforeskip=-3.5ex \@plus -1ex \@minus -.2ex,%
   afterskip=2.3ex \@plus.2ex,%
   tocstyle=section,%
+  tocindentfollows=chapter,%
   tocindent=1.5em,%
   tocnumwidth=2.3em%
 ]{section}
+\DeclareSectionCommand[%
+  style=part,%
+  level=\m@ne,%
+  pagestyle=plain,%
+  tocstyle=part,%
+  toclevel=\m@ne,%
+  tocindent=\z@,%
+  tocnumwidth=2em%
+]{part}
 \DeclareSectionCommand[%
   style=section,%
   level=2,%
@@ -19417,6 +19615,7 @@ to\rtside{\box\bslice\hfil}}
   indent=\z@,%
   beforeskip=3.25ex \@plus1ex \@minus.2ex,%
   afterskip=-1em,%
+  tocindentfollows=subsubsection,%
   tocstyle=section,%
   tocindent=10em,%
   tocnumwidth=5em%
@@ -19431,131 +19630,14 @@ to\rtside{\box\bslice\hfil}}
   tocindent=12em,%
   tocnumwidth=6em%
 ]{subparagraph}
-
-
 %    \end{macrocode}
 % \iffalse
 %</scrbook-xetex-bidi.def>
-%<*scrlettr-xetex-bidi.def>
-%\fi
-% \section{File \texttt{scrlettr-xetex-bidi.def}}
-%    \begin{macrocode}
-\ProvidesFile{scrlettr-xetex-bidi.def}[2015/11/14 v0.3 bidi adaptations for scrlettr class for XeTeX engine]
-\renewcommand\deffootnote[4][]{%
-  \long\def\@makefntext##1{%
-    \edef\@tempa{#1}\ifx\@tempa\@empty
-      \@setpar{\@@par
-        \@tempdima = \hsize
-        \addtolength{\@tempdima}{-#2}
-        \if@RTL\parshape \@ne 0pt \@tempdima\else\parshape \@ne #2 \@tempdima\fi}%
-    \else
-      \@setpar{\@@par
-        \@tempdima = \hsize
-        \addtolength{\@tempdima}{-#1}
-        \@tempdimb = \hsize
-        \addtolength{\@tempdimb}{-#2}
-        \if@RTL\parshape \tw@ 0pt \@tempdima 0pt \@tempdimb\else\parshape \tw@ #1 \@tempdima #2 \@tempdimb\fi}%
-    \fi
-    \par
-    \parindent #3\noindent
-    \hbox to \z@{\hss\@@makefnmark}##1}
-  \def\@@makefnmark{\hbox{#4}}
-}
-\deffootnote[1em]{1.5em}{1em}
-  {\textsuperscript{\thefootnotemark}}
-\def\left@footnoterule{\kern-1\p@
- \hrule width 0.4\columnwidth
- \kern .6\p@}
-\def\right@footnoterule{%
-  \kern-1\p@
-  \hbox to \columnwidth{\hskip .6\columnwidth \hrulefill }
-  \kern .6\p@}
-\def\@datefield{\@reffalse
- \ifx\varyourref\@empty \else \@reftrue \fi
- \ifx\varyourmail\@empty \else \@reftrue \fi
- \ifx\varmyref\@empty \else \@reftrue \fi
- \ifx\varcustomer\@empty \else \@reftrue \fi
- \ifx\varinvoice\@empty \else \@reftrue \fi
- \ifx\varrefitemi\@empty \else \@reftrue \fi
- \ifx\varrefitemii\@empty \else \@reftrue \fi
- \ifx\varrefitemiii\@empty \else \@reftrue \fi
- \vskip -\parskip
- \vskip \refvskip
- \if@ref
-  \ifx\varyourref\@empty \else
-   \settowidth{\sc@temp}{\varyourref}
-   \setbox0\hbox{\scriptsize \sf \yourrefname}
-   \ifdim \sc@temp > \wd0 \sc@@temp\sc@temp \else \sc@@temp\wd0 \fi
-   \parbox[t]{\sc@@temp}{\noindent \box0\par \varyourref}\hfill
-  \fi
-  \ifx\varyourmail\@empty \else
-   \settowidth{\sc@temp}{\varyourmail}
-   \setbox0\hbox{\scriptsize \sf \yourmailname}
-   \ifdim \sc@temp > \wd0 \sc@@temp\sc@temp \else \sc@@temp\wd0 \fi
-   \parbox[t]{\sc@@temp}{\noindent \box0\par \varyourmail}\hfill
-  \fi
-  \ifx\varmyref\@empty \else
-   \settowidth{\sc@temp}{\varmyref}
-   \setbox0\hbox{\scriptsize \sf \myrefname}
-   \ifdim \sc@temp > \wd0 \sc@@temp\sc@temp \else \sc@@temp\wd0 \fi
-   \parbox[t]{\sc@@temp}{\noindent \box0\par \varmyref}\hfill
-  \fi
-  \ifx\varcustomer\@empty \else
-   \settowidth{\sc@temp}{\varcustomer}
-   \setbox0\hbox{\scriptsize \sf \customername}
-   \ifdim \sc@temp > \wd0 \sc@@temp\sc@temp \else \sc@@temp\wd0 \fi
-   \parbox[t]{\sc@@temp}{\noindent \box0\par \varcustomer}\hfill
-  \fi
-  \ifx\varinvoice\@empty \else
-   \settowidth{\sc@temp}{\varinvoice}
-   \setbox0\hbox{\scriptsize \sf \invoicename}
-   \ifdim \sc@temp > \wd0 \sc@@temp\sc@temp \else \sc@@temp\wd0 \fi
-   \parbox[t]{\sc@@temp}{\noindent \box0\par \varinvoice}\hfill
-  \fi
-  \ifx\varrefitemi\@empty \else
-   \settowidth{\sc@temp}{\varrefitemi}
-   \setbox0\hbox{\scriptsize \sf \varrefitemnamei}
-   \ifdim \sc@temp > \wd0 \sc@@temp\sc@temp \else \sc@@temp\wd0 \fi
-   \parbox[t]{\sc@@temp}{\noindent \box0\par \varrefitemi}\hfill
-  \fi
-  \ifx\varrefitemii\@empty \else
-   \settowidth{\sc@temp}{\varrefitemii}
-   \setbox0\hbox{\scriptsize \sf \varrefitemnameii}
-   \ifdim \sc@temp > \wd0 \sc@@temp\sc@temp \else \sc@@temp\wd0 \fi
-   \parbox[t]{\sc@@temp}{\noindent \box0\par \varrefitemii}\hfill
-  \fi
-  \ifx\varrefitemiii\@empty \else
-   \settowidth{\sc@temp}{\varrefitemiii}
-   \setbox0\hbox{\scriptsize \sf \varrefitemnameiii}
-   \ifdim \sc@temp > \wd0 \sc@@temp\sc@temp \else \sc@@temp\wd0 \fi
-   \parbox[t]{\sc@@temp}{\noindent \box0\par \varrefitemiii}\hfill
-  \fi
-  \ifx\@date\@empty \else
-   \settowidth{\sc@temp}{\@date}
-   \setbox0\hbox{\scriptsize \sf \datename}
-   \ifdim \sc@temp > \wd0 \sc@@temp\sc@temp \else \sc@@temp\wd0 \fi
-   \parbox[t]{\sc@@temp}{\noindent \box0\par \@date}
-  \fi
-  \par
-  \vspace{2.5\baselineskip}
- \else
-  {\ifx\@date\@empty \else \if@RTL\raggedright\else\raggedleft\fi\fromplace\ \@date\par \fi}
-  \vspace{1.5\baselineskip}
- \fi}
-\long\def\closing#1{\par\nobreak\vspace{0.5\baselineskip}
- \stopbreaks \noindent \sc@temp\textwidth \advance\sc@temp by
- -\sigindent \hspace{\sigindent}%
- \parbox{\sc@temp}{\if@RTL\raggedleft\else\raggedright\fi\ignorespaces #1\mbox{}\\[\presig@skip]
- \fromsig\strut}\par
- \vspace{1.5\baselineskip}}
-%    \end{macrocode}
-% \iffalse
-%</scrlettr-xetex-bidi.def>
 %<*scrreprt-xetex-bidi.def>
 %\fi
 % \section{File \texttt{scrreprt-xetex-bidi.def}}
 %    \begin{macrocode}
-\ProvidesFile{scrreprt-xetex-bidi.def}[2017/06/09 v1.1 bidi adaptations for scrreprt class for XeTeX engine]
+\ProvidesFile{scrreprt-xetex-bidi.def}[2022/05/22 v1.2 bidi adaptations for scrreprt class for XeTeX engine]
 \newcommand{\scr@saved@LTRfootnotetext}{}
 \newcommand{\scr@saved@RTLfootnotetext}{}
 \let\scr@saved@footnotetext\@footnotetext
@@ -19574,28 +19656,69 @@ to\rtside{\box\bslice\hfil}}
   \csname FN@mf@prepare\endcsname
 }
 \renewcommand\deffootnote[4][]{%
-  \long\def\@makefntext##1{%
-    \setlength{\@tempdimc}{#3}%
-    \def\@tempa{#1}\ifx\@tempa\@empty
-      \@setpar{\@@par
-        \@tempdima = \hsize
-        \addtolength{\@tempdima}{-#2}%
-        \if@RTL\parshape \@ne 0pt \@tempdima\else\parshape \@ne #2 \@tempdima\fi}%
-    \else
-      \addtolength{\@tempdimc}{#2}%
-      \addtolength{\@tempdimc}{-#1}%
-      \@setpar{\@@par
-        \@tempdima = \hsize
-        \addtolength{\@tempdima}{-#1}%
-        \@tempdimb = \hsize
-        \addtolength{\@tempdimb}{-#2}%
-        \if@RTL\parshape \tw@ 0pt \@tempdima 0pt \@tempdimb\else\parshape \tw@ #1 \@tempdima #2 \@tempdimb\fi
+  \expandafter\ifnum\scr@v@is@ge{3.22}\relax
+    \long\def\@makefntext##1{%
+      \ExecuteDoHook{footnote/text/begin}%
+      \raggedfootnote
+      \if@RTL
+        \rightskip
+      \else
+        \leftskip 
+      \fi
+      #2
+      \l@addto@macro\@trivlist{%
+        \ifnum\@listdepth=\@ne
+          \if@RTL
+            \advance\rightmargin #2\relax
+          \else
+            \advance\leftmargin #2\relax
+          \fi
+        \fi
       }%
-    \fi
-    \par
-    \parindent\@tempdimc\noindent
-    \ftn@font\hbox to \z@{\hss\@@makefnmark}##1%
-  }%
+      \parindent #3\noindent
+      \IfArgIsEmpty{#1}{}{%
+        \hskip \dimexpr #1-#2\relax
+      }%
+      \ftn@font\hbox to \z@{\hss\@@makefnmark}##1%
+      \ExecuteDoHook{footnote/text/end}%
+    }%
+  \else
+    \ClassInfo{\KOMAClassName}{%
+      Using old \string\@makefntext\space due to compatibility
+      level\MessageBreak
+      less than 3.22}%
+    \long\def\@makefntext##1{%
+      \setlength{\@tempdimc}{#3}%
+      \def\@tempa{#1}\ifx\@tempa\@empty
+        \@setpar{\@@par
+          \@tempdima = \hsize
+          \addtolength{\@tempdima}{-#2}%
+          \if@RTL
+            \parshape \@ne \z@ \@tempdima
+          \else
+            \parshape \@ne #2 \@tempdima
+          \fi
+          }%
+      \else
+        \addtolength{\@tempdimc}{#2}%
+        \addtolength{\@tempdimc}{-#1}%
+        \@setpar{\@@par
+          \@tempdima = \hsize
+          \addtolength{\@tempdima}{-#1}%
+          \@tempdimb = \hsize
+          \addtolength{\@tempdimb}{-#2}%
+          \if@RTL
+            \parshape \tw@ \z@ \@tempdima \z@ \@tempdimb
+          \else
+            \parshape \tw@ #1 \@tempdima #2 \@tempdimb
+          \fi
+        }%
+      \fi
+      \par
+      \parindent\@tempdimc\noindent
+      \ftn@font\hbox to \z@{\hss\@@makefnmark}##1%
+    }%
+  \fi
   \def\@@makefnmark{\hbox{\ftnm@font{#4}}}%
 }
 \deffootnote[1em]{1.5em}{1em}{\textsuperscript{\thefootnotemark}}
@@ -19614,11 +19737,48 @@ to\rtside{\box\bslice\hfil}}
       \hbox to \columnwidth{\hskip \dimexpr\columnwidth-\ftn@rule@width\relax  \leavevmode\leaders\hrule\@height\ftn@rule@height\hfill\kern\z@}}}%
   \kern 2.6\p@}  
 \renewcommand*\maketitle[1][1]{%
+  \expandafter\ifnum \csname scr@v@3.12\endcsname>\scr@compatibility\relax
+  \else
+    \def\and{%
+      \end{tabular}%
+      \hskip 1em \@plus.17fil%
+      \begin{tabular}[t]{c}%
+    }%
+  \fi
   \if@titlepage
     \begin{titlepage}
       \setcounter{page}{%
         #1%
       }%
+      \if@titlepageiscoverpage
+        \edef\titlepage@restore{%
+          \noexpand\endgroup
+          \noexpand\global\noexpand\@colht\the\@colht
+          \noexpand\global\noexpand\@colroom\the\@colroom
+          \noexpand\global\vsize\the\vsize
+          \noexpand\global\noexpand\@titlepageiscoverpagefalse
+          \noexpand\let\noexpand\titlepage@restore\noexpand\relax
+        }%
+        \begingroup
+        \topmargin=\dimexpr \coverpagetopmargin-1in\relax
+        \oddsidemargin=\dimexpr \coverpageleftmargin-1in\relax
+        \evensidemargin=\dimexpr \coverpageleftmargin-1in\relax
+        \textwidth=\dimexpr
+        \paperwidth-\coverpageleftmargin-\coverpagerightmargin\relax
+        \textheight=\dimexpr
+        \paperheight-\coverpagetopmargin-\coverpagebottommargin\relax
+        \headheight=0pt
+        \headsep=0pt
+        \footskip=\baselineskip
+        \@colht=\textheight
+        \@colroom=\textheight
+        \vsize=\textheight
+        \columnwidth=\textwidth
+        \hsize=\columnwidth
+        \linewidth=\hsize
+      \else
+        \let\titlepage@restore\relax
+      \fi
       \let\footnotesize\small
       \let\right@footnoterule\relax
       \let\left@footnoterule\relax
@@ -19629,54 +19789,97 @@ to\rtside{\box\bslice\hfil}}
       \renewcommand*\thefootnote{\@fnsymbol\c@footnote}%
       \let\@oldmakefnmark\@makefnmark
       \renewcommand*{\@makefnmark}{\rlap\@oldmakefnmark}%
-      \ifx\@extratitle\@empty \else
-        \noindent\@extratitle\next@tpage\cleardoubleemptypage
-        \thispagestyle{empty}%
+      \ifx\@extratitle\@empty
+        \ifx\@frontispiece\@empty
+        \else
+          \if@twoside\mbox{}\next@tpage\fi
+          \noindent\@frontispiece\next@tdpage
+        \fi
+      \else
+        \noindent\@extratitle
+        \ifx\@frontispiece\@empty
+        \else
+          \next@tpage
+          \noindent\@frontispiece
+        \fi
+        \next@tdpage
       \fi
       \setparsizes{\z@}{\z@}{\z@\@plus 1fil}\par@updaterelative
       \ifx\@titlehead\@empty \else
         \begin{minipage}[t]{\textwidth}%
-        \@titlehead
+          \usekomafont{titlehead}{\@titlehead\par}%
         \end{minipage}\par
       \fi
       \null\vfill
       \begin{center}
         \ifx\@subject\@empty \else
-          {\subject@font \@subject \par}%
+          {\usekomafont{subject}{\@subject\par}}%
           \vskip 3em
         \fi
-        {\titlefont\huge \@title\par}%
+        {\usekomafont{title}{\huge \@title\par}}%
         \vskip 1em
-        {\ifx\@subtitle\@empty\else\usekomafont{subtitle}\@subtitle\par\fi}%
+        {\ifx\@subtitle\@empty\else\usekomafont{subtitle}{\@subtitle\par}\fi}%
         \vskip 2em
-        {\Large \lineskip 0.75em
-          \begin{tabular}[t]{c}
-            \@author
-          \end{tabular}\par
+        {%
+          \usekomafont{author}{%
+            \lineskip 0.75em
+            \begin{tabular}[t]{c}
+              \@author
+            \end{tabular}\par
+          }%
         }%
         \vskip 1.5em
-        {\Large \@date \par}%
+        {\usekomafont{date}{\@date \par}}%
         \vskip \z@ \@plus3fill
-        {\Large \@publishers \par}%
+        {\usekomafont{publishers}{\@publishers \par}}%
         \vskip 3em
       \end{center}\par
-      \@thanks
+      \@thanks\global\let\@thanks\@empty
       \vfill\null
-      \if@twoside\next@tpage
-        \begin{minipage}[t]{\textwidth}
-          \@uppertitleback
-        \end{minipage}\par
-        \vfill
-        \begin{minipage}[b]{\textwidth}
-          \@lowertitleback
-        \end{minipage}
+      \if@twoside
+        \@tempswatrue
+        \expandafter\ifnum \@nameuse{scr@v@3.12}>\scr@compatibility\relax
+        \else
+          \ifx\@uppertitleback\@empty\ifx\@lowertitleback\@empty
+            \@tempswafalse
+          \fi\fi
+        \fi
+        \if@tempswa
+          \next@tpage
+          \begin{minipage}[t]{\textwidth}
+            \@uppertitleback
+          \end{minipage}\par
+          \vfill
+          \begin{minipage}[b]{\textwidth}
+            \@lowertitleback
+          \end{minipage}\par
+          \@thanks\global\let\@thanks\@empty
+        \fi
+      \else
+        \ifx\@uppertitleback\@empty\else
+          \ClassWarning{\KOMAClassName}{%
+            non empty \string\uppertitleback\space ignored
+            by \string\maketitle\MessageBreak
+            in `twoside=false' mode%
+          }%
+        \fi
+        \ifx\@lowertitleback\@empty\else
+          \ClassWarning{\KOMAClassName}{%
+            non empty \string\lowertitleback\space ignored
+            by \string\maketitle\MessageBreak
+            in `twoside=false' mode%
+          }%
+        \fi
       \fi
-      \ifx\@dedication\@empty \else
-        \next@tpage\null\vfill
-        {\centering \Large \@dedication \par}%
+      \ifx\@dedication\@empty
+      \else
+        \next@tdpage\null\vfill
+        {\centering\usekomafont{dedication}{\@dedication \par}}%
         \vskip \z@ \@plus3fill
-        \if@twoside \next@tpage\cleardoubleemptypage \fi
+        \@thanks\global\let\@thanks\@empty
+        \cleardoubleemptypage
       \fi
+      \ifx\titlepage@restore\relax\else\clearpage\titlepage@restore\fi
     \end{titlepage}
   \else
     \par
@@ -19684,101 +19887,111 @@ to\rtside{\box\bslice\hfil}}
     #1%
     \relax\ifnum\@tempcnta=1\else
       \ClassWarning{\KOMAClassName}{%
-        Optional argument of \string\maketitle\space ignored
-        at\MessageBreak
-        notitlepage-mode%
+        Optional argument of \string\maketitle\space ignored\MessageBreak
+        in `titlepage=false' mode%
+      }%
+    \fi
+    \ifx\@uppertitleback\@empty\else
+      \ClassWarning{\KOMAClassName}{%
+        non empty \string\uppertitleback\space ignored
+        by \string\maketitle\MessageBreak
+        in `titlepage=false' mode%
+      }%
+    \fi
+    \ifx\@lowertitleback\@empty\else
+      \ClassWarning{\KOMAClassName}{%
+        non empty \string\lowertitleback\space ignored
+        by \string\maketitle\MessageBreak
+        in `titlepage=false' mode%
       }%
     \fi
     \begingroup
+      \let\titlepage@restore\relax
       \renewcommand*\thefootnote{\@fnsymbol\c@footnote}%
       \let\@oldmakefnmark\@makefnmark
-      \renewcommand*{\@makefnmark}{\rlap\@oldmakefnmark}
+      \renewcommand*{\@makefnmark}{\rlap\@oldmakefnmark}%
+      \next@tdpage
       \if@twocolumn
         \ifnum \col@number=\@ne
+          \ifx\@extratitle\@empty
+            \ifx\@frontispiece\@empty\else\if@twoside\mbox{}\fi\fi
+          \else
+            \@makeextratitle
+          \fi
+          \ifx\@frontispiece\@empty
+            \ifx\@extratitle\@empty\else\next@tdpage\fi
+          \else
+            \next@tpage
+            \@makefrontispiece
+            \next@tdpage
+          \fi
           \@maketitle
         \else
+          \ifx\@extratitle\@empty
+            \ifx\@frontispiece\@empty\else\if@twoside\mbox{}\fi\fi
+          \else
+            \twocolumn[\@makeextratitle]%
+          \fi
+          \ifx\@frontispiece\@empty
+            \ifx\@extratitle\@empty\else\next@tdpage\fi
+          \else
+            \next@tpage
+            \twocolumn[\@makefrontispiece]%
+            \next@tdpage
+          \fi
           \twocolumn[\@maketitle]%
         \fi
       \else
-        \newpage
-        \global\@topnum\z@
+        \ifx\@extratitle\@empty
+          \ifx\@frontispiece\@empty\else \mbox{}\fi
+        \else
+          \@makeextratitle
+        \fi
+        \ifx\@frontispiece\@empty
+          \ifx\@extratitle\@empty\else\next@tdpage\fi
+        \else
+          \next@tpage
+          \@makefrontispiece
+          \next@tdpage
+        \fi
         \@maketitle
       \fi
-      \thispagestyle{\titlepagestyle}\@thanks
+      \ifx\titlepagestyle\@empty\else\thispagestyle{\titlepagestyle}\fi
+      \@thanks\global\let\@thanks\@empty
     \endgroup
   \fi
   \setcounter{footnote}{0}%
-  \let\thanks\relax
-  \let\LTRthanks\relax
-  \let\RTLthanks\relax
-  \let\maketitle\relax
-  \let\@maketitle\relax
-  \global\let\@thanks\@empty
-  \global\let\@author\@empty
-  \global\let\@date\@empty
-  \global\let\@title\@empty
-  \global\let\@subtitle\@empty
-  \global\let\@extratitle\@empty
-  \global\let\@titlehead\@empty
-  \global\let\@subject\@empty
-  \global\let\@publishers\@empty
-  \global\let\@uppertitleback\@empty
-  \global\let\@lowertitleback\@empty
-  \global\let\@dedication\@empty
-  \global\let\author\relax
-  \global\let\title\relax
-  \global\let\extratitle\relax
-  \global\let\titlehead\relax
-  \global\let\subject\relax
-  \global\let\publishers\relax
-  \global\let\uppertitleback\relax
-  \global\let\lowertitleback\relax
-  \global\let\dedication\relax
-  \global\let\date\relax
-  \global\let\and\relax
-}%
-\renewcommand*{\@maketitle}{%
-  \clearpage
-  \let\footnote\thanks
-  \let\LTRfootnote\LTRthanks
-  \let\RTLfootnote\RTLthanks
-  \ifx\@extratitle\@empty \else
-    \noindent\@extratitle \next@tpage \if@twoside \null\next@tpage \fi
-  \fi
-  \setparsizes{\z@}{\z@}{\z@\@plus 1fil}\par@updaterelative
-  \ifx\@titlehead\@empty \else
-    \begin{minipage}[t]{\textwidth}
-      \@titlehead
-    \end{minipage}\par
+  \expandafter\ifnum \csname scr@v@3.12\endcsname>\scr@compatibility\relax
+    \let\thanks\relax
+    \let\LTRthanks\relax
+    \let\RTLthanks\relax
+    \let\maketitle\relax
+    \let\@maketitle\relax
+    \global\let\@thanks\@empty
+    \global\let\@author\@empty
+    \global\let\@date\@empty
+    \global\let\@title\@empty
+    \global\let\@subtitle\@empty
+    \global\let\@extratitle\@empty
+    \global\let\@frontispiece\@empty
+    \global\let\@titlehead\@empty
+    \global\let\@subject\@empty
+    \global\let\@publishers\@empty
+    \global\let\@uppertitleback\@empty
+    \global\let\@lowertitleback\@empty
+    \global\let\@dedication\@empty
+    \global\let\author\relax
+    \global\let\title\relax
+    \global\let\extratitle\relax
+    \global\let\titlehead\relax
+    \global\let\subject\relax
+    \global\let\publishers\relax
+    \global\let\uppertitleback\relax
+    \global\let\lowertitleback\relax
+    \global\let\dedication\relax
+    \global\let\date\relax
   \fi
-  \null
-  \vskip 2em%
-  \begin{center}%
-    \ifx\@subject\@empty \else
-      {\subject@font \@subject \par}
-      \vskip 1.5em
-    \fi
-    {\titlefont\huge \@title \par}%
-    \vskip .5em
-    {\ifx\@subtitle\@empty\else\usekomafont{subtitle}\@subtitle\par\fi}%
-    \vskip 1em
-    {\Large
-      \lineskip .5em%
-      \begin{tabular}[t]{c}
-        \@author
-      \end{tabular}\par
-    }%
-    \vskip 1em%
-    {\Large \@date \par}%
-    \vskip \z@ \@plus 1em
-    {\Large \@publishers \par}
-    \ifx\@dedication\@empty \else
-      \vskip 2em
-      {\Large \@dedication \par}
-    \fi
-  \end{center}%
-  \par
-  \vskip 2em
+  \global\let\and\relax
 }%
 \def\raggedsection{\if@RTL\raggedleft\else\raggedright\fi}
 \renewcommand*\autodot{\if@altsecnumformat\@SepMark\fi}
@@ -19794,14 +20007,12 @@ to\rtside{\box\bslice\hfil}}
 \renewcommand*{\thesubparagraph}{%
   \theparagraph\@SepMark\@arabic\c@subparagraph
 }
-\renewcommand*\thefigure{%
-  \thechapter\@SepMark%
-  \@arabic\c@figure
-}
-\renewcommand*\thetable{%
-  \thechapter\@SepMark%
-  \@arabic\c@table
-}
+\expandafter\ifnum\scr@v@is@le{2.97d}%
+  \renewcommand*\thefigure{\thechapter\@SepMark\@arabic\c@figure}
+\fi
+\expandafter\ifnum\scr@v@is@le{2.97d}%
+  \renewcommand*\thetable{\thechapter\@SepMark\@arabic\c@table}
+\fi
 \renewcommand*\theequation{%
   \thechapter\@SepMark%
   \@arabic\c@equation
@@ -19871,16 +20082,6 @@ to\rtside{\box\bslice\hfil}}
   \fi
   \bib@endhook
 }
-\renewcommand*\left@footnoterule{%
-  \kern-3\p@
-  \ifx\@textbottom\relax\else\vskip \z@ \@plus.05fil\fi
-  \hrule\@width.4\columnwidth
-  \kern 2.6\p@}
-\renewcommand*\right@footnoterule{%
-  \kern-3\p@
-  \ifx\@textbottom\relax\else\vskip \z@ \@plus.05fil\fi
-  \hbox to \columnwidth{\hskip .6\columnwidth \hrulefill }
-  \kern2.6\p@}
 \renewcommand*{\raggeddictum}{\if@RTL\raggedright\else\raggedleft\fi}
 \renewcommand*{\raggeddictumtext}{\if@RTL\raggedleft\else\raggedright\fi}
 \renewcommand*{\raggeddictumauthor}{\if@RTL\raggedright\else\raggedleft\fi}
@@ -19889,76 +20090,61 @@ to\rtside{\box\bslice\hfil}}
 }
 \renewcommand{\@@makecaption}[3]{%
   \cap@margin
-  \ifonelinecaptions
-    \@tempcnta=\value{mpfootnote}\@tempcntb=\value{footnote}%
-    \let\scr@tmp@footnotetext=\@footnotetext
-    \let\@footnotetext=\@gobble
-    \let\scr@tmp@LTRfootnotetext=\@LTRfootnotetext
-    \let\@LTRfootnotetext=\@gobble
-    \let\scr@tmp@RTLfootnotetext=\@RTLfootnotetext
-    \let\@RTLfootnotetext=\@gobble
-    \sbox\@tempboxa{%
-      {\capfont{\strut\ignorespaces
-        #1{{\caplabelfont{#2\captionformat}}}%
-        #3\unskip\strut}}%
-    }%
-    \let\@footnotetext=\scr@tmp@footnotetext
-    \let\scr@tmp@footnotetext=\undefined
-    \let\@LTRfootnotetext=\scr@tmp@LTRfootnotetext
-    \let\scr@tmp@LTRfootnotetext=\undefined
-   \let\@RTLfootnotetext=\scr@tmp@RTLfootnotetext
-    \let\scr@tmp@RTLfootnotetext=\undefined
-    \setcounter{footnote}{\@tempcntb}%
-    \setcounter{mpfootnote}{\@tempcnta}%
-  \else
-    \sbox\@tempboxa{\hspace*{2\cap@width}}%
-  \fi
-  \begingroup%
-    \setlength{\@tempdima}{\cap@width}%
-    \ifdim \wd\@tempboxa >\@tempdima
-      \hb@xt@\hsize{%
-        \setbox\@tempboxa\vbox{\hsize=\cap@width
-          \ifdofullc@p
-            {\capfont{\@hangfrom{\scr@smashdp{\strut\ignorespaces
-                  #1{{\caplabelfont{#2\captionformat}}}}}%
-              {#3\unskip\strut\par}}}%
-          \else%
-            \ifdim\cap@indent<\z@
-              {\capfont{\strut\ignorespaces
-                #1{{\caplabelfont{#2\captionformat\par}}}%
-                \noindent\hspace*{-\cap@indent}#3\unskip\strut\par}}%
-            \else%
-              \if@capbreak
-                {\capfont{\strut\ignorespaces
-                  #1{{\caplabelfont{#2\captionformat\par}}}%
-                  \noindent\@hangfrom{\hspace*{\cap@indent}}{#3\par}}}%
-              \else
-                {\capfont{\@hangfrom{\scr@smashdp\strut\hspace*{\cap@indent}}%
-                  {\hspace{-\cap@indent}\scr@smashdp{\ignorespaces#1%
-                    {{\caplabelfont{#2\captionformat}}}}#3\unskip\strut\par}}}%
-              \fi
-            \fi
-          \fi
+  \begingroup
+    \ifonelinecaptions
+      \def\stepcounter##1{\advance\value{##1}\@ne}%
+      \let\refstepcounter\stepcounter
+      \let\label\@gobble
+      \let\@footnotetext=\@gobble
+      \let\@LTRfootnotetext=\@gobble
+      \let\@RTLfootnotetext=\@gobble
+      \let\hypertarget\@gobbletwo
+      \edef\@xnewline{%
+        \unexpanded{\ClassInfo{\KOMAClassName}{%
+            Workaround for not recommended usage of \string\\ or\MessageBreak
+            \string\newline in caption text
+          }%
+          \hspace*{\linewidth}\hspace{1sp}%
         }%
-        \setlength{\@tempdima}{\ht\@tempboxa}%
-        \addtolength{\@tempdima}{\dp\@tempboxa}%
-        \addtolength{\@tempdima}{-\ht\strutbox}%
-        \ht\@tempboxa\ht\strutbox
-        \dp\@tempboxa\@tempdima
-        \strut\cap@left
-        \box\@tempboxa
-        \cap@right\strut
+        \unexpanded\expandafter{\@xnewline}%
       }%
-    \else
-      \global \@minipagefalse
-      \sbox\@tempboxa{%
-        {\capfont{\scr@smashdp{\strut\ignorespaces
-          #1{{\caplabelfont{#2\captionformat}}}}%
-          #3}}%
+      \edef\@xcentercr{%
+        \unexpanded{\ClassInfo{\KOMAClassName}{%
+            Workaround for not recommended usage of \string\\ or\MessageBreak
+            \string\newline in caption text
+          }%
+          \hspace*{\linewidth}\hspace{1sp}%
+        }%
+        \unexpanded\expandafter{\@xcentercr}%
       }%
-      {\capfont{\hb@xt@\hsize{\strut\cap@left\if@RTL\beginR\fi\box\@tempboxa\if@RTL\endR\fi\cap@right\strut}}}%
+      \settowidth{\@tempdima}{\scr@@makesinglelinecaption{#1}{#2}{#3}}%
+      \ifdim\@tempdima>\cap@width
+        \aftergroup\scr@makemultilinecaption
+      \else
+        \aftergroup\scr@makesinglelinecaption
+      \fi
+    \else
+      \aftergroup\scr@makemultilinecaption
     \fi
   \endgroup
+  {#1}{#2}{#3}%
+}
+\renewcommand{\scr@makesinglelinecaption}[3]{%
+  {%
+    \usefontofkomafont{caption}{%
+      \hb@xt@\hsize{%
+        \cap@left
+        \if@RTL
+          \beginR
+        \fi
+        \scr@@makesinglelinecaption{#1}{#2}{#3}%
+        \if@RTL
+          \endR
+        \fi
+        \cap@right
+      }\par\kern\dp\strutbox%
+    }%
+  }\kern-\dp\strutbox
 }
 \renewcommand{\@makecaption}[2]{%
   \if@captionabove
@@ -19974,9 +20160,6 @@ to\rtside{\box\bslice\hfil}}
   \fi
 }
 \bidi@AfterFile{longtable-xetex-bidi.def}{%
-  \@ifpackageloaded{caption2}{\@komalongtablefalse
-    \scr@caption@before@longtable@warning{caption2}%
-  }{}%
   \if@komalongtable
     \renewcommand{\LT@makecaption}[3]{%
       \noalign{%
@@ -19988,6 +20171,7 @@ to\rtside{\box\bslice\hfil}}
       }%
       \LT@mcol\LT@cols c{%
         \hbox to\z@{\hss\parbox[t]\linewidth{%
+            \def\@captype{table}%
             \@@makecaption{#1}{#2}{#3}%
             \endgraf
             \if@captionabove
@@ -20039,7 +20223,7 @@ to\rtside{\box\bslice\hfil}}
   \expandafter\renewcommand%
   \csname scr@tso@#1@linefill\endcsname{%
     \if@chapterentrywithdots
-      \TOCLineLeaderFill\relax
+      {\usekomafont{chapterentrydots}{\TOCLineLeaderFill}}\relax
     \else
       \hfill
     \fi
@@ -20061,15 +20245,6 @@ to\rtside{\box\bslice\hfil}}
 
 \CloneTOCEntryStyle{section}{default}
 
-\DeclareSectionCommand[%
-  style=part,%
-  level=\m@ne,%
-  pagestyle=plain,%
-  tocstyle=part,%
-  toclevel=\m@ne,%
-  tocindent=\z@,%
-  tocnumwidth=2em%
-]{part}
 \DeclareSectionCommand[%
   style=chapter,%
   level=\z@,%
@@ -20085,9 +20260,19 @@ to\rtside{\box\bslice\hfil}}
   beforeskip=-3.5ex \@plus -1ex \@minus -.2ex,%
   afterskip=2.3ex \@plus.2ex,%
   tocstyle=section,%
+  tocindentfollows=chapter,%
   tocindent=1.5em,%
   tocnumwidth=2.3em%
 ]{section}
+\DeclareSectionCommand[%
+  style=part,%
+  level=\m@ne,%
+  pagestyle=plain,%
+  tocstyle=part,%
+  toclevel=\m@ne,%
+  tocindent=\z@,%
+  tocnumwidth=2em%
+]{part}
 \DeclareSectionCommand[%
   style=section,%
   level=2,%
@@ -20114,6 +20299,7 @@ to\rtside{\box\bslice\hfil}}
   indent=\z@,%
   beforeskip=3.25ex \@plus1ex \@minus.2ex,%
   afterskip=-1em,%
+  tocindentfollows=subsubsection,%
   tocstyle=section,%
   tocindent=10em,%
   tocnumwidth=5em%
@@ -20128,8 +20314,6 @@ to\rtside{\box\bslice\hfil}}
   tocindent=12em,%
   tocnumwidth=6em%
 ]{subparagraph}
-
-
 %    \end{macrocode}
 % \iffalse
 %</scrreprt-xetex-bidi.def>
@@ -20971,7 +21155,7 @@ to\rtside{\box\bslice\hfil}}
 %\fi
 % \section{File \texttt{tocbasic-xetex-bidi.def}}
 %    \begin{macrocode}
-\ProvidesFile{tocbasic-xetex-bidi.def}[2016/09/14 v0.2 bidi adaptations for tocbasic package for XeTeX engine]
+\ProvidesFile{tocbasic-xetex-bidi.def}[2022/05/22 v0.3 bidi adaptations for tocbasic package for XeTeX engine]
 \bidi@undef\scr@dte@def@l@undottedtocline
 \bidi@undef\scr@dte@undottedtocline@init
 \DeclareTOCEntryStyle{undottedtocline}[{%
@@ -20980,15 +21164,15 @@ to\rtside{\box\bslice\hfil}}
   \DefineTOCEntryLengthOption{numwidth}%
     {scr@tso@}{@numwidth}{entry number width}%
   \@ifundefined{#1tocdepth}{%
-    \ifstr{#1}{part}{\@namedef{#1tocdepth}{-1}}{%
-      \ifstr{#1}{chapter}{\@namedef{#1tocdepth}{0}}{%
-        \ifstr{#1}{section}{\@namedef{#1tocdepth}{1}}{%
-          \ifstr{#1}{subsection}{\@namedef{#1tocdepth}{2}}{%
-            \ifstr{#1}{subsubsection}{\@namedef{#1tocdepth}{3}}{%
-              \ifstr{#1}{paragraph}{\@namedef{#1tocdepth}{4}}{%
-                \ifstr{#1}{subparagraph}{\@namedef{#1tocdepth}{5}}{%
-                  \ifstr{#1}{figure}{\@namedef{#1tocdepth}{1}}{%
-                    \ifstr{#1}{table}{\@namedef{#1tocdepth}{1}}{%
+    \Ifstr{#1}{part}{\@namedef{#1tocdepth}{-1}}{%
+      \Ifstr{#1}{chapter}{\@namedef{#1tocdepth}{0}}{%
+        \Ifstr{#1}{section}{\@namedef{#1tocdepth}{1}}{%
+          \Ifstr{#1}{subsection}{\@namedef{#1tocdepth}{2}}{%
+            \Ifstr{#1}{subsubsection}{\@namedef{#1tocdepth}{3}}{%
+              \Ifstr{#1}{paragraph}{\@namedef{#1tocdepth}{4}}{%
+                \Ifstr{#1}{subparagraph}{\@namedef{#1tocdepth}{5}}{%
+                  \Ifstr{#1}{figure}{\@namedef{#1tocdepth}{1}}{%
+                    \Ifstr{#1}{table}{\@namedef{#1tocdepth}{1}}{%
                       \expandafter\let\csname #1tocdepth\expandafter\endcsname
                       \csname #1numdepth\endcsname
                     }%
@@ -21003,20 +21187,20 @@ to\rtside{\box\bslice\hfil}}
   }{}%
   \@ifundefined{scr@tso@#1@indent}{%
     \@ifundefined{scr@#1@tocindent}{%
-      \ifstr{#1}{figure}{\@namedef{scr@tso@#1@indent}{1.5em}}{%
-        \ifstr{#1}{table}{\@namedef{scr@tso@#1@indent}{1.5em}}{%
-          \ifstr{#1}{part}{\@namedef{scr@tso@#1@indent}{0em}}{%
-            \ifstr{#1}{chapter}{\@namedef{scr@tso@#1@indent}{0em}}{%
+      \Ifstr{#1}{figure}{\@namedef{scr@tso@#1@indent}{1.5em}}{%
+        \Ifstr{#1}{table}{\@namedef{scr@tso@#1@indent}{1.5em}}{%
+          \Ifstr{#1}{part}{\@namedef{scr@tso@#1@indent}{0em}}{%
+            \Ifstr{#1}{chapter}{\@namedef{scr@tso@#1@indent}{0em}}{%
               \scr@ifundefinedorrelax{l@chapter}{%
-                \ifstr{#1}{section}{\@namedef{scr@tso@#1@indent}{0pt}}{%
-                  \ifstr{#1}{subsection}{\@namedef{scr@tso@#1@indent}{1.5em}}{%
-                    \ifstr{#1}{subsubsection}{%
+                \Ifstr{#1}{section}{\@namedef{scr@tso@#1@indent}{0pt}}{%
+                  \Ifstr{#1}{subsection}{\@namedef{scr@tso@#1@indent}{1.5em}}{%
+                    \Ifstr{#1}{subsubsection}{%
                       \@namedef{scr@tso@#1@indent}{3.8em}%
                     }{%
-                      \ifstr{#1}{paragraph}{%
+                      \Ifstr{#1}{paragraph}{%
                         \@namedef{scr@tso@#1@indent}{7em}%
                       }{%
-                        \ifstr{#1}{subparagraph}{%
+                        \Ifstr{#1}{subparagraph}{%
                           \@namedef{scr@tso@#1@indent}{10em}%
                         }{%
                         }%
@@ -21025,15 +21209,15 @@ to\rtside{\box\bslice\hfil}}
                   }%
                 }%
               }{%
-                \ifstr{#1}{section}{\@namedef{scr@tso@#1@indent}{1.5em}}{%
-                  \ifstr{#1}{subsection}{\@namedef{scr@tso@#1@indent}{3.8em}}{%
-                    \ifstr{#1}{subsubsection}{%
+                \Ifstr{#1}{section}{\@namedef{scr@tso@#1@indent}{1.5em}}{%
+                  \Ifstr{#1}{subsection}{\@namedef{scr@tso@#1@indent}{3.8em}}{%
+                    \Ifstr{#1}{subsubsection}{%
                       \@namedef{scr@tso@#1@indent}{7.0em}%
                     }{%
-                      \ifstr{#1}{paragraph}{%
+                      \Ifstr{#1}{paragraph}{%
                         \@namedef{scr@tso@#1@indent}{10em}%
                       }{%
-                        \ifstr{#1}{subparagraph}{%
+                        \Ifstr{#1}{subparagraph}{%
                           \@namedef{scr@tso@#1@indent}{12em}%
                         }{%
                         }%
@@ -21052,19 +21236,19 @@ to\rtside{\box\bslice\hfil}}
   }{}%
   \@ifundefined{scr@tso@#1@numwidth}{%
     \@ifundefined{scr@#1@tocnumwidth}{%
-      \ifstr{#1}{figure}{\@namedef{scr@tso@#1@numwidth}{2.3em}}{%
-        \ifstr{#1}{table}{\@namedef{scr@tso@#1@numwidth}{2.3em}}{%
-          \ifstr{#1}{chapter}{\@namedef{scr@tso@#1@numwidth}{1.5em}}{%
+      \Ifstr{#1}{figure}{\@namedef{scr@tso@#1@numwidth}{2.3em}}{%
+        \Ifstr{#1}{table}{\@namedef{scr@tso@#1@numwidth}{2.3em}}{%
+          \Ifstr{#1}{chapter}{\@namedef{scr@tso@#1@numwidth}{1.5em}}{%
             \scr@ifundefinedorrelax{chapter}{%
-              \ifstr{#1}{section}{\@namedef{scr@tso@#1@numwidth}{1.5em}}{%
-                \ifstr{#1}{subsection}{\@namedef{scr@tso@#1@numwidth}{2.3em}}{%
-                  \ifstr{#1}{subsubsection}{%
+              \Ifstr{#1}{section}{\@namedef{scr@tso@#1@numwidth}{1.5em}}{%
+                \Ifstr{#1}{subsection}{\@namedef{scr@tso@#1@numwidth}{2.3em}}{%
+                  \Ifstr{#1}{subsubsection}{%
                     \@namedef{scr@tso@#1@numwidth}{3.2em}%
                   }{%
-                    \ifstr{#1}{paragraph}{%
+                    \Ifstr{#1}{paragraph}{%
                       \@namedef{scr@tso@#1@numwidth}{4.1em}%
                     }{%
-                      \ifstr{#1}{subparagraph}{%
+                      \Ifstr{#1}{subparagraph}{%
                         \@namedef{scr@tso@#1@numwidth}{5m}%
                       }{%
                       }%
@@ -21073,15 +21257,15 @@ to\rtside{\box\bslice\hfil}}
                 }%
               }%
             }{%
-              \ifstr{#1}{section}{\@namedef{scr@tso@#1@numwidth}{2.3em}}{%
-                \ifstr{#1}{subsection}{\@namedef{scr@tso@#1@numwidth}{3.2em}}{%
-                  \ifstr{#1}{subsubsection}{%
+              \Ifstr{#1}{section}{\@namedef{scr@tso@#1@numwidth}{2.3em}}{%
+                \Ifstr{#1}{subsection}{\@namedef{scr@tso@#1@numwidth}{3.2em}}{%
+                  \Ifstr{#1}{subsubsection}{%
                     \@namedef{scr@tso@#1@numwidth}{3.1em}%
                   }{%
-                    \ifstr{#1}{paragraph}{%
+                    \Ifstr{#1}{paragraph}{%
                       \@namedef{scr@tso@#1@numwidth}{5em}%
                     }{%
-                      \ifstr{#1}{subparagraph}{%
+                      \Ifstr{#1}{subparagraph}{%
                         \@namedef{scr@tso@#1@numwidth}{6em}%
                       }{%
                       }%
@@ -21118,8 +21302,12 @@ to\rtside{\box\bslice\hfil}}
       \leavevmode
       \bfseries
       \advance\bidi@leftskip\@tempdima
-      \advance\bidi@leftskip\@nameuse{scr@tso@#1@indent}%
-      \hskip -\dimexpr \bidi@leftskip-\@nameuse{scr@tso@#1@indent}\relax
+      \Iftocfeature{\@currext}{noindent}{%
+        \hskip -\bidi@leftskip
+      }{%
+        \advance\bidi@leftskip\@nameuse{scr@tso@#1@indent}%
+        \hskip -\dimexpr \bidi@leftskip-\@nameuse{scr@tso@#1@indent}\relax
+      }%
       ##1%
       \nobreak
       \hfil \nobreak\hb@xt@\@pnumwidth{\hss ##2}%
@@ -21135,15 +21323,15 @@ to\rtside{\box\bslice\hfil}}
   \DefineTOCEntryLengthOption{indent}%
     {scr@tso@}{@indent}{entry indent}%
   \@ifundefined{#1tocdepth}{%
-    \ifstr{#1}{part}{\@namedef{#1tocdepth}{-1}}{%
-      \ifstr{#1}{chapter}{\@namedef{#1tocdepth}{0}}{%
-        \ifstr{#1}{section}{\@namedef{#1tocdepth}{1}}{%
-          \ifstr{#1}{subsection}{\@namedef{#1tocdepth}{2}}{%
-            \ifstr{#1}{subsubsection}{\@namedef{#1tocdepth}{3}}{%
-              \ifstr{#1}{paragraph}{\@namedef{#1tocdepth}{4}}{%
-                \ifstr{#1}{subparagraph}{\@namedef{#1tocdepth}{5}}{%
-                  \ifstr{#1}{figure}{\@namedef{#1tocdepth}{1}}{%
-                    \ifstr{#1}{table}{\@namedef{#1tocdepth}{1}}{%
+    \Ifstr{#1}{part}{\@namedef{#1tocdepth}{-1}}{%
+      \Ifstr{#1}{chapter}{\@namedef{#1tocdepth}{0}}{%
+        \Ifstr{#1}{section}{\@namedef{#1tocdepth}{1}}{%
+          \Ifstr{#1}{subsection}{\@namedef{#1tocdepth}{2}}{%
+            \Ifstr{#1}{subsubsection}{\@namedef{#1tocdepth}{3}}{%
+              \Ifstr{#1}{paragraph}{\@namedef{#1tocdepth}{4}}{%
+                \Ifstr{#1}{subparagraph}{\@namedef{#1tocdepth}{5}}{%
+                  \Ifstr{#1}{figure}{\@namedef{#1tocdepth}{1}}{%
+                    \Ifstr{#1}{table}{\@namedef{#1tocdepth}{1}}{%
                       \expandafter\let\csname #1tocdepth\expandafter\endcsname
                       \csname #1numdepth\endcsname
                     }%
@@ -21158,20 +21346,20 @@ to\rtside{\box\bslice\hfil}}
   }{}%
   \@ifundefined{scr@tso@#1@indent}{%
     \@ifundefined{scr@#1@tocindent}{%
-      \ifstr{#1}{figure}{\@namedef{scr@tso@#1@indent}{1.5em}}{%
-        \ifstr{#1}{table}{\@namedef{scr@tso@#1@indent}{1.5em}}{%
-          \ifstr{#1}{part}{\@namedef{scr@tso@#1@indent}{0em}}{%
-            \ifstr{#1}{chapter}{\@namedef{scr@tso@#1@indent}{0em}}{%
+      \Ifstr{#1}{figure}{\@namedef{scr@tso@#1@indent}{1.5em}}{%
+        \Ifstr{#1}{table}{\@namedef{scr@tso@#1@indent}{1.5em}}{%
+          \Ifstr{#1}{part}{\@namedef{scr@tso@#1@indent}{0em}}{%
+            \Ifstr{#1}{chapter}{\@namedef{scr@tso@#1@indent}{0em}}{%
               \scr@ifundefinedorrelax{l@chapter}{%
-                \ifstr{#1}{section}{\@namedef{scr@tso@#1@indent}{0pt}}{%
-                  \ifstr{#1}{subsection}{\@namedef{scr@tso@#1@indent}{1.5em}}{%
-                    \ifstr{#1}{subsubsection}{%
+                \Ifstr{#1}{section}{\@namedef{scr@tso@#1@indent}{0pt}}{%
+                  \Ifstr{#1}{subsection}{\@namedef{scr@tso@#1@indent}{1.5em}}{%
+                    \Ifstr{#1}{subsubsection}{%
                       \@namedef{scr@tso@#1@indent}{3.8em}%
                     }{%
-                      \ifstr{#1}{paragraph}{%
+                      \Ifstr{#1}{paragraph}{%
                         \@namedef{scr@tso@#1@indent}{7em}%
                       }{%
-                        \ifstr{#1}{subparagraph}{%
+                        \Ifstr{#1}{subparagraph}{%
                           \@namedef{scr@tso@#1@indent}{10em}%
                         }{%
                         }%
@@ -21180,15 +21368,15 @@ to\rtside{\box\bslice\hfil}}
                   }%
                 }%
               }{%
-                \ifstr{#1}{section}{\@namedef{scr@tso@#1@indent}{1.5em}}{%
-                  \ifstr{#1}{subsection}{\@namedef{scr@tso@#1@indent}{3.8em}}{%
-                    \ifstr{#1}{subsubsection}{%
+                \Ifstr{#1}{section}{\@namedef{scr@tso@#1@indent}{1.5em}}{%
+                  \Ifstr{#1}{subsection}{\@namedef{scr@tso@#1@indent}{3.8em}}{%
+                    \Ifstr{#1}{subsubsection}{%
                       \@namedef{scr@tso@#1@indent}{7.0em}%
                     }{%
-                      \ifstr{#1}{paragraph}{%
+                      \Ifstr{#1}{paragraph}{%
                         \@namedef{scr@tso@#1@indent}{10em}%
                       }{%
-                        \ifstr{#1}{subparagraph}{%
+                        \Ifstr{#1}{subparagraph}{%
                           \@namedef{scr@tso@#1@indent}{12em}%
                         }{%
                         }%
@@ -21226,7 +21414,10 @@ to\rtside{\box\bslice\hfil}}
       \leavevmode
       \large
       \bfseries
-      \advance\bidi@leftskip\@nameuse{scr@tso@#1@indent}%
+      \Iftocfeature{\@currext}{noindent}{%
+      }{%
+        \advance\bidi@leftskip\@nameuse{scr@tso@#1@indent}%
+      }%
       ##1%
       \hfil \nobreak\hb@xt@\@pnumwidth{\hss ##2}%
       \par
@@ -21245,14 +21436,57 @@ to\rtside{\box\bslice\hfil}}
   \else
     \tocbasic@DependOnPenaltyAndTOCLevel{#1}%
     \addvspace{\@nameuse{scr@tso@#1@beforeskip}}\relax
+    \@nameuse{Ifscr@tso@#1@dynindent}{%
+      \expandafter\ifx\csname scr@tso@#1@indentfollows\endcsname\@empty
+        \PackageWarning{tocbasic}{`dynindent' for `#1' not available}%
+      \else
+        \edef\reserved@a{\@nameuse{scr@tso@#1@indentfollows}}%
+        \@for \reserved@a:=\reserved@a\do {%
+          \scr@trim@spaces\reserved@a
+          \ifx\reserved@a\@empty\else
+            \scr@ifundefinedorrelax{\reserved@a tocdepth}{%
+            }{%
+              \ifnum \@nameuse{\reserved@a tocdepth}<\@nameuse{#1tocdepth}%
+                \@tempdima\@nameuse{scr@tso@\reserved@a @indent}\relax
+                \@nameuse{Ifscr@tso@\reserved@a @dynnumwidth}{%
+                  \scr@ifundefinedorrelax
+                  {scr@dte@\reserved@a @lastmaxnumwidth}{%
+                    \advance\@tempdima
+                    \@nameuse{scr@tso@\reserved@a @numwidth}\relax
+                  }{%
+                    \advance\@tempdima
+                    \@nameuse{scr@dte@\reserved@a @lastmaxnumwidth}\relax
+                  }%
+                }{%
+                  \advance\@tempdima
+                  \@nameuse{scr@tso@\reserved@a @numwidth}\relax
+                }%
+                \ifdim \@tempdima>\@nameuse{scr@tso@#1@indent}\relax
+                  \expandafter\edef\csname scr@tso@#1@indent\endcsname
+                  {\the\@tempdima}%
+                \fi
+              \fi
+            }%
+          \fi
+        }%
+      \fi
+    }{}%
     {%
-      \bidi@leftskip \@nameuse{scr@tso@#1@indent}\relax
-      \bidi@rightskip \@tocrmarg
+      \Iftocfeature{\@currext}{noindent}{%
+        \bidi@leftskip \z@
+      }{%
+        \bidi@leftskip \@nameuse{scr@tso@#1@indent}\relax
+      }%
+      \bidi@rightskip \@nameuse{scr@tso@#1@rightindent}\relax
       \parfillskip -\bidi@rightskip
       \@nameuse{Ifscr@tso@#1@raggedpage}{%
         \addtolength{\parfillskip}{\z@ \@plus 1fil}%
       }{}%
-      \parindent \@nameuse{scr@tso@#1@indent}\relax
+      \Iftocfeature{\@currext}{noindent}{%
+        \parindent \z@
+      }{%
+        \parindent \@nameuse{scr@tso@#1@indent}\relax
+      }%
       \@afterindenttrue
       \interlinepenalty\@M
       \expandafter\ifx\csname ragged#1entry\endcsname\raggedright
@@ -21286,6 +21520,7 @@ to\rtside{\box\bslice\hfil}}
           \sbox\scr@dte@tocline@numbox{\@nameuse{scr@tso@#1@numberformat}{##1}}%
           \global\scr@dte@tocline@numberwidth
           \dimexpr\wd\scr@dte@tocline@numbox+\@nameuse{scr@tso@#1@numsep}\relax
+          \relax
           \ifdim \scr@dte@tocline@numberwidth
                 >\@nameuse{scr@dte@#1@maxnumwidth}\relax
             \global\@nameuse{scr@dte@#1@maxnumwidth}\scr@dte@tocline@numberwidth
@@ -21293,9 +21528,8 @@ to\rtside{\box\bslice\hfil}}
           \@nameuse{Ifscr@tso@#1@dynnumwidth}{}{%
             \ifdim \scr@dte@tocline@numberwidth
                   >\dimexpr \@nameuse{scr@tso@#1@numwidth}%
-                           +\@nameuse{scr@tso@#1@numsep}\relax
-              \PackageWarning{tocbasic%
-              }{%
+                           +\@nameuse{scr@tso@#1@numsep}\relax\relax
+              \PackageWarning{tocbasic}{%
                 number width of #1 toc entries should be
                 increased!\MessageBreak
                 Currently used number width =
@@ -21319,6 +21553,8 @@ to\rtside{\box\bslice\hfil}}
           {%
             \normalfont\normalsize\@nameuse{scr@tso@#1@linefill}%
             \nobreak
+            \expandafter\let\expandafter\scr@dte@pagenumberwidth
+            \csname scr@tso@#1@pagenumberwidth\endcsname
             \@nameuse{scr@tso@#1@pagenumberbox}{%
               \@nameuse{scr@tso@#1@pagenumberformat}{#3}%
             }%
@@ -21331,6 +21567,7 @@ to\rtside{\box\bslice\hfil}}
   \fi
 }
 
+
 \bidi@undef\scr@dte@def@l@tocline
 \bidi@undef\scr@dte@tocline@init
 \DeclareTOCEntryStyle{tocline}[{%
@@ -21340,6 +21577,10 @@ to\rtside{\box\bslice\hfil}}
     {scr@tso@}{@breakafternumber}{line break after number flag}%
   \DefineTOCEntryIfOption{dynnumwidth}%
     {scr@tso@}{@dynnumwidth}{dynamic number width flag}%
+  \DefineTOCEntryListOption{indentfollows}%
+    {scr@tso@}{@indentfollows}{list of levels that define the indent}%
+  \DefineTOCEntryIfOption{dynindent}%
+    {scr@tso@}{@dynindent}{dynamic indent width flag}%
   \DefineTOCEntryCommandOption{entryformat}%
     {scr@tso@}{@entryformat}[1]{entry format}%
   \DefineTOCEntryCommandOption{entrynumberformat}%
@@ -21358,6 +21599,10 @@ to\rtside{\box\bslice\hfil}}
     {scr@tso@}{@pagenumberbox}[1]{page number box}%
   \DefineTOCEntryCommandOption{pagenumberformat}%
     {scr@tso@}{@pagenumberformat}[1]{page number format}%
+  \DefineTOCEntryLengthOption{pagenumberwidth}%
+    {scr@tso@}{@pagenumberwidth}{width of page number box}%
+  \DefineTOCEntryLengthOption{rightindent}%
+    {scr@tso@}{@rightindent}{entry's text right indent}%
   \DefineTOCEntryOption{raggedentrytext}[true]{%
     \FamilySetBool{KOMAarg}{raggedentrytext}{@tempswa}{##1}%
     \ifx\FamilyKeyState\FamilyKeyStateProcessed
@@ -21377,7 +21622,7 @@ to\rtside{\box\bslice\hfil}}
   \DefineTOCEntryLengthOption{numwidth}%
     {scr@tso@}{@numwidth}{entry number width}%
   \scr@ifundefinedorrelax{#1tocdepth}{%
-    \ifstrstart{#1}{sub}{%
+    \Ifstrstart{#1}{sub}{%
       \scr@ifundefinedorrelax{\scr@dte@nosub{#1}tocdepth}{}{%
         \expandafter\edef\csname #1tocdepth\endcsname{%
           \the\numexpr \noexpand\@nameuse{\scr@dte@nosub{#1}tocdepth}+\@ne\relax
@@ -21386,15 +21631,15 @@ to\rtside{\box\bslice\hfil}}
     }{}%
   }{}%
   \@ifundefined{#1tocdepth}{%
-    \ifstr{#1}{part}{\@namedef{#1tocdepth}{-1}}{%
-      \ifstr{#1}{chapter}{\@namedef{#1tocdepth}{0}}{%
-        \ifstr{#1}{section}{\@namedef{#1tocdepth}{1}}{%
-          \ifstr{#1}{subsection}{\@namedef{#1tocdepth}{2}}{%
-            \ifstr{#1}{subsubsection}{\@namedef{#1tocdepth}{3}}{%
-              \ifstr{#1}{paragraph}{\@namedef{#1tocdepth}{4}}{%
-                \ifstr{#1}{subparagraph}{\@namedef{#1tocdepth}{5}}{%
-                  \ifstr{#1}{figure}{\@namedef{#1tocdepth}{1}}{%
-                    \ifstr{#1}{table}{\@namedef{#1tocdepth}{1}}{%
+    \Ifstr{#1}{part}{\@namedef{#1tocdepth}{-1}}{%
+      \Ifstr{#1}{chapter}{\@namedef{#1tocdepth}{0}}{%
+        \Ifstr{#1}{section}{\@namedef{#1tocdepth}{1}}{%
+          \Ifstr{#1}{subsection}{\@namedef{#1tocdepth}{2}}{%
+            \Ifstr{#1}{subsubsection}{\@namedef{#1tocdepth}{3}}{%
+              \Ifstr{#1}{paragraph}{\@namedef{#1tocdepth}{4}}{%
+                \Ifstr{#1}{subparagraph}{\@namedef{#1tocdepth}{5}}{%
+                  \Ifstr{#1}{figure}{\@namedef{#1tocdepth}{1}}{%
+                    \Ifstr{#1}{table}{\@namedef{#1tocdepth}{1}}{%
                       \expandafter\let\csname #1tocdepth\expandafter\endcsname
                       \csname #1numdepth\endcsname
                     }%
@@ -21409,7 +21654,7 @@ to\rtside{\box\bslice\hfil}}
   }{}%
   \scr@ifundefinedorrelax{scr@tso@#1@indent}{%
     \@ifundefined{scr@#1@tocindent}{%
-      \ifstrstart{#1}{sub}{%
+      \Ifstrstart{#1}{sub}{%
         \scr@ifundefinedorrelax{scr@tso@\scr@dte@nosub{#1}@indent}{%
           \scr@ifundefinedorrelax{scr@tso@\scr@dte@nosub{#1}@numwidth}{}{%
             \expandafter\edef\csname scr@tso@#1@indent\endcsname{%
@@ -21436,21 +21681,47 @@ to\rtside{\box\bslice\hfil}}
       \@namedef{scr@tso@#1@indent}{\@nameuse{scr@#1@tocindent}}%
     }%
   }{}%
+  \scr@ifundefinedorrelax{scr@tso@#1@pagenumberwidth}{%
+    \Ifstrstart{#1}{sub}{%
+      \scr@ifundefinedorrelax{scr@tso@\scr@dte@nosub{#1}@pagenumberwidth}{%
+        \@namedef{scr@tso@#1@pagenumberwidth}{\@pnumwidth}%
+      }{%
+        \expandafter\let
+        \csname scr@tso@#1@pagenumberwidth\expandafter\endcsname
+        \csname scr@tso@\scr@dte@nosub{#1}@pagenumberwidth\endcsname
+      }%
+    }{%
+      \@namedef{scr@tso@#1@pagenumberwidth}{\@pnumwidth}%
+    }%
+  }{}%
+  \scr@ifundefinedorrelax{scr@tso@#1@rightindent}{%
+    \Ifstrstart{#1}{sub}{%
+      \scr@ifundefinedorrelax{scr@tso@\scr@dte@nosub{#1}@rightindent}{%
+        \@namedef{scr@tso@#1@rightindent}{\@tocrmarg}%
+      }{%
+        \expandafter\let
+        \csname scr@tso@#1@rightindent\expandafter\endcsname
+        \csname scr@tso@\scr@dte@nosub{#1}@rightindent\endcsname
+      }%
+    }{%
+      \@namedef{scr@tso@#1@rightindent}{\@tocrmarg}%
+    }%
+  }{}%
   \@ifundefined{scr@tso@#1@indent}{%
-      \ifstr{#1}{figure}{\@namedef{scr@tso@#1@indent}{1.5em}}{%
-        \ifstr{#1}{table}{\@namedef{scr@tso@#1@indent}{1.5em}}{%
-          \ifstr{#1}{part}{\@namedef{scr@tso@#1@indent}{0em}}{%
-            \ifstr{#1}{chapter}{\@namedef{scr@tso@#1@indent}{0em}}{%
+      \Ifstr{#1}{figure}{\@namedef{scr@tso@#1@indent}{1.5em}}{%
+        \Ifstr{#1}{table}{\@namedef{scr@tso@#1@indent}{1.5em}}{%
+          \Ifstr{#1}{part}{\@namedef{scr@tso@#1@indent}{0em}}{%
+            \Ifstr{#1}{chapter}{\@namedef{scr@tso@#1@indent}{0em}}{%
               \scr@ifundefinedorrelax{l@chapter}{%
-                \ifstr{#1}{section}{\@namedef{scr@tso@#1@indent}{0pt}}{%
-                  \ifstr{#1}{subsection}{\@namedef{scr@tso@#1@indent}{1.5em}}{%
-                    \ifstr{#1}{subsubsection}{%
+                \Ifstr{#1}{section}{\@namedef{scr@tso@#1@indent}{0pt}}{%
+                  \Ifstr{#1}{subsection}{\@namedef{scr@tso@#1@indent}{1.5em}}{%
+                    \Ifstr{#1}{subsubsection}{%
                       \@namedef{scr@tso@#1@indent}{3.8em}%
                     }{%
-                      \ifstr{#1}{paragraph}{%
+                      \Ifstr{#1}{paragraph}{%
                         \@namedef{scr@tso@#1@indent}{7em}%
                       }{%
-                        \ifstr{#1}{subparagraph}{%
+                        \Ifstr{#1}{subparagraph}{%
                           \@namedef{scr@tso@#1@indent}{10em}%
                         }{%
                         }%
@@ -21459,15 +21730,15 @@ to\rtside{\box\bslice\hfil}}
                   }%
                 }%
               }{%
-                \ifstr{#1}{section}{\@namedef{scr@tso@#1@indent}{1.5em}}{%
-                  \ifstr{#1}{subsection}{\@namedef{scr@tso@#1@indent}{3.8em}}{%
-                    \ifstr{#1}{subsubsection}{%
+                \Ifstr{#1}{section}{\@namedef{scr@tso@#1@indent}{1.5em}}{%
+                  \Ifstr{#1}{subsection}{\@namedef{scr@tso@#1@indent}{3.8em}}{%
+                    \Ifstr{#1}{subsubsection}{%
                       \@namedef{scr@tso@#1@indent}{7.0em}%
                     }{%
-                      \ifstr{#1}{paragraph}{%
+                      \Ifstr{#1}{paragraph}{%
                         \@namedef{scr@tso@#1@indent}{10em}%
                       }{%
-                        \ifstr{#1}{subparagraph}{%
+                        \Ifstr{#1}{subparagraph}{%
                           \@namedef{scr@tso@#1@indent}{12em}%
                         }{%
                         }%
@@ -21483,7 +21754,7 @@ to\rtside{\box\bslice\hfil}}
   }{}%
   \scr@ifundefinedorrelax{scr@tso@#1@numwidth}{%
     \scr@ifundefinedorrelax{scr@#1@tocnumwidth}{%
-      \ifstrstart{#1}{sub}{%
+      \Ifstrstart{#1}{sub}{%
         \scr@ifundefinedorrelax{scr@tso@\scr@dte@nosub{#1}@numwidth}{}{%
           \expandafter\edef\csname scr@tso@#1@numwidth\endcsname{%
             \glueexpr \noexpand\@nameuse{scr@tso@\scr@dte@nosub{#1}@numwidth}%
@@ -21497,19 +21768,19 @@ to\rtside{\box\bslice\hfil}}
     }%
   }{}%
   \@ifundefined{scr@tso@#1@numwidth}{%
-      \ifstr{#1}{figure}{\@namedef{scr@tso@#1@numwidth}{2.3em}}{%
-        \ifstr{#1}{table}{\@namedef{scr@tso@#1@numwidth}{2.3em}}{%
-          \ifstr{#1}{chapter}{\@namedef{scr@tso@#1@numwidth}{1.5em}}{%
+      \Ifstr{#1}{figure}{\@namedef{scr@tso@#1@numwidth}{2.3em}}{%
+        \Ifstr{#1}{table}{\@namedef{scr@tso@#1@numwidth}{2.3em}}{%
+          \Ifstr{#1}{chapter}{\@namedef{scr@tso@#1@numwidth}{1.5em}}{%
             \scr@ifundefinedorrelax{chapter}{%
-              \ifstr{#1}{section}{\@namedef{scr@tso@#1@numwidth}{1.5em}}{%
-                \ifstr{#1}{subsection}{\@namedef{scr@tso@#1@numwidth}{2.3em}}{%
-                  \ifstr{#1}{subsubsection}{%
+              \Ifstr{#1}{section}{\@namedef{scr@tso@#1@numwidth}{1.5em}}{%
+                \Ifstr{#1}{subsection}{\@namedef{scr@tso@#1@numwidth}{2.3em}}{%
+                  \Ifstr{#1}{subsubsection}{%
                     \@namedef{scr@tso@#1@numwidth}{3.2em}%
                   }{%
-                    \ifstr{#1}{paragraph}{%
+                    \Ifstr{#1}{paragraph}{%
                       \@namedef{scr@tso@#1@numwidth}{4.1em}%
                     }{%
-                      \ifstr{#1}{subparagraph}{%
+                      \Ifstr{#1}{subparagraph}{%
                         \@namedef{scr@tso@#1@numwidth}{5m}%
                       }{%
                       }%
@@ -21518,15 +21789,15 @@ to\rtside{\box\bslice\hfil}}
                 }%
               }%
             }{%
-              \ifstr{#1}{section}{\@namedef{scr@tso@#1@numwidth}{2.3em}}{%
-                \ifstr{#1}{subsection}{\@namedef{scr@tso@#1@numwidth}{3.2em}}{%
-                  \ifstr{#1}{subsubsection}{%
+              \Ifstr{#1}{section}{\@namedef{scr@tso@#1@numwidth}{2.3em}}{%
+                \Ifstr{#1}{subsection}{\@namedef{scr@tso@#1@numwidth}{3.2em}}{%
+                  \Ifstr{#1}{subsubsection}{%
                     \@namedef{scr@tso@#1@numwidth}{3.1em}%
                   }{%
-                    \ifstr{#1}{paragraph}{%
+                    \Ifstr{#1}{paragraph}{%
                       \@namedef{scr@tso@#1@numwidth}{5em}%
                     }{%
-                      \ifstr{#1}{subparagraph}{%
+                      \Ifstr{#1}{subparagraph}{%
                         \@namedef{scr@tso@#1@numwidth}{6em}%
                       }{%
                       }%
@@ -21546,13 +21817,13 @@ to\rtside{\box\bslice\hfil}}
   \expandafter\renewcommand%
   \csname scr@tso@#1@LastTOCLevelWasHigher\endcsname{\LastTOCLevelWasHigher}%
   \@ifundefined{scr@tso@#1@beforeskip}{%
-    \ifstr{#1}{part}{%
+    \Ifstr{#1}{part}{%
       \@namedef{scr@tso@#1@beforeskip}{\glueexpr 2.25em \@plus\p@\relax}%
     }{%
-      \ifstr{#1}{chapter}{%
+      \Ifstr{#1}{chapter}{%
         \@namedef{scr@tso@#1@beforeskip}{\glueexpr 1.0em \@plus\p@\relax}%
       }{%
-        \ifstr{#1}{section}{%
+        \Ifstr{#1}{section}{%
           \scr@ifundefinedorrelax{l@chapter}{%
             \@namedef{scr@tso@#1@beforeskip}{\glueexpr 1.0em \@plus\p@\relax}%
           }{}%
@@ -21572,16 +21843,16 @@ to\rtside{\box\bslice\hfil}}
   \csname scr@tso@#1@numsep\endcsname{.4em}%
   \expandafter\renewcommand%
   \csname scr@tso@#1@numberformat\endcsname[1]{##1}%
-  \ifstr{#1}{part}{%
+  \Ifstr{#1}{part}{%
     \expandafter\renewcommand%
     \csname scr@tso@#1@entryformat\endcsname[1]{\large\bfseries ##1}%
   }{%
-    \ifstr{#1}{chapter}{%
+    \Ifstr{#1}{chapter}{%
       \expandafter\renewcommand%
       \csname scr@tso@#1@entryformat\endcsname[1]{\bfseries ##1}%
     }{%
       \scr@ifundefinedorrelax{l@chapter}{%
-        \ifstr{#1}{section}{%
+        \Ifstr{#1}{section}{%
           \expandafter\renewcommand%
           \csname scr@tso@#1@entryformat\endcsname[1]{\bfseries ##1}%
         }{}%
@@ -21593,39 +21864,59 @@ to\rtside{\box\bslice\hfil}}
   \expandafter\renewcommand
   \csname Ifscr@tso@#1@breakafternumber\endcsname[2]{##2}%
   \@ifundefined{scr@tso@#1@linefill}{%
-    \ifstr{#1}{part}{%
+    \Ifstr{#1}{part}{%
       \@namedef{scr@tso@#1@linefill}{\hfill}%
     }{%
-      \ifstr{#1}{chapter}{%
+      \Ifstr{#1}{chapter}{%
         \@namedef{scr@tso@#1@linefill}{\hfill}%
       }{%
         \scr@ifundefinedorrelax{l@chapter}{%
-          \ifstr{#1}{section}{%
+          \Ifstr{#1}{section}{%
             \@namedef{scr@tso@#1@linefill}{\hfill}%
-          }{}
-        }{}
+          }{}%
+        }{}%
         \expandafter\renewcommand%
         \csname scr@tso@#1@linefill\endcsname{\TOCLineLeaderFill\relax}%
       }%
     }%
   }{}%
   \expandafter\renewcommand\csname Ifscr@tso@#1@raggedpage\endcsname[2]{##2}%
-  \ifstr{#1}{part}{%
+  \Ifstr{#1}{part}{%
     \expandafter\renewcommand%
     \csname scr@tso@#1@pagenumberformat\endcsname[1]{\large\bfseries ##1}%
   }{%
-    \expandafter\renewcommand%
-    \csname scr@tso@#1@pagenumberformat\endcsname[1]{%
-      {\normalfont\normalcolor ##1}}%
+    \Ifstr{#1}{chapter}{%
+      \expandafter\renewcommand%
+      \csname scr@tso@#1@pagenumberformat\endcsname[1]{\bfseries ##1}%
+    }{%
+      \scr@ifundefinedorrelax{l@chapter}{%
+        \Ifstr{#1}{section}{%
+          \expandafter\renewcommand%
+          \csname scr@tso@#1@pagenumberformat\endcsname[1]{\bfseries ##1}%
+        }{}%
+      }{}%
+      \expandafter\renewcommand%
+      \csname scr@tso@#1@pagenumberformat\endcsname[1]{%
+        {\normalfont\normalcolor ##1}}%
+    }%
   }%
   \expandafter\renewcommand%
   \csname scr@tso@#1@pagenumberbox\endcsname[1]{%
-    \hb@xt@\@pnumwidth{\hfil ##1}}%
+    \hb@xt@\@nameuse{scr@dte@pagenumberwidth}{\hfil ##1}}%
   \expandafter\renewcommand\csname Ifscr@tso@#1@dynnumwidth\endcsname[2]{##2}%
+  \expandafter\renewcommand\csname Ifscr@tso@#1@dynindent\endcsname[2]{##2}%
+  \scr@ifundefinedorrelax{scr@tso@#1@indentfollows}{%
+    \Ifstrstart{#1}{sub}{%
+      \expandafter\edef\csname scr@tso@#1@indentfollows\endcsname{%
+        \scr@dte@nosub{#1}%
+      }%
+    }{%
+      \expandafter\let\csname scr@tso@#1@indentfollows\endcsname\@empty
+    }%
+  }{}%
 }]{%
   \scr@dte@tocline{#1}{##1}{##2}%
 }
-
 %    \end{macrocode}
 % \iffalse
 %</tocbasic-xetex-bidi.def>
@@ -23024,7 +23315,6 @@ $\@@underline{\hbox{#1}}\m@th$\relax\fi\fi}
 \if@bidi@csundef{@idxitem}{}{%
 \renewcommand\@idxitem{\par\hangindent \if@RTL-\fi40\p@}%
 }
-\@ifpackageloaded{tocbasic}{\input{tocbasic-xetex-bidi.def}}{}
 \@ifclassloaded{article}{\@ifclassloaded{svmult}{}{\input{article-xetex-bidi.def}}}{}
 \@ifclassloaded{extarticle}{\input{extarticle-xetex-bidi.def}}{}
 \@ifclassloaded{artikel1}{\input{artikel1-xetex-bidi.def}}{}
@@ -23032,7 +23322,6 @@ $\@@underline{\hbox{#1}}\m@th$\relax\fi\fi}
 \@ifclassloaded{artikel3}{\input{artikel3-xetex-bidi.def}}{}
 \@ifclassloaded{amsart}{\input{amsart-xetex-bidi.def}}{}
 \@ifclassloaded{letter}{\input{letter-xetex-bidi.def}}{}
-\@ifclassloaded{scrlettr}{\input{scrlettr-xetex-bidi.def}}{}
 \@ifclassloaded{extletter}{\input{extletter-xetex-bidi.def}}{}
 \@ifclassloaded{memoir}{\input{memoir-xetex-bidi.def}}{}
 \@ifclassloaded{refrep}{\input{refrep-xetex-bidi.def}}{}
@@ -23163,6 +23452,7 @@ $\@@underline{\hbox{#1}}\m@th$\relax\fi\fi}
 \@ifpackageloaded{tabls}{\input{tabls-xetex-bidi.def}}{}
 \@ifpackageloaded{tabulary}{\input{tabulary-xetex-bidi.def}}{}
 \@ifpackageloaded{tcolorbox}{\input{tcolorbox-xetex-bidi.def}}{}
+\@ifpackageloaded{tocbasic}{\input{tocbasic-xetex-bidi.def}}{}
 \@ifpackageloaded{tocstyle}{\input{tocstyle-xetex-bidi.def}}{}
 \@ifpackageloaded{tocbibind}{\@ifclassloaded{memoir}{}{\input{tocbibind-xetex-bidi.def}}}{}
 \@ifpackageloaded{tocloft}{\@ifclassloaded{memoir}{}{\input{tocloft-xetex-bidi.def}}}{}
-- 
cgit v1.2.3

