I have a related question here whose solution is being blocked by the following error "Missing \endcsname inserted":
\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{csquotes}
%\usepackage{subcitations}
\usepackage{listofitems}
\usepackage{xifthen}
\usepackage{xstring}
\usepackage[backend=biber, style=numeric, subentry]{biblatex}
\begin{filecontents}{\jobname2.bib}
@set{two,
entryset = {twomain,twosub1},
}
@article{twomain,
author = {Yoon},
title = {A paper},
journaltitle = {Journal Title},
date = 2020,
}
@article{twosub1,
url={http://sub1.com}
}
@article{one,
url={http://other2.example.com}
}
@article{three,
url={http://other3.example.com}
}
\end{filecontents}
\addbibresource{\jobname2.bib}
\begin{document}
\newcommand{\subcite}[2]{
% Split the names of the references and the sub-citations on commas
\readlist\mains{#1}
\readlist\subs{#2}
% Define string to hold citations
\def\citations{\foreachitem\x\in\mains[]{\ifthenelse{\xcnt>1}{,}{}\x{\ifthenelse{\xcnt>\subslen}{}{\subs[\xcnt]}}}}
Citations: \citations % => Citations: one,twosub1,three
%\cite{\citations} % This errors with "Missing \endcsname inserted."
}
\def\citations1{one,twosub1,three}
- \cite{one,twosub1,three} % works fine => 1. [1,2,3]
- \cite{\citations1} % works fine => 2. [1,2,3]
- \subcite{one,two,three}{,sub1} % errors => 3. Citations: one,twosub1,three
\printbibliography
\end{document}
Is there a way to avoid / resolve this error?


\defand even less commands with numbers “in their name”. – egreg Dec 11 '20 at 15:43