# Labelling Theorem Environments across documents

This might seem like a really obvious question to some of you but I am having a bit of trouble.

I use Theorem (and Lemma etc.) environments in my documents and reference them in the proof of others - pretty standard.

The trouble I am having is what to call my theorems - the ones without names anyway.

An obvious way is to number them the same way they appear in the document, but if I then go back and add or remove theorem environments this all goes kablooey.

Does anyone have a nice logical system for doing this?

Minimal Working Example

\documentclass{article}

\newtheorem{thm}{Theorem}
\newtheorem{prop}[thm]{Proposition}
\newtheorem{lem}[thm]{Lemma}

\begin{document}

\begin{lem}\label{lem2}
This is the 1st lemma (2nd 'theorem') I write, but it clarifies the proof of the theorem below, so I place it above.
\end{lem}
\begin{proof}
The proof of lemma.
\end{proof}

\begin{thm}\label{thm1}
This is the 1st theorem I write.
\end{thm}
\begin{proof}
The proof of theorem using Lemma \ref{lem2}.
\end{proof}
\end{document}

• And do remember to use proper theorem constructions, not "homemade" ones. Apr 25 '17 at 13:50
• Can you please show us a minimal but working example (MWE) that illustrates your problem referencing theorems? Such a MWE should begin with \documentclass and end with \end{document}. Apr 25 '17 at 13:53
• Theorems and lemmas always have a meaning, so you can give them logical names even if they are not named in the printed document. You should not use numbers for \label. But even if you do so, you don't need to change the \label if you reorder, add or delete something. If your editor does not assist in finding labels you can use a package like showkeys. Apr 25 '17 at 13:58
• OTOH, remembering what you labeled theorem 3 could be more work than renaming them. I've never found a better system, but boy can I use Replace All! Apr 25 '17 at 22:34

If I understand it correctly, your problem is that you have some \labels in some document and want to refer to them using \ref in a separate (as in "compiled separately") document.

This is a job for the xr package:

If one document needs to refer to sections of another, say aaa.tex, then this package may be loaded in the main file, and the command \externaldocument{aaa} given in the preamble. Then you may use \ref and \pageref to refer to anything which has been given a \label in either aaa.tex or the main document. You may declare any number of such external documents.

Try naming the theorems as per convenience and then label them using preassigned suitable names. For example, \label{Continuity}, \label{date11.1.19} etx

• Better would be to use \label{thm:Continuity} etc. Feb 4 '19 at 21:06
• Ya. That is better. Feb 6 '19 at 7:07