TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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*?

share|improve this question
I think the following is a duplicate: Difference between \textrm{} and \mathrm{} – Werner Mar 2 '13 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 '13 at 10:58
up vote 5 down vote accepted

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

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).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.