I am looking for a command to return both the font size class and the font size in pt.

The following approach from @Alan Munn as per this SE post prints font-size values for all standard classes:

\newcommand\thefontsize[1]{{#1 The current font size is: \f@size pt\par}}


The current font size is: 17.28pt

I would like to twist the output such that it also prints the label of the font-size class

\newcommand\thefontsize[1]{{#1 FONTSIZECLASS is printed as \f@size pt \par}}

e.g. for \LARGE

LARGE is printed as 17.28pt

If not feasible, maybe one could twist this SE post that prints The current font size is: XXpt to include chapter/section/subsection in the print-out, i.e. The section font size is: 17.28pt

\newcommand\thefontsize{The HEADING font size is: \f@size pt}


Solution presented by @Peter Wilson: Extended MWE for future reference

\newcommand\getfontsizeofheading{The current font size is: \f@size pt}
% print given font size in point and in its "font size" (i.e. larger or smaller)
\newcommand\getfontsizeforfontsizeclass[1]{{\string #1 is printed as #1 \f@size pt\par}}
% print the entire string in the size of the fontsize (i.e. larger or smaller)
\newcommand\printfontsizeforfontsizeclass[1]{{#1 \string #1 is printed in \f@size pt\par}}



...which results in (for printfontsizeforfontsizeclass) printfontsizeforfontsizeclass

3 Answers 3


Hopefully this will lead you to what you are after.

% fontdataprob.tex SE 552560


\newcommand{\thisfontsize}[1]{{#1 The \string #1'' font size is: \f@size pt\par}}
\newcommand{\printfontsize}[1]{{The \string #1'' font size is: #1 \f@size pt\par}}





I showed two methods of printing out the font size. Hopefully one will be OK for you.

  • Sorry for the irrelevancy, but ... Peter, are you there? Your herries.press email started bouncing a couple hours ago ("user unknown") and I don't know any alternative. Help?!
    – Karl Berry
    Jul 8, 2020 at 1:18
  • @PeterWilson: Thank you so much! \newcommand\thefontsize[1]{{\string #1 is printed as #1 \f@size pt\par}} - this works like charm!!
    – mavericks
    Jul 8, 2020 at 6:13
  • @Peter Wilson: I would love to give you a thumbs up for your answer, but with my 13 points I am not permitted yet (needs 15 at least to caste a vote)
    – mavericks
    Jul 11, 2020 at 10:04

The fontsize package provides the \printsamples command to print a sample text for all (or some of) the sizing commands provided by the package. With \sampletext{} it is possible to print only the value of the font size and the line spacing:

% A smoothly scalable font is required for some features:




enter image description here


If you use a standard class (no titlesec package), you can access the font used for headings with some nasty tricks.

The code below is not optimized and could be better, but it's easier to say in the document \meaning\section and look at the final part.

One can devise similar tricks for \chapter and \part, but they're more complex.


\newcommand{\getsectionfont}[1]{% #1 = sectional level
  \texttt{\string#1}: \texttt{\detokenize\expandafter{\section@font}}
  (\section@size pt)%










enter image description here

  • @greg: thanks a lot for your proposal. I use the getsectionfont-code in an Rmd document knitted with knitr. For this, I included thenewcommand definition in a Tex-template sourced by the file. Unfortunately, I receive the following error when copy & pasting your code ! Argument of \@seventhofseven has an extra }. <inserted text> \par l.478 getsectionfont{\section}
    – mavericks
    Jul 8, 2020 at 6:06
  • @mavericks That probably depend on where you place the command.
    – egreg
    Jul 8, 2020 at 7:29
  • hmm, interesting. Placed \makeatletter COMMAND-DEFINITION \makeatother into the template.tex just like the solution proposed by @Peter Wilson and then in the Rmd file the code \getsectionfont{\section} .... Anyway, many, many thanks!
    – mavericks
    Jul 8, 2020 at 7:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .