It turns out that the problem was that I used
\usepackage{times}.
When I remove this package everything is great. In order to keep the nice fonts in the text mode I use
\usepackage{mathptmx}
\usepackage[scaled=0.9]{helvet}
\usepackage{courier}
Here is an alternative to your current situation - using an optional argument to specify the derivative order. This way you don't have to define a macro for "each" derivative:
\deriv[<order>]{<func>}{<var>}
Here's a minimal example:
\documentclass{article}
\newcommand{\deriv}[3][]{% \deriv[<order>]{<func>}{<var>}
\ensuremath{\frac{\partial^{#1} {#2}}{\partial {#3}^{#1}}}}
\begin{document}
In text mode there is~\deriv{y}{x} and~\deriv[2]{y}{x}. In display mode there is
\[
\deriv{y}{x}\ \textrm{and}\ \deriv[2]{y}{x}\rlap{.}
\]
\end{document}
The default <order>
is empty, implying the first order partial derivative. If you want the default to be 2
, modify the definition to read
\newcommand{\deriv}[3][2]{...}
Technically it is possible to use a macro with numbers in them, but the usage is much less intuitive than adding something like an optional argument (as given above). Here's an implementation that now allows you to use \nameuse{deriv2}{y}{x}
:
\expandafter\def\csname deriv2\endcsname#1#2{%
\ensuremath{\frac{\partial^2 {#1}}{\partial {#2}^2}}}
\makeatletter
\newcommand{\nameuse}[1]{\@nameuse{#1}}%
\makeatother
The optional argument beats this hands down.
Best Answer
Use the
serif
option to set the default family to roman, then set\rmdefault
and\mathfamilydefault
as you please:Note: Next time, please post a minimal working example (MWE) outlining at least one of the 'many combinations' you tried ;-)