I like to define commands to denote multi-parameter (mathematical) functions, e.g., \myf{x}{C}
expands to f(x;C)
. During writing, however, it is sometimes hard to remember if I should use \myf{x}{C}
or \myf{C}{x}
, so I would like to use something like keyword arguments from Python. In my example, this means I would like to write \myf{set=C,at=x}
or \myf{at=x,set=C}
and get f(x;C)
as the result for both commands. For that, I am using pgfkeys; see below.
I am running into an error when pdflatexing the code below:
\documentclass{article}
\usepackage{pgfkeys}
\usepackage{mathtools}
\usepackage{mathrsfs}
\pgfkeys{
/myf/set/.estore in = \myfset,
/myf/at/.estore in = \myfat,
}
\newcommand*{\myf}[1]{%
\begingroup
\pgfkeys{/myf/.cd, #1}
f(\myfat;\myfset)
\endgroup
}
\begin{document}
\(\myf{set=\mathscr{C},at=a}\)
\end{document}
I get an error
<inserted text>
\inaccessible
l.16 \(\myf{set=\mathscr{C},at=a}
\)
?
This error goes away if I replace \mathscr{C}
with C
or if I drop the package mathtools
(which I need for other features).
Could anybody please help me fix this? Thanks!
.estore in
rather than just.sotre in
? The former does expansion which may (and here does) go wrong with non-expandable input.