GeneralListing Refs for a Lable

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Wolfram Stahl
Posts: 1
Joined: Thu Dec 17, 2015 3:06 pm

Listing Refs for a Lable

Post by Wolfram Stahl »

Hey Community

I'll be working on a massively cross-linked document soon an I wonder if you know a way to list where a label or a group of labels is referenced.
(E.g. a passage in chapter 3.1 is referenced to in chapters 5.1.1, 5.2 and 6.4, then I would like a nice way to list those chapters and their titles at the end of 3.1.
Optimally I'd have ONE list for ALL labels contained in 3.1, but this is optional)

Any idea on how to accomplish this or do you know a package that does that?
Please tell me also if you understand what I want to do or if you need more than that rather vague sketch of an idea that I gave you.

Thanks!
Wolfram

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Listing Refs for a Lable

Post by Stefan Kottwitz »

Hi Wolfram,

welcome to the forum!

You could make index entries for each reference. Here I made a sample document showing what I mean.

Code: Select all

\documentclass[12pt]{book}
\usepackage{amsthm}
\usepackage{showkeys}
\usepackage{imakeidx}
\usepackage[colorlinks]{hyperref}

\makeindex
\makeindex[name=refs,title=References,columns=1]

\let\origref\ref
\begin{document}
\renewcommand{\ref}[1]{%
   \origref{#1}%
   \index[refs]{\getrefnumber{#1}!Section \thesection}
}

\chapter{First}
A section follows.
\section{One}
\label{sec:one}
See \ref{sec:two} and \ref{eq:sample}.
\section{Another}
\label{sec:two}
See \ref{sec:one} and \ref{sec:more}.

\chapter{Second}
The second chapter.
\section{Equations}
\begin{equation}
\label{eq:sample}
\end{equation}
\section{More}
\label{sec:more}
See again \ref{sec:one}.
\printindex[refs]
\end{document}
You can see the chapter and section numbers for each reference, grouped by reference number, and the page where the \ref has been placed (in red).
list-of-references.png
list-of-references.png (6.32 KiB) Viewed 3718 times
I loaded the showkeys package in addition to show the labels in the document body.

Stefan
LaTeX.org admin
Post Reply