0

Why does the MWE

\documentclass{article}
\begin{document}
\makeatletter
\def\CharBx{\textbf{\f@series}} 
\makeatother
\CharBx
\end{document}

compile normally (it returns 'bx'), while the MWE

\documentclass{article}
\begin{document}
\makeatletter
\edef\CharBx{\textbf{\f@series}} 
\makeatother
\CharBx
\end{document}

doesn't compile at all, but just hangs?

1
  • If I recall, \textbf is not expandable. \edef\CharBx{\noexpand\textbf{\f@series}} but it gives the tokens \textbf{m}. Commented Jan 28, 2022 at 1:12

1 Answer 1

5

\textbf (as many other commands in LaTeX is made robust using LaTeX's \protect system which you circumvent by manually using plain TeX's \edef instead of LaTeX's \protected@edef. With that your code works fine:

\documentclass{article}
\begin{document}
\makeatletter
\protected@edef\CharBx{\textbf{\f@series}} 
\makeatother
\CharBx
\end{document}

Of course this will show a bold m and not bx since \f@series gets expanded at the point of definition, while \textbf as a non-expandable command does not have any effect during the \edef.

You must log in to answer this question.

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