11

I really like the font \usepackage{mlmodern} and want to keep using it. Only when using \int in a section header, the integral sign for some reason shrinks in size relative to the rest of the expression. This happens with both pdflatex and also lualatex.

Why does this happen and is there a way to keep the integral sign from shrinking?

    \documentclass[12pt,titlepage]{article}  
    \usepackage{amsmath}
    
    \usepackage[T1]{fontenc}
    \usepackage{mlmodern}
    
    \begin{document}
    
    \section{$ \int \sqrt{1+2 x} \, dx$}
    This is a test
    \[
    \int \sqrt{1+2 x} \, dx
    \]    
    \end{document}

Compiled using pdflatex or lualatex gives

enter image description here

Compare to the output from

    \documentclass[12pt,titlepage]{article}  
    \usepackage{amsmath}
    \begin{document}
    
    \section{$ \int \sqrt{1+2 x} \, dx$}
    This is a test
    \[
    \int \sqrt{1+2 x} \, dx
    \]
    
    \end{document}

enter image description here

7
  • 1
    At least I can reproduce the problem :). Jun 1, 2022 at 2:59
  • See my not-answer, maybe the \int symbol has a maximum size?! The amsmath package does not seem to be relevant, in the MWE right? Jun 1, 2022 at 3:05
  • 4
    I looked into the code of the mlmodern package [2021/01/12 v1.1] and found that the line \SetSymbolFont{largesymbols}{normal}{OMX}{mlmex}{m}{n} causes the difference in the size of the integral. The corresponding fd file (omxmlmex.fd) includes the following macro call: \DeclareFontShape{OMX}{mlmex}{m}{n}{<->sfixed*mlmex10}{}. Based on page 21 at latex-project.org/help/documentation/fntguide.pdf, the size functions fixed or sfixed "Load font ⟨fontarg⟩ as is, disregarding the user-requested size. If present, ⟨optarg⟩ gives the “at . . . pt” size to be used." (1 of 2) Jun 1, 2022 at 3:48
  • 4
    That is, the font size you indicate is ignored. Now, when I changed sfixed to just s and compiled the TeX file, the integral returned to its normal, desired size. That is, the macro code was changed to \DeclareFontShape{OMX}{mlmex}{m}{n}{<->s*mlmex10}{}. The size function s is described as "Load the external font ⟨fontarg⟩ at the user-requested size. If ⟨optarg⟩ is present, it is used as the scale-factor." (2 of 2) Jun 1, 2022 at 3:49
  • 1
    @MiriamBriskman, those comments really look like an answer... 😉
    – Rmano
    Jun 1, 2022 at 5:46

2 Answers 2

9

EDIT: As egreg correctly noted in the comments below, the change that we describe in the answer here will last temporarily since, on a subsequent update of the package, the change we propose will be wiped out from the mlmodern font declaration.

As such, egreg recommends including a font family declaration within the TeX file, before begin{document}, similar to:

\DeclareFontFamily{OMX}{mlmex}{}
\DeclareFontShape{OMX}{mlmex}{m}{n}{%
   <->mlmex10%
   }{} 

Another possibility is to creat a package that is using mlmodern and containing a similar declaration and use this package in your TeX file, which avoids the need to include the font family declaration in each and every future TeX project.


Disclaimer: This solution involves making a change to the settings of the mlmodern package. Please be advised that, in general, changing a package may affect its functionality, so any changes you decide to make are at your own discretion.


Solution (Keeping Things Short)

To have \int displayed at the font size of your choice (in your case, 12pt):

  1. Find the mlmodern directory (in which the mlmodern.sty package file resides) on your computer.
    • If you are using texlive on Linux, you may find the package at /usr/share/texmf-texlive/tex/latex/ or /usr/share/texmf-dist/tex/latex/.
    • If you are using MiKTeX on Windows, you may find the package at C:\Users\<username>\AppData\Local\Programs\MiKTeX 2.9\tex\latex. enter image description here
  2. In this directory are numerous .fd (font definition) files. Open the file omxmlmex.fd for editing.
  3. Change the macro call
\DeclareFontShape{OMX}{mlmex}{m}{n}{%
 <->sfixed*mlmex10%
 }{}

in this file to

\DeclareFontShape{OMX}{mlmex}{m}{n}{%
 <->s*mlmex10% % <----- sfixed was changed to s
 }{}

enter image description here 4. Re-compile your TeX file, and you'll see that the integral symbol shows the correct size. enter image description here


Explanation

Note: The solution-search procedure described below was done on a Windows 10 device but can be applied on a Mac or Linux computer in a similar fashion.

Diagnosis

It is evident that the integral symbol was displayed with incorrect sizing.

Moreover, Dr. Manuel Kuehner showed in his test at https://tex.stackexchange.com/a/646334/256551 that setting a different font size didn't change the size of \int.

Digging up

The fact that commenting \usepackage{mlmodern} out brings the integral back to its desired size implies that the issue is rooted in the mlmodern package.

As such, we decided to view the mlmodern.sty file, most of which contains calls to \SetSymbolFont and \SetMathAlphabet:

%This package provides support for the mlmodern fonts. See mlmodern.pdf
%for more information.
%This work may be distributed and/or modified under the conditions
%of the LaTeX Project Public License, either version 1.3c of this
%license or (at your option) any later version.
%Copyright 2003--2009 by B. Jackowski and J.M. Nowacki.
%Copyright 2021 by Daniel Benjamin Miller.
%This work has the LPPL maintenance status "maintained".
%The Current Maintainer of this work is Daniel Benjamin Miller.


\ProvidesPackage{mlmodern}[2021/01/12 v1.1 Modified Latin Modern Fonts]

\renewcommand{\rmdefault}{mlmr}
\renewcommand{\sfdefault}{mlmss}
\renewcommand{\ttdefault}{mlmtt}
\renewcommand{\bfdefault}{bx}
\DeclareOption{nomath}{\endinput}
\DeclareOption{variablett}{%
  \renewcommand{\ttdefault}{mlmvtt}
}
\DeclareOption{lighttt}{%
  \let\mlmtt@use@light@as@normal\@empty
}
\ProcessOptions\relax

\SetSymbolFont{operators}   {normal}{OT1}{mlmr} {m}{n}
\SetSymbolFont{letters}     {normal}{OML}{mlmm} {m}{it}
\SetSymbolFont{symbols}     {normal}{OMS}{mlmsy}{m}{n}
\SetSymbolFont{largesymbols}{normal}{OMX}{mlmex}{m}{n}
\SetSymbolFont{operators}   {bold}  {OT1}{mlmr} {bx}{n}
\SetSymbolFont{letters}     {bold}  {OML}{mlmm} {b}{it}
\SetSymbolFont{symbols}     {bold}  {OMS}{mlmsy}{b}{n}
\SetSymbolFont{largesymbols}{bold}  {OMX}{mlmex}{m}{n}

\SetMathAlphabet{\mathbf}{normal}{OT1}{mlmr}{bx}{n}
\SetMathAlphabet{\mathsf}{normal}{OT1}{mlmss}{m}{n}
\SetMathAlphabet{\mathit}{normal}{OT1}{mlmr}{m}{it}
\SetMathAlphabet{\mathtt}{normal}{OT1}{mlmtt}{m}{n}
\SetMathAlphabet{\mathbf}{bold}  {OT1}{mlmr}{bx}{n}
\SetMathAlphabet{\mathsf}{bold}  {OT1}{mlmss}{bx}{n}
\SetMathAlphabet{\mathit}{bold}  {OT1}{mlmr}{bx}{it}
\SetMathAlphabet{\mathtt}{bold}  {OT1}{mlmtt}{m}{n}

\def\mathsterling{\mathit{\mathchar"70BF}}

\endinput

To check which of the calls influences the formatting of the integral, we commented out each of the calls, one at a time, and compiled the TeX file.

It turns out that the call

\SetSymbolFont{largesymbols}{normal}{OMX}{mlmex}{m}{n}

sets the formatting (font encoding + family) of \int (and other large math operators, like \sum and \prod, as page 12 in https://www.latex-project.org/help/documentation/fntguide.pdf mentions.)

Based on page 14, \SetSymbolFont has the synopsis:

\SetMathAlphabet {⟨math-alph⟩} {⟨version⟩} {⟨encoding⟩} {⟨family⟩} {⟨series⟩} {⟨shape⟩}

and is defined to change the symbol font ⟨sym-font⟩ for math version ⟨version⟩ to ⟨encoding⟩ ⟨family⟩ ⟨series⟩ ⟨shape⟩.

The font attributes of the OMX encoding and mlmex font family are specified in the omxmlmex.fd file, which is contained in the folder of mlmodern.sty, so the next step was to look into the file.

Finding the issue's source

The content of omxmlmex.fd is:

%This package provides support for the mlmodern fonts. See mlmodern.pdf
%for more information.
%This work may be distributed and/or modified under the conditions
%of the LaTeX Project Public License, either version 1.3c of this
%license or (at your option) any later version.
%Copyright 2003--2009 by B. Jackowski and J.M. Nowacki.
%Copyright 2021 by Daniel Benjamin Miller.
%This work has the LPPL maintenance status "maintained".
%The Current Maintainer of this work is Daniel Benjamin Miller.

\ProvidesFile{omxmlmex.fd}[2021/01/11 v1.0 Font defs for mlmodern]

\DeclareFontFamily{OMX}{mlmex}{}
\DeclareFontShape{OMX}{mlmex}{m}{n}{%
   <->sfixed*mlmex10%
   }{}
\endinput
%%
%% End of file `omxmlmex.fd'.

Notice the macro call \DeclareFontShape and, specifically, its 5th argument, <->sfixed*mlmex10.

According to page 18, this argument "contains the information that combines sizes with external fonts. "

Section 4.3 (pages 19-20) in the document tells that <-> is the range of font sizes on which this rule is applied (in our case, any font size), sfixed is a size function, and mlmex10 is the font argument ⟨fontarg⟩ of the size function.

Now, sfixed in particular "loads font ⟨fontarg⟩ as is, disregarding the user-requested size." Given that mlmex10 is a font argument corresponding to a font of size 10pt, the entire argument simply keeps all the symbols at size 10pt, regardless of the user's attempts to change it.

Solving the issue

The solution, based on the findings above, is to opt for a different size function that allows the user to customize the font size. A function that meets this condition is s, which is defined on page 20 as loading "the external font ⟨fontarg⟩ at the user-requested size."

When we change sfixed to s, and then recompile the TeX file, the \int symbol is displayed at the font of 12pt, as desired.


Final Comments

I am unable to tell whether the use of the sfixed size function is an intentional decision of the developers of mlmodern or if it is a bug. In any case, I would recommend to notify the maintainer of mlmodern, Daniel Benjamin Miller, about the issue that sfixed caused.

Hopefully, this approach above addressed your question! If it hasn't, I will be more than happy to adjust the answer accordingly to adequately address your question.

5
  • 1
    Modifying a distributed file is a no-go. An update to the package would destroy the edit. It's much simpler to add the font family declaration in the document (and s* is not needed).
    – egreg
    Jun 1, 2022 at 9:07
  • @egreg, thank you very much for your important comment! What change should be done, then, if we wish to apply the change to any future TeX file, without including the declaration in each file? Thank you again! Jun 1, 2022 at 9:13
  • 2
    Write a package similar to fixcmex and upload it to CTAN. When and if mlmodern changes to allow arbitrary size, the package can be made into a no-op.
    – egreg
    Jun 1, 2022 at 9:17
  • @egreg, this is a wonderful approach. Thank you very much! Would you like to make an edit to the answer that reflects the concern that the edit will be gone on a subsequent update, and that building a package will address the issue, just as you explained? You raised this important concern, so it is your right to edit the answer. Thank you very much for your great contribution! Jun 1, 2022 at 9:26
  • 2
    The answer is yours. I gave an answer that I removed as per your request (the gratuitous and undeserved downvote is not how the site works, by the way). I'm not going to change answers unless they contain serious errors. The responsibility is on the poster.
    – egreg
    Jun 1, 2022 at 9:49
3

Not an answer, just a test.

\documentclass{article}

\usepackage{amsmath}
\usepackage{mlmodern}

\begin{document}

\section{$ \int \sqrt{2x^2}$}
$ \int \sqrt{2x^2}$

\end{document}

LuaLaTeX Output

enter image description here

enter image description here

pdfLaTeX Output

enter image description here

enter image description here


Edit

Maybe the integral symbol is just not available in a size that large, see the following MWE.

enter image description here

\documentclass{article}

\usepackage{amsmath}
\usepackage{mlmodern}

\begin{document}

\section{$ \int \sqrt{2x^2}$}

$ \int \sqrt{2x^2}$

{\huge $ \int \sqrt{2x^2}$} % <-- \huge

\end{document}
2
  • 1
    Thanks for the test. I assume then you agree the integral sign should be larger in section header.
    – Nasser
    Jun 1, 2022 at 3:17
  • @Nasser Yes, I agree. See also my edit. (going offline now) Jun 1, 2022 at 3:21

You must log in to answer this question.

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