Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 3

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

\documentclass{article}
\usepackage{fontspec}
\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
\begin{document}
Some text in Linux Libertine.
{\lmr Some text in Latin Modern}
\end{document}

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.

\renewcommand\rmdefault{lmr}
\renewcommand\sfdefault{lmss}
\renewcommand\ttdefault{lmtt}

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

share|improve this answer
    
This doesn't work for me: I get a message that Latin Modern Roman cannot be found (even when I copy your example). Still, I know I do have computer modern, because when I don't switch fonts, I stay with it! –  Mayer Goldberg Aug 5 '11 at 17:11
    
Unfortunately, XeTeX on (Linux?) TeX Live does not find fonts in the system texmf tree by name. –  Caramdir Aug 5 '11 at 17:15
    
But somehow xelatex does know how to find CM when it starts! There should be some way to save that font somewhere. [I'm using MacTeX] –  Mayer Goldberg Aug 5 '11 at 17:19
2  
It's hard for me to test this, since it works on my system (a Mac). But try the following then: \newcommand{\lmodern}{\fontfamily{lmr}\selectfont} instead of the \newfontfamily command. –  Alan Munn Aug 5 '11 at 17:24
3  
Note that the first solution is not very desirable, because it does not restore Latin Modern's setup for optical font sizes. –  Andrey Vihrov Aug 5 '11 at 18:16

As a default fontspec doesn't use computer modern but the latin modern font. To get back exactly the default setup set the font family to lmr, lmss, lmtt. Either localy or by redefining the defaults:

\documentclass{scrartcl}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\setsansfont{Arial}
\setmonofont{Cambria}
\begin{document}
rm \texttt{tt} \textsf{sf}

{\fontfamily{lmr}\selectfont rm
 \fontfamily{lmss}\selectfont sf
 \fontfamily{lmtt}\selectfont tt}

\renewcommand\rmdefault{lmr}
\renewcommand\sfdefault{lmss}
\renewcommand\ttdefault{lmtt}
\normalfont
rm \textsf{sf} \texttt{tt} 
\end{document}
share|improve this answer

Old fontspec had a cm-default option. Now it is obsolete.

However, you can still switch back to OT1 or T1 font encoding with CM families. For example:

\documentclass{article}
\usepackage{fontspec}
\newfontfamily\xits{XITS}
\newfontfamily\cursor{TeX Gyre Cursor}
\usepackage[OT1]{fontenc}
\renewcommand\rmdefault{cmr}
\renewcommand\sfdefault{cmss}
\renewcommand\ttdefault{cmtt}
\begin{document}
This is Computer Modern Roman.

\textsf{This is Computer Modern Sans.}

\texttt{This is Computer Modern Typewriter.}

{\xits This is Times-like XITS font.}

{\cursor This is Courier-like TeX Gyre Cursor.}
\end{document}

enter image description here

This is obtained by pdffonts utility:

name                                 type              emb sub uni object ID
------------------------------------ ----------------- --- --- --- ---------
DQLQYU+CMR10                         Type 1C           yes yes no       4  0
ZSODJO+CMSS10                        Type 1C           yes yes no       5  0
YLHYBL+CMTT10                        Type 1C           yes yes no       6  0
EKZHDP+XITS-Identity-H               CID Type 0C       yes yes yes      8  0
PMNGJM+TeXGyreCursor-Regular-Identity-H CID Type 0C       yes yes yes     10  0

It's OK if you want to use EU1 (i.e. Unicode in XeTeX) as default font encoding. You can switch to OT1 encoding whenever you want:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Linux Libertine O}
\usepackage[OT1,EU1]{fontenc}
\begin{document}
This is Linux Libertine O.

{\fontencoding{OT1}\fontfamily{cmr}\selectfont
This is Computer Modern Roman.}
\end{document}

enter image description here

name                                 type              emb sub uni object ID
------------------------------------ ----------------- --- --- --- ---------
BLJUZB+LinLibertineO-Identity-H      CID Type 0C       yes yes yes      5  0
ANBDAK+CMR10                         Type 1C           yes yes no       6  0
share|improve this answer
    
Although this works, I'm not sure why anyone would really want to use the OT1 encoding. (Since I don't think that Mayer literally requires Computer Modern; he just wants the same default font that fontspec uses when no main font is set, which is Latin Modern (with the EU1 encoding)). –  Alan Munn Aug 5 '11 at 18:00
    
@Alan: Well, the OP may not really want the actual Computer Modern families. But the answer provides them for those who are interested. Usually, default Latin Modern families in EU1 encoding are very well (or even better than CM), and nothing is to be worried. BTW, except Latin Modern, there are also Computer Modern Unicode (CMU) families. –  Leo Liu Aug 5 '11 at 18:06
2  
@Alan: Indeed, CM in OT1 or T1 may be not attractive when LM and CMU are available. However, there are still many Type1 fonts in old font encoding distributed with TeX. When some one want to use those fonts (e.g. Iwona, Kurier, URW Bookman), this technique will be useful. –  Leo Liu Aug 5 '11 at 18:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.