Consider the following MWE:
\documentclass{article}
\usepackage{amsmath}
\renewcommand{\d}{\text{d}}
\usepackage{hyperref}
\begin{document}
$\d x$
$\text{d} x$
\end{document}
If hyperref is loaded after the redefinition of \d, then the first expression is rendered as an upright x with a dot below, just as if the macro had not been redefined. Additionally, I get the warning
LaTeX Warning: Command \d invalid in math mode on input line 12.
On the other hand, if I do not load hyperref or load it before the redefinition of \d, everything works as expected.
Why does this happen?
\ais also predefined but redefining it\renewcommand{\a}{\text{a}}does not makes any error!!! – Aug 21 '20 at 10:39\text{d}to make an uprightdis wrong, (1) it is a textdnot mathd, (2) it will be italic if the text outside of math is italic. Use\mathrm{d}instead. – daleif Aug 21 '20 at 10:53hyperrefmanual, there is a command\DeclareTextCompositeCommand{\d}{PU}{a}{\9036\241}that produce1EA1;LATIN SMALL LETTER A WITH DOT BELOW;...and the error is because of this maybe. – Aug 21 '20 at 10:58\ais needed in atabbingenvironment to get accents. But I would advise against redefining commands without knowing what they do and hoping for the best. – campa Aug 21 '20 at 11:02\d. The advantage in having a short command outweighs the risk. I might switch to\dd{x}from thephysicspackage; did not know that, when I first used this macro ~15 years ago. – Philipp Imhof Aug 21 '20 at 11:19physicsin new (and larger) documents. – Philipp Imhof Aug 21 '20 at 11:32\newcommand{\dd}{\mathrm{d}}? – Philipp Imhof Aug 21 '20 at 11:40\mathrminstead of\text. I think, I did not yet know about (or pay attention to) those details ~15 years ago. And there was no tex.stackexchange.com :) – Philipp Imhof Aug 21 '20 at 11:41