RosettaCodeData/Task/Increment-a-numerical-string/LaTeX/increment-a-numerical-strin...

17 lines
525 B
TeX

\documentclass{article}
% numbers are stored in counters
\newcounter{tmpnum}
% macro to increment a string (given as argument)
\newcommand{\stringinc}[1]{%
\setcounter{tmpnum}{#1}% setcounter effectively converts the string to a number
\stepcounter{tmpnum}% increment the counter; alternatively: \addtocounter{tmpnum}{1}
\arabic{tmpnum}% convert counter value to arabic (i.e. decimal) number string
}
%example usage
\begin{document}
The number 12345 is followed by \stringinc{12345}.
\end{document}