I'm writing a discussion document where contributors get their own pages and I want to mention these pages in the general text So I have this which seems to do the trick
% usage: create printed page space for artist and the short form reference
% \artist{Jo Blow}{JoBl}
\newcommand{\artist}[2]{
\newpage
\subsection{#1}
Lorem ipsum
\newpage
Et tu quoque! #2\label{artist:#2}
% page reserved for artwork by #1
}
% obtain page numbering for artist image page given shortform reference
% \mention{JoBl}
\newcommand{ \mention}[1] { \emph{[p.\pageref{artist:#1}]}}
but I wanted to extend mention{} to take a variable length list of arguments
I found this iterating-through-comma-separated-arguments
A case of running before I can walk, but bear with me I'm only a stupid artist, I tried this
%!TEX TS-program = lualatex
%!TEX encoding = UTF-8 Unicode
\documentclass{article}
\newcommand{\artist}[2]{
\newpage
\subsection{#1}
Lorem ipsum
\newpage
Et tu quoque! #2\label{artist:#2}
% page reserved for artwork by #1
}
% obtain page numbering for artist image page given short form reference
% \mention{HoBu}
\newcommand{ \mention}[1] { \emph{[p.\pageref{artist:#1}]}}
\makeatletter
\newcommand{\lmention}[2][$,$]{%
\def\nextitem{\def\nextitem{#1}}%
@for \el:=#2\do{\nextitem\el}%
}
\makeatother
\begin{document}
\artist{Arty Blow}{Arty}
\artist{Jo Blow}{Jo}
What I want is the stylised \mention{Arty}
What would be nice would be an arg count to say p.18 or pp.18,23,24
A list of mentions is \lmention{Arty,Jo,Fred} tho we havent talked about Fred
Did I forget \lmention{Bart} who is yet to be referenced
\artist{Bart Beast}{Bart}
\artist{Fred Geest}{Fred}
\end{document}
Long story, short question? How can I get it to do the \pageref lookup on an arg by arg basis
I try
\newcommand{\lmention}[2][$:$]{%
\def\nextitem{\def\nextitem{#1}}%
\@for \el:=#2\do{\pageref{artist:#2}\nextitem\el}%
}
but get
A list of mentions is ??Arty??:Jo??:Fred tho we havent talked about Fred
Well out of my depth here


\artistyou need the syntax\artist{Arty Blow}{Arty}, so no commas and no extra pair of{}. – Marijn Jun 23 '23 at 13:07