2

I currently have the following following setup (but with many more keys), which works, but isn't as clean as I'd like it.

\pgfkeys {
    /title/.is family, /title,
    first/.estore in = \title@first,
    last/.estore in = \title@last,
    city/.estore = \title@city,
}
\renewcommand {\title} [3] [] {
    \pgfkeys{/title,#1}
    {\huge \title@first\ \title@last} \\
    Location: (\title@city) \\
}

\title [
    first = Fred,
    last = Flinstone,
    city = New York\, NY,
]

I would like to do something like the following

\pgfkeys {
    /title/name.is family, /title/name,
    first/.estore in = \title@name@first,
    last/.estore in = \title@name@last,
    /title/contact/.is family, /title/contact,
    city/.estore = \title@contact@city,
}
\renewcommand {\title} [3] [] {
    \pgfkeys{/title,#1}
    {\huge \title@name@first\ \title@name@last} \\
    Location: (\title@contact@city) \\
}

\title [
    name = [ % {} instead of [] would be fine as well for me.
        first = Fred,
        last = Flinstone,
    ],
    location = [
        city = New York\, NY,
    ],
]

I was inspired by \setmainfont, which does a similar thing for SmallCapsFeatures

\setmainfont [
    Path = font/,
    Extension = .otf,
    BoldFont = MyFont-Bold,
    SmallCapsFeatures = {
        Letters = SmallCaps
    }
] {MyFont-Regular}
Updates
  • Corrected number of arguments from 4 to 3
  • 2
    yes that's the whole point of key families. – percusse Jan 14 '18 at 18:55
  • Why do you specify 4 arguments to \title of which one is optional? Your shown use cases only have one optional argument to it, so it should be \renewcommand{\title}[1][]{...}. The number of arguments you specify for \renewcommand does not correlate to the number of options you define with \pgfkeys. – Skillmon Jan 14 '18 at 19:07
  • The 4 is a typo and should have been 3. Also, none of the arguments are supposed optional as I don't provide a default for any. @percusse, could you provide an example of how to use key families to achieve this? – quittle Jan 15 '18 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.