# Make \overrightarrow colored

It is possible to make \overrightarrow (the arrow itself not what is under it) colored? (LaTeX)

Replay

The following elementary redefinition inserts the appropriate colour, while setting whatever is underneath the arrow in \color{black}:

\documentclass{article}

\usepackage{amsmath,xcolor}

\let\oldoverrightarrow\overrightarrow
\renewcommand{\overrightarrow}[2][]{{%
\if$#1$\else\color{#1}\fi% Optional argument given...
\oldoverrightarrow{\color{black}#2}%
}}

\begin{document}

$A \quad \overrightarrow{\text{some text}} \quad B \quad \overrightarrow[red]{\text{some text}} \quad C$

\end{document}



If the preservation of the current colour is required, you can use the following definition:

\renewcommand{\overrightarrow}[2][]{%
{\colorlet{thecurrentcolour}{.}\if$#1$\else\color{#1}\fi%
\oldoverrightarrow{\color{thecurrentcolour}#2}%
}%
}



It stores the current colour - . as thecurrentcolour, and uses that (instead of black) for the text underneath the arrow.

Category: color Time: 2016-07-28 Views: 0
Tags: color arrows