[Tex/LaTex] Using/Forcing upright text within theorem environment

environmentsformattingmacrostext;theorems

I would like to write an equation within a theorem that involves an integrand and the upright symbol $ \textrm{d} $ which I have abbreviated in my preamble with

\newcommand{\dmath}{\textrm{d}}

(and the preamble also contains)

\usepackage{array}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
... etc
\newtheorem{theorem}{Theorem}[section]

I have the following theorem:

\begin{theorem}[Fubini's theorem]
\label{app:thrm:fubini}
Suppose $ X $ and $ Y $ are measurable spaces. If $ f(x,y) $ is integrable ($ f(x,y) $ is measurable and $ \int_{X,Y} \left| f(x,y)\right| \dmath (x,y) < \infty$) then
\begin{equation*}
\int_{X} \left(\int_{Y} f(x,y) \dmath y \right) \dmath x
=
\int_{Y} \left(\int_{X} f(x,y) \dmath x \right) \dmath y
=
\int_{X,Y} f(x,y) \dmath (x,y).
\end{equation*}
\end{theorem}

and have the following output

Output within theorem environment

but would like the \dmath to produce $\textrm{d}$ to produce an upright 'd' character whenever it is called, and would like the following output:

Desired result with correct formatting of upright mathematical symbols

Any suggestions on a simple way to achieve the desired result?

I have looked at the following Qs but they don't quite address the issue:

Best Answer

Here's a better reimplementation; \mathrm will always choose upright medium, whereas \textrm will retain the settings of the font current outside the formula.

Note some further refinements. See Better automatic spacing of differential d? for more information.

\documentclass{article}

\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amssymb}

\newtheorem{theorem}{Theorem}[section]

\newcommand{\dmath}{\mathop{}\!\mathrm{d}}

\begin{document}
\begin{theorem}[Fubini's theorem]
\label{app:thrm:fubini}
Suppose $ X $ and $ Y $ are measurable spaces. If $ f(x,y) $ is integrable
\textup{(}$ f(x,y) $ is measurable and
$ \int_{X,Y} \lvert f(x,y)\rvert \dmath (x,y) < \infty$\textup{)} then
\begin{equation*}
\int_{X} \left(\,\int_{Y} f(x,y) \dmath y \right) \dmath x
=
\int_{Y} \left(\,\int_{X} f(x,y) \dmath x \right) \dmath y
=
\int_{X,Y} f(x,y) \dmath (x,y).
\end{equation*}
\end{theorem}

\end{document}

I wouldn't use \dmath, though, because breqn uses it and you never know if you're going to reuse the code.

enter image description here

Related Question