summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/fixcmex/fixcmex.dtx
blob: 1e4003007429c149aaa8b499f22ffb27d448e912 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
% \iffalse meta-comment
%
% Copyright (C) 2015-2019 by Enrico Gregorio
% <Enrico dot Gregorio (at) univr dot it>
% ---------------------------------------
%
% This file 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.
% The latest version of this license is in:
%
%    http://www.latex-project.org/lppl.txt
%
% and version 1.3c or later is part of all distributions of LaTeX
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{fixcmex.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{fixcmex}
%<*package>
    [2019/08/05 v1.1 Scalable math extensions font (Enrico Gregorio)]
%</package>
%
%<*driver>
\documentclass{ltxdoc}

\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{fixcmex.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{48}
%
% \changes{v1.0}{2015/11/10}{Initial version}
% \changes{v1.1}{2019/08/05}{Fix lmodern}
%
% \GetFileInfo{fixcmex.dtx}
%
% \DoNotIndex{\begingroup,\endgroup,\aftergroup,\@nil,\cmex,\lmex}
% \DoNotIndex{\def,\edef,\else,\escapechar,\expandafter,\fi,\ifx}
% \DoNotIndex{\m@ne,\string,\textfont,\the,\thr@@}
%
%
% \title{The \textsf{fixcmex} package\thanks{This document corresponds
% to \textsf{itnumpar}~\fileversion, dated \filedate.}}
%
% \author{Enrico Gregorio \\ \texttt{Enrico dot Gregorio (at) univr
% dot it}}
%
% \date{\filedate}
%
% \maketitle
%
% \section{Description}
%
% Knuth's Computer Modern fonts only provide the math extensions
% font \texttt{cmex10} at just one size. Together with a release
% of AMS-\TeX{}, the American Mathematical Society also provided
% the font at sizes 7, 8 and 9; these fonts are automatically loaded
% when \verb+\usepackage{amsmath}+ is done for a document. The
% option \texttt{cmex10} is allowed for reverting back to the fixed
% size, but it should only be used when the \TeX{} distribution is
% more than, say twenty years old (at the time of writing).
%
% Where's the difference? With the standard setup, a symbol like
% summation or integral in a footnote or in a \verb+\Large+ context
% will have the same size as in normal text. This size is also
% independent of the main point size of a document.
%
% When \textsf{amsmath} (or \textsf{exscale}) is loaded, the symbols
% will be scaled, but only at the standard sizes, not arbitrarily.
% This is not a limitation any more, because the Type1 version of
% the \texttt{cmex} fonts has been available for several years and
% this package addresses it.
%
% Many people use the Latin Modern fonts that are, in several respects,
% superior to the European Modern fonts when T1 font encoding is
% required. However, when \verb+\usepackage{lmodern}+ is done,
% the situation about the math extensions font goes back to the
% standard state described above, because \texttt{lmex10} is only
% provided at a fixed size.
%
% The present package can be used when the main font of the document
% is Computer Modern (or European Modern, if T1 encoding is selected)
% or Latin Modern. It redefines the math extensions font so that it
% is arbitrarily scalable, using the optical size fonts provided by
% the AMS together with the original \texttt{cmex10} font.
%
% The package should be loaded as late as possible, in any case
% \emph{after} any font package. Its position with respect to
% \textsf{hyperref} or \textsf{cleveref} is irrelevant. It will do
% nothing if the math extensions font turns out to be not from
% Computer Modern or Latin Modern (with a warning).
%
% There are no options and no commands.
%
% \StopEventually{\PrintChanges\PrintIndex}
%
% \section{Implementation}
% \begin{macro}{\fixcmex@fix}
% \changes{v1.1}{2019/08/05}{Fix lmodern}
% The main command just resets the math extensions font to
% be \texttt{cmex}, fully scalable.
%    \begin{macrocode}
%<*package>
\def\fixcmex@fix{%
  \DeclareFontShape{OMX}{cmex}{m}{n}{%
    <-7.5> cmex7
    <7.5-8.5> cmex8
    <8.5-9.5> cmex9
    <9.5-> cmex10
  }{}%
  \SetSymbolFont{largesymbols}{normal}{OMX}{cmex}{m}{n}%
  \SetSymbolFont{largesymbols}{bold}{OMX}{cmex}{m}{n}%
  \mathversion{\math@version}%
}
\@onlypreamble\fixcmex@fix
%    \end{macrocode}
% \end{macro}
%
% Next, at begin document, the \verb+\check@mathfonts+ command
% makes sure the font assignments are performed for the normal
% size and the family name corresponding to the OMX encoding
% is extracted. If it is either \texttt{cmex} or \texttt{lmex}
% the command \verb+\fixcmex@fix+ will be executed. Otherwise
% a warning is issued, telling that the package has done nothing.
%    \begin{macrocode}
\AtBeginDocument{%
  \begingroup
    \check@mathfonts
    \expandafter\expandafter\expandafter
      \split@name\expandafter\string\the\textfont\thr@@\@nil
    \escapechar=\m@ne
    \edef\fixcmex@cmex{\string\cmex}\edef\fixcmex@lmex{\string\lmex}%
    \ifx\f@family\fixcmex@cmex
      \aftergroup\fixcmex@fix
    \else
      \ifx\f@family
        \fixcmex@lmex\aftergroup\fixcmex@fix
      \else
        \PackageWarningNoLine{fixcmex}{No change in the math extension font}%
      \fi
    \fi
  \endgroup
}
%</package>
%    \end{macrocode}
% \Finale
\endinput