#### How can I tag all occurrences of a keyword then reference all the pages containing the same tag?

##### Replies

###### Rukhsar Fatima

User

( 6 months ago )

I am writing a syllabus with specific curricular requirements. Activities are tagged with these requirements to demonstrate alignment. I want to use a labelling or indexing system to tag the instances of alignment and then refer to all of the pages were an instance of alignment occurs.

Is there a package that will reference all of the pages containing the same label, as in an index, but allow me to print the pages for that label at an arbitrary point in the document?

This need seems to have elements of \label - \ref and of \index.

I don't have a minimal working example but what I want would look something like this.

\documentclass{article}
\begin{document}
\begin{description}
\item[CR1] This is a description of a requirement. \\ See page <LIST OF PAGES LABELED WITH CR1>
\item[CR2] This is a description of another requirement. \\ See page <LIST OF PAGES LABELED WITH CR2>
\end{description}

\section{Section 1}
This is an activity aligned with CR1. (\label{CR1} or \index{CR1})

This is an activity aligned with CR2. (\label{CR2} or \index{CR2})
\section{Section 2}
This is another activity aligned with CR1. (\label{CR1} or \index{CR1})

\end{document}

###### Jai Khanna

User

( 6 months ago )

I see Nicola just did a glossaries version but here's my barebones makeindex version.

You just want an index style that saves each page list in a definition rather than typesetting, say foo.ist:

preamble
"\n\\makeatletter{"
postamble
"}\n\\makeatother\n"

item_0 "}\n\\@namedef{"
delim_0 "}{"

Then

pdflatex file
makeindex -s foo.ist file
pdflatex file

should produce the above output from a document like

\documentclass{article}
\usepackage{makeidx}
\makeindex
\def\listfor#1{\csname #1\endcsname}
\begin{document}

\printindex

\begin{description}
\item[CR1] This is a description of a requirement. \\ See pages \listfor{CR1}
\item[CR2] This is a description of another requirement. \\ See pages \listfor{CR2}
\end{description}

\section{Section 1}
This is an activity aligned with CR1\index{CR1}.

aa
\clearpage

This is an activity aligned with CR2\index{CR2}.
\section{Section 2}
This is another activity aligned with CR1\index{CR1}.

\section{Section 3}
This is an activity aligned with CR1\index{CR1}.

aa
\clearpage

This is an activity aligned with CR2\index{CR2}.
\section{Section 4}
This is another activity aligned with CR1\index{CR1}.

aa
\clearpage

aa
\clearpage

This is an activity aligned with CR2\index{CR2}.
\section{Section 4}
This is another activity aligned with CR1\index{CR1}.

\end{document}

Ra
04-Sep-2019

2 Replies

Ra
05-Sep-2019

2 Replies

11-Sep-2019

0 Replies