I'm trying to get this trivial proof of concept demo of pgfopts
to work and I keep getting inconsistent results. I have another version working in which the keys are handled with an .is if
handler and now I'm trying to use the .is choice
handler. I understand that .default
and .initial
won't work with .is choice
.
The default with no keys specified should be bold
. Loading the demo package with no keys given yields the correct result (the correct code executes, and the vector is bold). Loading the demo package with [vectors=arrowed]
still gives a bold vector and both code choices execute. Loading the demo package with [vectors=bold]
gives a bold vector, but the corresponding code executes twice. I can't see what's causing the problem.
Here is the demo pgfoptspkgtwo.sty
file.
\ProvidesPackage{pgfoptspkgtwo}
\RequirePackage[math-style=ISO]{unicode-math}
\setmathfont{Latin Modern Math}
\RequirePackage{pgfopts}
\pgfkeys{%
/pgfoptspkgtwo/.cd,
vectors/.is choice,
% vectors/.default = bold, % won't work with .is choice
% vectors/.initial = bold, % won't work with .is choice
vectors/bold/.code={%
\typeout{}%
\typeout{pgfoptspkgtwo: You'll get bold vectors.}%
\typeout{}%
\renewcommand{\vec}{\symbfit}%
},
vectors/arrowed/.code={%
\typeout{}%
\typeout{pgfoptspkgtwo: You'll get arrowed vectors.}%
\typeout{}%
},
vectors=bold % this should be the default
}%
\ProcessPgfPackageOptions{/pgfoptspkgtwo}
Here is the demo document pgfoptstestingtwo.tex
.
% !TEX TS-program = lualatexmk
% !TEX encoding = UTF-8 Unicode
\documentclass{article}
\usepackage{pgfoptspkgtwo}
%\usepackage[vectors=arrowed]{pgfoptspkgtwo}
%\usepackage[vectors=bold]{pgfoptspkgtwo}
\begin{document}
\[
\vec{E}
\]
\end{document}