1

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}

% Colored links by default
\definecolor{marineblue}{rgb}{0.05,0.1,0.5}

\hypersetup{
    colorlinks=true,
    urlcolor=marineblue,
}

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

\begin{document}

% {\bwhref{https://company_a.com}{Company A (black link)}}
\href{https://test.com}{blue link}

\end{document}
1
  • 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, 2021 at 21:10

1 Answer 1

2

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{
    colorlinks=true,
    urlcolor=black,}
  \href{#1}{#2}%
  }%
}

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

{\hypersetup{
    colorlinks=true,
    urlcolor=black,}
\href{https://company_a.com}{Company A (black link)}}

With the following MWE

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

% Colored links by default
\definecolor{marineblue}{rgb}{0.05,0.1,0.5}

\hypersetup{
    colorlinks=true,
    urlcolor=red,
}

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

\begin{document}

{\hypersetup{
    colorlinks=true,
    urlcolor=black,}
\href{https://company_a.com}{Company A (black link)}}

\bwhref{https://company_a.com}{Company A (black link, command)}

\href{https://test.com}{blue link}

\end{document}

you get the resulting page with wished result:

enter image description here

For better seeing I changed your blue color to red ...

3
  • it works perfectly, thanks a lot @Mensch May 19, 2021 at 21:35
  • 1
    be aware that you can run into problem if the url contains special chars like % or #. May 19, 2021 at 21:57
  • by the way, for the new bwhref command, you can drop the colorlinks=true, it should work fine with urlcolor=black only. May 20, 2021 at 7:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .