[Tex/LaTex] Switching back to Computer Modern within XeLaTeX


Until I select a font using \fontspec{ ... }, XeLaTeX uses the default of Computer Modern. Once I select some font, I have no idea how to re-select Computer Modern. Can anyone help?

Best Answer

XeLaTeX (via fontspec) actually uses the Latin Modern version of Computer Modern. So to change back to it you can do two things:

  1. Install the Latin Modern Fonts into your system and load the font using \newfontfamily
  2. Use the standard \fontfamily...\selectfont method.

% !TEX TS-program = XeLaTeX

\setmainfont{Linux Libertine O}
%\newfontfamily\lmodern{Latin Modern Roman} % If font exists on your system
% Optical sizes need to be set up manually using the [SizeFeatures] option
% or select the font using the regular font selection methods
\newcommand{\lmr}{\fontfamily{lmr}\selectfont} % Latin Modern Roman
\newcommand{\lmss}{\fontfamily{lmss}\selectfont} % Latin Modern Sans
\newcommand{\lmss}{\fontfamily{lmtt}\selectfont} % Latin Modern Mono
Some text in Linux Libertine.
{\lmr Some text in Latin Modern}

output of code

Alternatively, if you are mainly using Computer Modern in your document, you can use \newfontfamily to define the alternative font.

As noted by Andrey Vihrov, the second solution is probably to be preferred, since the optical sizes of Latin Modern are set up when the font is loaded in the regular way. With the first solution, you would need to add the optical size information using the [SizeFeatures] option when declaring the \newfontfamily.

If you want to restore the defaults completely (rather than just have access to the Latin Modern fonts with a command) you can redefine \rmdefault, \sfdefault and \ttdefault instead (as suggested by Ulrike Fischer). This will override the \setmainfont settings.


Edit note: Please note that the current version of this answer has been reorganized to reflect the discussion in the comments. Thanks.