I would like to have a “math upright” command that would automatically conform to the “normal” math typeface of the document. By “normal” math typeface here I mean the typeface that is used if I just type any simple math formula (such as a + b = c) in my document.
That is, in an article, this “math upright” command would behave like \mathrm, but in a beamer presentation (which uses sans serif maths), it wouldn’t behave like \mathrm (which switches to serif).
I am thinking of defining a command \mathup, that I could use as \mathrm, but which would not switch to roman if the rest of the math is not in roman.
I thought about using \DeclareMathAlphabet{\mathup}{OT1}{\familydefault}{m}{n} (as suggested here) but as pointed out by David Carlisle in the comments (if I understood correctly), this is not a good idea because it ties the math “upright” font to the text family default, and not to the normal math typeface as I want.
\mathrm? but all the standardard ones use OT1, eg\DeclareMathAlphabet {\mathsf}{OT1}{cmss}{m}{n}so that but replacingcmssby\familydefaultI guess. – David Carlisle May 09 '20 at 11:10mathupcommand I dream of means “please now write in math upright and keep the rest (font family, font size…) intact.mathrmdiffers. I think most uses ofmathrmin the wild are semantically wrong in the sense that I suspect that the user meansmathup(it’s just that in many cases there is no difference, difference appears if you copy-paste formulæ to a beamer presentation for example). – Olivier Cailloux May 10 '20 at 11:25\mathrmbe whatever font you want, it's not normal to make the math fonts rely on the external text font setup. If you do not chose OT1 you have to redefine almost all the math symbol declarations which assume OT1 layout (eg upper case Greek in the control code slots of the roman font) that is why lualatex and xelatex default to OT1 math even though they use TU text fonts – David Carlisle May 10 '20 at 11:46mathrmchanges the font that is normally used for math. You are right that I shouldn’t use defaultfamily as that one is for text, not math. – Olivier Cailloux May 10 '20 at 12:14\logI think you should make\mathrmdo the, same (and make \mathsf` do something else, perhaps picking a visually distinct different sans serif font) – David Carlisle May 10 '20 at 12:39\mathrmprint in sans serif strikes me as an implementation of the advice @UlrikeFischer jokingly gives here: “You can also confuse everyone by defining \mathbf to be light itshape palatino and \mathit a bold Arial.” – Olivier Cailloux May 10 '20 at 12:45mathrm, if I understand correctly, says: switch to math roman (thus, with serif). You are right that typing in math upright should type using the usual math font (only upright), but I don’t think it’s nice to the reader of my code or user of my template thatmathrmwould not switch to a roman font by second-guessing the user’s intent. Hence my hope for defining another command that does the right thing and has an appropriate name. You may be right that what you propose is a practical solution to the problem, however. – Olivier Cailloux Jun 10 '20 at 07:33\mathrmis\DeclareSymbolFontAlphabet{\mathrm} {operators}That is, it is not defined as "make a serif roman font" it is defined as "use the same font as used for operators like log" you could define a command with a more semantic name like\DeclareSymbolFontAlphabet{\mathwhatever} {operators}but it would be the same as mathrm (not that that is necessarily a bad thing) – David Carlisle Jun 10 '20 at 07:58\mathrmdoes not behave in the right way in a Beamer presentation, if what one wants is to type upright but not change the typeface: in Beamer,\mathrmtypes upright, but also switches typeface. This is the right behavior considering that it satisfies what the command says it does according to its name, but not the right behavior if one wants the thing you say (and I agree) everybody really wants when typing upright (that is, not switch the typeface). – Olivier Cailloux Jun 10 '20 at 08:19\mathrm, because of its name, is: make the font roman. Now we can decide that this is a misunderstanding of me (and a poor naming choice) and that its contract really is: type upright and do not touch the typeface. In both cases, there is a problem with beamer presentations when one desires to type upright without changing the typeface. – Olivier Cailloux Jun 10 '20 at 08:26sansmathfontsfor beamer as the roman stuff works better and\mathrmis mapped to\mathsf. – daleif Jun 10 '20 at 08:59\mathrm. A) Switch to roman family; B) Use the same font as used for operators (thus, generally, not switching family). Interpretation A) is reasonable considering the name of the command and the example Lamport gives page 51 of The Book. Interpretation B) is reasonable considering that this is probably what the user really wants. – Olivier Cailloux Jun 11 '20 at 09:39