29

Every time I want to write an (ordinary) derivative I have to use frac, like this:

\frac{\mathrm{d}^2 \omega}{\mathrm{d}\theta^2}

Or using \partial for partial derivatives.

Is there a package or a command that takes, for instance, (Ordinary or Partial, Power of derivative, variables) and outputs the formatted expression?

3
  • one is physics for other i temporary don't remember a name :-( – Zarko Jan 27 '18 at 17:28
  • 2
    Certainly you can define abbreviations, but I would recommend not doing this since you may want to share your TeX code with others. Then you probably don't want to mess with their shortcuts, and the others may not be too excited about yours either. Use shortcuts in your editor instead. – user121799 Jan 27 '18 at 17:28
  • \partial, for example. – Oleg Lobachev Jan 27 '18 at 17:35
36

You can use the esdiff package, which has handy macros for derivatives and partial derivatives, taking care of indices. Here is a demo;

\documentclass{article}%

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{mathtools}
\usepackage[thinc]{esdiff}

 \begin{document}

\begin{alignat*}{3}
     \diff{f}{x} &\qquad \diff*[4]{g}{t}{t = 1} \\[2ex]
     \diffp{f}{x} &\qquad\diffp{g}{tu}& & \qquad & \diffp*{g}{{t^2}{u^3}}{(0,0)}
 \end{alignat*}

 \end{document}

enter image description here

6
  • +5 for my friend. I still have the account stuck on Mathematics. Could you please take a look at my combinatorial question and publish it, please? – Sebastiano Jan 27 '18 at 20:49
  • @ Sebastiano: Do you mean, publish it in my name, or edit yours? Or if you want, I know a combinatorial proof for your question? – Bernard Jan 27 '18 at 21:11
  • Edit my question and after you give me a combinatorial proof for your question. The answers are blocked – Sebastiano Jan 27 '18 at 21:12
  • @Sebastiano: I've modified your question (without changing its title) to put it in a more general context. Please see if it's OK. I'm not sure it will be enough to re-open it, though. – Bernard Jan 27 '18 at 21:29
  • 1
    @ParthaD.: No there is n't. But you may take a look at the diffcoeff package, which has a \dl command and is quite customisable through a set of options, and a config file if you want. – Bernard Feb 17 '19 at 10:39
21

Oh, you mean not symbol, but operator. There is physics, as stated by @Zarko.

  • \differential produces the variants of d: \dd x
  • \derivative yields the $df/dx$ in variants: \dv{x}, \dv{f}{x}
  • \partialderivative produces the partial symbol in derivaties a la carte, similar to \dv, use \pdv x, etc.
  • \variation and \functionalderivative are also there, e.g. \fdv{F}{g}.

It's all in the documentation on pages 5-6, say texdoc physics for the pdf.


Screenshot from the document.

enter image description here

9

There is also another important and easy package to write ordinary derivate and partial derivatives named derivative. I have added only some simple examples how to use this package where the d ("classical derivate") is written in roman.

enter image description here

\documentclass[12pt]{article}
\usepackage{derivative}
\usepackage{amsmath,amssymb}
\begin{document}

\[\odv{f(x)}{x}, \qquad \odv[n]{f(x)}{x}, \qquad \pdv[\alpha,b,c]{f}{x,y,z}\]
\[\pdv{f}{x,y}, \qquad \odv{e^{\tan(x)}}{x}, \qquad \odv{\cos t}{t}_{t=0}^{}\]
\end{document}
7

One option is to use \newcommand. Add the following lines to the preamble of your document

\newcommand{\pd}[2]{\frac{\partial{#1}}{\partial{#2}}}
\newcommand{\pdd}[2]{\frac{\partial^2{#1}}{\partial{#2}^2}}

These can be used within the document as follows

\pd u t = \pdd u x

Result:

enter image description here

Of course, \pd{u}{x} is preferable aesthetically and often the only correct syntax, but I am mainly trying to illustrate a minimal method to print the derivatives.

3

There is also another package (commath) that provides, along with many other commands for general mathematical typesetting, a few ways to print derivatives via \od, \pd or \md. These commands automatically choose the dimensions for text or display style. You can also use \tod, \tpd or \tmd for text style derivatives and their relative \dod, \dpd and \dmd versions.

\documentclass[12pt]{article}

\usepackage{commath,amsmath}

\begin{document}
  \begin{equation*}
    \od{f}{x},\qquad\pd{f}{x},\qquad\pd[2]{f}{x}
  \end{equation*}
  \begin{equation*}
    \od[2]{f}{x},\qquad\md{f}{4}{x}{3}{y}{ }
  \end{equation*}
  \begin{equation*}
    \tod{f}{x},\qquad\tpd[2]{f}{x},\qquad\tmd{f}{4}{x}{3}{y}{ }
  \end{equation*}
\end{document}

example

1
  • That's very good. I didn't know this package. In fact, it's a little old. – Sebastiano Mar 23 '20 at 15:40
3

Another package datated December 28, 2019 is diffcoeff to write the differential coefficients. Here there is some examples:

\documentclass[a4paper,12pt]{article}
\usepackage{diffcoeff,amssymb}


\begin{document}

\begin{equation}
    \diffp L{q_k}-\diff*{\diffp L{\dot{q}_k}[]}t = 0
\end{equation}

\begin{equation}
    \diffp {F(x,y)}x[(1,-4)]
\end{equation}

\begin{equation}
    \diffp*{\diff{x^\mu}{y}}{x^\lambda}
\end{equation}

\end{document}

enter image description here

There is not only the symbol of partial but also the classical derivates d/dx.

0

For macOS users of iWork

The solution pointed out by @pulkit (define a new command) is your only choice if you are typesetting in the iWork office suite.

These are the commands he proposed:

\newcommand{\pd}[2]{\frac{\partial{#1}}{\partial{#2}}}
\newcommand{\pdd}[2]{\frac{\partial^2{#1}}{\partial{#2}^2}}

In case you don't know, you can use LaTeX and MathML in all iWork apps (see here).
Go to Insert > Equation... or press E.

However, in iWork you cannot import a package, but you are allowed to define new commands.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.