# Best way of using the full range of full fonts/styles/faces for Latin Modern Roman?

The following is what I've put together as a way of making sure the full(est) range of fonts/styles are available when using Latin Modern as the mainfont using fontspec, including bold smallcaps, italics smallcaps, etc.:

\setmainfont[
SmallCapsFont={Latin Modern Roman Caps},
SlantedFont={* Slanted},
ItalicFeatures  = {
SmallCapsFont = {LMRomanCaps10-Oblique}
},
BoldFeatures = {
SmallCapsFont = {CMU Serif-Bold},
Letters=SmallCaps
}
]{Latin Modern Roman}


(Slightly cheating because it uses Computer Modern Unicode for the bold smallcaps.)

Is this reasonable, or is there a better way?

Full minimal example:

\documentclass{article}[12pt]

\usepackage[T1]{fontenc}
\usepackage{fix-cm}
\usepackage{fontspec}
\defaultfontfeatures{Renderer=Full,Ligatures=TeX,Numbers=OldStyle,Scale=MatchLowercase}
\setmainfont[
SmallCapsFont={Latin Modern Roman Caps},
SlantedFont={* Slanted},
ItalicFeatures  = {
SmallCapsFont = {LMRomanCaps10-Oblique}
},
BoldFeatures = {
SmallCapsFont = {CMU Serif-Bold},
Letters=SmallCaps
}
]{Latin Modern Roman}
\begin{document}

\begin{tabular}{ll}
Plain roman & Hello, world.\\
Bold roman & \textbf{Hello, world.}\\
Italics & \textit{Hello, world.}\\
Bold italics & \textit{\textbf{Hello, world.}}\\
Plain smallcaps & \textsc{Hello, world.}\\
Bold smallcaps & \textbf{\textsc{Hello, world.}}\\
Italics smallcaps & \textit{\textsc{Hello, world.}}\\
Bold italic small caps & \textit{\textbf{\textsc{Hello, world.}}} [doesn't work]\\
&\textbf{\textit{\textsc{Hello, world.}}} [doesn't work]\\
Typewriter & \texttt{Hello, world.}\\
Italic typewriter & \textit{\texttt{Hello, world.}}\\
Bold typewriter & \textbf{\texttt{Hello, world.}}\\
Bold italic typewriter & \textit{\textbf{\texttt{Hello, world.}}}\\
Slanted & \textsl{Hello, world.}\\
Bold slanted & \textbf{\textsl{Hello, world.}}\\
\end{tabular}

\end{document}


The bold, italics, smallcaps combos don't work (I don't know that I ever need that combination anyway), and I do get some warnings:

Package fontspec Warning: OpenType feature 'Letters=SmallCaps' (smcp) not
(fontspec)                available for font 'Latin Modern Roman/B' with
(fontspec)                script 'Latin' and language 'Default'.

(./test5.aux)

LaTeX Font Warning: Font shape TU/lmtt/bx/it' in size <10> not available
(Font)              Font shape TU/lmtt/b/sl' tried instead on input line 38.


Is there any better way of setting up Latin Modern with fontspec?

[Edit: To make the goal explicit, I'm looking for the widest character coverage, the widest face/style coverage, with the best rendering (ranking in order of importance) while using the Latin/Computer Modern family of typefaces.]

• I'm afraid that your mileage vary according the selected font. With Noto fonts all styles work but slanted is really italics, many others fonts do not have SC at all, and so on. – Fran Jan 6 at 10:08
• CMU Serif BoldItalic doesn't have small caps. – egreg Jan 6 at 10:49
• @Fran Right, understood but I'm asking specifically for Latin Modern Roman (supplemented with related fonts, e.g. Computer Modern Unicode, where necessary). – emacsomancer Jan 6 at 18:38
• One error: BoldFeatures = {Letters = SmallCaps} should be BoldFeatures = { SmallCapsFeatures = {Letters = SmallCaps, ... } }, unless you want to use small caps for all bold text. – Davislor Jan 7 at 1:21

You’re off to a good start, but that doesn’t even scratch the surface of all the typefaces in the Computer Modern family. If you see Appendix A of “The LaTeX Font Installation Guide”, which expands on a scheme in The LaTeX Companion, there are official, standardized names for many more widths, weights and shapes. Several are present in Latin Modern, Computer Modern Unicode, or both.

For reference, here are the full lists of fonts in the Latin Modern collection and in the Computer Modern Unicode collection. There is also, of course, Latin Modern Math to replace the math and math symbol fonts. The program otfinfo (which works on the .ttf fonts from CMU as well) is useful to see which CMU fonts contain small-caps.

Of the extra faces in Latin Modern, I treat Demi as an additional weight, which I call sb (because sb is the only weight between m and b in the second edition of The LaTeX Companion.), and Unslanted as an additional shape, ui. I add the commands \sbseries and \textsb corresponding to \bfseries and \texbf, and \uishape and \textui corresponding to \itshape and \textit. You can use these as templates to add any other series or shape.

If you want to be able to set the font weight and extent separately, so that you can select bold in the middle of a block of Latin Modern Sans Cond, you might want to check out the package nfssext-cfr for inspiration.

Both Latin Modern and the Computer Modern Unicode fonts include several other families. Of these, CMU Concrete is a conversion of a completely different font originally commissioned for DEK’s book, Concrete Mathematics. I also treat Latin Modern Roman Dunhill and CMU Classical Serif as different families. It might, however, make sense to treat CMU Bright as a lighter weight of the sans-serif font.

CMU contains one series not present in Latin Modern: bold non-extended. For these purposes, I’ll give it the series bc, for bold condensed. It does not come with either italic, slanted or small caps. Other than that, I use some of its bold small-caps.

Here’s a sample for just the Latin Modern Roman family.

\documentclass[varwidth]{standalone}
\usepackage{amsmath}
\usepackage{unicode-math}
\usepackage{microtype}

\defaultfontfeatures{ Scale = MatchUppercase }

\setmainfont{Latin Modern Roman}[
Scale = 1.0 ,
Ligatures = {Common, Rare, TeX} ,
UprightFont = {Latin Modern Roman} ,
UprightFeatures = {
Ligatures = Discretionary ,
SmallCapsFeatures = { Ligatures = ResetAll } ,
SmallCapsFont = {lmromancaps10-regular.otf}
} ,
BoldFeatures = {
Ligatures = Discretionary ,
SmallCapsFeatures = {Letters = SmallCaps } ,
SmallCapsFont = {CMU Serif Bold}
} ,
ItalicFeatures = {
Ligatures = Discretionary ,
SmallCapsFeatures = { Ligatures = ResetAll } ,
SmallCapsFont = lmromancaps10-oblique.otf
} ,
BoldItalicFeatures = {
Ligatures = Discretionary ,
SmallCapsFeatures = { % Ligatures = ResetAll ,
Letters = SmallCaps } ,
SmallCapsFont = cmunbl.ttf
} ,
SlantedFont = {Latin Modern Roman Slanted} ,
SlantedFeatures = {
Ligatures = Discretionary ,
SmallCapsFeatures = { Ligatures = ResetAll } ,
SmallCapsFont = lmromancaps10-oblique.otf
} ,
BoldSlantedFont = lmromanslant10-bold.otf ,
BoldSlantedFeatures = {
Ligatures = Discretionary ,
SmallCapsFeatures = { % Ligatures = ResetAll ,
Letters = SmallCaps } ,
SmallCapsFont = cmunbl.ttf
} ,
FontFace = {sb}{n}{
Font = {Latin Modern Roman Demi} ,
Ligatures = Discretionary } ,
FontFace = {sb}{sl}{
Font = lmromandemi10-oblique.otf ,
Ligatures = Discretionary } ,
FontFace = {sb}{it}{
Font = lmromandemi10-oblique.otf ,
Ligatures = Discretionary } ,
FontFace = {bc}{n}{CMU Serif Bold Non-Extended} ,
FontFace = {m}{ui}{Latin Modern Roman Unslanted}
]

\setmathfont{Latin Modern Math}
\setmathfont[range=up]{Latin Modern Roman Unslanted}

\DeclareRobustCommand\sbseries{\fontseries{sb}\selectfont}
\DeclareTextFontCommand{\textsb}{\sbseries}
\DeclareRobustCommand\uishape{\fontshape{ui}\selectfont}
\DeclareTextFontCommand{\textui}{\uishape}

\begin{document}
\begin{minipage}{10cm}

\textrm{
Latin Modern Roman \textit{Italic} \textsl{Slanted} \textui{Upright-Italic}
\textsb{Demibold \textit{Oblique}}
\textbf{Bold \textit{Italic} \textsl{Slanted}} {\fontseries{bc}\selectfont Non-extended}
\textsc{Small Caps \textit{Italic} \textsl{Slanted} \textbf{Bold \textit{Italic} \textsl{Slanted}}}
}
$\symup{e}^{\symup{i}x} = \cos x + \symup{i} \sin x \implies \symup{e}^{\symup{i}\muppi} + 1 = 0$
\end{minipage}
\end{document}


I threw in an example of how the Upright Italic style is useful: it’s great for setting mathematical constants such as e, π and i upright, in ISO style. Compare the imaginary unit i in i sin x with the i in sin and the italic variable name x. You can also take that as an example of how to use any other font face in math mode.

You could eliminate some of the warnings by removing the Ligatures commands. For whatever reason, possibly a bug in fontspec, SmallCapsFeatures = {Ligatures = ResetAll} does nothing and Ligatures = NoDiscretionary only produces a second error message saying that the font does not support dlig. However, the warning is harmless.

If you want more kinds of small caps, you might apply the FakeBold feature to a different weight, or you might find this code useful.

• Thanks for this. Yes, the upright italic style is indeed useful. So is this in general the best approach to getting different Computer Modern style faces? And am I correct in thinking the Latin Modern fonts are generally higher quality than the Computer Modern Unicode fonts? – emacsomancer Jan 7 at 0:19
• @emacsomancer The CMU fonts were autotraced from Metafont, whereas Latin Moern was done by hand. ”Better” is subjective, but Latin Modern does have several objective advantages, including support for many more OpenType features (Tabular/Proportional numbers, optical sizes, fractions, and a slashed zero), more glyphs, and a math font. One big difference is the ß. – Davislor Jan 7 at 0:43
• @emacsomancer On the other hand, CMU does contain a couple of fonts that LM doesn’t (while missing a couple of other faces), supports a few more languages, including Serbian and Macedonian, and includes the small caps in the same file rather than separately. – Davislor Jan 7 at 0:54
• @emacsomancer This approach is generally what I’d recommend. It’s the closest thing in LaTeX to a standard, and this approach is source-compatible with a number of existing packages. – Davislor Jan 7 at 0:57
• I think my setup wants filenames to be formatted as e.g. ..= {[lmromancaps10-oblique.otf]}. Does it work as you have it for you? "CMU Serif Bold Non-Extended" seems to be missing for me - I have the CMU fonts installed - is there a special (or separate) version I need? – emacsomancer Jan 9 at 0:39

As fas I know, there are not any good solution for this.

One approach to solve this could be change the Latin Modern by another font with enough glyphs (I do not know a free font with enough glyphs, but probably a professional font could cover all your desired styles).

Other is botch with one has available: Using pdflatex you can simulate "Italics smallcaps" with "Slanted smallcaps" using slantsc packages, at least with pdflatex (not tested with lualatex, sorry) and the simulate the bold variant overlaping text. The macros \textbfsl and \textbfslsc are for now very naive approaches to do this, unbreakable text, but I hope that enough to check is it could look like true bold fonts (sorry again, but now I do not have time to test a more handy approach to overlap text, maybe later):

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{slantsc}
\def\textbfsl#1{\makebox[.3pt][l]{%
\makebox[.29pt][l]{\textsc{#1}}%
\makebox{\textsc{#1}}}}
\def\textbfslsc#1{%
\makebox[.29pt][l]{\textsl{\textsc{#1}}}%
\makebox{\textsl{\textsc{#1}}}}
\begin{document}

\begin{tabular}{ll}
Plain roman & Hello, world.\\
Bold roman & \textbf{Hello, world.}\\
Italics & \textit{Hello, world.}\\
Bold italics & \textit{\textbf{Hello, world.}}\\
Plain smallcaps & \textsc{Hello, world.}\\
Bold smallcaps & \textbfsl{Hello, world.}\\
Italics smallcaps & \textsl{\textsc{Hello, world.}}\\
Bold italic small caps & \textbfslsc{Hello, world.}\\
Typewriter & \texttt{Hello, world.}\\
Italic typewriter & \textit{\texttt{Hello, world.}}\\
Bold typewriter & \textbf{\texttt{Hello, world.}}\\
Bold italic typewriter & \textit{\textbf{\texttt{Hello, world.}}}\\
Slanted & \textsl{Hello, world.}\\
Bold slanted & \textbf{\textsl{Hello, world.}}\\
\end{tabular}

\end{document}


If lmodern is not an absolute must, with tgtermes and slantsc you do not need any macro:

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{tgtermes}
\usepackage{slantsc}

\begin{document}

\begin{tabular}{ll}
Plain roman & Hello, world.\\
Bold roman & \textbf{Hello, world.}\\
Italics & \textit{Hello, world.}\\
Bold italics & \textit{\textbf{Hello, world.}}\\
Plain smallcaps & \textsc{Hello, world.}\\
Bold smallcaps & \textbf{\textsc{Hello, world.}}\\
Italics smallcaps & \textit{\textsc{Hello, world.}}\\
Bold italic small caps & \textit{\textbf{\textsc{Hello, world.}}}\\
Typewriter & \texttt{Hello, world.}\\
Italic typewriter & \textit{\texttt{Hello, world.}}\\
Bold typewriter & \textbf{\texttt{Hello, world.}}\\
Bold italic typewriter & \textit{\textbf{\texttt{Hello, world.}}}\\
Slanted & \textsl{Hello, world.}\\
Bold slanted & \textbf{\textsl{Hello, world.}}\\
\end{tabular}

\end{document}

• This is informative, but is still really an answer to a different question. I'm really interested in using Unicode fonts, and specifically ones in the style of Computer Modern. For good character coverage generally, for free fonts, the DejaVu fonts, the Noto series, Junicode, and Linux Libertine are good options. – emacsomancer Jan 7 at 0:10

CM Serif BoldItalic has no small caps, but you can fake them.

\documentclass{article}

\usepackage{fontspec}
\defaultfontfeatures{
Renderer=Full,
%Ligatures=TeX,
Numbers=OldStyle,
Scale=MatchLowercase,
}

\setmainfont{Latin Modern Roman}[
SlantedFont = {* Slanted},
UprightFeatures = {
SmallCapsFont = {* Caps},
},
ItalicFeatures = {
SmallCapsFont = LMRomanCaps10-Oblique,
},
BoldFeatures = {
SmallCapsFont = CMUSerif-Bold,
SmallCapsFeatures={Letters = SmallCaps},
},
% Neither Latin Modern nor CM Unicode have bold italic small caps
BoldItalicFeatures = {
SmallCapsFont = CMUSerif-Bold,
SmallCapsFeatures={FakeSlant=0.25,Letters=SmallCaps},
},
]

\begin{document}

\begin{tabular}{ll}
Plain roman & Hello, world.\\
Bold roman & \textbf{Hello, world.}\\
Italics & \textit{Hello, world.}\\
Bold italics & \textit{\textbf{Hello, world.}}\\
Plain smallcaps & \textsc{Hello, world.}\\
Bold smallcaps & \textbf{\textsc{Hello, world.}}\\
Italics smallcaps & \textit{\textsc{Hello, world.}}\\
Bold italic small caps & \textit{\textbf{\textsc{Hello, world.}}}\\
Typewriter & \texttt{Hello, world.}\\
Italic typewriter & \textit{\texttt{Hello, world.}}\\
Bold typewriter & \textbf{\texttt{Hello, world.}}\\
Bold italic typewriter & \textit{\textbf{\texttt{Hello, world.}}}\\
Slanted & \textsl{Hello, world.}\\
Bold slanted & \textbf{\textsl{Hello, world.}}\\
\end{tabular}

\end{document}


• Ah, thanks for this. I don't know where I would use bold italic smallcaps in practice, but it's nice to have them specified in case. – emacsomancer Jan 7 at 0:11
• @emacsomancer I hope nowhere. ;-) That would be triple emphasis! – egreg Jan 7 at 7:45
• amusingly enough, right after asserting my doubt about needing the combination, I ended up using it (italics to distinguish 'object' language from 'meta' and smallcaps to indicate focus within the 'object' language, and finally bold for emphasis of the relevant piece). – emacsomancer Jan 9 at 2:46