# why \everymath{\scriptsize} works with matrix environment only?

I need to make one equation in an {align*} env. to have very small font, since the matrix is too wide. So I use this method, found in how-can-i-change-the-font-size-in-math-equations

\begingroup
\everymath{\scriptsize}
\scriptsize
\begin{bmatrix}
.... very wide matrix here..
\end{bmatrix}
\endgroup


This always worked, even though I see LaTeX Font Warning: Command \scriptsize invalid in math mode on input line .... all the time. So I ignored these since it works and it does make it scriptsize font.

But now what I tried it on normal math, i.e. not matrix environment, it had no effect, and the math size did not change.

I'd like to ask why it works for bmatrix and not for normal math. Here is a MWE

\documentclass[11pt]{article}%
\usepackage{amsmath}
\usepackage{mathtools}
\begin{document}
\begin{align*}
T   &  =
\begingroup
\everymath{\scriptsize}
\scriptsize
\begin{bmatrix}
\cos(x)    %this works, i.e. the font becomes scriptsize
\end{bmatrix}
\endgroup
\\
&  =
\begin{bmatrix}
\cos(x)    %this is to compare size with the above
\end{bmatrix}
\\
& =
\begingroup
\everymath{\scriptsize}
\scriptsize
\cos(x)    %this does not work, font size does not change!
\endgroup
\end{align*}
\end{document}


Here is the pdf

We can see it did work for the first case, but not for normal math. Note that I need to change one equation inside a large align env. And not the whole aligned env. So that is why I use this method as I do not know another way to do this.

• it's "too late" to change sizes one you're inside math mode. you need to get back into text mode. try \text{\scriptsize $\begin{bmatrix} ... \end{bmatrix}$}. – barbara beeton Feb 15 '15 at 1:52
• @barbarabeeton thanks! your method works and is much better and no warnings. But the question remains, as to why it worked for matrix above? I guess at this point, it is not really important for me to know why, since I'll just use your method and it works for both cases. But may be some one can find the reason interesting. – Nasser Feb 15 '15 at 2:02
• can't give a sensible answer right now; i think it may be a restriction of what tex itself allows in math mode, but to know for sure, have to do some digging into code and possibly tex-the-program. i do know i'm tired of seeing the warnings about "invalid in math mode", but haven't ever bothered to do the digging. – barbara beeton Feb 15 '15 at 2:30

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}