3

In the following example, how can I treat the output of \cite as it was a simple string of text?

\documentclass{article}
\usepackage[style=numeric-comp]{biblatex}

\begin{filecontents*}{\jobname.bib} @book{A, title = {A Bla}, author = {A Foo} }

@book{B, title = {B Bla}, author = {B Foo} }

@book{C, title = {C Bla}, author = {C Foo} }

@book{D, title = {D Bla}, author = {D Foo} }

@book{E, title = {E Bla}, author = {E Foo} }

@book{F, title = {F Bla}, author = {F Foo} }

@book{G, title = {G Bla}, author = {G Foo} } \end{filecontents*} \addbibresource{\jobname.bib}

\usepackage{listofitems} \usepackage{scontents}

\begin{document} \nocite{*}

I would like this example:

\setsepchar{,} \readlist\foo{\cite{A,B,C,E,F,G}} Show items: \showitems\foo\par Term 1: \foo[1]\par

would give the same output as this example:

\setsepchar{,} \readlist\bar{[1-3,5-7]} Show items: \showitems\bar\par Term 1: \bar[1]\par Term 2: \bar[2]\par

\printbibliography \end{document}

enter image description here

CarLaTeX
  • 62,716
  • 3
    You have (at least) two issues: \cite is not expandable, and you have invoked \readlist in a manner that will not do any expansion on \cite even if that were possible. – Steven B. Segletes Mar 13 '23 at 21:52
  • I'm not sure what you're asking, because with just \cite{A,B,C,E,F,G} I get [1–3,5–7] – egreg Mar 14 '23 at 09:52
  • @egreg I would like to treat [1-3, 5-7] as a string, not as a unique block. – CarLaTeX Mar 14 '23 at 10:11
  • What's a string? Seriously, context is missing. – egreg Mar 14 '23 at 10:28
  • @egreg An alphanumeric set of chars, like a piece of ordinary text. I think in LaTeX "string" has another meaning... – CarLaTeX Mar 14 '23 at 11:23
  • Related: https://tex.stackexchange.com/questions/519654/apply-a-string-replacement-on-the-citation-as-returned-by-cite – Marijn Mar 14 '23 at 11:57
  • @Marijn That's similar to what I need, but I need to identify the groups 1-3 and 5-7. – CarLaTeX Mar 17 '23 at 06:39
  • @CarLaTeX I mentioned that question because the problem and proposed approach is related (i.e., string processing on \cite results) and the reason why this can't be done is mentioned in comments and in the answer (\cite is not expandable). Other than that the answer does not apply to your current problem, so it was more intended as general background information that may give you some insight in the problem and possible approaches, not as a solution to the question you asked here. – Marijn Mar 17 '23 at 07:33
  • 1
    @Marijn Yes, I know, I replied only for others that can read and think it's a duplicate – CarLaTeX Mar 17 '23 at 07:41

0 Answers0