Notation problem in integration: write $dx$ or ${\mathrm{d}}x$? I have a question. When I write the integral of a generic function $f(x)$, do I have to write $$\int f(x) \color{red}dx$$ or $$\int f(x) \color{red}{\mathrm{d}}x \quad ?$$ Why?
Thank you!
 A: The underlying rule (which is often violated) is that variables should be in italic, but names should not. In ${\rm d}x$, $x$ is a variable which could be exchanged with any other letter, but ${\rm d}$ is the name of the differential operator and cannot be exchanged with any other letter.
For the same reason, a general function $f$ is in italic, but the particular functions $\sin$, $\cos$, $\log$ are not. Similarly, numerals are names of particular numbers, and are therefore not italicized.
A: As pointed out in another answer,
the notation $\int \ldots\mathrm dx$ is consistent with the typesetting of other
mathematical symbols, since $\mathrm d$ is the name of a specific operator.
There is also an ISO standard governing these things, which purportedly
specifies $\int \ldots\mathrm dx$ as the correct notation,
but a copy of the latest standard, which apparently is
ISO 80000-2:2009, costs $158$ Swiss francs (about US\$$173$ according
to today's exchange rate) and I don't have ready access to one as far as I know.
So it would seem that technically, you should write $\int \ldots\mathrm dx$,
but hundreds of years of convention, countless textbooks and reference books,
and millions of people who have been accustomed to seeing $\int \ldots dx$
for most of their lives (and who have never even considered that there was likely
an ISO standard governing the notation, as I had not until today)
all say that as a practical matter you do not have to write $\int \ldots\mathrm dx$.
If you do write $\int \ldots\mathrm dx$ and someone complains that it should
have been $\int \ldots dx$, however, now you have the resources to back up your choice.

Update for $2023$: For some time now, I personally have been writing $\int \ldots \mathrm dx$ in my posts here. Also $\dfrac{\mathrm d}{\mathrm dx}.$ But I will sometimes use the older notation when responding to someone who seems to prefer it.
A: $$\int f(x) dx$$ is just fine, though some people, as a matter of preference, write $$\int f(x) \mathrm{d}x$$ (perhaps to indicate that we are not taking the product of $d$ and $x$.) Just as there are folks, like me, who like to insert space between the function and $dx$: E.g. $$\int f(x)\,dx$$
But rest assured that the appearance of the integral sign makes the use of plain-old $dx$ pretty self-evident.
