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?

2 Answers 2


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.




%%% hyperref should go after the patch, if used


This section is long, go to section~\nextsection.



\section{THIS IS IT}\label{foo}


\section{Again TL;DR}
Check if it works \ref{foo}; now go to section~\nextsection.


  • That works perfectly well. Would this be easily extended to other sectioning levels, as parts or chapters? Dec 19, 2013 at 15:15
  • 2
    @DenisBitouzé The idea would be the same; but the more patches you do, the more fragile the entire building becomes.
    – egreg
    Dec 19, 2013 at 15:17

This answer has been EDITED to work for the next section, the next subsection, as well as the next subsubsection.

In essence, rather that try to invoke a label in one place meant to apply to a subsequent report section, it makes more sense to me to create macros \nextsection, \nextsubsection, and \nextsubsubsection in which the next [[sub]sub]section number is computed based on the current [[sub]sub]section number. It will, however, require you to know in advance whether the next sectioning unit entity is a section, a subsection, or a subsubsection.


\section{First Section\label{s:first}}

This is section \ref{s:first}.  The following section is \nextsection,\\
but the next subsection is \nextsubsection.

\subsection{A subsection\label{s:firstsub}}

This is subsection \ref{s:firstsub}.  The following subsection is \nextsubsection.

\subsection{Next subsection}

\section{Next Section}

The next subsubsection will be \nextsubsubsection.


enter image description here

  • This is helpful but I should have mentioned (should I edit the original question?) that I'd like to refer to the page of the section as well and, on top of that ;), I'd like to make the text an hyperlink to the next section. Dec 19, 2013 at 14:43
  • @DenisBitouzé I do see in your original question the phrase \(page)ref{sec:next}. That, of course, is not the right syntax for getting a page number, but I see now that you had mentioned the word "page" in your question. So perhaps, an edit is a viable course of action, for clarification. Dec 19, 2013 at 14:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .