A variation on Alan's answer can show you also all font attributes:
\documentclass{book}
\usepackage[T1]{fontenc}
\newcommand\thefont{\expandafter\string\the\font}
\begin{document}
\chapter{\thefont}
\section{\thefont}
\subsection{\thefont}
\subsubsection{\thefont}
\thefont
\end{document}
What's the trick? It uses rather low level functionality of TeX; actually all control sequences in
\expandafter\string\the\font
are primitives of TeX. The primitive \font
is used for assigning a name to a font loading its metric file, but it can follow \the
(see The \the command) and, in this case, it returns a control sequence corresponding to what's needed to use the current font (a low level command, not the high level \bfseries
and siblings). For example, in the default setting and for normal text,
\the\font
would return the control sequence \OT1/cmr/m/n/10
(that's not writable without special tricks). With \string
we can print that control sequence, but we need to make \the
act before \string
does its job, so the need for \expandafter
. I've used the T1 encoding in the example because in the OT1 encoding the slot normally allotted to the backslash is occupied by ”
.
*.clo
).