The hyperref package (for example) provides a \hypersetup command where key-value options can be provided as an alternative to \usepackage[key=value]{hyperref}.

I'm trying to do the same, using kvoptions, but it doesn't seem to be working for me.

As far as I understand it, in my .sty file I should be able to say

\SetupKeyvalOptions{family=X, prefix=X@}

and then in my .tex file say \Xsetup{key=value}. This would provide the \X@key macro inside the .sty file.

Unfortunately, \X@key is set to default instead of value when I do this.







\SetupKeyvalOptions{family=X, prefix=X@}

  • Welcome to TeX.SX! Could you please make a minimal, but compilable example that we could test (with documentclass and the document environment). Maybe you can reduce your package snippet to document commands, otherwise you may include it with filecontents. – TeXnician May 16 '18 at 18:25
  • @TeXnician I just added a complete MWE. I'm not sure it's possible to merge the package and document in this case, but hopefully it's simple enough. – fionn May 16 '18 at 18:39
  • Works for me (just tested). The value of key is value. – TeXnician May 16 '18 at 20:06
  • @TeXnician thanks for compiling it! That is not what I was expecting. I'm on pdfTeX 3.14159265-2.6-1.40.18, kpathsea version 6.2.3 and compiling with pdflatex kvtest.tex. In my log I see > \X@key=macro: ->default. Very strange that it would work on your machine and not mine. – fionn May 17 '18 at 1:36
  • Just tried it on a machine with pdflatex 1.40.17, kpathsea 6.2.2 with the same result. – fionn May 17 '18 at 1:54