Arithmetic of composite counter

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?

\documentclass{article}
\begin{document}
\section{Section}
Next section would be: \the\numexpr\thesection+1
% outputs "2"
\subsection{Subsection}
Next subsection would be: \the\numexpr\thesubsection+1
% prints literary "1.1+1" instead of "1.2"
\end{document}

• Next subsection would be: \thesection.\the\numexpr\value{subsection}+1\relax – Marijn Aug 17 '17 at 12:36
• Obviously you wouldn't use this to refer to the next section or subsection, however. – cfr Aug 17 '17 at 12:59

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:

\documentclass{article}

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

\begin{document}

\section{Section}
Next section would be: \the\numexpr\value{section}+1\relax \par
Next section would be: \ref{sec:another_section} \par

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

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