summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/crumbs
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/crumbs')
-rw-r--r--macros/latex/contrib/crumbs/crumbs.pdfbin332452 -> 345356 bytes
-rw-r--r--macros/latex/contrib/crumbs/crumbs.sty83
-rw-r--r--macros/latex/contrib/crumbs/crumbs.tex23
3 files changed, 73 insertions, 33 deletions
diff --git a/macros/latex/contrib/crumbs/crumbs.pdf b/macros/latex/contrib/crumbs/crumbs.pdf
index f9e2892b64..4d7bd0169f 100644
--- a/macros/latex/contrib/crumbs/crumbs.pdf
+++ b/macros/latex/contrib/crumbs/crumbs.pdf
Binary files differ
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
diff --git a/macros/latex/contrib/crumbs/crumbs.tex b/macros/latex/contrib/crumbs/crumbs.tex
index ce34e8c650..dbed6fc408 100644
--- a/macros/latex/contrib/crumbs/crumbs.tex
+++ b/macros/latex/contrib/crumbs/crumbs.tex
@@ -42,7 +42,7 @@
\title{\ff{crumbs}: \LaTeX{} Package \\ for Navigation Crumbs}
\author{Yegor Bugayenko}
-\date{0.2.2 2021/09/09}
+\date{0.3.0 2021/09/12}
\begin{document}
\pagenumbering{gobble}
@@ -114,6 +114,27 @@ an optional argument, which will be used in the crumbs, e.g.:
\subsection{How to Contribute}
+You may turn on the ``dry'' mode, which will prohibit the package to
+renew \ff{\char`\\section\{\}} and \ff{\char`\\subsection\{\}} commands.
+You will still be able to use the crumbs mechanism through
+\ff{\char`\\crumbection\{\}} and \ff{\char`\\subcrumbection\{\}}
+commands, for example:
+
+\begin{ffcode}
+\documentclass{article}
+\usepackage[dry]{crumbs}
+\begin{document}
+\crumbection[Intro]{Introduction} % Add it to \crumbs
+\section{Introduction} % Print it to the page
+Hello, world!
+\end{document}
+\end{ffcode}
+
+You can also instruct it to increment
+\ff{\char`\\section\{\}} and \ff{\char`\\subsection\{\}}
+on each call to \ff{\char`\\crumbection\{\}} and \ff{\char`\\subcrumbection\{\}}
+respectively. Just use the \ff{increment} package option.
+
More details about this package you can find
in the \ff{yegor256/crumbs} GitHub repository.