[Tex/LaTex] How to use all variants of Latin Modern Roman with fontspec

fontspeclatin-modern

Sorry I have minimal knowledge of how font families work in TeX. After trying to read the fontspec documentation I get more and more confused. I am trying to get as many variants of Latin Modern Roman working as I can, especially the variants of unslanted roman, oblique small caps. Foe example I do not know how to get small caps oblique to be used when itshape and scshape are both in effect.

I originally wanted \textup to have the Unslanted variant of the font but doing UprightFont = Latin Modern Roman Unslanted would change all normal font to that as well. I thought the whole point of \textup and \textrm being separate commands is allow distinction with upshape? Anyhow because of this I am defining \textun for the unslanted variant.

Is it also possible to have fake bold with small caps by using, say, weight in fontspec such that I can put \textsc{Abc} in section headings (i.e. such that it works with \bfseries)?

\documentclass[a4paper,10pt,english,draft]{article}
% Additional Options
\usepackage[log-declarations=false]{xparse}
\usepackage[quiet]{fontspec}
%fontspec options:
\setmainfont[Ligatures=TeX,SmallCapsFont={* Caps}, SlantedFont={* Slanted}]{Latin Modern Roman}
\newfontface\textun{lmromanunsl10-regular.otf} 
%I cannot use \newfontface\textun{Latin Modern Roman Unslanted} for some reason...
\begin{document}
    Latin Modern Roman normal text \newline  
    \textit{Latin Modern Roman italic text} \newline  
    \textsl{Latin Modern Roman Slanted} \newline  
    \textun{Latin Modern Roman Unslanted} \newline
    \textsc{Latin Modern Roman Caps} \newline  
    \emph{\textsc{Latin Modern Roman Oblique small caps?}}
\end{document}

Best Answer

Your original \textun acted as an switch (like \itshape) so I redefined \textun as

\newfontface\unshape[]{Latin Modern Roman Unslanted} 
\newcommand\textun[1]{{\unshape #1}}

\textrm, \textup and/or \textun

You easily could re-defined \textrm and \textup with

\renewcommand\textup[1]{{\unshape #1}} % see section "Code" for \unshape
\renewcommand\textrm[1]{{\unshape #1}}
normal \textup{unslanted} normal \textup{unslanted}

which gives you
rm and up as un

While that does work it is not a good idea. \textrm and \textup are well implemented macros. Who knows which package you might break?

Besides, \textrm and \textup aren't the same, for LaTeX applies:

  • rm (roman) is a family specifier (“Serifs”). Families are (generally) roman/serif/antiqua, sans-serif/grotesque and typewriter.
  • up is a shape specifier (“Slope”). Other shapes are: italics, oblique/slanted/sloped, Sᴍᴀʟʟ Cᴀᴘꜱ
  • And then there are series (“Weight”): light, medium, semi-bold, bold, heavy, … (names and definitions may vary). bf stands for boldface.

Code (Example)

{\sffamily sans-serif family \textrm{roman family} sf \textup{up shape} sf} \par
{\itshape italics \textrm{roman family} it \textup{up shape} it}

Output (Example)

rm and up

FakeBold and SmallCaps

Borrowing from sdaau's answer the OP himself has found the following map-workaround:

Code (FakeBold SmallCaps)

\fontspec[
    FakeBold=4,
    SmallCapsFont={Latin Modern Roman Caps}
    ]{Latin Modern Roman}
\DeclareFontShape{EU1}{LatinModernRoman(0)}{bx}{sc}{<->ssub * LatinModernRoman(1)/m/sc}{}

Font sizes?

The following code shows these fonts included in the PDF:

  • 5: Regular
  • 7: Regular, Italic
  • 8: Regular, Italic, Slant
  • 9: Regular, Italic, Slant
  • 10: Regular (+Caps), Italic, Oblique Caps, Slant, Unsl
  • 12: Regular, Italic, Slant
  • 17: Regular, Slant

Code

\documentclass[a4paper,10pt,draft]{article}
% Additional Options
\usepackage[landscape]{geometry}
\usepackage{fontspec}
%fontspec options:
\setmainfont[
    Ligatures=TeX,
    SmallCapsFont={Latin Modern Roman Caps},
    SlantedFont={* Slanted},
    ItalicFeatures  = {
        SmallCapsFont = {LMRomanCaps10-Oblique}
    },
    ]{Latin Modern Roman}

\newfontface\unshape[]{Latin Modern Roman Unslanted} 
\newcommand\textun[1]{{\unshape #1}}

\fontspec[
    FakeBold=4,
    SmallCapsFont={Latin Modern Roman Caps}
    ]{Latin Modern Roman}
\DeclareFontShape{EU1}{LatinModernRoman(0)}{bx}{sc}{<->ssub * LatinModernRoman(1)/m/sc}{}

\def\testtext{%
    Latin Modern Roman normal text \par
    \textit{Latin Modern Roman italic text} \par
    \textsl{Latin Modern Roman Slanted} \par
    {\textun{Latin Modern Roman Unslanted}} \par
    \textsc{Latin Modern Roman Caps} \par
    \emph{\textsc{Latin Modern Roman Oblique small caps?}} \par
    {\bfseries\scshape Latin Modern Roman Caps FakeBold}\par
    \null\par
}
\begin{document}
{\tiny\testtext}
{\scriptsize\testtext}
{\footnotesize\testtext}
{\small\testtext}
\testtext
{\large\testtext}
{\Large\testtext}
{\LARGE\testtext}
{\huge\testtext}
{\Huge\testtext}
\end{document}

Output (normal size)

normal size output


Yes there are \mdshape and \textmd.