# How can I fully replace \mathsf without using a math alphabet?

Currently I have to reduce math fonts used in an article. In spite of this, I do not want to lose these features. Hence I have found a method: replace math version by text version.

E.g. assume we used \mathsf. Add a code in the head: \renewcommand{\mathsf}{\textsf}. Then one room of mathalphabet will be vacated.

However what are differents between \mathsf and \textsf? They look the same, moreover \mathsf can be used in math mode only whereas \textsf can also be used in text mode; but \textsf can be used in math mode too, so what is the necessity for \mathsf? Moreover, why not replace all \math* to \text*?

-
I think the following is a duplicate: Difference between \textrm{} and \mathrm{} –  Werner Mar 2 at 5:47
The question linked to by Werner is not really a full duplicate; if you change your question to be more "how can I fully replace \mathsf without using a math alphabet", it won't be a duplicate any more. –  egreg Mar 2 at 10:58

The main problem is that \textsf only changes the current family to \sfdefault (which corresponds to whatever the class or loaded packages set, the default out of the box is cmss for Computer Modern Sans), as explained in Difference between \textrm{} and \mathrm{} for \textrm and \mathrm, but the same concepts apply here.

By loading amsmath, all \textXY commands can be used in math mode and they automatically change size according to the current math style (\displaystyle and \textstyle in the current font size, \scriptstyle and \scriptscriptstyle reduced size, depending on the current font size).

On the contrary, \mathsf is usually set up for choosing sans serif upright medium, in the current font size (or reduced in subscripts and superscripts). This is much more efficient in terms of processing time than using \textsf, but in cases when one is short of math groups, a good alternative is to avoid using up one of them just for a little number of cases.

One can do with

\usepackage{amsmath} % for enabling reduced size in sub/superscripts
\let\mathsf\relax    % just to avoid a message in the log file
\DeclareRobustCommand{\mathsf}[1]{\text{\normalfont\sffamily#1}}


that ensures the same font selection as made by \mathsf, independently of the context. This redefinition should be made after loading font packages that can issue a \DeclareMathAlphabet{\mathsf} command.

If \mathsf has not been used in advance for typesetting (usage in definitions are not important), a math group will be effectively saved at the expense of processing time (some milliseconds, probably, with fast machines).

-