Here's my current MWE: (Note, you must save the file as lec-05.tex)
\documentclass{article}
\usepackage{currfile}
\usepackage{substr}
\def\fulllecnum{
\BehindSubString{lec-}{\scantokens\expandafter{\currfilebase\noexpand}}
}
\newcommand\lecnum{
\IfBehindSubStringEmpty{lec-0}{\scantokens\expandafter{\currfilebase\noexpand}}{
\BehindSubString{lec-}{\scantokens\expandafter{\currfilebase\noexpand}}
}{
\BehindSubString{lec-0}{\scantokens\expandafter{\currfilebase\noexpand}}
}
}
\setcounter{section}{\lecnum}
\begin{document}
\section{HI}
\end{document}
Here's the error:
! Missing number, treated as zero.
<to be read again>
\let
l.17 \setcounter{section}{\lecnum}
?
How can I convert \lecnum to an integer and then pass it to \setcounter{section}{}?
xstringmacros first, before you can pass that to some other function; fundamentally thexstringextractions aren't expandable. – Werner Nov 13 '22 at 05:48xstring, use the optional final argument to store the result of some string test/extraction. Then you can use that result somewhere else. – Werner Nov 13 '22 at 07:12