Revised question:

I'm using TikZ to re-design \rightarrow for the Lucida Bright fonts, to better match tikzcd arrows. How do I scale that mathrel for script- and scriptscript-styles (as well as have the scaling sensitive to enclosing \large, \tiny, etc., commands).

With the lucidascale or lucidasmallscale option of lucidabr.sty (or lucimatx.sty), scaling is non-linear.

Originally I thought I should base the scaling factor upon the document class's font size option (or its default). And Phelype Oleinik;s answer showed how to obtain the document class's font size.

However, as David Carlisle pointed out, that approach is neither necessary or sufficient for achieving my actual aim.

Original question: For a document class being used, is there a way to determine through TeX or LaTeX code what the declared font size option is, or in the absence of a user-declared option, what the default font size is?

I want this font size just as an integer (12, 11, 10, e.g.) and not as an actual dimension such as 12.0 pt.

In particular, is it possible to do this with the article and memoir document classes?

  • @PhelypeOleinik: That's almost what I need. I think I'll want the font size parameter as a simple integer, not a decimal length. Unclear to me yet how to do that. (I'll be doing some \ifthenelse tests on the font size parameter, and I think comparing with an integer would be simpler.) – murray Jul 5 at 15:25
  • why does knowing the document option help? you may be in the scope of \footnotesize or \large or whatever so knowing what is the document default settings seems of little use. Just use the font dimens of the \textfont0, \scriptfont0 and \scriptscriptfont0 in the current math expression. – David Carlisle Jul 5 at 15:51
  • @DavidCarlisle: Yes, I'm aware of that issue of scope. But "Just use the font dimens..." is beyond my depth of understanding. Even after some online searching, I'm at a complete loss as to what \textfont0, etc., mean or how to use them. Since my purpose is to scale a symbol constructed in TikZ, I need to determine a scaling factor for script, etc. – murray Jul 5 at 16:00
  • the title of the question is a duplicate of the stated one but the actual question (or at least the stated use case) is a completely unrelated problem so if you wanted to edit the question a bit it could probably be re-opened – David Carlisle Jul 5 at 20:08

For the stated use case knowing the documentclass options does not seem that useful as you need to know the math font sizes in the current size, something more like this which gives the x-height in the three math font sizes current at that point.

enter image description here


\def\zz{\mbox{ex-height  is
 text:  \the\fontdimen5\textfont2\ 
 script:  \the\fontdimen5\scriptfont2\ 
 scriptscript:  \the\fontdimen5\scriptscriptfont2


{\large $\zz$}

{\tiny $\zz$}


Or the same scaling an arrow:

enter image description here



\sbox\zzarrowbox{\mbox{-->>}}% draw with tikz if you prefer...


$a\zzarrow b  X_{a\zzarrow b}$

{\large $a\zzarrow b  X_{a\zzarrow b}$}

{\tiny $a\zzarrow b  X_{a\zzarrow b}$}

  • How to detect whether a given string of math is in a \large, \normalsize, \tiny, etc? I'm trying to write a command to scale a \mathrel object. I'm starting with this, from lucidabr.sty, based on font size, not x-height: \def\DeclareLucidaFontShape#1#2#3#4#5#6{% \DeclareFontShape{#1}{#2}{#3}{#4}{% <-5.5>s*[.98]#5% <5.5-6.5>s*[.96]#5% <6.5-7.5>s*[.94]#5% <7.5-8.5>s*[.92]#5% <8.5-9.5>s*[.91]#5% <9.5-10.5>s*[.9]#5% <10.5-11.5>s*[.89]#5% <11.5-13>s*[.88]#5% <13-15.5>s*[.87]#5% <15.5-18.5>s*[.86]#5% <18.5-22.5>s*[.85]#5% <22.5->s*[.84]#5% }{#6}}} – murray Jul 5 at 19:23
  • @murray that's the whole point of the answer, you do not need to look at those definitions at all, just make the arrow match the current font size, what else do you need? – David Carlisle Jul 5 at 19:47
  • @murray I modified the example to show a scaled arrow rather than text. – David Carlisle Jul 5 at 19:57
  • How disentangle my original question, for which Phelype Oleinik provides an emended answer to the poit, from your answer -- which solves my problem but not in the way I thought I had to do it? – murray Jul 5 at 20:17
  • @murray well if your problem is solved you could just let it be. it's not like I'm in desperate need of lots of people to come by and vote up my rep:-) – David Carlisle Jul 5 at 20:20

This is the same principle as my other answer, except that here I use expl3's \token_if_dim_register:NTF, \token_if_int_register:NTF, and \token_if_macro:NTF to set the argument of \classfontsize accordingly. If the argument is a dimen register, the value set is the font size (the option used in \documentclass, not the actual font size) as a TeX dimension. If the argument is a count register, then the value is store as an integer, and if it is another control sequence, then the value is also stored as the integer representation of the option.

Note that the font size used in the \documentclass is purely symbolic! The actual size of the font not necessarily (and hardly) matches the class option. For example, the 11pt option loads a 10.95pt font.

Use as \classfontsize<count register> or \classfontsize<dimen register> or \classfontsize<control sequence>:

enter image description here

\NewDocumentCommand \classfontsize { m }
  { \murray_def_class_font_size:N #1 }
\cs_new_protected:Npn \murray_def_class_font_size:N #1
    \token_if_dim_register:NTF #1
      { \__murray_class_size:NNn \dim_set:Nn #1 { pt } }
        \token_if_int_register:NTF #1
          { \__murray_class_size:NNn \int_set:Nn #1 { } }
            \token_if_macro:NTF #1
              { \__murray_class_size:NNn \cs_set:Npx #1 { } }
                \cs_if_exist:NTF #1
                  { \msg_error:nnn { murray } { invalid-token } {#1} }
                  { \__murray_class_size:NNn \cs_set:Npx #1 { } }
\msg_new:nnn { murray } { invalid-token }
  { Token~#1 invalid~for~assignment~\msg_line_context:.}
\cs_new_protected:Npn \__murray_class_size:NNn #1 #2 #3
  { #1 #2 { \__murray_get_class_size_int: #3 } }
\cs_new:Npn \__murray_get_class_size_int:
    \cs_if_exist:cTF { ver@beamer.cls } \__murray_get_beamer_size:
        \cs_if_exist:cTF { ver@memoir.cls } \__murray_get_memoir_size:
            \cs_if_exist:cTF { ver@extarticle.cls } \__murray_get_extarticle_size:
              { \__murray_get_standard_size: }
\cs_new:Npn \__murray_get_beamer_size:
  { \exp_args:NNNo \exp_args:No \__murray_get_beamer_size_aux:w \use:n \beamer@size }
\cs_new:Npn \__murray_get_beamer_size_aux:w size#1.clo {#1}
\cs_new:Npn \__murray_get_memoir_size: { \@memptsize }
\cs_new:Npn \__murray_get_extarticle_size: { \@ptsize }
\cs_new:Npn \__murray_get_standard_size: { 1 \@ptsize }
Length: \the\dimfontsize

Integer: \the\intfontsize

Macro: \csfontsize

and, as requested, a macro-only version without expl3:

      \vincent@ifclassloaded {beamer}
          \vincent@ifclassloaded {memoir}
              \vincent@ifclassloaded {extarticle}
  \expandafter\ifx\csname ver@#1.cls\endcsname\relax
\def\get@@beamersize size#1.clo{#1}
  • How might I get the "macro" version of the class font size without having to use expl3 syntax (which is totally opaque to me)? That is, how do it based upon your answer tex.stackexchange.com/a/487949/13492? – murray Jul 5 at 16:13
  • @murray I added a macro version of that answer. Of course you don't need to understand expl3 to use the code; it works as is. \begin{advertisement} However I must say that once you get used to it, you can do things much easier with expl3 than plain (La)TeX programming. It offers a lot of predefined tests (such as the ones I showed), some new data types, and a precise expansion control, greatly reducing the usage of the infamous \expandaftery. \end{advertisement} – Phelype Oleinik Jul 5 at 16:18
  • I do strongly prefer to understand code that I use! Eventually I'll get around to learning expl3, but that would be a diversion right now. Thanks for the expl3-free macro version. – murray Jul 5 at 18:59
  • @murray You're welcome. Of course I agree that understanding the code is the best way to make proper use of it. expl3 is really not that hard if you have some TeX background and a little time to get your hands dirty in it. The syntax is a bit scary at first, but you get used to it :-) – Phelype Oleinik Jul 5 at 19:07
  • My limitation here will doubtless be in limited understanding of TeX syntax & semantics. – murray Jul 5 at 19:40

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.