I really want in my book pdf file (article) on each page at the bottom to have interactive icons like in beamer. Namely: go to the next page, to the previous one, go to the next/previous section/subsection/subsubsection. Ideally, you need to move on to the next subsection if there is no nearest subsection. For example, after 4.8.1–4.8.2 and then 4.9.
Attached my terrible code and a screenshot of what I would like to get (only the panel at the bottom, not on the right as in the screenshot). I haven't been able to do anything all day:(
\usepackage[margin=1.5cm, a4paper]{geometry}
\usepackage{fontspec, titlesec}
\setmainfont{Times New Roman}
\usepackage{polyglossia, textgreek}
\usepackage{tikz}
\usepackage{fancyhdr}
\usepackage{hyperref, lastpage, etoolbox, refcount}
\usepackage{lipsum}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancyfoot[C]{%
\begin{tikzpicture}[overlay, remember picture]
% rectangle
\fill[blue!20] ([xshift=2cm, yshift=0.5cm]current page.south west) rectangle ([xshift=-2cm, yshift=1cm]current page.south east);
% icons
\ifnum\value{page}>1
\node[align=center] at ([xshift=1cm, yshift=0.75cm]current page.south) {%
\hyperlink{page.\the\numexpr\value{page}-1\relax}{\tikz\fill[red] (0,0) circle (5pt);}};
\fi
\ifnum\value{page}>1
\ifnum\value{page}<\getpagerefnumber{LastPage}
\node[align=center] at ([xshift=-1cm, yshift=0.75cm]current page.south) {%
\hyperlink{page.\the\numexpr\value{page}+1\relax}{\tikz\fill[green] (0,0) circle (5pt);}};
\fi
\fi
\ifnum\value{page}>1
%\ifnum\getrefnumber{section.\number\numexpr\value{section}\relax}>0
\node[align=center] at ([xshift=-3.5cm, yshift=0.75cm]current page.south) {%
\hyperlink{section.\number\numexpr\value{section}+1\relax}{\tikz\fill[black] (0,0) circle (5pt);}};
%\fi
\fi
\ifnum\value{page}>1
\node[align=center] at ([xshift=3.5cm, yshift=0.75cm]current page.south) {%
\hyperlink{section.\number\numexpr\value{subsection}+1\relax}{\tikz\fill[white] (0,0) circle (5pt);}};
\fi
\end{tikzpicture}
}
% Marking sections with the section number
\preto{\section}{%
\ifnum\value{section}>0
\label{section.\number\value{section}}
\fi
}
\preto{\subsection}{%
\ifnum\value{subsection}>0
\label{subsec:\thesection:\thesubsection}
\fi
}
\begin{document}
\section{s1}
\subsection{ghjffgo}
\lipsum[1-40]
\section{s2}
\lipsum[11-40]
\section{s3}
\lipsum[21-40]
\subsection{ghjffgo}
\lipsum[21-40]
\subsection{ghjffgo}
\lipsum[21-40]
\subsection{ghjffgo}
\lipsum[21-40]
\subsection{ghjffgo}
\end{document}
SECOND VARIANT BUT DOSNT WORK SUBSEC
\usepackage[margin=1.5cm, a4paper]{geometry}
\usepackage{fontspec, titlesec}
\setmainfont{Times New Roman}
\usepackage{polyglossia, textgreek}
\usepackage{fancyhdr}
\usepackage{hyperref, lastpage, etoolbox, refcount}
\usepackage{lipsum}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancyfoot[C]{%
\ifnum\value{page}>1
\raisebox{0.75cm}{%
\hyperlink{page.\the\numexpr\value{page}-1\relax}{\fbox{\strut Previous Page}}
\hspace{1cm}
\hyperlink{section.\number\numexpr\value{section}+1\relax}{\fbox{\strut Next Section}}
\hspace{1cm}
\hyperlink{subsec:\number\value{section}:\number\numexpr\value{subsection}+1\relax}{\fbox{\strut Next Subsection}}
}%
\fi
}
\preto{\section}{%
\ifnum\value{section}>0
\label{section.\number\value{section}}
\fi
}
\preto{\subsection}{%
\ifnum\value{subsection}>0
\label{subsec:\thesection:\thesubsection}
\fi
}
\begin{document}
\section{s1}
\subsection{ghjffgo}
\lipsum[1-40]
\section{s2}
\lipsum[11-40]
\section{s3}
\lipsum[21-40]
\subsection{ghjffgo}
\lipsum[21-40]
\subsection{ghjffgo}
\lipsum[21-40]
\subsection{ghjffgo}
\lipsum[21-40]
\subsection{ghjffgo}
\end{document}
Best Answer
The links work as I think they are meant to, but I'm not sure if I think they are meant to work in the way they are meant to work. The double-arrow links always point to the next/previous division, whether that be a section or a subsection.
Note that you cannot leave the link node empty or
hyperref
unhelpfully 'suppresses' the 'empty' link, which is most frustrating (especially if you don't realise that's why it thinks it is empty).On the other hand, I'm also reasonably certain this is completely wrong ....
Caveat emptor
EDIT
Adding links to the first and last pages is easier because you don't need to calculate anything.
As I mentioned in a comment, I only used
fontawesome
because I know it is compatible with all engines (pdfTeX, XeTeX, LuaTeX etc.) and because it provides an easy source of symbols. If you have an alternative set of symbols, just substitute them in the definitions of\prevdiv
etc. It is also possible to draw something with TikZ, as you did in your question, but you shouldn't nesttikzpicture
s and you need some text or the hyperlink gets 'suppressed'. So then you need to mess around with\phantom
again.I also used
fontawesome
because your screenshot used symbols and these seemed clearer to me than differently coloured dots.