He who knows not and knows not he knows not: he is a fool - shun him. He who knows not and knows he knows not: he is simple - teach him. He who knows and knows not he knows: he is asleep - wake him. He who knows and knows he knows: he is wise - follow him.

# A New Latex Macro

In a recent attempt to make a general partial derivative macro i came across the xparse package.

The problem is that the default latex macro command \newcommand only allows for one optional argument and I wanted to make a command that could take 3 argument. The variable, the function, and the order of derivative. I turns out that this is not so easy as it might sound. At lest not without using xparse. With xparse it is quit easy.

First we call the xparse package as usual with \usepackage{}. Then we use \DeclareDocumentCommand which takes on 3 values. First we have to give your macro a new name. I choose \pder for partial derivative.1 The second command defines optional and mandatory arguments. I choose the first 2 variables to be optional by o{}. You can put a default value in {} if you desire. The last file is simply the latex formula with #1 for the first variable, #2 for the second and so on.

If we then call

the result is

$\frac{\partial}{\partial&space;x}&space;$

$\frac{\partial&space;f}{\partial&space;x}$

$\frac{\partial^2&space;f}{\partial&space;x^2}$

1. Don’t use \pd. It does not work.