[Tex/LaTex] How to check what font size is in pt for \section, \subsection, and \subsubsection

fontsizesectioning

There are a lot of results for "setting" the font size, but I can't find one how to "get" them.

Here's some code from What point (pt) font size are \Large etc.? I can use to check what font size for \normalsize, \large, etc.

\makeatletter

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

\makeatother

\begin{document}

\thefontsize\normalsize

\end{document}

But \thefontsize\section doesn't work…

Could anyone help me how to get it?

Best Answer

You can do a similar thing by putting the \thefontsize command inside the argument of the sectioning command. In this case the command doesn't need to take an argument. (If you want to use the same command as in your code above, just type \thefontsize{} instead.

\documentclass{book}
\makeatletter
\newcommand\thefontsize{The current font size is: \f@size pt}
\makeatother
\begin{document}
\chapter{\thefontsize}
\section{\thefontsize}
\subsection{\thefontsize}
\subsubsection{\thefontsize}
\end{document}

output of code