I do \font\testFont="Arial"\testFont to set the font to Arial (or to any font I need), but after I'm done displaying some characters I need to revert to previous font. What can be done to achieve this, aside from enclosing the above font change within {} (a group)? I use XeTeX so you can rely on XeTeX-related functionality, but non-XeTeX solutions (that would work there) are welcome too.

  • 2
    if you are using latex why are you using primitive \font loading at all? Nov 19, 2019 at 20:37
  • 1
    it's like saying it's helpful to insert assembly code into a C program, yes it's possible to get some optimisations but it's also possible to completely break the system. Latex font handling is built around a coherent mechanism for tracking font size, baselines font styles etc, if you insert a primitive font selection in to the mix then anything that happens is accidental untested code path, if it works it works if it does anything else, it is unsupported and a user error. Nov 19, 2019 at 21:19
  • 1
    See \the\font under “Special uses” in tex.stackexchange.com/a/38680/4427
    – egreg
    Nov 19, 2019 at 21:34
  • 1
    \font itself isn't especially bad it is the general principle I am questioning that using tex primitives in a latex document is somehow normal. It is open source and due to the macro expansion nature of the system hard to prevent, but if you use commands (that are not mentioned in any user facing latex documentation) like \font or \countdef or for that matter \def, then at some point something will break, but however it breaks it will, by definition, be user error. Nov 19, 2019 at 21:40
  • 1
    @DavidCarlisle Wouldn't that rule out using most third party packages, since most use \def and many have to, given the limitations of LaTeX. (l3 changes this quite a bit, but setting that aside.) [I'd agree that using \def where you could use \newcommand or whatever is unnecessarily dangerous, but you can't avoid all the dangers. The path is full of perils.)
    – cfr
    Nov 20, 2019 at 1:20

1 Answer 1


You can expand \font with \the, so \edef\lastfont{\the\font} should work (notice how the name "Arial" comes out different when typeset... weird ;-)

enter image description here

Computer Modern


Computer Modern Again

  • 1
    @bp2017 Don't worry, it happens to everyone ;-) (to be honest, I also didn't know this before your question :-) Nov 19, 2019 at 20:02
  • @bp2017 It shouldn't be Nov 19, 2019 at 20:41
  • 2
    @PhelypeOleinik Didn't you read tex.stackexchange.com/a/38680/4427 ? ;-)
    – egreg
    Nov 19, 2019 at 21:35
  • @egreg Oh, I remember that one, when I learned about \the :-) At the time I had no idea what \font was, so it didn't stick to my memory Nov 19, 2019 at 21:43
  • @PhelypeOleinik Typical Knuth-style overloading to save on memory.
    – egreg
    Nov 19, 2019 at 22:03

You must log in to answer this question.

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