2

I was following the answers to How to iterate over a comma separated list? and especially the way working with ExplSyntax.

But the hyperref does not work with the \clist_map_inline:nn however it works with the straight LaTeX-way extracting data from the comma separated list.


\documentclass{scrartcl}

\makeatletter
\newcommand{\dois}[2][,]{%
\begin{description}%
     \itemsep0em \def\dolist##1{\expandafter\@dolist##1#1\@eol}%
  \def\@dolist##1#1##2\@eol{%
    \begingroup\setbox0=\hbox{##1\unskip}\ifdim\wd0=0pt\endgroup\else\endgroup\item[DOI:] \ignorespaces\href{https://doi.org/##1}{##1} \unskip\fi%
    \ifx\@eol##2\@eol\else\@dolist##2\@eol\fi}%
  \dolist{#2}%
\end{description}}
\makeatother




\usepackage{xparse}
\ExplSyntaxOn

\NewDocumentCommand{\doisltx}{ m }
 {
  \begin{description}
  \clist_map_inline:nn { #1 } { \item[DOI:] \href{https://doi.org/##1}{##1}}
  \end{description}
 }

\ExplSyntaxOff


\usepackage{hyperref}
\begin{document}

hyperref does not work
\doisltx{%
  10.17171/2-2-90,%
  10.17171/2-2-91
  }


hyperref does work
\dois{%
  10.17171/2-2-90,%
  10.17171/2-2-91
  }


hyperref: \href{https://doi.org/10.17171/2-2-90}{10.17171/2-2-90}
\end{document}

enter image description here

1 Answer 1

5

colons are letters in expl3 context, so you must be a bit careful when using them. hyperref is expecting a catcode 12 colon after the https:

\ExplSyntaxOn

\NewDocumentCommand{\doisltx}{ m }
 {
  \begin{description}
  \clist_map_inline:nn { #1 } { \item[DOI:] \href{https\c_colon_str//doi.org/##1}{##1}}
  \end{description}
 }

\ExplSyntaxOff

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .