I have a strange problem with cross-referencing my equations: no matter how often I run pdflatex they stay undefined. Other references do get resolved.

Is there something wrong with the way I label my equation? Pdflatex does not complain about it (other than reporting it is undefined when trying to reference it).

Edit: As requested below I made a minimal working example. From this I learned that the problem seems to be a conflict between the amsmath and ntheorem packages. Not including one of these solves the problem.

Consider for example the following example:

\documentclass{article}
\usepackage{amsmath}
\usepackage[thmmarks]{ntheorem}

\begin{document}

\section{My Section}
\label{sec:MySection}

\begin{equation} \label{eq:MyEquation}
a = b
\end{equation}

Reference my section \ref{sec:MySection}.
Reference my equation \ref{eq:MyEquation}.

\end{document}

Which is rendered as:

Not working

  • 2
    This is not a complete example. The easiest way to make it a complete document is to add \documentclass{article} and \begin{document} at the beginning, and \end{document} at the end. If you do that, do you still get a strange result? If not, what do you have to add from your original document to make a complete example to show the problem? – pst Mar 27 '14 at 12:29
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Please complete you code snippet to a minimal working example (MWE). As it stands when placed a simple document it does not produce the behaviour you describe. – Andrew Swann Mar 27 '14 at 12:55
  • If I add an appropriate \documentclass declaration and the document environment, I get no problem. My advice is “look for a typo” in the label name. – egreg Mar 27 '14 at 12:57
up vote 3 down vote accepted

You need the additional option amsmath for ntheorem, see "3.2.1 amsmath" of ntheorem's documentation.

\documentclass{article}
\usepackage{amsmath}
\usepackage[thmmarks,amsmath]{ntheorem}

\begin{document}
\setcounter{section}{4}
\section{My Section}
\label{sec:MySection}

\begin{equation} \label{eq:MyEquation}
a = b
\end{equation}

Reference my section \ref{sec:MySection}.
Reference my equation \ref{eq:MyEquation}.

\end{document}

Result

  • And a useful further information is, that amsmath also provides \eqref to reference equations, i.e. it surrounds the number with brackets like (1). – Ronny Mar 27 '14 at 14:58

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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