# how to encourage custom commands to adopt the math font

When defining new commands or math operators, I have trouble convincing the operator to adopt the ambient math font instead of the default CM font. I observed that if I use the mathdesign package, then the operators do my bidding, but I want to use eulervm or other packages.

\documentclass{article}
\usepackage{eulervm} % eulervm for math
\usepackage{bera} % bitstream font for text
\newcommand{\tot}{\mathrm{tot}}

\begin{document}
This text is bitstream, X'' below is eulervm. Problem: tot'' is CM.
$f: X \to \tot(L)$
\end{document}

-

As the documentation says:

Function names as well as math accents are taken from the default text font family. This holds for the math alphabets \mathrm and \mathbf, too. The eulervm package determines the default font family (i.e., the meaning of the macro \familydefault) at load time and will apply it for the above purposes then. In the same way, the math alphabets \mathsf and \mathtt are mapped to \sfdefault and \ttdefault. Thus, you should redefine the default text fonts before loading the eulervm package!

Which means that \mathrm etc will use the textfont families. So if you want eulervm you should either use the chars directly:

\documentclass{article}
\usepackage{bera} % bitstream font for text
\usepackage{eulervm} % eulervm for math
\newcommand{\tot}{\mathrm{bitstream}}
\newcommand{\tat}{\mathsf{sffamily}}
\newcommand{\tit}{\mathtt{ttfamily}}
\begin{document}
This text is bitstream, X'' below is eulervm. Problem: tot'' is CM.
\textsf{sffamily}, \texttt{ttfamily}

$f: X \to eulervm, \tot, \tat, \tit$
\end{document}


Or define/redefine your own math alpabeth:

\documentclass{article}
\usepackage{bera} % bitstream font for text
\usepackage{eulervm} % eulervm for math
\DeclareMathAlphabet{\matheuler}  {U}{zeur}{m}{n}
\begin{document}
This text is bitstream, X'' below is eulervm.

$f: X \to \matheuler{eulervm}$
\end{document}

-

Use eulervm (math) after bera (text).

\documentclass{article}
\usepackage{bera} % bitstream font for text
\usepackage{eulervm} % eulervm for math
\newcommand{\tot}{\mathrm{tot}}

\begin{document}
This text is bitstream, X'' below is eulervm. Problem: tot'' is CM.
$f: X \to \tot(L)$
\end{document}

-
 Your solution puts "tot" in bera, not eulervm. Since it is defined using \mathrm, I would expect it to use the math font... – mgualt Dec 7 '11 at 8:26 @mgualt: Well, LaTeX usually uses text font for \mathrm, \mathsf and \mathtt by default. This is also what other font packages do. Personally, Euler fonts are not very good for \mathrm, the \mathnormal and \mathrm should differ. And of courcse you can redefine \mathrm using \DeclareMathAlphabet or \DeclareSymbolFontAlphabet if you wish. – Leo Liu Dec 7 '11 at 11:22