2

I want to write the partial derivative of a function, while making the parameters of that function explicit, like so:

\dfrac{\partial f(x, y)}{\partial x}

But this leads to an elongated horizontal line, which I don't think looks very nice (although it's possible that this is just the right way of doing it, and I should live with it). I have seen some books where the line ends before the parentheses start, so that df and dx are aligned.

Another way is:

\dfrac{\partial f}{\partial x}(x, y)

but then the parentheses are not level with the function, and in fact, this kind of changes the meaning of the line.

  • Is the first approach the standard / usual way of doing it? I've seen both approaches in textbooks and papers.
  • Is there a third, more correct way of placing the parentheses, that I am not aware of?

Edit: Adding compilable code and screenshot of output.

Code that can be compiled to reproduce the two methods:

\documentclass[11pt]{scrartcl}

\usepackage{amsmath}

\title{}
\author{}
\date{}

\begin{document}
\maketitle

\begin{itemize}
    \item Method 1
    \begin{equation*}
        \dfrac{\partial f(x, y)}{\partial x}
    \end{equation*}
    \item Method 2
    \begin{equation*}
        \dfrac{\partial f}{\partial x}(x, y)
    \end{equation*}
\end{itemize}

\end{document}

Output it produces:

output of the two methods

Thanks!

0
1

I’ve usually seen it written either f_x (x, y)or the second way, that is \dfrac{\partial f}{\partial x} (x, y).

I’m not sure exactly what you mean by parentheses “level with the function.” If you want the parentheses to match the height of the fraction, you might use this unusual formatting:

\documentclass[varwidth, preview]{standalone}
\usepackage[T1]{fontenc}
\usepackage{textcomp, amssymb}
\usepackage{mathtools}

\makeatletter
\newsavebox\frac@box

\newcommand\dfracparens[3]{%
\sbox{\frac@box}{\ensuremath{\dfrac{#1}{#2}}}%
\usebox{\frac@box}%
\left( \vphantom{\usebox{\frac@box}}%
       \vcenter{\hbox{\(#3\)}}%
\right)%
}
\makeatother

\begin{document}
\( \dfracparens{\partial f}{\partial x}{x, y} \)
\end{document}

Sample of large parentheses

That version forces the parentheses to be at least as tall as the fraction by inserting a \vphantom inside them, then vertically aligns the contents inside a box.

To get vertical alignment between the numerator and the following parentheses, you could use:

\documentclass[varwidth, preview]{standalone}
\usepackage[T1]{fontenc}
\usepackage{textcomp, amssymb}
\usepackage{mathtools}

\makeatletter
\newlength\numerator@height
\newlength\frac@height
\newsavebox\numerator@box
\newsavebox\frac@box

\newcommand\dfracparens[3]{%
\sbox{\numerator@box}{\ensuremath{#1}}%
\sbox{\frac@box}{\ensuremath{\dfrac{#1}{#2}}}%
\settoheight{\frac@height}{\usebox{\frac@box}}%
\settoheight{\numerator@height}{\usebox{\numerator@box}}%
\addtolength{\frac@height}{-\numerator@height}%
\usebox{\frac@box}%
\raisebox{\frac@height}{%
\( \left( {#3} \right)
\)}%
}
\makeatother

\begin{document}
\( \dfracparens{\partial f}{\partial x}{x, y} \)
\end{document}

Example of raised parentheses

That version raises the parentheses by the difference between the height of the fraction and the height of the numerator. (It would need to be tweaked to lower the parentheses if necessary, but you might not want to match the depth of, say, subscripts in the numerator.)

2
  • The second suggestion is exactly what I was looking for - thanks. – josh_eime Feb 10 '19 at 16:43
  • @EM_IE Great! It ought to suffice for this simple use case. – Davislor Feb 10 '19 at 17:31
1
\[\left.\frac{\partial f}{\partial x}\right|_{(x,y)}\]
\[\left.\frac{\partial f}{\partial x}\right|_{(x,y)=(x_0,y_0)}\]

enter image description here

2
  • The diffcoeff package or the cool package might be more helpful, since you can automate the layout of partial derivatives, and then you can more easily change your mind later about how you want them laid out. – Benjamin McKay Feb 10 '19 at 14:07
  • I might be wrong, but I think this conveys a different meaning from what I had intended. I wanted to express that "f is a function of x and y, and now I'm going to differentiate it w.r.t. x", rather than "differentiate f w.r.t. x, and then evaluate it at (x, y)". – josh_eime Feb 10 '19 at 16:50

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.