4

This is more of a philosophical question. I was looking for ways to increase the font size within math mode locally (eg. in only one equation/align environment) but the solutions I come across often just revert to text mode. I was wondering is there some structural reason in the TeX system that we cannot access directly the font size for mathematical symbols (locally in only a single equation/align environment)? There are commands such as "dfrac", so I would expect to have more global control too.

For example, as you can see in these answers, the authors revert to text mode.

thanks

3 Answers 3

9

To expand on David's answer, what \DeclareMathSizes does is define a macro S@XX where XX is the current type size in points, e.g.,

 \S@10 = macro: -> {
    \gdef\tf@size{10}
    \gdef\sf@size{7}
    \gdef\ssf@size{5}
 }

(I've modified spaces and line breaks from the output of \meaning for the sake of clarity).

This means that if you want to see what the sizes are, you can just look at the values of those macros and, in fact that's exactly what happens in the definition of the LaTeX macro:

\DeclareRobustCommand{\LaTeX}{L\kern-.36em%
        {\sbox\z@ T%
         \vbox to\ht\z@{\hbox{\check@mathfonts
                              \fontsize\sf@size\z@ % 👈
                              \math@fontsfalse\selectfont
                              A}%
                        \vss}%
        }%
        \kern-.15em%
        \TeX}

But you want to change this locally. For this, there is a sneaky way to do it. We can't sprinkle \DeclareMathSizes around the document since it's preamble-only, but we can create a new type size that's slightly off³,⁴ from the normal typesize and use that.

In the preamble:

\DeclareMathSizes{10.0001}{12}{10}{8}

Then we can write (but this is best in a command or environment):

\fontsize{10.0001}{\baselineskip}\selectfont

This is $x^2$ 

Now as for why this is all so weird, it comes down to the fact that math fonts and text fonts are treated distinctly in the underlying TeX engine. In text, it's enough to invoke a control sequence that loaded a font with \font, so in plain TeX, \fiverm selects cmr5 or in LaTeX \OT1/cmr/m/n/10 selects cmr10. But font selection in math mode is handled via families instead of the text font selection, which is why \mathbf{+} does not give a bold +. This parallel-universe font selection also applies to size changes which are restricted to the \displaystyle, \textstyle, \scriptstyle and \scriptscriptstyle commands. You really would need to read the relevant chapters of The TeXbook to get a full picture of how this works.


  1. For all the hyperrationality of Lamport's user interface in designing LaTeX, I curse that he followed Knuth's lead in randomly sprinkling @ in different places in private macro names. This is one of the biggest plusses of ExpL3 to me. Finally some Teutonic organization applied to the naming conventions.²

  2. Us older folks will remember the inscrutable names that were used in the Bitnet/EARN days for German and Austrian host names which, while they looked like a cat sat on the keyboard when it was time to pick a hostname were actually a mapping of key information about each host into the available 8 characters for a hostname.

  3. The variation in size here is miniscule, 0.001% which means that, for example, the amount of space that a lowercase m in cmr10 takes up will increase from 8.33336pt to 8.3334433336pt, a difference of about 5.5sp=.03μm so we're looking at molecular-scale dimensions here.

  4. Although this is moot with Computer Modern since NFSS will switch to cmr10 at 10pt anyway. In XeLaTeX and LuaLaTeX, though, since they're using lmr instead of cmr, they'll happily request a 10.0001pt font.

8

For global choice of math font sizes, the command \DeclareMathSizes specifies the math font sizes relative to the text size although it is somewhat rare to change the defaults. At 10pt the default is set by

\DeclareMathSizes{10pt}{10pt}{7}{5}

that is, if the current text is 10pt then 10pt is used in \displaystyle and \textstyle, 7pt is used in \scriptstyle and 5pt is used in \scriptscriptstyle.

For local choice within a formula the situation is rather different. You mention \dfrac but that is not choosing a font size but rather a math font style. A given math formula has access to fonts in three styles (sizes) (textstyle, scriptstyle, scriptscriptstyle) in 16 fonts (fam0 ... fam15)

You can see which font is set for any of these by eg \showthe\textfont2 to see which font is set for the textstyle in fam2. Note these settings apply to the entire formula: if you change them just before the final $ (or \end{equation} or whatever) that change will apply to the entire expression.

If you have

$ x  + \mbox{\large $x+y$} + y$

Then \large as well as changing the current text font at that point also arranges that all 3*16 math font settings will be changed if math is used in that scope so the nested math list x+y will use the larger fonts.

If you try to use \large directly in the outer math list then LaTeX warns that the usage is wrong (it should probably be an error not a warning). What actually happens depends on exactly where the size change is used. It may apply to the whole expression including terms before the size change, it may have no visible effect at all, or it may appear to work and just apply to a sub formula (if for technical reasons the sub formula is already a new nested math list, eg an array cell).

4
  • Interesting. But I was more thinking of locally such as inside a single align/equation environment as opposed to changing all math equations. Aug 8, 2021 at 23:38
  • @OOESCoupling you gave so little information in the question it was hard to guess what you intended. then $x + \mbox{\large $ x $} + y$ Aug 8, 2021 at 23:45
  • I was not looking for a solution per se. My question was precisely this. Is there a TeX-reason that we cannot locally and directly change the font size in math mode but instead need to revert to text mode. Aug 9, 2021 at 1:17
  • @OOESCoupling I added some words Aug 9, 2021 at 7:46
1

It's a case of different hats, or parallel threads.

The idea of families might be more accessible if thought of as sets of (already-formatted) glyphs within a font.

In text, x (the glyph U+0078 LATIN SMALL LETTER X) can be typeset as upright, or italic or bold etc, according to the font file(s).

In math, 𝑥 and 𝒙 are two additional, different, glyphs in the same font, and they belong to different sets ("alphabet families"), mathematical italic, and mathematical bold italic: U+1D465 MATHEMATICAL ITALIC SMALL X = (𝑥) and U+1D499 MATHEMATICAL BOLD ITALIC SMALL X = (𝒙)

Which means that it should be possible to map elements from one set to another (and also across fonts, too).

unicode-math package allows mapping using the -> operator of the range= option.

Here, the same font is mapped to itself, specifically, math bold italic is replaced by math italic which in turn has been doubled in size and made blue, for clarity. Math bold italic being accessed via the \symbfit{} command.

range mapping

MWE

\documentclass[12pt]{article}
\usepackage{xcolor}
\usepackage{amsmath,amssymb}
\usepackage{unicode-math}
\setmainfont{Liberation Serif}
\newfontface\fmlmm{Latin Modern Math}

\setmathfont{Latin Modern Math}
\setmathfont{Latin Modern Math}[range=bfit->it,Scale=2,Colour=blue]
%-----------
\begin{document}

U+1D465 MATHEMATICAL ITALIC SMALL X = ({\fmlmm 𝑥})

U+1D499 MATHEMATICAL BOLD ITALIC SMALL X = ({\fmlmm 𝒙})

$ x  + x+y + y$

$ x  + \symbfit{x}+\symbfit{y} + y$

\end{document}

Alternatively, a lower-level method, but still using a scaled-version of the font as symbol-source, can be by assigning a \Umathcode to a glyph (red, below, accessed via direct input, or unicode-math symbol name, or unicode codepoint value), or obtained by defining a formatted custom command (green).

glyphs

MWE

\documentclass[12pt]{article}
\usepackage{xcolor}
\usepackage{amsmath,amssymb}
\usepackage{unicode-math}

\setmainfont{Liberation Serif}

\setmathfont{XITS Math}

\newfontfamily\fmymath{XITS Math}[Colour=red,Scale=2,NFSSFamily=mymath]
\newfontfamily\fmymathg{XITS Math}[Colour=green,Scale=2]


\DeclareSymbolFont{bigletters}{\encodingdefault}{mymath}{m}{it}
\newcommand{\makebigmathletter}[1]{%
  \begingroup\lccode`a=#1\lowercase{\endgroup
  \Umathcode`a}="0 \csname symbigletters\endcsname\space #1
}
%\count255="409
%\loop\ifnum\count255<"44F
%  \advance\count255 by 1
%  \makebigmathletter{\count255}
%\repeat
\makebigmathletter{"1D465}
\makebigmathletter{"1D466}
%-----------


\newcommand{\declaresymbols}[2]{\expandafter\newcommand\csname#1big\endcsname{%
\text{\fmymathg#2}}}
\declaresymbols{x}{\symbol{"1D465}}
\declaresymbols{y}{\symbol{"1D466}}

%-----------

\begin{document}


\[
x + 𝑥 +\mitx + \symbol{"1D466} + y +\xbig + \ybig
\]

\end{document}

What the start of Unicode's Mathematical Alphanumeric Symbols codeblock looks like in BabelMap:

The MAS

996 characters!

So, to take a step towards trying to answer the question, the size/shape/weight levers for the single-thread in text mode has resulted in a different approach to the many-levered multi-threads of math mode. They are almost orthogonal in approach.

Italics (and bold and Fraktur etc) in math mode has semantic meaning; text mode, it's more a style or decoration; if text mode had retained its original meaning for italics (names of people, places and things), for example, then perhaps likely every font would have italic x and upright x as separate glyphs.

You must log in to answer this question.

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