How do I calculate and display an incremented value of a numeric composite counter, such as \thesubsection? Do I try to extract and increment the "decimal" part separately and then glue the result back together?

    Next section would be: \the\numexpr\thesection+1
    % outputs "2"
    Next subsection would be: \the\numexpr\thesubsection+1
    % prints literary "1.1+1" instead of "1.2"
  • 4
    Next subsection would be: \thesection.\the\numexpr\value{subsection}+1\relax
    – Marijn
    Commented Aug 17, 2017 at 12:36
  • Obviously you wouldn't use this to refer to the next section or subsection, however.
    – cfr
    Commented Aug 17, 2017 at 12:59

1 Answer 1


You can't use the composite display as-is. You need to extract the value of the counter (using \value) which might be different from its representation (like \alph or \roman), perform your calculation (perhaps using \numexpr), and display the composition again (with \the or \number). Here are some ways of achieving this:

enter image description here


\setlength{\parindent}{0pt}% Just for this example


Next section would be: \the\numexpr\value{section}+1\relax \par
Next section would be: \ref{sec:another_section} \par
Next section would be: \stepcounter{section}\thesection\addtocounter{section}{-1}

Next subsection would be: \thesection.\the\numexpr\value{subsection}+1\relax \par
Next subsection would be: \ref{sec:another_subsection} \par
Next subsection would be: \stepcounter{subsection}\thesubsection\addtocounter{subsection}{-1}

\subsection{Another subsection}\label{sec:another_subsection}

\section{Another section}\label{sec:another_section}


Using \label-\ref is far better, period.

  • Thanks Werner, for a good summary of methods. Indeed I was particularly interested in subsections and hoped to manipulate its representation, as in the headings where I need them the section and subsection counters are usually wrong. I solved it now by asking titlesec to save extramarks. Your answer was helpful.
    – user612313
    Commented Aug 24, 2017 at 6:44

You must log in to answer this question.

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