I want to try to communicate what I want to achieve with the following code example. I would like to have one left- and right-command for this functionality, which compiles in reasonable time. I am happy with the aesthetics achieved by the routines below. I apologize if that question could be solved using other answers from the site. Thank you for taking a look at it!
\documentclass{amsart}
\usepackage{amsmath}
\usepackage{stackengine}
\newcommand\constantoverleftarrow[1]{\stackengine{0pt}{$\smash{\mbox{\scriptsize\ensuremath{\overleftarrow{\normalsize\hphantom{D}\vphantom{#1}}}}}$}{$#1$}{O}{l}{F}{F}{L}}
\newcommand\constantoverrightarrow[1]{\stackengine{0pt}{$\smash{\mbox{\scriptsize\ensuremath{\overrightarrow{\normalsize\hphantom{D}\vphantom{#1}}}}}$}{$#1$}{O}{l}{F}{F}{L}}
\newcommand\constantfootoverleftarrow[1]{\stackengine{0pt}{$\smash{\mbox{\tiny\ensuremath{\overleftarrow{\footnotesize\hphantom{D}\vphantom{#1}}}}}$}{$#1$}{O}{l}{F}{F}{L}}
\newcommand\constantfootoverrightarrow[1]{\stackengine{0pt}{$\smash{\mbox{\tiny\ensuremath{\overrightarrow{\footnotesize\hphantom{D}\vphantom{#1}}}}}$}{$#1$}{O}{l}{F}{F}{L}}
\newcommand\constantunsmashedoverleftarrow[1]{\stackengine{0pt}{$\mbox{\scriptsize\ensuremath{\overleftarrow{\normalsize\hphantom{D}\vphantom{#1}}}}$}{$#1$}{O}{l}{F}{F}{L}}
\newcommand\constantunsmashedoverrightarrow[1]{\stackengine{0pt}{$\mbox{\scriptsize\ensuremath{\overrightarrow{\normalsize\hphantom{D}\vphantom{#1}}}}$}{$#1$}{O}{l}{F}{F}{L}}
\begin{document}
I write longer sentences which have inline math and wrap over several lines. It might happen that I speak about a derivative $\constantoverleftarrow{D_{x_1\cdots x_n}}$ and put it inside the text. It is important for me that the arrow of such a formula does not expand over the indices. I used the smashed version of my own arrow here because I do not want that the lines spread apart.
Of course, it might as well happen that I speak about a derivative
\[
\constantunsmashedoverleftarrow{D_x}
\]
which occurs in display math. Here, I use the unsmashed version of my own arrow because I want the spacing to be ordinary. This is important, in particular if I have display math with several lines or even boxes around the math from empheq package.\footnote{A derivative $\constantfootoverrightarrow{D_y}$ in a footnote needs to be smaller.} (It might also be important for deliminators. But there, I usually control the size myself and do not use the $\left(\right)$ version. This seems less important to me.)
The experts from \TeX Stackexchange might notice: Such a macro does not always work. Indeed, it will not adjust to subscripts for example, like $\int_{\constantoverrightarrow{D_z}}$. However, I do not need this. I don't have to worry about all the functionality but only about the one I really use.
I finally want to remark: My document may have around 200 to 300 arrows. And using the code above in the preamble takes a lot of time to compile.
\end{document}
\int_{\overrightarrow{D}_z}? – Sigur Aug 31 '19 at 15:23$z$gets shifted to the right. Concerning compiling, I thought it is maybe bad coding. – Christoph Mark Aug 31 '19 at 15:42z. It is subscript, so should be moved a little bit. Do you want to reduce the right spacing? – Sigur Aug 31 '19 at 15:44$D_z$is at the right place, but in$\overrightarrow{D}_z$it gets shifted to the right as an effect of the arrow. – Christoph Mark Aug 31 '19 at 15:47