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.
Perhaps you meant something like the following, note that dcases
must be in mathmode
, and ideally in displayed mathmode
such as
\[...\]
\begin{equation}...\end{equation}
\begin{equation*}...\end{equation*}
Here's a complete MWE:
% arara: pdflatex
\documentclass{article}
\usepackage{mathtools}
\begin{document}
Let $g: N \rightarrow N$ be given by
\[
n=
\begin{dcases*}
1 & if $n=1$ \\
n-1 & if $n \ne 1$
\end{dcases*}
\]
\end{document}
For future reference, you can view pages 17 and 18 of the documentation
which describe that
dcases
puts every column in mathmode
dcases*
puts only the first column in mathmode
, and the second column in the normal roman font of the document (hence the need to step back into mathmode
in the second column)
Best Answer
Before you load the offending package, put
and then you can say
Erd\Horig{o}s