0

I would like to have different versions of the same theorem or definition. So version 0 of definition 1 would be called "Definition 1.0" and version 1 would be called "Definition 1.1". The file below returns the error TeX capacity exceeded, sorry [input stack size=5000]. on compilation. What am I doing wrong?

I copied the relevant code from here and changed some of the details:

\documentclass[12pt]{article}

\usepackage{amsthm}
\usepackage{amsmath}

\newcounter{dfn}[section]

\newcounter{dfnv}

\makeatletter
\@namedef{thedfnv}{\@nameuse{thedfn}.\arabic{dfnv}}
\makeatother

\newtheorem{dfn}[dfnv]{Definition}

\begin{document}

\section{First section}

\begin{dfn}% Should display as Definition 1.0
  Version 0 of the definition of foo.
\end{dfn}

\begin{dfn}% Should display as Definition 1.1
  Version 1 of the definition of foo.
\end{dfn}
\stepcounter{dfn}

\begin{dfn}% Should display as Definition 2.0
  Version 0 of the definition of bar.
\end{dfn}

\begin{dfn}% Should display as Definition 2.1
  Version 1 of the definition of bar.
\end{dfn}
\stepcounter{dfn}

\end{document}
2
  • I fixed it, I just apparently can't use the same name, dfn, for the theorem type and the counter. I'm not putting this as an answer because I don't know why it's a problem. Commented May 26, 2017 at 5:11
  • 1
    Circular definition, probably
    – daleif
    Commented May 26, 2017 at 5:38

1 Answer 1

1

You of course cannot intermix versioned definitions. I suggest two environments: dfn will step the main number, whereas dfn* only steps the version number.

\documentclass[12pt]{article}

\usepackage{amsmath}
\usepackage{amsthm}

\newcounter{dfnmain}[section]
\newtheorem{dfninner}{Definition}[dfnmain]
\makeatletter
\renewcommand{\thedfninner}{%
  \arabic{dfnmain}.\@arabic{\numexpr\value{dfninner}-1\relax}%
}
\makeatother
\newenvironment{dfn}
 {\stepcounter{dfnmain}\dfninner}
 {\enddfninner}
\newenvironment{dfn*}
 {\dfninner}
 {\enddfninner}

\begin{document}

\section{First section}

\begin{dfn}
  Version 0 of the definition of foo.
\end{dfn}

\begin{dfn*}
  Version 1 of the definition of foo.
\end{dfn*}

\begin{dfn}
  Version 0 of the definition of bar.
\end{dfn}

\begin{dfn*}
  Version 1 of the definition of bar.
\end{dfn*}

\section{Second section}

\begin{dfn}
  Version 0 of the definition of foo.
\end{dfn}

\begin{dfn*}
  Version 1 of the definition of foo.
\end{dfn*}

\begin{dfn}
  Version 0 of the definition of bar.
\end{dfn}

\begin{dfn*}
  Version 1 of the definition of bar.
\end{dfn*}

\end{document}

enter image description here

If you want the numbers to also refer to the section number, add \arabic{section}. in the definition of \thedfninner.

You must log in to answer this question.

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