# fontspec – sans-serif as main font? [duplicate]

fontspec defines the commands

\setmainfont{font name}[font features]
\setsansfont{font name}[font features]
\setmonofont{font name}[font features]


to set the document’s default fonts. However, if I use a sans-serif font as the main font, e. g. \setmainfont{Latin Modern Sans}, \rmfamily is redefined as Latin Modern Sans, so I lose the ability to specify a separate serif font. Of course, I could set the serif font with \setsansfont, but then I have the fonts all backwards.

Shouldn’t there also be a command \setseriffont? I don't think a “main” font should necessarily always be a serif font. If this is intended, what is the best way to have a sans-serif font as the default font, but still have a serif font defined as \rmfamily?

(This is unrelated to “What is the simplest way to typeset an entire document in sans-serif?”. I already explained that I could typeset the document in a sans-serif font by using \setmainfont. This question is about the semantics of the command \setmainfont, which doesn’t seem to imply any specific font characteristics from its name, compared to \setsansfont, \rmfamily and \sffamily – see also the comment by Will Robertson.)

• You could just use the \newfontfamily command; e.g., \newfontfamily\garamond[<options>]{EB Garamond}.
– jon
Nov 10, 2014 at 2:38
• Well, yes, from a practical point of view, but wouldn't that be an oversight in the design of the fontspec package? Nov 10, 2014 at 2:40
• I see what you're saying, but I'll let those responsible for the design weigh in.
– jon
Nov 10, 2014 at 2:52
• I have toyed in the past with renaming \setsansfont to \setaltfont (or similar) but never got around to it. \setromanfont became \setmainfont many many years ago because ‘roman’ isn't a good descriptor when you're writing Greek, e.g. Perhaps \setseriffont would have been a better idea, but I didn't think of it at the time :) Nov 10, 2014 at 5:19
• That's the way LaTeX is designed. However, if you use a sans serif font as the main document font, no part of it should use a serif font. Nov 10, 2014 at 7:54

\renewcommand{\familydefault}{\sfdefault}


That is:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Latin Modern Roman}
\setsansfont{Latin Modern Sans}
\renewcommand{\familydefault}{\sfdefault}

\begin{document}
abc
\textrm{abc}
\textsf{abc}
\end{document}


• \textsc{} is not working with this settings. How do I achieve its usual behaviour? Jun 13 at 21:15

If it helps to keep everything clear, you can use the \setromanfont command instead of \setmainfont, although the fontspec manual doesn't mention it:

\documentclass{article}
\usepackage{fontspec}
\setromanfont{Latin Modern Roman}
\setsansfont{Latin Modern Sans}
\renewcommand{\familydefault}{\sfdefault}

\begin{document}
abc
\textrm{abc}
\textsf{abc}
\end{document}

• Why won't it work if I also set a mono font? Nov 28, 2020 at 0:47