36

Edit: I understand this question has been marked as a duplicate, but the question I linked to doesn't have a solution for me (unless I'm missing something obvious, which is likely). The effect is quite visible when printed on paper. Can anyone suggest how I can avoid the problem and still use Latin Modern for non-maths text? I'm using pdfLaTeX.

I've run into an issue using the implies glyph. I'm using a Latin Modern typeface, 12pt document. The horizontal lines that make up the arrow have a "bump" in the middle. I found this similar question when trying to figure it out, but the issue persists even after printing.

Possible bug with \implies and \Longrightarrow -- there's a dot in the middle of it

To illustrate, here's a picture:

Implies glyph

The issue basically disappears when I use \scriptstyle, but I'd rather not. Any ideas?

\documentclass[12pt]{article}

\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{mathtools} 

\begin{document} 
  $\implies$\par
  $\scriptstyle \implies$   
\end{document}
  • It's an evident bug of the Latin Modern fonts; it's not the same in the OpenType version. The equals sign is used for lengthening the double arrow, but in the 12pt font they don't agree; they do at 10pt (and 11pt, where the scaled 10pt font is used). – egreg Oct 12 '13 at 09:05
  • 3
    Sorry, I posted this one because the accepted answer on the other had

    "note that this only affects on-line viewing, but printing should be OK"

    Which wasn't the case for me. Is there a known workaround? I'm a relative newcomer to fiddling with fonts, any suggestions would be appreciated :)

    – Callum Webb Oct 12 '13 at 09:06
  • 6
    I don't think it's the same problem or, at least, the other question was answered without knowing the real problem which appears when 12pt font size is used. The issue is in the fact that the two glyphs are taken from different fonts: the equals sign from lmr12, the arrow from lmsy10 at 12pt. – egreg Oct 12 '13 at 09:16

3 Answers3

29

The problem is this: \Longrigtharrow (over which \implies is defined) is built with two characters that come from different fonts.

The equals sign for lengthening the arrow is taken from \textfont0 (the normal text font), while the arrow (\Rightarrow) is taken from \textfont2 (the math symbol font).

When a current font size is 10pt, lmodern defines \textfont0 as rm-lmr10 (the prefix rm means OT1 encoding) and \textfont2 as lmsy10 and all is good. If the current font size is 11pt, the fonts are rm-lmr10 at 10.95pt and lmsy10 at 10.95pt, which again agree with each other.

The problem is at 12pt: in this case \textfont0 is rm-lmr12, while \textfont2 is lmsy10 at 12pt. Here is where the problem arises: the thickness of the strokes is scaled for \Rightarrow but not with = and the difference is noticeable, particularly at low resolution.

The following image is taken at 4x magnification (\mag=4000) by compiling with pdftex the input

\mag=4000
\font\xy=lmsy10 at 12pt
\font\xz=rm-lmr12
\textfont2=\xy \textfont0=\xz
$\Longrightarrow$
\bye

enter image description here

and the difference cannot be attributed to pixel adjustments of the onscreen previewer.

A possible workaround is to redefine the font used for \textfont0 to use scaled rm-lmr10 when the current font size is above 10pt and using T1 as the default encoding for text fonts.

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\makeatletter
% Load the OT1 definitions for lmodern
\input{ot1lmr.fd}
% Change the definition for \OT1/lmr/m/n/<size>
\DeclareFontShape{OT1}{lmr}{m}{n}%
  {<-5.5>    rm-lmr5  <5.5-6.5> rm-lmr6
   <6.5-7.5> rm-lmr7  <7.5-8.5> rm-lmr8
   <8.5-9.5> rm-lmr9  <9.5->    rm-lmr10
  }{}
\makeatother

\begin{document}
\noindent
$\Longrightarrow$\\
The text font\\
is \expandafter\texttt\expandafter{\fontname\font}
\end{document}

enter image description here

David Carlisle
  • 757,742
egreg
  • 1,121,712
  • 1
    Wow, I wasn't sure if I'd get a fix, let alone that quickly! Before I accept this answer though, do you know of any side effects this may have? I've haven't noticed any yet. – Callum Webb Oct 12 '13 at 14:15
12

Package amsmath uses \Longrightarrow to get the \Implies symbol. \Longrightarrow and \Longleftarrow are composed symbols with the standard fonts (unless a math font is used, which contain ready glyphs for the symbol). The arrow is taken from \Rightarrow and \Leftarrow, the equals sign = is used as prolongation, see macro \Relbar. At larger font sizes, the lines do not match too well, as can be observed in the image of the question.

A minimal example:

\documentclass{article}
\begin{document}
  \Huge$\Longrightarrow$
\end{document}

Problem: \Longrightarrow as composed symbol

The following reimplementation of \Longrightarrow and \Longleftarrow uses a different method to get the prolongation. Instead of using the equals sign, the left part of \Rightarrow is used for the left part of the new macro \NewRelbar and the right part of \Leftarrow is used for the right part of \Leftbar. The width of the equal sign is too large to be able to take the prolongation in one piece. Also the side bearings are preserved and the new symbol can be used both for \Longrightarrow and \Longleftarrow.

Example with implementation and test:

\documentclass{article}

% Save original macros
% --------------------
\usepackage{letltxmacro}

\LetLtxMacro\OriginalLongrightarrow\Longrightarrow
\LetLtxMacro\OriginalLongleftarrow\Longleftarrow

% Implement new macros
% --------------------
\usepackage{trimclip}
\DeclareRobustCommand\Longrightarrow{\NewRelbar\joinrel\Rightarrow}
\DeclareRobustCommand\Longleftarrow{\Leftarrow\joinrel\NewRelbar}

\makeatletter
\DeclareRobustCommand\NewRelbar{%
  \mathrel{%
    \mathpalette\@NewRelbar{}%
  }%
}
\newcommand*\@NewRelbar[2]{%
  % #1: math style
  % #2: unused
  \sbox0{$#1=$}%
  \sbox2{$#1\Rightarrow\m@th$}%
  \sbox4{$#1\Leftarrow\m@th$}%
  \clipbox{0pt 0pt \dimexpr(\wd2-.6\wd0) 0pt}{\copy2}%
  \kern-.2\wd0 %
  \clipbox{\dimexpr(\wd4-.6\wd0) 0pt 0pt 0pt}{\copy4}%
}
\makeatother

% Testing
% -------
\usepackage{booktabs}
\usepackage{color}
\begin{document}
  \Huge
  \newcommand*{\Test}[1]{%
    \color{red}%
    $#1\OriginalLongrightarrow\OriginalLongleftarrow$&%
    \color{blue}%
    $#1\Longrightarrow\Longleftarrow$%
  }
  \begin{tabular}{cc}
    \toprule
    Original & New \\
    \midrule
    \Test{}\\
    \Test\scriptstyle\\
    \Test\scriptscriptstyle\\
    \bottomrule
  \end{tabular}
\end{document}

Result

Heiko Oberdiek
  • 271,626
1

As or 2020, this is one of those bits of decades-old technical debt that you can sweep away by loading unicode-math.

Davislor
  • 44,045