TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Why does a choice key not save it’s value to a macro as a cmd key and as the corresponding xkeyval \define@choicekey do?

In the following example I have to define my@key manually by using the callback.




\mykeya% works
%\mykeyb% doesn't work

With xkeyval it is possible to define a bin i.e. a macro that saves the value:


an later \mybin holds the value of keyc

share|improve this question
up vote 2 down vote accepted

The command \define@choicekey of the xkeyval package doesn't yield a macro of the form \<macro-prefix>@<key-name> to hold the user input. The command \krddefinekeys of the keyreader package uses xkeyval's \define@choicekey in the background.

The feature you're asking for is available only in the ltxkeys package. Try the following:

% choice/<key name>.{<alternate values>}/<default>/<callback>;
% cmd/<key name>/<default>/<callback>;

\mykeya, \mykeyb\space and \mykeyc
share|improve this answer
But I can define a bin to save the value, please see my edit. Thath’s what I meant but had it wrong in my mind O:-) – Tobi Mar 4 '12 at 2:34
Yes, you can define two bins \bina (to hold current user value) and \binb (to hold the numerical order of the user input, starting from 0). Your \mybin is well placed. NOTE: It is advisable to always provide a key prefix (eg, [TOB]) and a family (eg, {tobi}). – Ahmed Musa Mar 4 '12 at 3:19
OK. But I can’t define a bin with \krddefinekeys right?. Why is it better to define a prefix? And why it this argument optional, though? – Tobi Mar 4 '12 at 12:20
I have uploaded onto CTAN a version of keyreader package that allows macro prefixes to be used in \krddefinekeys for choice keys (like it has always been for command keys). It will take perhaps 24 hours before the upload is propagated to mirror sites. So for a choice key keya, you can now have \mykeya as you wanted. Note: Providing both key prefix and family makes your keys unique and reduces the chances of name clashes within and between packages. The default value of key prefix is often KV. – Ahmed Musa Mar 4 '12 at 16:03
Thanks for the upload! I’ll do my update tomorrow. But if I define a <mpprefix> (\my) in my example the prefix isn’t uses anywhere, is it? – Tobi Mar 4 '12 at 17:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.