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}:

Make \overrightarrow colored

\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

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.224 (s). 12 q(s)