I was wondering if anyone could help me with this:
I've got this report for which I show the paragraph numbers. The paragraph number is then used as part of the label so I can extract it later on, and I have standard label names e.g. sci1, sci2, clin1, etc.
I need to produce a list of the paragraph and page numbers at which each of the labels appear separately (see image). I could do it manually but my report is quite big so was wondering if I could write a macro to do it "automatically" since I've standardised the labels.
I've browsed the internet for solution and tried working with and modifying the code from List of all labels with hyperlinks with no luck unfortunately.
I am fairly new to Latex so would welcome any suggestions, corrections or what not :)
MWE:
\documentclass{article}
\usepackage{hyperref}
\usepackage{xstring}
\usepackage{blindtext}
\newcounter{par}
\newenvironment{pns}{\everypar={\refstepcounter{par}\makebox[0pt]{\makebox[15ex][l]{\arabic{par}}}}}
\long\def\findlabel#1#2\findlabel{\ifx\newlabel#1\complist\expandafter{\the\complist\showlabel#2}\fi}
\def\showlabel#1#2{\S\texttt{\ref{#1}~(p.\pageref{#1})}}
\newtoks\complist
\newread\zz
\immediate\openin\zz=\jobname.aux
\loop
\ifeof\zz\else
\read\zz to \tmp
\expandafter\findlabel\tmp\relax\findlabel
\repeat
\begin{document}
\section{Text}
\begin{pns}
\blindtext\label{sci1:1}
\blindtext\label{sci2:1}
\end{pns}
\subsection{other}
\begin{pns}
\blindtext[2]\label{sci1:2}
\blindtext
\blindtext\label{clin1:1}
\end{pns}
\section*{Labels}
This is the list of all labels:
\the\complist
\vspace{12pt}
And this is what I would like it to look like:
\vspace{12pt}
\begin{tabular}{r|l}
Sci1 & \S\ref{sci1:1} (p.\pageref{sci1:1}), \S\ref{sci1:2} (p.\pageref{sci1:2}) \\
Sci2 & \S\ref{sci2:1} (p.\pageref{sci2:1})\\
Clin1 & \S\ref{clin1:1} (p.\pageref{clin1:1})\\
\end{tabular}
\end{document}

