I know that "scriptstyle" is a style, and "scriptsize" is a font size, but what are the main differences between the two? Is it merely that "scriptstyle" should be used in math mode, and "scriptsize" should generally not? I also understand that both are defined as 30% reduced from the default font size, or no?
[Tex/LaTex] Difference between \scriptsize and \scriptstyle
fontsfontsize
Related Solutions
If I understand your question correctly, you're asking why TeX uses different fonts for (Latin-alphabet) letters and numbers depending on whether they are set in text or math mode. Put differently, if a well-designed math font happens to contain all letters, digits, and punctuation marks that can possibly occur in text mode settings, why not use this math font for text mode too? Why use two different fonts in such cases? (Of course, math frequently also requires symbols -- e.g., summation and integral symbols, fraction bars, and primes -- which don't occur in text mode at all. I take it that symbol fonts are not a part of your question.)
You already mention one reason for having different fonts: Text fonts frequently provide ligatures for character pairs and triples such as
ff
,fi
,fl
,ffi
,ffl
, possibly also forft
,fft
,fj
,fh
,ct
,st
,sp
, etc. In math mode, replacing these character pairs and triples with ligatures is almost certainly undesirable.A second, and probably more important, reason, for having separate fonts is that the side bearings around letters can (and should!) differ considerably depending on whether they occur in text or math mode. Consider the character strings
fly
andoffice
; in the following example they're first set in text italic mode, with ligatures suppressed via\kern0pt
instructions, and then in math italic mode. (The vertical bar is provided to indicate the left-hand edge of the text block.)
(Point two, continued.) Observe that in text-italic mode, the letter f actually has a negative left-hand side bearing, so that its descender can "encroach" into the space occupied by the preceding character or interword space; its right-hand side-bearing seems to be pretty much zero, so that it touches subsequent characters such as l. In contrast, in math-italic mode the left-hand side bearing of f is zero and its right-hand side bearing is positive. I suppose this is done so that if and when the character combinations
ff
andfl
occur in math mode, it'll be abundantly clear that we're dealing with the products of one-letter variables namedf
andl
, respectively, rather than with two-letter variables namedff
andfl
. To be extra-super clear, some people may resort to writingf\cdot f
andf\cdot l
. If the math font is designed correctly, it shouldn't be necessary to do so.Observe that the spaces between "l" and "y", "f" and "i", "i" and "c", and "c" and "e" are also greater in math mode than they are in text mode. This is true not only for the font family used in the example above (
newtx
) but for all well-designed font families that have both text and math modes.The issue of setting the side bearings differently in text and math mode contexts extends to punctuation marks: Characters such as
,
(comma),:
(colon),;
(semi-colon), and!
(exclamation mark/factorial) generally have different meanings in text and math mode; the spacing around them reflect the context in which they occur. (Note that I'm not talking about symbols such as+
and=
which usually occur only in math mode. The appearance of the latter two symbols in text mode is generally a signal of poor typography.)Third, using different fonts for text and math provides an important degree of freedom from the point of view of document design: Even though you, personally, may be content using the same font family (e.g., Computer Modern, Latin Modern, newtx, or newpx) for both text and math material, others may not. E.g., somebody might prefer to use
newpxtext
(a Palatino clone) withnexpxmath
, whereas someone else might prefer to combine it witheulervm
. To provide this degree of design freedom, it's almost certainly necessary to store math and text fonts in separate files.
Finally, here's the code used to generate the example shown above.
\documentclass{article}
\usepackage[showframe]{geometry} % draw vertical lines around text block
\setlength\parindent{0pt} % just for this example
\usepackage{newtxtext,newtxmath}
\begin{document}
\emph{f\kern0pt ly} % text italic mode
$fly$ % math (italic) mode
\emph{o\kern0pt f\kern0pt f\kern0pt ice}
$office$
\end{document}
First of all, \everymath={\scriptsize}
is wrong. It somehow works, but with warnings. So, open an \hbox
which takes you out of math mode, select \scriptsize
, open a formula in \displaystyle
and, at the end, close the formula and the box.
\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{mathtools}
\newenvironment{reduce}
{\hbox\bgroup\scriptsize$\displaystyle}
{$\egroup}
\begin{document}
\begin{align*}
T & =
\begin{reduce}
\begin{bmatrix}
\cos(x) %this works, i.e. the font becomes scriptsize
\end{bmatrix}
\end{reduce}
\\
& =
\begin{bmatrix}
\cos(x) %this is to compare size with the above
\end{bmatrix}
\\
& =
\begin{reduce}
\cos(x) %this does not work, font size does not change!
\end{reduce}
\end{align*}
\end{document}
Best Answer
While it is true that one is to be used in text mode, the other in math mode, also remember, smaller than
\scriptsize
is\tiny
, but a script of a\scriptstyle
is a\scriptscriptstyle
. Thus, the context of the two terms (\scriptsize
and\scriptstyle
), while both using the word script, is actually different. One refers to font size, the other to sub- and super-scripting.We can see that they are fundamentally different in the following MWE, where
\scriptstyle
does not produce something in\scriptsize
if one was already in\scriptsize
to begin with. That is to say, the finalX
is not in\scriptsize
, even though\scriptstyle
is invoked at the time.As to how it is brought about in TeX, know that
\scriptstyle
is one of the boxes built via\mathchoice
(the other three are\displaystyle
,\textstyle
, and\scriptscriptstyle
) whereas none of that process applies to the invocation of\scriptsize
which changes the font size characteristics. You could even say that\scriptstyle
shares more in common with\displaystyle
(in terms of how it is implemented) than with\scriptsize
.