I use the multline feature from amsmath to display an equation that spreads acroos multiple rows. I tried to do that like this:

    \int\limits_S \Gamma\nabla\phi\cdot\mathbf{n}\d{S} =
    \int\limits_{S_\text{n}} (\Gamma\nabla\phi\cdot\mathbf{n})_\text{n}\d{S_\text{n}} 
    +\int\limits_{S_\text{e}} (\Gamma\nabla\phi\cdot\mathbf{n})_\text{e}\d{S_\text{e}}\\
    +\int\limits_{S_\text{s}} (\Gamma\nabla\phi\cdot\mathbf{n})_\text{s}\d{S_\text{s}}
    +\int\limits_{S_\text{w}} (\Gamma\nabla\phi\cdot\mathbf{n})_\text{w}\d{S_\text{w}}

However this leads to the error message Missing $ inserted. \end{multline}. What did I do wrong here?

  • 2
    Please tell us how or where the \d macro is defined. (Usually, it's a text-mode-only macro.)
    – Mico
    Commented Feb 17, 2021 at 16:22
  • 1
    @Axel if you're writing in English, yes I would use mathrm and I would use _{...} it is a bit of a floke that this can be used with braces so no a good idea to depen on it.
    – daleif
    Commented Feb 17, 2021 at 16:58
  • 1
    @WillieWong a text label should always be upright, but that is not what \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.
    – daleif
    Commented Feb 17, 2021 at 17:02
  • 1
    As @Mico said: Your problem is most likely that you are trying to use the \d command to set an upright letter d 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...) Commented Feb 17, 2021 at 17:05
  • 1
    @WillieWong that would be fine or textup. In the idea world the letters would be the same in text and math. But if you need to write non-ascii letters you need to use textup or textnormal, so in Danish the radius of a lake would be R_{\textup{sø}} because ø is not allowed in math mode.
    – daleif
    Commented Feb 17, 2021 at 17:13

1 Answer 1


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.,


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.

enter image description here

\documentclass{article} % or some other suitable document class
\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

\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}}
  • 1
    Just to be picky, \diff{S} (in math mode) is completely equivalent to \diff S, because TeX strips off the braces when the subformula consists of a single atom.
    – egreg
    Commented Feb 17, 2021 at 18:29
  • @egreg - I know that too. :-) My point was not so much about the appearance of the output than about not creating a misleading impression that \diff is a macro that takes an argument. I will update my answer to clarify this.
    – Mico
    Commented Feb 17, 2021 at 18:41
  • 1
    I had already upvoted, of course.
    – egreg
    Commented Feb 17, 2021 at 22:30

You must log in to answer this question.

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