# Where will a theorem be used?

I have once seen a book (Graph Theory by Reinhard Diestel) where the author flags his theorems by adding on the left/right of the page the reference number of later theorems where said theorem will be applied. A truly bidirectional cross-reference!

I assume this is done automatically, but how? I have never seen a package for this.

Here is a screenshot:

• I'm not aware of a package that does it for you. Have you thought of asking the author.
– user10274
Mar 11, 2013 at 4:54
• See tex.stackexchange.com/q/37918/15925 and tex.stackexchange.com/q/14981/15925 for implementations of related types of back referencing. Mar 11, 2013 at 8:11
• thanks Andrew. it is not quite what I was looking for, but it comes very, very close to it, and what's left to do I can probably solve myself. thanks a lot. Mar 11, 2013 at 11:11
• @Delio If you have found a solution, would you like to share it here? Apr 21, 2013 at 22:28
• This feature clearly deserves a package. Apr 27, 2013 at 13:01

## Update 2

In this update I eliminated the blemish that there is another environment refprop to use when a reference is needed. Now, you can use the originary theorem environment (prop) as \begin{prop}[<specification>][<label>] (see the code below). The solution has to be triggered by \RefthmPatch{<list of your thm-envs>}

\documentclass{book}
\usepackage[margin=3cm,marginparwidth=2cm]{geometry}
\usepackage{lipsum}
\usepackage{marginnote}
\usepackage{etoolbox}
\usepackage{twoopt}
\usepackage{amsthm}
\newtheorem{prop}{Proposition}[section]
% \newtheorem{thm}{Theorem}[section]
% \newtheorem{lem}{Lemma}[section]

\makeatletter
\newcommand{\do@patch@refthm}[1]{%
\expandafter\let\csname svd@#1\expandafter\endcsname\csname #1\endcsname
\expandafter\renewcommandtwoopt\csname #1\endcsname[2][][]{%
\csname svd@#1\endcsname[##1]
\if\relax\detokenize{##2}\relax\else
\marginnote{\centering\normalfont\lbrack\ref{##2}\rbrack}\fi}}
\def\@patch@refthm@list{}
\newcommand{\RefthmPatch}[1]{\gdef\@patch@refthm@list{#1}}
\AtBeginDocument{%
\let\do=\do@patch@refthm
\expandafter\docsvlist\expandafter{\@patch@refthm@list}}
\makeatother

\RefthmPatch{prop}
%If you use more theorems:
%\RefthmPatch{thm,prop,lem}

\begin{document}
%%%%%%%%%%%%%%%%%%%%
\makeatletter
\c@chapter=1
\c@section=9
\c@prop=2
\makeatother
%%%%%%%%%%%%%%%%%%%%
\mbox{}
\clearpage
\lipsum[1-4]
\begin{prop}[][somethm:1]
Together with $\emptyset$ the cuts in $G$ from a subspace $\mathcal{C}^*$ of $\mathcal{E}(G)$. This space is generated by cuts of the form $E(v)$.
\end{prop}
\lipsum[5-8]
...
%%%%%%%%%%%%%%%%%%%%
\makeatletter
\c@chapter=4
\c@section=6
\c@prop=2
\makeatother
%%%%%%%%%%%%%%%%%%%%
\begin{prop}\label{somethm:1}
A Theorem in which a certain theorem is used.
\end{prop}
\end{document}


## Update 1

I slightly modified my previous approach. Now the solution does, what it is supposed to:

\documentclass{book}
\usepackage[margin=3cm,marginparwidth=2cm]{geometry}
\usepackage{lipsum}
\usepackage{marginnote}
\usepackage{amsthm}

\newtheorem{prop}{Proposition}[section]

\newenvironment{refprop}[1]
{\begin{prop}\marginnote{\centering\normalfont\lbrack\ref{#1}\rbrack}}
{\end{prop}}

\begin{document}
%%%%%%%%%%%%%%%%%%%%
\makeatletter
\c@chapter=1
\c@section=9
\c@prop=2
\makeatother
%%%%%%%%%%%%%%%%%%%%
\mbox{}
\clearpage
\lipsum[1-4]
\begin{refprop}{somethm:1}
Together with $\emptyset$ the cuts in $G$ from a subspace $\mathcal{C}^*$ of $\mathcal{E}(G)$. This space is generated by cuts of the form $E(v)$.
\end{refprop}
\lipsum[5-8]
...
%%%%%%%%%%%%%%%%%%%%
\makeatletter
\c@chapter=4
\c@section=6
\c@prop=2
\makeatother
%%%%%%%%%%%%%%%%%%%%
\begin{prop}\label{somethm:1}
A Theorem in which a certain theorem is used.
\end{prop}
\end{document}


### Remark

The next step would be to apply this to a given set of theorem environments. For that task a wrapper could be written. But this is not the scope of the answer.

## Original Solution

Allthough the \vskip is disturbing me a little, because it is arbitrary, this could work:

\reversemarginpar

\newenvironment{refthm}[1]
{\marginpar[\centering\vskip3mm\lbrack\ref{#1}\rbrack]{}\begin{somethmenv}}
{\end{somethmenv}}

\begin{refthm}{somethm:1}
A theorem which will be applied in a later theorem with the label somethm:1.
\end{refthm}

...

\begin{someotherthmenv}\label{somethm:1}
A Theorem in which a certain theorem is used.
\end{someotherthmenv}


This is my "budget Diestel" answer, because my solution simply puts all the margin text to the right, instead of checking if the page is meant to be on the left/right side. For me, this works well enough because I don't print out my documents.

My trick is to simply use marginpar. The critical line of code is:

\newcommand{\margin}[1]{\marginpar{\flushright \textcolor{blue}{\small{#1}}}}.

Minimal working example:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath, amsthm}
\usepackage[]{geometry}
\newtheorem{theorem}{Theorem}[section]
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}

\newcommand{\margin}[1]{\marginpar{\flushright \textcolor{blue}{\small{#1}}}}

\begin{document}
\begin{theorem}[Hall's] \label{theorem1}
Let $G = (A, B)$ be a bipartite graph. Then $G$ has a matching \margin{bipartite} if and only if $|N_G(S)| \geq |S|$ for all $S \subseteq A$ \margin{$N_G(S)$}.
\end{theorem}

\begin{theorem}[Tutte's] \label{theorem2}
Let $G$ be a graph. Then $G$ has a matching if and only if $q(G-S) \leq |S|$ for all $S \subseteq V(G)$. \margin{$q$, [\ref{theorem3}]}
\end{theorem}
This is a strengthening of Theorem \ref{theorem1}.

\begin{theorem}[Gallai-Edmonds] \label{theorem3}

Every \margin{[\ref{theorem2}]} graph $G$ contains $S \subseteq V(G)$ with the following two properties:
\begin{enumerate}
\item $S$ is matchable to $G-S$, \margin{matchable}
\item Every component of $G-S$ is factor critical. \margin{factor critical}
\end{enumerate}
Given $S$ satisfying the following two properties, $G$ contains a $1$-factor if and only if $|S| = |\mathcal{C}_{G-S}|$. \margin{$\mathcal{C}_{G-S}$}
\end{theorem}
\end{document}


Which produces the following output: Note that you need the hyperref package to make the references clickable as well.

I've tried to intimate Diestel as much as possible, so if everything is set up properly, the references in the square brackets should be clickable and direct you to the correct theorem, much like how normal referencing should.

Of course, you can change the colour, size or font family in the \newcommand{\margin}[1]{\marginpar{\flushright \textcolor{blue}{\small{#1}}}} command.

Unfortunately, I wasn't able to do this automatically.