Math & ScienceDifferential operator

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Differential operator

Post by svend_tveskaeg »

Hi everyone.

Consider the following document:

Code: Select all

\documentclass{article}

\usepackage{amsmath}

\makeatletter
\providecommand*{\diffoperator}%
   {\@ifnextchar^{\diff}{\diff^{}}}
\def\diff^#1{%
   \mathop{\mathrm{\mathstrut d}}%
      \nolimits^{#1}\gobblespace
}
\def\gobblespace{%
   \futurelet\diffarg\opspace}
\def\opspace{%
   \let\DiffSpace\!%
   \ifx\diffarg(%
      \let\DiffSpace\relax
   \else
      \ifx\diffarg\[%
         \let\DiffSpace\relax
      \else
         \ifx\diffarg\{%
            \let\DiffSpace\relax
         \fi\fi\fi\DiffSpace}
\makeatother

\begin{document}

Consider the following examples:
\begin{equation*}
  \int_{a}^{b}\text{foal}(t) \operatorname{d}t = \text{horse}
\end{equation*}
versus
\begin{equation*}
  \int_{a}^{b}\text{foal}(t) \diffoperator t = \text{horse}.
\end{equation*}
\end{document}
Should I use the differential operator in the first expression or the one in the second expression?

Thank you in advance!

PS. The code for creating the second differential operator was found in the article ``Typesetting mathematics for science and technology according to ISO31/XI'' in TUGBoat 18:1.
Last edited by svend_tveskaeg on Thu Feb 17, 2011 1:46 am, edited 1 time in total.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Differential operator

Post by frabjous »

Of those two, I definitely prefer the second one.

You might also consider the \dif command from the commath package.
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Re: Differential operator

Post by svend_tveskaeg »

Thank you very much!
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Differential operator

Post by svend_tveskaeg »

According to this post on {TeX} SX, the correct code for the differential operator (here \diff) would be

Code: Select all

\newcommand*\diff{\mathop{}\!\mathrm{d}}
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
Post Reply