The root cause of the problem you've encountered is that you're trying to use a text-mode-only command -- \d
-- in math mode.
Rather than undefine and then redefine \d
suitably, I think it's better to create a macro with a new name -- say, \diff
-- to denote the "differential operator". E.g.,
\newcommand{\diff}{\mathop{}\!\mathrm{d}}
Observe that this command does not take an argument. Thus, I would encourage you to just write \diff S
, not \diff{S}
, as the latter might create the (misleading and inappropriate) impression that \diff
is a macro that takes an argument.
I would also replace with all instances of \int\limits
with just \int
, as I can't see a (typographic) justification for elongating the equation in the vertical direction.
Finally, I think the equation is easier to read if you used an \equation
/aligned
combination instead of a multline
environment.

\documentclass{article} % or some other suitable document class
\usepackage{amsmath}
\newcommand{\diff}{\mathop{}\!\mathrm{d}} % don't re-purpose the existing '\d' macro
\newcommand{\gnpn}{\Gamma\nabla\mkern-2mu \phi\cdot\mathbf{n}} % handy shortcut macro
\begin{document}
\begin{equation}\label{eq:volume_boundaries}
\begin{aligned}[b]
\int_S \gnpn \diff S
&= \int_{S_\mathrm{n}}\! (\gnpn)_{\mathrm{n}}\diff S_{\mathrm{n}}
+\int_{S_\mathrm{e}}\! (\gnpn)_{\mathrm{e}}\diff S_{\mathrm{e}}\\
&\quad +\int_{S_\mathrm{s}}\! (\gnpn)_{\mathrm{s}}\diff S_{\mathrm{s}}
+\int_{S_\mathrm{w}}\!\!(\gnpn)_{\mathrm{w}}\diff S_{\mathrm{w}}
\end{aligned}
\end{equation}
\end{document}
\d
macro is defined. (Usually, it's a text-mode-only macro.)_{...}
it is a bit of a floke that this can be used with braces so no a good idea to depen on it.\text
does. Try\textit{test $\text{test}$}
. The construction you use for something like this formatting should not depend on the context. Therefore\text
is wring here. Generally\text
is for textual comments in displayed math, not textual indices, they are not the same thing.\d
command to set an upright letterd
in math mode (something like\mathrm{d}
), perhaps with some spacing, But you likely forgot to load the package that actually (re)defines the command. By default\d
is not a math-mode macro. (Also, in some packages I've seen this defined as\D
and not\d
...)R_{\textup{sø}}
because ø is not allowed in math mode.