When I try to put in my package options with not yet defined macro (even if I use noexpand), the document fails to compile (even if I don't use the macro!). Any idea if it's fundamental or not? (I tried with kvoptions, but also with the regular system) Ideally I'd like to avoid \noexpand but for now any solution is interesting!



\usepackage[conf={I would like to use not (yet) defined macro here}]{teststy}
% Uncommenting the following line produces errors:
% \usepackage[conf={The value is: \noexpand\number\noexpand\value{counterAllProofEnd}}]{teststy}

\pratendOptconf %% Should display "The value is: 0"

\pratendOptconf %% Should display 1 "The value is: 1"



\ProvidesPackage{teststy}[2019/05/06 A test]


%% https://tex.stackexchange.com/questions/109747/put-all-package-options-into-one-command
%% Forward the options list to the command \pratendOptdefconf
%% in order to use:
%% \usepackage[conf={normal}]{proofAtTheEnd}
\DeclareLocalOptions{conf}% \pratendOptdefconf contains the proof

% \DeclareOption*{\PackageWarning{proofAtTheEnd}{Unknown}}
% \ProcessOptions\relax


1 Answer 1


Currently (although there may be plans to change this) the options argument is normalized by the standard option handling code before being passed to the package and so before being accessed by the kvoptions code used by the package.

Basically that means that the code passes through \edef and has white space removed.

That means that it is only really safe to have "classic" valueless options to a package [dvips], [fleqn] etc. In some cases you can make key=value options work but only if they are safe in an edef.

This is why for example hyperref allows kvoptions in the package option list but provides (and recommends) specifying the options separately via \hypersetup{...} which is only parsed by the keyvalue parser and so does not pre-expand the argument.

  • Ok thanks. But why "noexpand" does not work then if it goes through an edef?
    – tobiasBora
    May 7, 2019 at 12:01
  • 2
    @tobiasBora there are multiple edefs scattered around..... May 7, 2019 at 12:08

This site is temporarily in read-only mode and not accepting new answers.

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