Somewhere I read that fontspec uses Latin Modern by default, so I assumed that loading the lmodern package is not required anymore when using LuaLaTeX. But today I noticed that kerning does not seem to work within amsmath's \operatorname command:

\documentclass{scrartcl}

\usepackage{fontspec}
%\usepackage{lmodern}
\usepackage{amsmath}
\usepackage{microtype}

\begin{document}
$\operatorname{Wait}, \text{Wait}$ 
\end{document}

This produces the following output on my machine:

wrong kerning

When loading lmodern explicitly (remove comment sign on line 4), kerning will be applied within \operatorname and both words look the same.

Although I already found a solution, I would like to understand what is going on here. In particular, are there any further things that need to be considered when using latin modern along with LuaLaTeX?

up vote 8 down vote accepted

You should load fontspec with the no-math option. And yes, you should also load lmodern for using the Latin Modern (legacy) math fonts. Without it the math fonts would be the usual Computer Modern ones.

\documentclass{scrartcl}

\usepackage{amsmath}
\usepackage{lmodern}
\usepackage[no-math]{fontspec}
\usepackage{microtype}

\begin{document}
$\operatorname{Waitfi}, \mathrm{Waitfi}$
\end{document}

I added also a ligature, just to show it works.

enter image description here

This is the output of pdffonts:

name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
VQXSIW+LMRoman10-Regular             Type 1            Custom           yes yes no       4  0
HQUSZE+LMMathItalic10-Regular        Type 1            Custom           yes yes no       5  0
JFRMQG+LMRoman10-Regular             CID Type 0C       Identity-H       yes yes yes      6  0

This is imho due to the problem described here Ligatures are not used in OpenType maths families?. Ligatures and kernings of open type fonts are not used in math mode. You can as suggested by egreg switch to "classical" math fonts. With luatex you can also load the operator font in base mode:

\documentclass{scrartcl}
\usepackage{amsmath}
\usepackage{fontspec}

\setmainfont{Latin Modern Roman}[Renderer=Basic]
\newfontfamily\latinmathoperators{Latin Modern Roman}[Renderer=Basic]
%
\makeatletter
\AtBeginDocument{%
\latinmathoperators
\DeclareSymbolFont{operators}{EU2}\f@family\mddefault\updefault
\SetSymbolFont{operators}{normal}{EU2}\f@family\mddefault\updefault
\normalfont}
\makeatother


\begin{document}
Waitffi
$\operatorname{WAitffi} \mathrm{WAitffi}\text{WAitffi}$
\end{document}

enter image description here

Addition

with unicode-math you could also define a specific font which uses the base mode:

\documentclass{scrartcl}
\usepackage{amsmath}
\usepackage{unicode-math}
\setmathfontface\mathrmoperator{Latin Modern Roman}[Renderer=Basic]
\setoperatorfont\mathrmoperator

\begin{document}
$\operatorname{Waitffi}   = a_{\operatorname{Waitffi}}$

$\mathrmoperator{Waitffi} = a_{\mathrmoperator{Waitffi}}$

$\mathrm{Waitffi}         = a_{\mathrm{Waitffi}}$
\end{document}

Don't use mathematical symbols like \delta or \int in the argument of such a command. As Latin Modern Roman is not a math font, they would be lost.

enter image description here

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.