23

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:

screenshot from Diestel's book

jub0bs
  • 58,916
Delio
  • 344
  • 1
  • 8
  • 1
    I'm not aware of a package that does it for you. Have you thought of asking the author. –  Mar 11 '13 at 04:54
  • 2
    See http://tex.stackexchange.com/q/37918/15925 and http://tex.stackexchange.com/q/14981/15925 for implementations of related types of back referencing. – Andrew Swann Mar 11 '13 at 08: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. – Delio Mar 11 '13 at 11:11
  • 2
    @Delio If you have found a solution, would you like to share it here? – egreg Apr 21 '13 at 22:28
  • @egreg unfortunately not quite. I have made a couple of experiments with the solution suggested by Andrew. It does somehow work, but it is graphically not as pleasant as in Diestel's book. It is more than sufficient for own's use, however (e.g., if you are writing a long article and want to be sure that you are not referring to something that still has to be introduced). – Delio Apr 22 '13 at 10:17
  • 2
    This feature clearly deserves a package. – TonioElGringo Apr 27 '13 at 13:01
  • @ReinhardDiestel Not sure if you're one and the same, on the chance that you are, and the answer is easy, just pointing you this direction. – Scott H. Apr 28 '13 at 00:15

2 Answers2

4

refthm_output

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}
Ruben
  • 13,448
0

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}

\usepackage[colorlinks=true, linkcolor=blue, citecolor=blue, allcolors=blue]{hyperref} \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: enter image description here Note that you need the hyperref package to make the references clickable as well.

I've tried to imitate 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.

Paul Wintz
  • 402
  • 2
  • 14
koifish
  • 101