6

I'm using ntheorem package and I would like to use the theorem's counter within the theorem's statement. This is useful when you're defining a special object you wish to reference elsewhere, like:

\begin{theorem}
     For every foo, there exists a bar_\thcounter such that blah. 
\end{theorem}

Since the text has more than one bar defined, I wan't this particular one to be "bar_{1.1.2}" if the theorem is named as "Theorem 1.1.2".

5

The counter associated to a structure defined with \newtheorem{<env-name>}{<doc-name>} is named <env-name>, so you can use \the<env-name> (for the string including possible prefixes if the counter has been subordinated to another counter) or \number\value{<env-name>} (for just the value of the counter):

\documentclass{book}
\usepackage{ntheorem}

\newtheorem{theorem}{Theorem}[section]

\begin{document}

\chapter{Test Chapter}
\section{Test Section}
\begin{theorem}
     For every foo, there exists a bar\textunderscore\thetheorem\ such that blah. 
\end{theorem}

\end{document}

enter image description here

Another option, would be to use the \label, \ref mechanism:

\documentclass{book}
\usepackage{ntheorem}

\newtheorem{theorem}{Theorem}[section]

\begin{document}

\chapter{Test Chapter}
\section{Test Section}
\begin{theorem}\label{thm:test}
     For every foo, there exists a bar\textunderscore\ref{thm:test} such that blah. 
\end{theorem}

\end{document}

Notice the use of \textunderscore instead of simply _ which outside math mode will produce an error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.