6

I am using the commath package to typeset the derivative operator "D" with the command \Dif. This work well unless I want to add subscripts or superscripts. In this case, the spacing after operator is too small and the exponent / index "touches" the operator:

enter image description here

where the first operator is created via \Dif and the second one via \mathrm{D} (full MWE see below).

Is there some way to "redefine" the \Dif command in order to fix the spacing?


\documentclass{article}
\usepackage{commath}

\begin{document}

\begin{align*}
  \Dif^2_x f(x) \\
  \mathrm{D}^2_x f(x)
\end{align*}

\end{document}
7
  • 1
    {\Dif\,}^2_x will do it, but that might be a nuisance, and not generally applicable. Jul 10, 2013 at 12:02
  • Is there a way to make this automatically happen in general? I.e. to make \Dif work as it currently does almost always, but to produce something like {\Dif\,}^2_x when sub/superscripts are used? Apr 14, 2014 at 21:20
  • @AbeSchulte What's the problem in using the definition I proposed in my answer? The definition by commath is inherently wrong and should never be used.
    – egreg
    Apr 14, 2014 at 21:47
  • 1
    tex.stackexchange.com/questions/14821/… It seems there is quite a bit of disagreement regarding what exactly is "right" and therefore what is wrong. Unless you can cite a source, I really don't think you can say something is "inherently wrong", especially when an international organization entirely dedicated to stuff like this says otherwise (see the top answer of the linked post). Apr 15, 2014 at 1:58
  • 1
    My suggestion: \renewcommand{\Dif}{\operatorname{D}} Apr 18, 2014 at 11:19

2 Answers 2

11
+50

The definition of \Dif in commath.sty is

\DeclareMathOperator{\Dif}{D \!}

which is simply wrong. The \! backspace is the cause of your problem. It's not the only part in commath that I consider wrong, so I can't recommend using the package.

A more correct definition would be

\newcommand{\Dif}{\mathop{}\!D}

that you can add to your document (with \renewcommand if you insist in using commath).

5
  • 1
    Thanks a lot for this! Just out of curiosity - could you elaborate on why commath should not be used? If I exclude it, I better do so now (i.e. before relying on too many of its commands).
    – Bernd
    Jul 10, 2013 at 12:09
  • @Bernd See, for instance, tex.stackexchange.com/a/120379/4427
    – egreg
    Jul 10, 2013 at 16:48
  • Ah, I see. I saw e.g. (tex.stackexchange.com/questions/22076/…) that the cool package seems to accomplish some things imilar to commath. Do you also recommend avoiding this package, or is it "kosher"?
    – Bernd
    Jul 11, 2013 at 7:56
  • @Bernd I never used cool, so I don't know about it.
    – egreg
    Jul 11, 2013 at 8:31
  • @egreg, what is your opinion about using the package esdiff for typesetting differentials?
    – mas
    Apr 15, 2014 at 2:01
-1
\documentclass{article}

\usepackage{commath}

\begin{document}

\begin{align*}
\Dif^{^2}_{_x} f(x) \\
\mathrm{D}^{^2}_{_x} f(x)
\end{align*}

\end{document} 

enter image description here

1
  • 5
    Using double sub- and superscripts to avoid kerning problems is never a good solution. It makes your equation much more difficult to read because of the smaller symbols and the text will get inconsistent if you use “normal” sub- and superscripts in other equations (or other contexts in the same equation).
    – Lupino
    Apr 20, 2014 at 9:30

You must log in to answer this question.

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