# Define newcommand to change the color of the href links to black

By default, I have used hyperref and xcolor to set the color of some of the URL links in my resume, but I also want to have some hidden links which are working, but not shown. Like the names of the companies I worked for, should lead to their respective homepages, but I want those links not to be colored in blue.

I was thinking that I can create a new command bwhref but I don't know how I can do it. I found an answer here but it is using the \documentclass{beamer} and I have already set my class to. This is my code:

\documentclass[11pt,twoside,a4paper]{article}
\usepackage{xcolor}
\usepackage{hyperref}

\definecolor{marineblue}{rgb}{0.05,0.1,0.5}

\hypersetup{
urlcolor=marineblue,
}

% Here I want to define bwhref, which will revert to black on the URLs.
% \newcommand{\bwhref}{???}

\begin{document}

\end{document}

• By hidden, do you must mean \hypersetup{urlcolor=\normalcolor} or do you mean \hypersetup{hidelinks}? Keep in mind that these change are local to the group. May 19 at 21:10

You can group command \hypersetup and \href like this:

% Here I want to define bwhref, which will revert to black on the URLs.
\newcommand{\bwhref}[2]{
{\hypersetup{
urlcolor=black,}
\href{#1}{#2}%
}%
}


to get an own command or you can use \href and grouped \hypersetup as two commands like:

{\hypersetup{
urlcolor=black,}


With the following MWE

\documentclass[11pt,twoside,a4paper]{article}
\usepackage{xcolor}
\usepackage{hyperref}

\definecolor{marineblue}{rgb}{0.05,0.1,0.5}

\hypersetup{
urlcolor=red,
}

% Here I want to define bwhref, which will revert to black on the URLs.
\newcommand{\bwhref}[2]{
{\hypersetup{
urlcolor=black,}
\href{#1}{#2}%
}%
}

\begin{document}

{\hypersetup{
urlcolor=black,}


• by the way, for the new bwhref command, you can drop the colorlinks=true, it should work fine with urlcolor=black only. May 20 at 7:42