0

I'd like to use some theorem environment. But I'm using the nath package, which is unfortunately incompatible with every solution I've found. I don't need anything very fancy, just the following features:

  • (Basic) Automatic numbering of theorems and being able to redefine the words for "Theorem", "Lemma", etc, since I'm not writing in English.

  • (Needed) Being able to reference theorems so that \magicref{that-first-lemma-of-section1} produces "Lemma 1.1" and not just "1.1".

  • (Optional) Being able to give names to important results to that \magicref{very-important-named-theorem} produces "Pi's Theorem" instead of "Theorem 3.1.4".

  • (Optional) I don't even know exactcly what would be the interface to this, but it's not rare to see texts in which "Theorem 2.71" defines some especial objects, like \psi_{2.7.1} that are referenced elsewhere. I'd like to that in a easy way.

  • Welcome to TeX.SX! Can you show an attempt that doesn't work? – egreg Jun 13 '13 at 16:36
  • Sorry, when trying to extract a minimal non working example (I should had done that earlier) I realized the problem was with the babel package, which should be put before nath. Anyway, I'm still interested on how to accomplish the two (Optional) items using ntheorem. Should I post another question or edit this one? – TheoremNath Jun 13 '13 at 18:32
  • Please edit this question – egreg Jun 13 '13 at 19:34
  • 1
    Why closing? The question is pretty clear. – Heiko Oberdiek Jul 13 '13 at 16:57
5
  • Referencing with theorem name and package ntheorem can be achieved by defining \p@<counter>. It adds a prefix to the counter value used in references.
\documentclass{article}

\usepackage{ntheorem}

\newtheorem{lemma}{Lemma}
\makeatletter
\renewcommand*{\p@lemma}{Lemma~}
\makeatother

\begin{document}
\section{Test document}

\begin{lemma}
\label{first}
This is the first lemma.
\end{lemma}
\begin{lemma}[Pi's Lemma]
\label{pi}
This is a named lemma.
\end{lemma}

References: \ref{first} and \ref{pi}.

\end{document}

Result

  • References to the title of the theorems can be done by package nameref. However nameref does not yet support ntheorem's theorems. Therefore the internals are patched to get the title in to the reference by defining \@currentlabelname. In case of unnamed theorems, the theorem name with number is used as title for \nameref. Therefore the example file does not redefine \p@<counter> to keep a way to get the number only.
\documentclass{article}

\usepackage{ntheorem}
\usepackage{nameref}
\usepackage{gettitlestring}% also used by nameref 2009/12/08 or later

\makeatletter
\@ifdefinable{\saved@ythm}{%
  \let\saved@ythm\@ythm
  \def\@ythm#1#2#3[#4]{%
    \GetTitleString{#4}%
    \let\@currentlabelname\GetTitleStringResult
    \saved@ythm{#1}{#2}{#3}[{#4}]%
  }%
}
\@ifdefinable{\saved@xthm}{%
  \let\saved@xthm\@xthm
  \def\@xthm#1#2#3{%
    \protected@edef\@currentlabelname{%
      #3~\csname the#2\endcsname
    }%
    \saved@xthm{#1}{#2}{#3}%
  }%
}
\makeatother

\newtheorem{lemma}{Lemma}

\begin{document}
\section{Test document}

\begin{lemma}
\label{first}
This is the first lemma.
\end{lemma}
\begin{lemma}[Pi's Lemma]
\label{pi}
This is a named lemma.
\end{lemma}

References via \verb|\ref|: \ref{first} and \ref{pi}.

References via \verb|\nameref|: \nameref{first} and \nameref{pi}.

\end{document}

Result

1

"Every solution does not work"? in which manner?

This compiles just fine (TUG TeX Live 2012 frozen)

\documentclass[a4paper]{article}
\usepackage{amsthm,nath}
\newtheorem{test}{Test}
\begin{document}

\begin{test}
$$(\sum_i f_i(x)) $$
\end{test}

\end{document}
  • I'm having trouble with ntheorem and I thought that amsthm would include amsmath, which conflicts with nath. But do you know if at least the (Needed) item is possible to do using amsthm? – TheoremNath Jun 13 '13 at 16:06

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.