% (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.2.1 2021/09/06}

\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.

The first parameter of both \ff{\char`\\crumb\{\}} and \ff{\char`\\subcrumb\{\}}
is the optional parameter of \ff{\char`\\section\{\}} and \ff{\char`\\subsection\{\}}
calls respectively. The second one is the mandatory parameter of them, which
is the full text of the section and sub-section.

You can use \ff{\char`\\section} and \ff{\char`\\subsection} with
an optional 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}