# How can I define a command for urls using hyperref

I know I can use the package hyperref for urls, but I want is to create a definition that uses this and assigns a color, for example

\c{url}{Something}


would write Something in crimson color linked to the url (and assume default urls aren't in crimson)

• what about \usepackage[colorlinks=true,urlcolor=magenta]{hyperref} and \href{http://www.myurl.com}{something} ? – ebosi Apr 6 '16 at 7:47

You can use hyperref options, and locally modify it when needed.

\documentclass{article}

\newcommand{\myhref}[2]
{\hypersetup{urlcolor=blue}%
\href{#1}{#2}%
\hypersetup{urlcolor=magenta}%
}

\begin{document}