I want to make a navigation menu at the bottom of each section|subsection|subsubsection|paragraph.
This document will be embedded in the binary of an application. It is what the user will see when he or she clicks on help. Because of the nature of this document (too long to be printed, yet can be printed), it should have some navigational assistance for an audience with a mouse.
I imagine something like the navigation menu for the beamer
class at the bottom of each slide. I am using the article
class (though heavily modified), however.
When searching for this, I found
- Automatic hyperlinks within document? (only relevant for TOC, not automatic end-of-section "up-to-top" links)
Implementation
Note that I will use POSIX directory notation to represent parent sections (.. and ../..). The implementation would likely require a macro for the menu with some if/then logic that can detect whether the section has a parent for determining whether or not the "Jump up ../.." button should be visible or at least visibly disabled. The titlesec
definitions would need to have hooks such that automatic links to the parent sections (..) and parent parent (../..) sections can be created.
I need to be able to
- Reference ToC with a static link DONE
- Reference parent .. section dynamically (probably could use Get the value of current \label)
- Reference parent ../.. section dynamically
- Reference previous page
\thepage - 1
DONE - Reference next page
\thepage + 1
DONE
Mock-up Implementation
\documentclass{article}
\usepackage{fontspec}
\usepackage{lipsum}
\usepackage[compact,explicit,noindentafter]{titlesec}
\usepackage{fancyhdr}
\usepackage{xcolor}
\usepackage[hidelinks]{hyperref}
\usepackage{amsmath,amssymb}
\fancypagestyle{digitalpage} % This style could inject the implementation of the navigation menu into titlesec definitions maybe (so that it can be toggled easily)?
{
\fancyhf{} % clear all fields
\renewcommand{\headrulewidth}{0pt}
\lhead{}
\lfoot{}
\cfoot{}
\rfoot{%
\bfseries\footnotesize\thepage
}%
}%
\newcommand\navigationmenu{\vspace{1ex}\noindent\footnotesize\textcolor{gray}{\sffamily Jump to Contents $\Uparrow$} | \textcolor{gray}{\hyperlink{sub}{\sffamily Jump .. $\uparrow$}} | \textcolor{gray}{\hyperlink{sec}{\sffamily Jump ../.. $\upuparrows$}} | \textcolor{gray}{\sffamily $\leftarrow$ Previous Page} | \textcolor{gray}{\sffamily $\rightarrow$ Next Page}} % contains some logic, if section has no ../.., don't reveal.
% SECTION
\titleformat{\section}[hang]{\Huge\bfseries}{\thesection}{1cm}{#1}[\thispagestyle{digitalpage}]
% SUBSECTION
\titleformat{\subsection}[hang]{\Large\bfseries}{\thesubsection}{1cm}{#1}
\begin{document}
\hypertarget{sec}{\section{Something}}
\lipsum[1]
\navigationmenu
\hypertarget{sub}{\subsection{Something something}}
\lipsum[2]
\navigationmenu
\end{document}
jump ..
means go back to paragraph heading andJump ../..
means go back to subsubsection heading, no? 2) are paragraphs numbered?jump ..
means go back to the previous/latest paragraph heading (whether it be section/subsection/subsub.. etc.). Whereasjump ../..
means to back to the paragraph heading above the previous/latest paragraph heading-a function only available when this is possible.