8

I would like to print the partial derivative operator $\frac{\partial}{\partial k_x}$, but the spacing and the length of the bar bug me a little. I would really like the fraction to be typeset as $\frac{\partial}{\partial k}$ (which has a shorter bar and the upper $\partial$ further to the left), with the subscript ${}_x$ added afterwards.

I'm definitely sure this is possible. What would be the quickest, cleanest way?

0

4 Answers 4

9

enter image description here

\documentclass{article}
\begin{document}


1 $\frac{\partial}{\partial k}$

2 $\frac{\partial}{\partial k_x}$


3 $\frac{\partial}{\partial k}_{\scriptscriptstyle x}$

4 $\frac{\partial}{\partial k_{\rlap{$\scriptscriptstyle x$}}}$


\end{document}
2
  • Your solution 4 does what the OP wants, but it has the same drawback (mentioned by Matthew Leingang) as A. Ellett's answer. Feb 19, 2013 at 11:24
  • 1
    yes true any version that hides the width inside the frac ought to add some white space after the frac to compensate. Feb 19, 2013 at 11:46
5

Here's a solution that works with \mathrlap from the mathtools package, combined with a \phantom to get proper spacing after the derivative. (It's not so efficient since I nested \mathrlap.)

output

\documentclass{article}
\usepackage{mathtools}
\newcommand*\xpartial[2]{%
  \mathrlap{\frac{\partial}{\partial #1_{\mathrlap{#2}}}}%
  \phantom{\frac{\partial}{\partial #1_{#2}}}%
  }
\begin{document}
$\frac{\partial}{\partial k_x} g$ versus $\xpartial{k}{x} g$
\end{document}

(By the way, I would have expected x_k, not k_x in the denominator.)

1
  • The derivative is with respect to the $x$ component of a wave vector $\mathbf{k}$.
    – E.P.
    Feb 28, 2013 at 17:41
4

Using mathtools there is \mathmakebox which behaves much like \makebox but is sensitive to the mathematical context and will set things correctly:

Or as @Qrrbrbirlbel suggested, you can use \mathrlap and its ilk. I illustrate both \mathmakebox and \mathllap here (I've never like the way the numerator and denominator are off set when you want a negative in the numerator).

\documentclass{article}
\usepackage{amsmath,amssymb,mathtools}
\pagestyle{empty}
\begin{document}
    \[
        \frac{\partial}{\partial k_{\mathmakebox[0pt][l]{x}}}
    \]


    \[
        \frac{\mathllap{-}1}{2}
    \]
\end{document}

enter image description here

What I like about \mathmakebox is that it allows you define the width of the box and the positioning. Probably for your purposes, \mathrlap is all you need.

5
  • 2
    Hint: \mathrlap Feb 18, 2013 at 18:04
  • 3
    But the subscripted x now crashes into whatever would follow this symbol. Consider \frac{\partial}{\partial k_{\mathmakebox[0pt][l]{x}}}\frac{k_x}{k_x + k_y}. Maybe you should add a \phantom{\scriptstyle x}? Feb 18, 2013 at 18:07
  • @MatthewLeingang indeed. I was a bit hasty and neglected to think of the spacing issue.
    – A.Ellett
    Feb 18, 2013 at 18:12
  • 1
    Should have said \scriptscriptstyle x, sorry. Feb 18, 2013 at 18:15
  • 2
    why to load both amsmath and mathtools?
    – user11232
    Feb 18, 2013 at 22:43
1

Bingo! Got it. Some negative space does it: $\frac{\partial}{\partial k_x\!\!\!}\,$

2
  • 1
    No, in all honesty, you did not get it: Using \!\!\! and \, just "almost next to each other" shows that something is wrong.
    – yo'
    Feb 28, 2013 at 16:10
  • 2
    @tohecz: The only problems I see here is that 1. one has to guess the spacing and 2. the positive spacing with \, is too small so that one can have an overlap. The \! and \, are only almost next to each other, and this makes a lot of sense. Feb 28, 2013 at 19:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .