# font families side by side

for sure nothing that not has been answered already but i can't find it.

How to get roman and sansserif fonts in one document?

I need the LATEX Roman while my document is sans serif.

\documentclass[11pt]{article}
\usepackage{fontspec}
\setromanfont{Times-Roman}
\setmonofont{FiraMono-Regular.otf}
\setmainfont{FiraSans}[
Ligatures=TeX,
Path = /Users/novski/Library/Fonts/,
BoldFont = *-Regular,
BoldItalicFont = *-Italic,
ItalicFont = *-Italic,
UprightFont = *-UltraLight,
]
\begin{document}
\thispagestyle{empty}
\begin{center}
\vspace*{\fill}
\noindent\rule{\textwidth}{1pt} \\ [4mm]
\Large{\textsc{this Document is Typset with}} \\ [3mm]
\textrm{ \Huge{\LaTeX{}} }\\ [1mm]
\noindent\rule{\textwidth}{1pt}\\
\vspace*{\fill}
\end{center}
\end{document}


• I should have mentioned that i have a full document that i like to be set in sans serif. This is the last page of that document... – novski Sep 19 '18 at 19:04
• {\setmainfont{Times-Roman}\LaTeX}? – TeXnician Sep 19 '18 at 19:26
• This works. Can you explain why the font set by '\setromanfont{Times-Roman}' can not be called? To set the main font seams to me as a workaround but not a solution. I wold expect to call the special font and leave the main font for the document untouched... – novski Sep 20 '18 at 4:49
• Because \setromanfont is the outdated equivalent of \setmainfont and you override your roman font by making Fira Sans the main font. Alternatively you can do \newfontfamily\myfont{Times-Roman} in the preamble and do {\myfont\LaTeX}. – TeXnician Sep 20 '18 at 6:02
• doesn't that mean that i can not exchange this part of text because its depending on a self declared fontname 'myfont' that somebody else needs to declare first? Is it possible to make that exchangeable? – novski Sep 20 '18 at 6:04

I'm a bit late to the party, but if you just want to make sure the \LaTeX command expands correctly without kerning adjustments (which you can do with the metafont package), you can force the command to use the Computer Modern font family.

To achieve this, you redefine the command from where you want to apply it:

\let\myLaTeX\LaTeX
\def\LaTeX{\fontfamily{cmr}\rmfamily\selectfont\myLaTeX}


You can as easily revert this back to normal by doing:

\let\LaTeX\myLaTeX


after the \LaTeX you need to typeset occurs.

so the following:

    % .... %
\vspace*{2mm}
\let\myLaTeX\LaTeX % <- Copy \LaTeX here
\def\LaTeX{\fontfamily{cmr}\rmfamily\selectfont\myLaTeX} % <- Redefine here
{\Large\mdseries\textsc{The logo with Computer Modern:}\par}
{\Huge\LaTeX\par}
\let\LaTeX\myLaTeX % <- Revert changes
{\Large\mdseries\textsc{The logo with default font:}\par}
{\Huge\LaTeX\par}
\vspace*{2mm}
% .... %


Will produce something like this:

### Explanation

1. The \let\myLaTeX\LaTeX command will copy \LaTeX into \myLaTeX, we do this to avoid overwriting the command \LaTeX in the next step. Think of it as "\let \this be the same as \that"
2. \def\LaTeX{...} redefines the \LaTeX command sequence with whatever is entered inside the brackets {...} (know as a group).
3. {\fontfamily{cmr}\rmfamily\selectfont\myLaTeX} sets the font cmr on what follows, in our case, the previously \let (or copied) command sequence \myLaTeX. Note: I've specifically set \rmfamily here to avoid warnings of undefined shapes in some fonts.

This can also be done with some of \TeX and friends in the same way.

### For the entire document

If you want to use this for every macro, you can put the definition in the preamble of your main *.tex file, as in the MWE below:

\documentclass[11pt]{article}
\usepackage[light, default]{sourcesanspro} % <- Using this sans serif
\usepackage[T1]{fontenc}
\let\myLaTeX\LaTeX
\def\LaTeX{\fontfamily{cmr}\rmfamily\selectfont\myLaTeX}
\begin{document}
\thispagestyle{empty}
\begin{center}
\vspace*{\fill}
\noindent\rule{\textwidth}{1pt}\par
\vspace*{2mm}
{\Large\mdseries\textsc{This Document is typeset with}\par}
{\Huge\LaTeX\par}
\vspace*{2mm}
\noindent\rule{\textwidth}{1pt}\par
\vspace*{\fill}
\end{center}
\end{document}


I generally recommend doing this over making inline changes to fonts. And since LaTeX traditionally is typeset with roman font, I think it should be eaten as intended. Even so, I've added a few options further down.

### Result

To illustrate how this works, I use the Source Sans Pro font family as the document font (like I did in the example above). This font does not expand \LaTeX well (in my opinion), as shown below:

And here is how it will look once you force the font for \LaTeX:

### Other options

If you want to use the same font type for consistency, you can use a font that \LaTeX expands well with:

For Typewriter fonts, try pcr (Courier), which looks like this:

For Sans Serif fonts, try phv (Helvet), which looks like this:

For Serif fonts, you can also try ppl (Palatino), which looks like this:

1. How to typeset every TeX related logo
2. The difference between local and global scope
3. Changing the font of specific words or paragraphs (LaTeX), (XeLaTeX & LuaTeX)
• Please note that you are \def-overwriting a robust command. – TeXnician Dec 12 '18 at 10:42
• I have made an update to the answer. Thank you for the insight! – Ole Anders Dec 12 '18 at 14:42

• You set \setromanfont and \setmainfont where the former is an outdated synonym for the latter. So basically Fira Sans overwrites Times Roman.
• You use size commands like \Huge as if they were commands with arguments. Either use them properly in groups ({\Huge Test}) or use \DeclareTextFontCommand{\textHuge}{\Huge} and then \textHuge{Text}.
• Should you ever have more than one line in one of these lines with changed font size consider adding a paragraph break, so that the inter-line-spacing adjusts.

Regarding your problem: You decided to typeset your document in sans serif font. That's fine, but as you use it as main font you might want to disregard the command names and simply use your roman font family as "sans font" as you swapped meanings either way.

Then you are able to use \textsf or \sffamily on your example and it will work. Btw: \LaTeX might not look good in fonts other than Computer/Latin Modern because of kerning issues, so if you really want to emphasize the "Typeset with LaTeX" aspect you might want to adjust the kerning to your font.

For illustration purposes, I have used the Fira fonts included in TeX Live (removed your paths) and Libertinus Serif which is also part of TeX Live.

\documentclass[11pt]{article}
\usepackage{fontspec}
\setmainfont{Fira Sans}
\setsansfont{Libertinus Serif}
\setmonofont{Fira Mono}
\begin{document}
\thispagestyle{empty}
\begin{center}
\vspace*{\fill}
\noindent\rule{\textwidth}{1pt}\par
\vspace*{2mm}
{\Large\textsc{This Document is typeset with}\par}
{\Huge\sffamily\LaTeX\par}
\vspace*{2mm}
\noindent\rule{\textwidth}{1pt}\par
\vspace*{\fill}
\end{center}
\end{document}


One thing you could do is to load your serif font as a named font family, say \libertine, which most font packages support, then set your sans serif font as your main font (In many packages, this is the [sfdefault] package option).

You can then declare the new commands

\newcommand\seriffamily{\libertine}
\DeclareTextFontCommand\textserif{\seriffamily}


Thus allows you to write \seriffamily in place of \rmfamily and \textserif{...} in place of \textrm{...}.

• +1, unfortunately the OP does not like the solution (see here). – TeXnician Sep 21 '18 at 7:14
• @TeXnician I think the objection is that it makes it hard to change the font, because it depends on a family name. But that's what \seriffamily and \textserif let you do! Besides, you can always declare the family yourself with \newfontfamily or use a documented package interface. – Davislor Sep 21 '18 at 18:17
• I think the objection was that it is not possible to simply copy the code to another document irrespective of possible settings in the preamble. But as I said, I second your solution (that's why I wrote +1) and leave it to the OP what he wants to do. – TeXnician Sep 21 '18 at 19:55
• @TeXnician If the OP wants that, the right approach might be to stick a bunch of \sffamily and \rmfamily commands all over the place. – Davislor Sep 21 '18 at 20:03
• That's what I suggested in my answer ;) – TeXnician Sep 21 '18 at 20:43