12

I came across some spacing glitches when I use the f symbol (I'm not having similar weirdness with most other symbols). Here's a very simple MWE to show the issue:

\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{microtype}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathtools}
\usepackage{tensor}
\newcommand*{\kp}[1]{\mskip+#1mu}
\newcommand*{\kn}[1]{\mskip-#1mu}

\begin{document}

    \begin{equation}
        \frac{d f}{d r} = \frac{d\kp1 f}{d\kp1 r} = \frac{d\kp1 \kn2 f}{d\kp1 r}.
    \end{equation}

\end{document}

Preview:

enter image description here

The case A is too tight for my taste. I frequently add some small space between symbols to "kern" my equations. Adding a simple 1/3 of a small space (\,) between d and f gives an output space that is too large, while it's not the case with other symbols (case B). Then adding 1/3 and removing 2/3 gives a nice output (case C). What is going on here? How can I use the f symbol without having to add some kerning each time with it?

11
  • My guess is the \mskip interferes with the natural kerning mechanism built into the font. The fact that \kp0 changes the result seems to indicate this, Commented Apr 1, 2021 at 17:06
  • 6
    Just compare df and d{}f to get an idea of what is going on. Commented Apr 1, 2021 at 17:07
  • I was just about to say what @HenriMenke said Commented Apr 1, 2021 at 17:08
  • 3
    For differentials in particular you may also be interested in the diffcoeff package on CTAN.
    – chsk
    Commented Apr 1, 2021 at 17:12
  • 1
    @Sebastiano that's fine. The whole point of the site is to provide useful answers, is it not? And yours definitely is.
    – chsk
    Commented Apr 3, 2021 at 16:04

3 Answers 3

20

The cmmi10 font (and this is followed by lmmi10) has specifically a kerning between d and f:

(CHARACTER C d
   (CHARWD R 0.520488)
   (CHARHT R 0.694445)
   (COMMENT
      (KRN C Y R 0.055555)
      (KRN C Z R -0.055555)
      (KRN C j R -0.111112)
      (KRN C f R -0.166667)
      (KRN O 177 R 0.166672)
      )
   )

exactly in order to avoid the unsightly hole that you seem to like.

Here's my suggestions: I'd use \standarddiff, you might prefer \chamdiff (rename your choice to \diff or whatever you like).

\documentclass{article}
\usepackage{amsmath}
\usepackage{lmodern}
\usepackage{fixcmex} % don't forget with lmodern

\newcommand{\standarddiff}{\mathop{}\!d}
\newcommand{\chamdiff}{\mathop{}\!d\/}

\begin{document}

$\standarddiff f \quad \standarddiff j \quad \standarddiff r$

$\chamdiff f \quad \chamdiff j \quad \chamdiff r$

$d\mkern1mu f$ $d\mkern-1mu f$

\end{document}

Either no kerning (1mu is not good, in my opinion), or the standard.

enter image description here

10

You might be interested in the esdiff package, which takes care of the spacing problem, and simplifies the typing of Leibniz notation, for both ordinary and partial derivatives. By default the differential symbol is in roman, but you have the [italic] option at loading time.

Unrelated: needless to load amsmath if you load mathtools, which is an extension of the former.

Here is an example:

\documentclass[11pt, letterpaper, twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{microtype}
\usepackage{amsfonts}
\usepackage{mathtools}

\usepackage[italic]{esdiff}

\begin{document}

    \[ \diff{f}{r}, \quad \diff[2]{f}{r}, \qquad \diffp{h}{{x^2}{y}}. \]

\end{document} 

enter image description here

10

You could to use also diffcoeff package like this minimal example:

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage{diffcoeff}
\begin{document}
\[\diff[1]fr=\diff{\onemu f}{r}=\diff {\nilmu f}{\onemu r}\]
\end{document}

where the correct spacing are defined from the commands:

\negmu insert spacing of −1 mu

\nilmu insert spacing of 0 mu

\onemu insert spacing of 1 mu

\twomu insert spacing of 2 mu

See the guide to the pag. 7/32.

enter image description here

You must log in to answer this question.

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