From the answers available at hyperref changing the linkcolor locally in the toc and disable colorlinks locally or just for the toc, here is the more specific answer by myself the OP.
Hopefully it is more comprehensible and reachable than the ones above. (especially for the questions being ToC-specific, which could have been the reason why I didn't find in the first place)
The main take-away is that \hypersetup{}
, which is for setting any option of the package hyperref
outside \usepackage[..]{hyperref}
call, works not only globally within the header, but also locally within the main body of text. So surrounded with braces, it applies those options to any block of text.
Accordingly the specific solution to coloring problem is to use something as below.
For discoloring:
{\hypersetup{hidelinks}<TEXT-OF-INTEREST>}
For coloring differently:
{\hypersetup{allcolors=<COLOR-OF-UR-WISH>}<TEXT-OF-INTEREST>}
Some examples with emails, URL-with-anchor, URLs, citations, references, an entire Table-of-contents, or an entire section respectively:
<TEXT-OF-INTEREST> = \href{mailto:xxxx@xyz.com}{xxxx@xyz.com}
<TEXT-OF-INTEREST> = \href{www.URL.com}{anchor-text}
<TEXT-OF-INTEREST> = \url{www.URL.com}
<TEXT-OF-INTEREST> = \cite{XYZ}
<TEXT-OF-INTEREST> = \ref{XYZ}
<TEXT-OF-INTEREST> = \tableofcontents
<TEXT-OF-INTEREST> = \section{....} ....... block of text .....
Thanks to @Torbjørn T.
If needed often, or not, you may prefer to use it as a user-command.
For discoloring:
\newcommand{\discolorlinks}[1]{{\hypersetup{hidelinks}#1}}
Usage: \discolorlinks{<TEXT-OF-INTEREST>}
For coloring differently:
The most general one (as a copy of \textcolor
syntax) in the context of forcing a specific color on all links/urls/citations within a block of text (may customize more as you need with options such as citecolor
, urlcolor
,linkcolor
):
\newcommand{\colorlinks}[2]{{\hypersetup{allcolors=#1}#2}}
Example usage: \colorlinks{red}{<TEXT-OF-INTEREST>}
\hypersetup{hidelinks}
inside thetitlepage
environment will for example hide all the links on the titlepage. (Assuming you're using that environment.) Edit: More specific duplicate: tex.stackexchange.com/questions/179506/…