I apologize that this isn't particularly short.

I'm going through old code and refactoring. In the process, I'm running into various bugs in how I've written things. In this particular example, the font sizes are not getting properly initialized and I can figure out why.

My issue here is that I can't seem to get the usefontsize/.initial to take effect unless I explicitly make a call to the fontsize key.

% first line of material I don't want to see
  document content here
    /ae/ncode/.is family,
    examcode/.code       = {\code@cat},
    gobble/.initial        = 2,
    width/.initial         = 3in,
    firstline/.initial     = 1,
    lastline/.initial      = 5000,
    firstnumber/.initial   = 1,
    rulecolor/.initial     = black,
    fillcolor/.initial     = red!20,
    numbers/.initial       = none,
    numbersep/.initial     = 1em,
    indent/.initial        = 0pt,
    usefontsize/.initial     = \normalsize,
    fontsize/.style          = { usefontsize=\csname #1\endcsname},
    fontsize/relsize/.style  = { usefontsize=\relsize{#1}},
    examcodecolor/.style   = { fillcolor=#1 },
    examcodecolor/.default = red!30,
    mboxheight/.initial = \ae@mboxheight,
    height/.code = {\expandafter\ifx\csname ae@value@is@#1\endcsname\ae@value@is@none\else
    fbox/.style = { select/box/style/#1/.get = \ae@box@fbox, }, 
      fbox/.initial      = \fbox,
      fcolorbox/.initial = \fcolorbox{\ae@ncode@get{rulecolor}}{\ae@ncode@get{fillcolor}},                   
  \pgfqkeys{/ae/ncode}{usefontsize,#1}% <--- doesn't seem to matter whether `usefontsize` is here or not
      \ae@ncode@get{usefontsize}% <--- doesn't seem to be taking effect in left version

Shouldn't the left and the right boxes look identical?

%        fontsize=normalsize,


enter image description here

I know there are parts of this code I could have written differently. For example, it looks like I could have just written one key word fontsize to accept, not a bare word, but the actual command name for the font. But keep in mind that I'm refactoring old code. My old version of this code, when I was just learning to use key-values, didn't allow me to pass command names. I now have hundreds of lines of code which now depend upon that old syntax. So, I need a solution that recognizes the need for the fontsize key word to accept a bare word (instead of macro name) for its value. Similarly with the wonky way I'm handling the keyword height since in my old code it's not always specified as a dimension.


I should point out that there are other keys where I do similar finagling with other initialized keys. For example, examcodecolor resets the fillcolor, but seems to work fine whether or not examcodecolor was actually invoked. A bit more off the beaten path is height, but if you redefine \ae@mboxheight as say:


without having to invoke height at all the correct parameter value is used.

Is there something special about \normalsize that I'm not considering? Is it somehow being invoked at the time I'm defining usefontsize/.initial?

  • @cgnieder That shouldn't be the case at all. usefontsize doesn't invoke the code involving \csname...\endcsname, and there's no where in my code where I write fontsize=\normalsize. – A.Ellett Jul 26 '13 at 17:57
  • @cgnieder your suggestion should result in the string normalsize being printed in the final document. – A.Ellett Jul 26 '13 at 17:58
  • Oh, you're right! I misread your code, sorry! Adding usefontsize/.code = #1 additional to usefontsize/.initial = normalsize seems to work. – clemens Jul 26 '13 at 18:03
  • @cgnieder That works! But why??? In all the other initialized key values, I can access and use their initialized value through \ae@ncode@get. Why is that not the case with usefontsize and why then does writing usefontsize/.code = #1, produce the desired effect? – A.Ellett Jul 26 '13 at 18:06
  • 1
    usefontsize is set to \relsize{-0.75} by \code@cat which you call implicitly by calling the examcode option. In the left example this is overwritten again, in the right it isn't. – clemens Jul 26 '13 at 18:28

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.