Some sections of my document start with a remark such as the following: "This section may be omitted at the first reading."
I'd like to add to this text a (hypertext) reference to the next section (page) number and I can do it by labeling the next section (\label{sec:next}
) and make use of \ref{sec:next}
and/or \pageref{sec:next}
. But, because the sec:next
label is hard coded, the reference could be wrong in case of changes in the order of the sections.
Hence my question: is there a way to refer to the next section, whatever it is?
Best Answer
We have to setup a
\label
that will be evaluated at the next\section
command.So I patch
\@sect
to add a\label
command to its argument#8
(which refers to the main section title), which is evaluated only if the command has been called by\section
and a\nextsection
command has been issued. Also\section
and\subsection
need to be patched, because they both use\@sect
for typesetting the title. The argument to\label
is automatically generated via a counter.Note that the patches must be made before
hyperref
is loaded.