[Tex/LaTex] How to rotate TikZ decoration (arrow)

arrow-curvetikz-arrowstikz-decorationstikz-pgf

While TikZ has the option of bending arrows that appear at the tip of an edge (library bending), and has the option of placing arrows in the middle of edges (library decorations), I did not manage to combine the two. In the code below I use the library decorations to place an arrow near the middle of a loop, but the arrow is oriented according to the tangent to the curve at the tip. Is it possible to bend the arrow or even just to rotate it by a hard-coded angle?

\pdfoutput=1
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}
  \tikzset{->-/.style={decoration={markings, mark=at position #1 with {\arrow{stealth}}},postaction={decorate}}}
  \node[draw,circle] (n) {$n$};
  \draw [->-=.5] (n) to [distance=5ex, in=60, out=120, loop] ();
\end{tikzpicture}
\end{document}

Circled letter with arrow looping above it: the arrow head is tangent to the point of the loop where its tip lies, instead of following the curvature of the loop

Best Answer

At the time of decoration, \pgfdecoratedangle holds the path tangent angle to adjust the transformation. You can use that or any hard coded value offset with this amount

\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}
\tikzset{->-/.style={
  decoration={markings, mark=at position #1 with {%
    \arrow[rotate=-\pgfdecoratedangle]{stealth}% always point right
    }
  },
  postaction={decorate}
  }
}

  \node[draw,circle] (n) {$n$};
  \draw [->-=.2] (n) to [distance=5ex, in=60, out=120, loop] ();
\end{tikzpicture}
\end{document}

enter image description here