10

Consider the code

\documentclass[12pt]{article}   
\usepackage{amsmath}            
\usepackage{lmodern}    

\begin{document}
    \[ \sqrt{\frac{m}{n}} \]    
\end{document}

The output is a different square root symbol than with merely Computer Modern, where it fits well. What's the problem with Latin Modern in this case? Why does it yield a different (why not the same) and ugly output although it is ought to be an improvement of Computer Modern. Is it better to use Latin Modern than Computer Modern? Why? I see that Latin Modern causes more problems. What should I do? Is lmodern somehow in conflict with amsmath?

  • 2
    You can reproduce using amsmath. I recommend editing your code to reflect that, as it sill be easier to get the attention of the person most likely to know the answer to your question. – cfr Jun 20 '17 at 1:29
  • The body of your posting still states that "m" and "n" are too far away from the fraction line. Is that, in fact, still the issue? – Mico Jun 20 '17 at 2:15
  • No, it's the square root symbol which causes the problem. – Thrash Jun 20 '17 at 13:28
6

You have (re)discovered an important weakness in the Latin Modern math fonts. If we look at omxlmex.fd we see

% This file belongs to the Latin Modern package. The work is released
% under the GUST Font License. See the MANIFEST-Latin-Modern.txt and
% README-Latin-Modern.txt files for the details. For the most recent version of
% this license see http://www.gust.org.pl/fonts/licenses/GUST-FONT-LICENSE.txt
% or http://tug.org/fonts/licenses/GUST-FONT-LICENSE.txt

\ProvidesFile{omxlmex.fd}[2009/10/30 v1.6 Font defs for Latin Modern]

\DeclareFontFamily{OMX}{lmex}{}
\DeclareFontShape{OMX}{lmex}{m}{n}{%
   <->sfixed*lmex10%
   }{}
\endinput
%%
%% End of file `omxlmex.fd'.

This means that the math extension font is loaded at a fixed size, 10pt, independently of the document font. Let's try with

\documentclass[10pt]{article}
\usepackage{lmodern}
\begin{document}
\[
\sqrt{\frac{m}{n}}+\sum\frac{m}{n}+\int\frac{m}{n}
\]
\end{document}

enter image description here

Let's change 10pt into 12pt (with 11pt the problem is the same, but it's somewhat less easy to see):

enter image description here

Do you see? The fraction grew bigger, the symbols didn't. It's more evident if we typeset the example at 17pt (with extarticle):

enter image description here

Solution

\documentclass[12pt]{article}
\usepackage{lmodern}

\DeclareFontShape{OMX}{cmex}{m}{n}{%
  <-7.5> cmex7
  <7.5-8.5> cmex8
  <8.5-9.5> cmex9
  <9.5-> cmex10
}{}
\DeclareSymbolFont{largesymbols}{OMX}{cmex}{m}{n}

\begin{document}
\[
\sqrt{\frac{m}{n}}+\sum\frac{m}{n}+\int\frac{m}{n}
\]
\end{document}

And ask the Latin Modern team to fix this embarrassing glitch. Maybe if they get tons of mail they'll reconsider it.

enter image description here

Update

One can do \usepackage{fixcmex}

\documentclass[12pt]{article}
\usepackage{lmodern}
\usepackage{fixcmex}

\begin{document}
\[
\sqrt{\frac{m}{n}}+\sum\frac{m}{n}+\int\frac{m}{n}
\]
\end{document}
  • Thank you very much! That means, with your solution Latin Modern behaves like Computer Modern within the math mode overall? Is Computer Modern always better in math mode than (default) Latin Modern? How can I compare the definition file of LM to that one of CM? – Thrash Jun 22 '17 at 2:31
  • @Thrash This only changes the largesymbols font; the rest of math is still Latin Modern. – egreg Jun 22 '17 at 7:29
  • Are there any further differences between between the math modes of CM (with enabled amsmath) and LM? – Thrash Jun 22 '17 at 10:33
  • By the way, the following additional lines solve the problem, too. \DeclareFontFamily{OMX}{lmex}{} \DeclareFontShape{OMX}{lmex}{m}{n}{<-> lmex10}{} as you wrote here some years ago: tex.stackexchange.com/questions/74623/… (redefining nearly such as in the LM file, but without sfixed*) – Thrash Jun 22 '17 at 18:33
3

To reproduce the issue you've encountered, it's crucial that the document font size be set to 12pt. Loading the lmodern and mathtools packages may be more of a side show.

I take it that you don't like the fact that the horizontal rule of the square root symbol is too close to the letter "m". To fix this issue, you could insert a \mathstrut directive in the first argument of \frac. If you have a lot of \frac terms, you may want to set up a dedicated macro called, say, \myfrac, that automatically inserts a \mathstrut in the numerator terms. This is what's done in the third expression of the following example.

enter image description here

\documentclass[12pt]{article}           
\usepackage{lmodern,mathtools}
\newcommand\myfrac[2]{\frac{#1\mathstrut}{#2}}    
\begin{document}
\[ 
\sqrt{\frac{m}{n}} 
\quad 
\sqrt{\frac{m\mathstrut}{n}} 
\quad 
\sqrt{\myfrac{m}{n}} 
\]    
\end{document}

Addendum: If you must use 12pt as the main document size, you may want to consider switching from pdfLaTeX to LuaLaTeX and the unicode-math package. Doing so will yield much better spacing between the numerator term and the horizontal portion of the square root symbols, whether or not the amsmath package (or its superset, the mathtools package) is loaded. (If you do choose to load mathtools, you should do so before loading unicode-math.)

enter image description here

% !TeX program = lualatex  % tested with MacTeX2017
\documentclass[12pt]{article} 
%\usepackage{mathtools} % optional         
\usepackage{unicode-math}   
\begin{document}
\[ 
\sqrt{\frac{m}{n}} \quad \sqrt{\frac{m\mathstrut}{n}} 
\]    
\end{document}
2

This modifies the font configuration for Latin Modern in a way which I think is analogous to the modifications amsmath.sty makes for Computer Modern. It is not exactly analogous because Computer Modern provides additional sizes of the maths extension font, whereas Latin Modern provides only 10pt. However, it does seem --- in absolutely minimal testing --- to work in a similar way.

Caveat emptor ...

\documentclass[12pt]{article}
\makeatletter
% \usepackage[cmex10]{amsmath}
\usepackage{amsmath}
\usepackage{lmodern}
% from omxlmex.fd
\DeclareFontFamily{OMX}{lmex}{}
% modified from amsmath.sty
\ifnum\cmex@opt=7 \relax
  \DeclareFontShape{OMX}{lmex}{m}{n}{%
    <-8>lmex10<8>lmex10<9>lmex10%
    <10><10.95><12><14.4><17.28><20.74><24.88>lmex10%
  }{}%
  \expandafter\let\csname OMX/cmex/m/n/10\endcsname\relax
\else
  \ifnum\cmex@opt=\z@ % need to override cmex7 fontdef from amsfonts
    \begingroup
    \fontencoding{OMX}\fontfamily{lmex}%
    \expandafter\let\csname OMX+cmex\endcsname\relax
    \try@load@fontshape
    \endgroup
    \expandafter\let\csname OMX/cmex/m/n/10\endcsname\relax
    \def\cmex@opt{10}%
  \fi
\fi
\makeatother
\begin{document}
  \[ \sqrt{\frac{m}{n}} \sqrt[3]{\frac{m}{n}} \]
\end{document}

Latin Modern adjustments

  • I'm not at all convinced this is right. – cfr Jun 20 '17 at 12:14
2

I've found a practical solution (for pdfLaTeX). One can set the option nomath for lmodern. Then the usual CM (with the improved output caused by amsmath) is used in math mode while LM is used in text mode.

\documentclass[12pt]{article}   
\usepackage{amsmath}            
\usepackage[nomath]{lmodern}    

\begin{document}
    \[ \sqrt{\frac{m}{n}} \]    
\end{document}

The amsmath package improves the square root symbol by changing the original IBBYVH+CMEX10 font to MNPEHI+CMEX10. However, if lmodern is fully enabled, amsmath doesn't have any influence.

Alternatively, one can use the package ae instead of lmodern, see here: Latin Modern vs cm-super?

  • 1
    ae is not recommended at all. And those fonts are not different. amsmath does not change IBBYVH+CMEX10 to MNPEHI+CMEX10. Those fonts are both cmex10. You are just looking at the fonts embedded in your document. Those are different subsets of the same font. pdfTeX does not embed the entire font but only subsets of the font. It adds those codes to distinguish the subsets. – cfr Jun 20 '17 at 23:23
  • Why is ae not recommended at all? Thanks for explaning the font situation! – Thrash Jun 21 '17 at 2:21
  • You probably should ask somebody who's been using TeX longer than me, as it was considered deprecated when I started using TeX. I don't think it covers the T1 encoding range properly, but I'm not certain. – cfr Jun 21 '17 at 2:29
  • See tex.stackexchange.com/questions/1390/latin-modern-vs-cm-super/… re. ae and why you shouldn't use it or recommend it. – cfr Jun 21 '17 at 2:36
  • Copy and paste works for me with ae, too. – Thrash Jun 22 '17 at 2:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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