I'm trying to pick something out of a list that has been passed from some package options by kvoptions
, but docsvlist
doesn't appear to be recognising the commas.
I suspect this may be something to do with the Knuth "mouth and stomach" paradigm, but I'm not enough of a TeXnician to understand why, nor how to do it correctly. Can someone explain what's going on?
Here's my MWE:
testx.sty:
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{testx}
\RequirePackage{kvoptions}
\RequirePackage{etoolbox}
\SetupKeyvalOptions{family=test,prefix=test@}
\DeclareStringOption{refnames}
\ProcessKeyvalOptions*
\newcommand{\vtag}{(None)}
\csdef{xferret}{} % This is what I want to extract
\newcommand{\testtag}[1]{%
\PackageWarning{testx}{Processing #1}
\def\do##1{%
\ifcsdef{x##1}{%
\renewcommand{\vtag}{##1}%
\listbreak
}{%
\PackageWarning{testx}{##1 not selected}
}
}%
\docsvlist{#1}%
}%
\testtag{\test@refnames}
test.tex:
\documentclass[10pt,a4paper]{article}
\usepackage[refnames={rat, ferret, 1.0, mole}]{testx}
\begin{document}
\vtag
\testtag{rat, ferret, 1.0, mole}
\vtag
\end{document}
The first \vtag
(set in the package) produces "(None)"
The second \vtag
produces "ferret"
in the log, we have this:
(from the package):
Package testx Warning: Processing rat, ferret, 1.0, mole on input line 22.
Package testx Warning: rat, ferret, 1.0, mole not selected on input line 22.
(from the call in the document body)
Package testx Warning: Processing rat, ferret, 1.0, mole on input line 5.
Package testx Warning: rat not selected on input line 5.