From 1e90c2e6f453642528ed8049736556a5f79a4152 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 12 Sep 2021 20:34:58 +0000 Subject: crumbs (12sep21) git-svn-id: svn://tug.org/texlive/trunk@60483 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/crumbs/crumbs.pdf | Bin 332452 -> 345356 bytes Master/texmf-dist/doc/latex/crumbs/crumbs.tex | 23 ++++++- Master/texmf-dist/tex/latex/crumbs/crumbs.sty | 83 ++++++++++++++++---------- 3 files changed, 73 insertions(+), 33 deletions(-) (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/doc/latex/crumbs/crumbs.pdf b/Master/texmf-dist/doc/latex/crumbs/crumbs.pdf index f9e2892b643..4d7bd0169ff 100644 Binary files a/Master/texmf-dist/doc/latex/crumbs/crumbs.pdf and b/Master/texmf-dist/doc/latex/crumbs/crumbs.pdf differ diff --git a/Master/texmf-dist/doc/latex/crumbs/crumbs.tex b/Master/texmf-dist/doc/latex/crumbs/crumbs.tex index ce34e8c6503..dbed6fc4089 100644 --- a/Master/texmf-dist/doc/latex/crumbs/crumbs.tex +++ b/Master/texmf-dist/doc/latex/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. diff --git a/Master/texmf-dist/tex/latex/crumbs/crumbs.sty b/Master/texmf-dist/tex/latex/crumbs/crumbs.sty index 2b497078da6..17194892c04 100644 --- a/Master/texmf-dist/tex/latex/crumbs/crumbs.sty +++ b/Master/texmf-dist/tex/latex/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