In my TeX file I have a something like this:

\textbf{#1 \imp:} \textit{#2}\\



As I write my lemmata and definitions it is hard to keep track of them. So I'd like to use labels. And then I'd love to write something like this

According to Lemma 3 we know that ....

Where Lemma 3 is filled in on the fly by nameref, so that I'd only have to write this

According to \nameref{lemma_cook} we know that .....

I tried to use labels and references but they only work within sections, figures and stuff that can be enumerated. Is there a way to adjust my new commands to make this possible (put them in an enumerable environment, use a virtual counter, use hyperref package, ...)?

  • 3
    Welcome to TeX.SX! You seem not to have heard about \newtheorem. – egreg Dec 15 '13 at 10:54
  • You're right. Never heard of that, but exactly what I was looking for. Thank you very much! – user42756 Dec 15 '13 at 12:01

Instead of doing things by hand, use the \newtheorem command; the amsthm package extends the command with the notion of “current style”:


%\theoremstyle{plain} % implicit
\newtheorem{thm}{Theorem}[section] % theorems are numbered by section
\newtheorem{lem}[thm]{Lemma}       % lemmas share the numbering

\theoremstyle{definition} % body font is upright
\newtheorem{defn}[thm]{Definition} % definitions share the numbering

\newtheorem*{rem}{Remark} % unnumbered




The proof is easy when one recalls Lemma~\ref{lem:easy}.

A natural number is \emph{nice} when it has good properties.

Every natural number is nice.
Easy induction, the inductive step is provided by Theorem~\ref{thm:add}.

All of the above extends to real numbers, but this paper is too
short for showing the proof.


enter image description here

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.