summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/crumbs
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2021-09-05 03:01:31 +0000
committerNorbert Preining <norbert@preining.info>2021-09-05 03:01:31 +0000
commitb1acf2edfe185dad0e33c76ffd94306f1e4530fe (patch)
tree90716c6f05f89f4430a3057d4410a00c63b1ee62 /macros/latex/contrib/crumbs
parentf569b5dc84d8ea85a85d7e92a9bd54142e0b778e (diff)
CTAN sync 202109050301
Diffstat (limited to 'macros/latex/contrib/crumbs')
-rw-r--r--macros/latex/contrib/crumbs/DEPENDS.txt2
-rw-r--r--macros/latex/contrib/crumbs/README.md31
-rw-r--r--macros/latex/contrib/crumbs/crumbs.pdfbin0 -> 332170 bytes
-rw-r--r--macros/latex/contrib/crumbs/crumbs.sty92
-rw-r--r--macros/latex/contrib/crumbs/crumbs.tex129
5 files changed, 254 insertions, 0 deletions
diff --git a/macros/latex/contrib/crumbs/DEPENDS.txt b/macros/latex/contrib/crumbs/DEPENDS.txt
new file mode 100644
index 0000000000..79f2bb0b5f
--- /dev/null
+++ b/macros/latex/contrib/crumbs/DEPENDS.txt
@@ -0,0 +1,2 @@
+hard etoolbox
+hard catchfile
diff --git a/macros/latex/contrib/crumbs/README.md b/macros/latex/contrib/crumbs/README.md
new file mode 100644
index 0000000000..d01b1cc418
--- /dev/null
+++ b/macros/latex/contrib/crumbs/README.md
@@ -0,0 +1,31 @@
+[![make](https://github.com/yegor256/crumbs/actions/workflows/latexmk.yml/badge.svg)](https://github.com/yegor256/crumbs/actions/workflows/latexmk.yml)
+[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/crumbs/blob/master/LICENSE.txt)
+
+This LaTeX package adds nagivation crumbs to your document, which
+may be very useful for presentation and slide decks.
+
+First, [install it](https://en.wikibooks.org/wiki/LaTeX/Installing_Extra_Packages)
+from [CTAN](https://ctan.org/pkg/crumbs)
+and then use in the preamble:
+
+```tex
+\documentclass{article}
+\usepackage{crumbs}
+\usepackage{fancyhdr}
+\fancyhead[L]{\crumbs}
+\begin{document}
+\section{Introduction}
+Some text here.
+\section{Related Works}
+Some other text here.
+\end{document}
+```
+
+The full example and all commands are available in the
+[`crumbs.tex`](https://github.com/yegor256/crumbs/blob/master/crumbs.tex) file.
+
+If you want to contribute yourself, make a fork, then create a branch,
+then run `make` in the root directory.
+It should compile everything without errors. If not, submit an issue and wait.
+Otherwise, make your changes and then run `make` again. If the build is
+still clean, submit a pull request.
diff --git a/macros/latex/contrib/crumbs/crumbs.pdf b/macros/latex/contrib/crumbs/crumbs.pdf
new file mode 100644
index 0000000000..f930fb6401
--- /dev/null
+++ 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
new file mode 100644
index 0000000000..9c29b5dc78
--- /dev/null
+++ b/macros/latex/contrib/crumbs/crumbs.sty
@@ -0,0 +1,92 @@
+% (The MIT License)
+%
+% Copyright (c) 2021 Yegor Bugayenko
+%
+% Permission is hereby granted, free of charge, to any person obtaining a copy
+% of this software and associated documentation files (the 'Software'), to deal
+% in the Software without restriction, including without limitation the rights
+% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+% copies of the Software, and to permit persons to whom the Software is
+% furnished to do so, subject to the following conditions:
+%
+% The above copyright notice and this permission notice shall be included in all
+% copies or substantial portions of the Software.
+%
+% THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+% SOFTWARE.
+
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{crumbs}[2021/09/04 0.1.0 Navigation Crumbs]
+
+\RequirePackage{etoolbox}
+
+% see https://tex.stackexchange.com/a/12414/1449
+\makeatletter\newcommand\back{\@backslashchar}\makeatother
+\makeatletter\newcommand\percent{\@percentchar}\makeatother
+\RequirePackage{catchfile}
+ \newwrite\appendwrite
+ \newcommand*\appendtofile[2]{%
+ \begingroup
+ \IfFileExists{#1}%
+ {\CatchFileDef{\filecontent}{#1}{\endlinechar=`^^J\catcode\endlinechar=12\relax}}% keep existing end-of-lines
+ {\let\filecontent\empty}%
+ \immediate\openout\appendwrite=#1\relax
+ \immediate\write\appendwrite{\unexpanded\expandafter{\filecontent} #2}%
+ \immediate\closeout\appendwrite
+ \endgroup
+ }
+
+\newcommand\subcrumbs{
+ \ifnum\value{section}=0\else
+ \expandafter\ifcsname crumbs\romannumeral\the\value{section}\endcsname
+ \csname crumbs\romannumeral\the\value{section}\endcsname{}
+ \fi
+ \fi
+}
+
+\newcommand\crumb[2]{#1}
+\newcommand\subcrumb[2]{#1}
+\newcommand*\crumbs{}
+\newcounter{crumbi}
+\newcounter{subcrumbi}
+\AtBeginDocument{
+ \let\oldsection\section%
+ \renewcommand\section[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
+ \oldsection{#2}
+ }%
+ \let\oldsubsection\subsection
+ \renewcommand\subsection[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}
+ }
+ \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}
+ }
+ }
+ \fi
+ \oldsubsection{#2}
+ }%
+ \IfFileExists{\jobname.crumbs}{\input{\jobname.crumbs}}{}%
+}
+
+\endinput
diff --git a/macros/latex/contrib/crumbs/crumbs.tex b/macros/latex/contrib/crumbs/crumbs.tex
new file mode 100644
index 0000000000..b80776ffcb
--- /dev/null
+++ b/macros/latex/contrib/crumbs/crumbs.tex
@@ -0,0 +1,129 @@
+% (The MIT License)
+%
+% Copyright (c) 2021 Yegor Bugayenko
+%
+% Permission is hereby granted, free of charge, to any person obtaining a copy
+% of this software and associated documentation files (the 'Software'), to deal
+% in the Software without restriction, including without limitation the rights
+% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+% copies of the Software, and to permit persons to whom the Software is
+% furnished to do so, subject to the following conditions:
+%
+% The above copyright notice and this permission notice shall be included in all
+% copies or substantial portions of the Software.
+%
+% THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+% SOFTWARE.
+
+\documentclass[12pt]{article}
+\usepackage[T1]{fontenc}
+\usepackage[tt=false,type1=true]{libertine}
+\usepackage{ffcode}
+\usepackage{xcolor}
+\usepackage{crumbs}
+\usepackage{fancyhdr}
+ \fancyhf{}
+ \setlength{\headheight}{1.2in}
+ \renewcommand{\headrulewidth}{1pt}
+ \renewcommand\crumb[2]{{\sffamily[{\ifnum\value{section}=\value{crumbi}\color{orange}\fi#1}]\quad}}
+ \renewcommand\subcrumb[2]{{\sffamily[{\ifnum\value{subsection}=\value{subcrumbi}\color{orange}\fi#1}]$\;$}}
+ \fancyhead[L]{
+ \ff{\char`\\crumbs}: \crumbs
+ \\[3pt]
+ \small\ff{\char`\\subcrumbs}: \subcrumbs
+ \\[3pt]
+ \footnotesize\ttfamily section=\the\value{section}, crumbi=\the\value{crumbi}, subcrumbi=\the\value{subcrumbi}
+ }
+
+\title{\ff{crumbs}: \LaTeX{} Package \\ for Navigation Crumbs}
+\author{Yegor Bugayenko}
+\date{0.1.0 2021/09/04}
+
+\begin{document}
+\pagenumbering{gobble}
+\raggedbottom
+\setlength{\parindent}{0pt}
+\setlength{\columnsep}{32pt}
+\setlength{\parskip}{6pt}
+
+\maketitle
+\pagestyle{fancy}
+\thispagestyle{fancy}
+
+Before the first \ff{\char`\\section} command:
+
+\ff{\char`\\crumbs}: \crumbs
+\\[3pt]
+\small\ff{\char`\\subcrumbs}: \subcrumbs
+
+\section[Intro]{Introduction}
+
+This package helps you add navigation crumbs to your document,
+which is most useful for presentation and slide decks:
+
+\begin{ffcode}
+\documentclass{article}
+\usepackage{crumbs}
+\usepackage{fancyhdr}
+ \fancyhf{}
+ \pagestyle{fancy}
+ \fancyhead[L]{\crumbs / \subcrumbs}
+\begin{document}
+\section{Introduction}
+Some text here.
+\section{Related Works}
+Some other text here.
+\end{document}
+\end{ffcode}
+
+You may redefine \ff{\char`\\crumb\{\}} and \ff{\char`\\subcrumb\{\}}
+commands, if you want your crumbs to look nicer, for example:
+
+\begin{ffcode}
+\renewcommand\crumb[2]{
+ {
+ \ifnum\value{section}=\value{crumbi}
+ \color{orange}
+ \fi
+ #1
+ }
+}
+\end{ffcode}
+
+The same for \ff{\char`\\subcrumb\{\}}, but the comparison should be
+done not between \ff{section} and \ff{crumbi}, but between
+\ff{subsection} and \ff{subcrumbi} counters.
+
+You can use \ff{\char`\\section} and \ff{\char`\\subsection} with
+an option argument, which will be used in the crumbs, e.g.:
+
+\begin{ffcode}
+\section[Details]{More Details About The Method}
+\subsection[SLR]{Systematic Literature Review}
+\end{ffcode}
+
+\subsection{How to Contribute}
+
+More details about this package you can find
+in the \ff{yegor256/crumbs} GitHub repository.
+
+If you want to add a feature or fix a bug, you are welcome
+to submit an issue or make a pull request.
+
+\section{How It Works}
+
+On the first run, a new file \ff{\char`\\jobname.crumbs} is created,
+where all \ff{\char`\\section} and \ff{\char`\\subsection} commands
+are being logged.
+
+On the second run, the file is loaded and two commands are being
+created: \ff{\char`\\crumbs} and \ff{\char`\\subcrumbs}. The first
+one is a collection of \ff{\char`\\crumb\{\}} calls, while the second
+one is a collection of \ff{\char`\\subcrumb\{\}} ones.
+
+\end{document} \ No newline at end of file