From e403b5892f209477e44b123a10b5b35cc425d8e9 Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Mon, 13 Sep 2021 03:01:31 +0000
Subject: CTAN sync 202109130301

---
 macros/latex/contrib/crumbs/crumbs.sty | 83 +++++++++++++++++++++-------------
 1 file changed, 51 insertions(+), 32 deletions(-)

(limited to 'macros/latex/contrib/crumbs/crumbs.sty')

diff --git a/macros/latex/contrib/crumbs/crumbs.sty b/macros/latex/contrib/crumbs/crumbs.sty
index 2b497078da..17194892c0 100644
--- a/macros/latex/contrib/crumbs/crumbs.sty
+++ b/macros/latex/contrib/crumbs/crumbs.sty
@@ -21,13 +21,19 @@
 % SOFTWARE.
 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{crumbs}[2021/09/09 0.2.2 Navigation Crumbs]
+\ProvidesPackage{crumbs}[2021/09/12 0.3.0 Navigation Crumbs]
+
+\makeatletter\newif\ifcrumbs@dry\makeatother
+\makeatletter\DeclareOption{dry}{\crumbs@drytrue}\makeatother
+\makeatletter\newif\ifcrumbs@increment\makeatother
+\makeatletter\DeclareOption{increment}{\crumbs@incrementtrue}\makeatother
+\ProcessOptions\relax
 
 \RequirePackage{etoolbox}
 
 % see https://tex.stackexchange.com/a/12414/1449
-\makeatletter\newcommand\back{\@backslashchar}\makeatother
-\makeatletter\newcommand\percent{\@percentchar}\makeatother
+\makeatletter\newcommand\crumbs@back{\@backslashchar}\makeatother
+% \makeatletter\newcommand\crumbs@percent{\@percentchar}\makeatother
 \RequirePackage{catchfile}
   \newwrite\appendwrite
   \newcommand*\appendtofile[2]{%
@@ -49,46 +55,59 @@
   \fi
 }
 
-\NewCommandCopy\crumbsoldsection\section
-\renewcommand\section[2][]{
-  \def\temp{#1}
-  \ifx\crumbs\empty
+\makeatletter\newcommand\crumbection[2][]{%
+  \def\temp{#1}%
+  \ifx\crumbs\empty%
     \appendtofile{\jobname.crumbs}{
-      \back ifx \back crumbs \back empty
-        \back gappto \back crumbs{\back setcounter{crumbi}{0}}
-      \back fi
-      \back gappto\back crumbs{\back stepcounter{crumbi}\back crumb{\ifx\temp\empty #2\else #1\fi}{#2}}
-    }
-  \fi
-  \crumbsoldsection{#2}
-}
+      \crumbs@back ifx \crumbs@back crumbs \crumbs@back empty
+        \crumbs@back gappto \crumbs@back crumbs{\crumbs@back setcounter{crumbi}{0}}
+      \crumbs@back fi
+      \crumbs@back gappto\crumbs@back crumbs{\crumbs@back stepcounter{crumbi}\crumbs@back crumb{\ifx\temp\empty #2\else #1\fi}{#2}}
+    }%
+  \fi%
+  \ifcrumbs@increment\stepcounter{section}\fi%
+}\makeatother
 
-\NewCommandCopy\crumbsoldsubsection\subsection
-\renewcommand\subsection[2][]{
-  \def\temp{#1}
-  \ifx\crumbs\empty
+\makeatletter\newcommand\subcrumbection[2][]{%
+  \def\temp{#1}%
+  \ifx\crumbs\empty%
     \appendtofile{\jobname.crumbs}{
-      \back ifcsname crumbs\romannumeral\the\value{section}\back endcsname\back else
-        \back expandafter\back newcommand\back csname crumbs\romannumeral\the\value{section}\back endcsname{%
-          \back setcounter{subcrumbi}{0}
+      \crumbs@back ifcsname crumbs\romannumeral\the\value{section}\crumbs@back endcsname\crumbs@back else
+        \crumbs@back expandafter\crumbs@back newcommand\crumbs@back csname crumbs\romannumeral\the\value{section}\crumbs@back endcsname{%
+          \crumbs@back setcounter{subcrumbi}{0}
         }
-      \back fi
-      \back expandafter\back gappto\back csname crumbs\romannumeral\the\value{section}\back endcsname{%
-        \back stepcounter{subcrumbi}
-        \back subcrumb{\ifx\temp\empty #2\else #1\fi}{#2}
+      \crumbs@back fi
+      \crumbs@back expandafter\crumbs@back gappto\crumbs@back csname crumbs\romannumeral\the\value{section}\crumbs@back endcsname{%
+        \crumbs@back stepcounter{subcrumbi}
+        \crumbs@back subcrumb{\ifx\temp\empty #2\else #1\fi}{#2}
       }
-    }
-  \fi
-  \crumbsoldsubsection{#2}
-}
+    }%
+  \fi%
+  \ifcrumbs@increment\stepcounter{subsection}\fi%
+}\makeatother
+
+\makeatletter\ifcrumbs@dry
+  \message{Since "dry" mode is ON we don't renew "section" and "subsection" commands}
+\else
+  \NewCommandCopy\crumbs@oldsection\section
+  \renewcommand\section[2][]{%
+    \crumbection[#1]{#2}%
+    \crumbs@oldsection{#2}%
+  }
+  \NewCommandCopy\crumbs@oldsubsection\subsection
+  \renewcommand\subsection[2][]{%
+    \subcrumbection[#1]{#2}%
+    \crumbs@oldsubsection{#2}%
+  }
+\fi\makeatletter
 
 \ifcsname crumb\endcsname
-  \message{The command "crumb" already defined}
+  \message{The command "crumb" is already defined}
 \else
   \newcommand\crumb[2]{#1}
 \fi
 \ifcsname subcrumb\endcsname
-  \message{The command "crumb" already defined}
+  \message{The command "subcrumb" is already defined}
 \else
   \newcommand\subcrumb[2]{#1}
 \fi
-- 
cgit v1.2.3

