6

This question has been bugging me for a long time: How do I properly typeset volume integrals? I would like to use the convention often used in Physics: d^3x=dV and \int dx f(x) instead of \int f(x) dx

Example:

    The kinetic energy is simply given by
    \begin{equation}
      T = \int\,\mathrm{d}^3\mathbf{x}\frac{\rho}{2} \mathbf{\dot x}^2 = \frac{3}{10}M\dot R^2\;.
    \end{equation}

But the integral looks somehow bad as the spacing between the x and the d is too big. How can I change this?

Nils L
  • 9,716
  • 1
    you can tweak the spacing by yourself, try with \! or \mkern. This may be useful or not: http://tex.stackexchange.com/questions/67912/large-negative-spaces – ShinTakezou May 02 '13 at 13:45

1 Answers1

5

Maybe the following is what you're after:

output

I raised the 3 quite a bit and slightly moved it to the left; this way I could move the x much closer to the d. Here's the code for a command \d that takes one optional and one mandatory argument:

\documentclass{article}
\usepackage{calc}
\renewcommand*\d[2][]{%
  \mathrm{d}%
  \ifx\relax#1\relax\else
    \rule{-0.05em}{1.9ex}^{#1}\!
  \fi
  #2\,
  }
\begin{document}
\[
  \int \d[3]{\mathbf{x}} \frac{\rho}{2} \mathbf{\dot x}^2 \qquad
  \int \d{\mathbf{y}} f(\mathbf{y})
\]
\end{document}

Note that this only works for "small" integration variables like x. Moreover, I removed the \, between \int and \mathrm{d} that you had and put it after the differential instead. You can of course adjust this to your needs.

Hendrik Vogt
  • 37,935
  • Thanks, that helps! A friend pointed out, though, that the "x" should not be bold, as it is not a vector in that context. What do you say to that? – user1834164 May 03 '13 at 06:54
  • If the x in \dot x is bold, than I'd also make it bold in the differential. (Personally, as a mathematician, I make neither of them bold.) – Hendrik Vogt May 03 '13 at 07:35