I was wondering if it is possible to have the page numbers that appear in the footer of each page link back to the beginning of the section or chapter in which they appear.
I have this code that works for linking back to the table of contents:
\usepackage{fancyhdr}
\fancypagestyle{plain}{% % <-- this is new
\fancyhf{}
\fancyfoot[CO]{\hyperref[sec:toc]{\thepage}}
...that I found here: Here
I've tried using \thechapter and the \thesection as the hyperlink target but it does not work, even though I accomplished something similar in another question of mine: Question
Here I have every group letter of a glossary list link back to the start of the glossary using \thechapter as a hyperlink target:
...
\renewcommand*{\glsgroupheading}[1]
{
\begin{center}
\vspace{25pt}
\glsnavhypertarget{##1}{}
\vspace{25pt}
\end{center}
\needspace{6\baselineskip}\item[]\makebox[-85pt]{\begin{Large}\textbf{\glsgetgrouptitle{\hyperref[\thechapter]{##1}}}\end{Large}}
}
...
I'm guessing it's because \thechapter and \thesection return a chapter/section number. But not sure why it works in my other question and not here. I was thinking it was a fluke but I get a reference error when trying to link the to the beginning of the chapter using page numbers (using fancyhdr) and not when linking to the start of the glossary (renewing the glossary group header command).
Is there a way to generalize the page numbers as links to the current chapter or section?
Any help is appreciated.
Here is a MWE:
\documentclass{report}
\usepackage[margin=1in]{geometry}
\usepackage{setspace}
\doublespacing
\emergencystretch=1em
\usepackage{ragged2e}
\usepackage[english]{babel}
\usepackage{hyperref}
\usepackage{bookmark}
\usepackage{fancyhdr}
\fancypagestyle{plain}{
\fancyhf{}
\fancyfoot[CO]{\hyperref[sec:toc]{\thepage}}
\renewcommand{\headrulewidth}{0pt}}
%Quick Filler Text
\usepackage{blindtext}
\usepackage{kantlipsum}
\begin{document}
\tableofcontents
\label{sec:toc}
\pagestyle{plain}
\chapter{Introduction}
\label{intro}
\blindtext[5]
\chapter{Next}
\label{next}
\blindtext[3]
\blinditemize
\blindtext[2]
\section{And Then}
\label{andthen}
\blindtext[6]
\blindenumerate
\chapter{Math}
\label{math}
\blindtext[5]
\section{Some Math}
\label{somemath}
\blindmathpaper
\chapter{Conclusion}
\label{conclusion}
\blindtext{20}
\end{document}
sec:tocwith\magicmacro". In any case, I've provided a MWE. – ErMo Jun 23 '20 at 11:00\theHsectionnear chapter\section declarations and the\hyperlinkcode inside the\fancyhdrcodebut it takes me to the first word of the chapter/section instead of the title. Nit picky, I know :/ – ErMo Jun 23 '20 at 12:34