Take the 2-minute tour ×
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.

Please is there a way to avoid xkeyval package bombing out in endless loop, as implied by the following simplified case?

\documentclass{article}
\usepackage{xkeyval}
\makeatletter
\define@key{fam}{key1}[key1-def]{\def\x##1{#1*##1}}
\define@cmdkey{fam}[store@]{key2}[key2-def]{\setkeys{fam}{key1=#1}}
%\define@key{fam}{key3}[key3-def]{\def\keyvalue{#1}}
\presetkeys{fam}{key2=val2}{}
\setkeys{fam}{key1}
\makeatother

\begin{document}
x
\end{document}

I get "If you really absolutely need more capacity, you can ask a wizard to enlarge me."

share|improve this question

1 Answer 1

I and Hendri Adriaens (the author of xkeyval package) agree that the following patch does solve the problem. We also agreed to collaborate to integrate xkeyval, ltxkeys and skeyval packages into xkeyval2, if we are able to find spare time.

\def\XKV@badsetkeys{%
  \@latex@error{You can't nest \noexpand\setkeys in preset keys.
    \MessageBreak That could cause an endless loop}\@ehd
}
\let\XKV@savsetkeys\setkeys
\def\XKV@usepresetkeys#1#2{%
  \XKV@presettrue
  \let\setkeys\XKV@badsetkeys
  \XKV@for@eo\XKV@fams\XKV@tfam{%
    \XKV@makehd\XKV@tfam
    \XKV@ifundefined{XKV@\XKV@header#2}{}{%
      \XKV@toks\expandafter\expandafter\expandafter
        {\csname XKV@\XKV@header#2\endcsname}%
      \@expandtwoargs\XKV@s@tkeys{\the\XKV@toks}%
        {\XKV@naa\ifx\XKV@naa\@empty\else,\fi#1}%
    }%
  }%
  \let\setkeys\XKV@savsetkeys
  \XKV@presetfalse
} 
share|improve this answer

Your Answer

 
discard

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.