What is the cleanest way to redefine math-mode font commands such as \mathrm
and \mathit
?
I would like everything else to be unaffected; for example, perhaps I enjoy working with mathptmx
and I want to keep its \mathnormal
, but I want to change \mathrm
and mathit
to use a different font.
\documentclass{article}
\usepackage{mathptmx}
\begin{document}
Some text.
Some formula: \(abc = de/f \quad[\mathrm{var}, \mathit{val}]\)
\(\mathnormal{abc = de/f}\)
var, \textit{val}
\(\mathrm{var}, \mathit{val}\)
% Bitstream Charter
{\fontfamily{bch}\fontseries{m}\fontshape{n}\selectfont var,
\fontfamily{bch}\fontseries{m}\fontshape{it}\selectfont val}
% Linux Biolinum
{\fontfamily{LinuxBiolinumT-OsF}\fontseries{m}\fontshape{n}\selectfont var,
\fontfamily{LinuxBiolinumT-OsF}\fontseries{m}\fontshape{it}\selectfont val}
% Linux Libertine
{\fontfamily{LinuxLibertineT-OsF}\fontseries{m}\fontshape{n}\selectfont var,
\fontfamily{LinuxLibertineT-OsF}\fontseries{m}\fontshape{it}\selectfont val}
\end{document}
Best Answer
Just redefine the macros
\mathrm
and\mathit
to use a different font: the interface isYou can also supplement the font for a different math version: say also
for defining the font to be used in a
\boldmath
(or\mathversion{bold}
) context.An example follows. But beware that using Charter for
\mathrm
and\mathit
is a typographical nonsense. Here's the visual proof of my claim.Instead of
\DeclareMathAlphabet
one can define a substitute that won't eat up math families:and use it as
or even