[Tex/LaTex] LaTeX code for text above the $\rightarrow$

math-moderelation-symbolssymbols

Hi I am wondering what code is used to get text above the $\rightarrow$

have tried $ \xrightarrow{P}$ but not running on my LaTeX as I do not know which package to install or how to install it.

currently using \usepackage{mathtools} but it wants to load from a random directory and then LaTeX stops working.

Best Answer

\xrightarrow is provided by package amsmath:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$\xrightarrow{P}$
\end{document}

Result

LaTeX package amsmath is part of distribution package amsmath in TeX Live and MiKTeX. Usually it should be already installed, because it belongs to the "required" packages: CTAN:macros/latex/required/amslatex/.

Package mathtools loads package amsmath and provides further extensible arrows, see section "3.3 Extensible symbols" in its documentation. It is part of distribution package mh in MiKTeX and TeX Live.