[Tex/LaTex] fontspec – sans-serif as main font?

fontsfontspecluatexsans-serif

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.)

Best Answer

\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}

sans and serif

Related Question