2

I am using \usepackage{amsthm} to create propositions. Under my \begin{document}, I have

\theoremstyle{definition}
\newtheorem{thm}{Theorem}[section]
\newtheorem{defn}[thm]{Definition}
\newtheorem{lem}[thm]{Lemma}
\newtheorem{cor}[thm]{Corollary}
\newtheorem{conj}[thm]{Conjecture}
\newtheorem{prop}[thm]{Proposition}
\newtheorem{alg}[thm]{Algorithm}

So if I want to make a proposition in my document, I just wrote \begin{prop} (stuff) \end{prop}. So far, everything works great. But suppose I want to refer to a particular proposition (e.g. proposition 2.11). I could just find its assigned number and write it, but if I add new propositions in the future, then the numbering will be all ruined. Is there a way I can assign keywords or something to propositions and write something like "By \prop{EulersTheorem}, it follows..."

Mico
  • 506,678
  • 3
    Yes, for sure. You have to insert a \label{} within the prop environment and refer to it using \ref{}. Search for cross reference. It is powerful. – Sigur Dec 31 '21 at 00:52
  • @Sigur This is great. One issue is \ref{} that it only returns the number of that prop. Is there a way to make it return "Prop. 2.7" instead of just "2.7"? Other than that, this helps a lot, thanks. And can it be boldened, or do I have to manually type that? – Spencer Kraisler Dec 31 '21 at 00:55
  • 1
    Welcome to tex.sx. As suggested by @sigur, adding a \label{<name>} within the environment (if you put it at the beginning, it will be easy to find later) will allow you to use \ref{<name>} from anywhere else in your document; you will have to process the document twice to resolve the reference. You might also find it helpful to read the document for amsthm -- texdoc amsthdoc. – barbara beeton Dec 31 '21 at 00:57
  • 1
    You say that your theorem definitions follow \begin{document}. They should be before it, in the preamble. – barbara beeton Dec 31 '21 at 00:59
  • 3
    In addition to @barbarabeeton nice comment, there is the cleveref package to do what you wish about the Prop. names. – Sigur Dec 31 '21 at 01:00
  • 1
    Not meaning to be pesty, but Propositions are part of amsthm, not amsmath. I've edited the tags accordingly. – barbara beeton Dec 31 '21 at 01:57

1 Answers1

5

For a general intro to LaTeX's basic method for creating cross-references and an overview of various cross-referencing packages, please see the posting Cross-reference packages: which to use, which conflict [shameless self-citation alert!].

If you will cross-reference single instances of theorems, lemmas, propositions, etc, all you need to do is load the cleveref package and write \cref{EulersTheorem} instead of \ref{EulersTheorem} in order to get both a name label and the number for the proposition. If there's a chance that you'll create to two or more instances of a theorem, lemma, proposition, etc in one \cref directive, it's necessary to inform cleveref about the plural forms of the labels via \crefname directives. How to do this is shown in the following example document.

enter image description here

Observe that all cross-references were generated with a single \cref statement.

\documentclass{article} % or some other suitable document class
\usepackage{multicol}
\usepackage{amsthm} % for '\theoremstyle' and '\newtheorem' macros
\usepackage[colorlinks,allcolors=blue]{hyperref}
\usepackage[nameinlink,noabbrev]{cleveref}

% The following \crefname declarations are needed only % if your cross-references contain plural items \crefname{thm}{theorem}{theorems} \crefname{defn}{definition}{definitions} \crefname{lem}{lemma}{lemmas} % or 'lemmata'? \crefname{cor}{corollary}{corollaries} \crefname{conj}{conjecture}{conjectures} \crefname{prop}{proposition}{propositions} \crefname{alg}{algoirithm}{algorithms}

\theoremstyle{definition} \newtheorem{thm}{Theorem}[section] \newtheorem{defn}[thm]{Definition} \newtheorem{lem}[thm]{Lemma} \newtheorem{cor}[thm]{Corollary} \newtheorem{conj}[thm]{Conjecture} \newtheorem{prop}[thm]{Proposition} \newtheorem{alg}[thm]{Algorithm}

\begin{document}

\setcounter{section}{3}

\begin{multicols}{2} \begin{thm} AAA \label{thm:aaa} \end{thm} \begin{defn} BBB \label{defn:bbb} \end{defn} \begin{lem} CCC \label{lem:ccc} \end{lem} \begin{cor} DDD \label{cor:ddd} \end{cor} \begin{conj} EEE \label{conj:eee} \end{conj} \begin{prop} FFF \label{prop:fff} \end{prop} \begin{alg} GGG \label{alg:ggg} \end{alg} \begin{thm} AAAA \label{thm:aaaa} \end{thm} \begin{defn} BBBB \label{defn:bbbb} \end{defn} \begin{lem} CCCC \label{lem:cccc} \end{lem} \begin{cor} DDDD \label{cor:dddd} \end{cor} \begin{conj} EEEE \label{conj:eeee} \end{conj} \begin{prop} FFFF \label{EulersTheorem} \end{prop} \begin{alg} GGGG \label{alg:gggg} \end{alg} \end{multicols}

\noindent Cross-references to \cref{thm:aaa,defn:bbb,lem:ccc,cor:ddd,conj:eee,prop:fff,alg:ggg,% thm:aaaa,defn:bbbb,lem:cccc,cor:dddd,conj:eeee,EulersTheorem,alg:gggg}. \end{document}

Mico
  • 506,678