In the code below, I would like to store the number of theorems as there are formatted by amsmath. How can I do that ?
My code stores 1, 2, 3, 1 instead of 1.1, 1.1, 1.1, 2.1. In other cases the numbering could be different so I need to have access to the macro displaying the counter in the final PDF output.
\documentclass[12pt]{article}
\usepackage{amsthm}
\newwrite\tempscoresfile
\immediate\openout\tempscoresfile=\jobname.test
\AtEndDocument{\immediate\closeout\tempscoresfile}
\newtheorem{@theorem@}{Théorème}[section]
\newenvironment{theorem}[1][]{
\begin{@theorem@}[#1]
\immediate\write\tempscoresfile{\arabic{@theorem@}}
}{
\end{@theorem@}
}
\begin{document}
\section{Section 1}
\begin{theorem}
Bla, blo, bli...
\end{theorem}
\begin{theorem}
Bla, blo, bli...
\end{theorem}
\begin{theorem}
Bla, blo, bli...
\end{theorem}
\section{Section 2}
\begin{theorem}
Bla, blo, bli...
\end{theorem}
\end{document}
\csname the@theorem@\endcsname, or\the@theorem@with a\makeatletter...\makeatotherpair. – Werner Sep 12 '19 at 18:20