10

For Latin Modern fonts, there are the packages lmodern and cfr-lm. Additionally, there are the font packages lm and lm-math. For a beginner, it is difficult to figure out the relations between these packages. The confusing thing is that lmodern documentation indirectly points to lm, but lm is "just" a font, not a thing directly being usable by \usepackage{lm}.

2 Answers 2

18

lm is a package which contains various things. Most importantly, it contains the Latin Modern fonts themselves, together with the files required to use them with TeX and friends. The fonts are provided in type1 format for use with TeX and pdfTeX, and in opentype format for use with XeTeX and LuaTeX, for example.

One element of the lm package is a set of support files for use of the type1 fonts with LaTeX or pdfLaTeX. This includes the lmodern.sty package which you use as \usepackage{lmodern}.

So far, so good.

Now, if you are using XeTeX or LuaTeX, then you may, if you wish, use lm-math which consists of an opentype maths font. unicode-math provides a means to use this. You don't have to do this - you can use the standard maths support - but you may.

If you are using TeX or pdfTeX, lm-math is irrelevant. You can't use it and you don't need it as lmodern already supports mathematics for these engines.

So far, that's all official support - or as official as it gets, anyway.

Now, if you are using TeX or pdfTeX with the type1 fonts, lmodern is somewhat limited. It supports only some of the features available in the fonts themselves. For example, it uses tabular, lining figures and, although you can access oldstyle numerals using special commands, these are still tabular and awkward to use. Moreover, there is no easy way to use italic small-caps, non-extended bold or upright italics, for example, as these are just not supported well by LaTeX by default. The variable width typewriter, the slashed zero and quotation sans are beyond reach and there is no easy, document-level command to access Latin Modern Dunhill.

For these engines, cfr-lm provides enhanced support. Insofar as possible, cfr-lm aims to provide access to everything in the fonts which might be useful through a fairly straightforward set of commands and options. cfr-lm is not just a package file, cfr-lm.sty. The bulk of cfr-lm consists of a set of TeX font files and LaTeX definition files. Essentially, these are files *.tfm, *.vf, *.fd and a new *.map file. This is all behind the scenes, though. All that matters to the end user is cfr-lm.sty and the documentation.

For example, you can pass options to the package saying whether you would prefer figures which are tabular or proportional, lining or oldstyle for each of typewriter, sans and serif. You can say which style of typewriter font you'd like. Moreover, you can switch between different styles within your document itself. For example, you can use oldstyle, proportional figures for text but switch to tabular, lining figures for a tabular.

If you don't want any of the features, use lmodern. Not only is that easier, it does not rely on virtual fonts which can be disadvantageous in some circumstances. (Don't ask me which circumstances - I haven't learnt this yet.)

If you want to use any of these features, however, cfr-lm will make life much easier. In some cases, it will make possible something which you could otherwise do only by creating the equivalent of cfr-lm yourself.

Note that cfr-lm uses just the same type1 fonts as lmodern. In addition, the support for maths is identical. cfr-lm just loads the maths support provided by lmodern. (The relevant parts of the package file are simply copied from lmodern.sty.

Note that cfr-lm will load fontenc with option T1. It will also load textcomp for access to the TS1 encoding.

Here's a sample:

cfr-lm sampler

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[rm={proportional,oldstyle},sf={proportional,oldstyle},tt={lining,tabular,monowidth}]{cfr-lm}


\begin{document}

1234567890\zeroslash (serif, oldstyle, proportional)

\textsf{1234567890\zeroslash} (sans, oldstyle, proportional)

\texttt{1234567890\zeroslash} (monowidth, tabular, lining typewriter)

\textpl{1234567890\zeroslash} (serif, proportional, lining)

\texttl{1234567890\zeroslash} (serif, tabular, lining)

\textsf{\tlstyle 1234567890\zeroslash} (sans, tabular, lining)

\textsl{This is oblique text.}

\textit{This is in regular italics.}

\textui{This text is in upright italics.}

\textsc{Here are some small-caps.}

\textsi{This is italic small-caps.}

Text weight and width (Medium)

\textsb{Text weight and width} (Bold)

\textbf{Text weight and width} (Bold Extended)

\textti{This is Latin Modern Dunhill.}

\texttt{Typewriter text.} (Monowidth)

\texttv{Typewriter text.} (Variable)
\end{document}

The documentation aims to be clear and comprehensive. If it is not, you could always try complaining to the package's maintainer.

texdoc cfr-lm
6
  • Both answers here are good but I hope the OP accepts this one (can't do much better than the package author answering) :-)
    – Joseph Wright
    May 29, 2015 at 5:57
  • 1
    Docs for cfr-lm describe it as experimental. Is that comment now outdated? Also, if I'm fine with lmodern and use no new features, how sure is it that everything still works after switching to cfr-lm? Sep 24, 2017 at 3:39
  • 1
    @Blaisorblade I had some reports a few years ago about inconveniences and updated the package. Nobody has contacted me since. So, either nobody now uses it or they haven't found the bugs yet. As far as I know, it works as advertised and I use it in almost every document I write. No guarantees. If you don't want the new features, there's no reason to use it. However, it is 99% sure it would still work if you switched, provided you set the relevant options if you want the output to look like lmodern. (cfr-lm has different defaults.) If you don't use the new features, it is 99.99%,
    – cfr
    Sep 24, 2017 at 3:46
  • 1
    @Blaisorblade There are certain complications created by the limitations of NFSS, basically, which make it tricky to implement new font selection commands in ways which will always work as expected. cfr-lm uses nfssext-cfrwhich attempts to hide these complications from the user. Almost always, this works smoothly in practice, but there are some edge cases where it will do something strange. Basically, there are a couple of cases where it is hard to select a particular combination of font features because there are missing steps (i.e. no font exists) and accumulation fails.
    – cfr
    Sep 24, 2017 at 3:51
  • 1
    @Blaisorblade But this is not something which I can fix, I don't think, or that anybody can fix - at least unless L3 comes up with some souped-up NFSS, which doesn't seem terribly likely. So suppose a font has a light condensed version, then nfssext-cfr provides macros to switch to light and to switch to condensed. This is fine if the font also provides light regular width and regular weight condensed - the commands can be combined in any order. If it has only one, the order of invocation is crucial. If it has neither, you have to resort to low-level font selection macros.
    – cfr
    Sep 24, 2017 at 3:56
10

You shouldn't confuse a “CTAN package” with a “LaTeX package”. The former are sets of files that provide support for different kinds of TeX related objects, whereas a LaTeX package is a single file with extension .sty, possibly related to other support text files.

The lm and lm-math CTAN packages provide font files; the first one also contains lmodern.sty, a support LaTeX package for using those fonts within LaTeX. The second one just provides fonts in OpenType format, with no support LaTeX package (one can load unicode-math for using those fonts in XeLaTeX or LuaLaTeX).

Also cfr-lm is a CTAN package that provides several font files and a support LaTeX package called cfr-lm.sty.

You may have noticed that I use different markup for the two things: a CTAN package and a LaTeX package.sty.

What's the difference between lmodern.sty and cfr-lm.sty? The latter comes with many font files in cfr-lm; they are virtual fonts that eventually map glyphs to fonts coming with lm, and it makes it easy to select among several different features not present in the basic lm distribution and lmodern.sty: old style and lining figures, proportional or tabular, oblique small caps, condensed sans serif, semi-bold weight. Read the documentation for more information.

4
  • Great answer, I would have written the first part (but probably not as well) if I wasn’t so lazy. It has to be said that the word “package” is a little confusing here. May 28, 2015 at 22:42
  • 2
    @ArthurReutenauer Thanks. Yes, it's confusing; I blame David and the others of the LaTeX team for having chosen “package” for the .sty files. ;-) Don't forget the “TeX Live packages” which are yet another different beast.
    – egreg
    May 28, 2015 at 22:47
  • @egreg Could you comment on cfr-lm and LuaLaTex? Should that work?
    – koppor
    Mar 8, 2018 at 21:45
  • 1
    @koppor cfr-lm is only for pdflatex.
    – egreg
    Mar 8, 2018 at 21:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .