0

The code below is borrowed from this post. Sol #1: I expected foo to be highlighted, it isn't. Since I want the change to be local anyway, how would I restore the defaults?

\documentclass[oneside,fontsize=12pt]{scrbook}
\usepackage{fontawesome}
\usepackage{expl3}
\usepackage{xparse}
\usepackage{hyperref}


%\usepackage{hyperref}

\NewDocumentCommand{\thisfbshare}{}{\href{https://www.facebook.com/sharer/sharer.php}{\faFacebookSquare}}
\NewDocumentCommand{\thistwshare}{}{\href{http://foo.com/?share=twitter\&nb=1}{\faTwitterSquare}}
\NewDocumentCommand{\thisshare}{}{\thisfbshare\thistwshare}

\begin{document}

%https://tex.stackexchange.com/questions/823/remove-ugly-borders-around-clickable-cross-references-and-hyperlinks

% SOL # 1
\hypersetup{hidelinks}
\hypersetup{
  colorlinks   = true, %Colours links instead of ugly boxes
  urlcolor     = blue, %Colour for external hyperlinks
  linkcolor    = blue, %Colour of internal links
  citecolor   = red %Colour of citations
}

% SOL # 2
%\hypersetup{
%    colorlinks=false,
%    pdfborder={0 0 0},
%}

{\large Don't forget to share on \thisshare~for \href{http://foo.com}{foo}}

%HOW TO RESTORE?

\end{document}

PS: the surrounding boxes for FB and Tw would be just fine if they didn't overlap with each other.

Print Print

0

The colorlinks option must be set in the preamble.

\documentclass[oneside,fontsize=12pt]{scrbook}
\usepackage{fontawesome}
\usepackage{xparse}
\usepackage{hyperref}
\hypersetup{colorlinks}

\NewDocumentCommand{\thisfbshare}{}{\href{https://www.facebook.com/sharer/sharer.php}{\faFacebookSquare}}
\NewDocumentCommand{\thistwshare}{}{\href{http://foo.com/?share=twitter\&nb=1}{\faTwitterSquare}}
\NewDocumentCommand{\thisshare}{}{\thisfbshare\thistwshare}

\begin{document}

{\large Don't forget to share on \thisshare~for \href{http://foo.com}{foo}}

\hypersetup{
  urlcolor     = blue, %Colour for external hyperlinks
  linkcolor    = blue, %Colour of internal links
  citecolor   = red %Colour of citations
}

{\large Don't forget to share on \thisshare~for \href{http://foo.com}{foo}}

\hypersetup{allcolors=black,pdfborder=0 0 1}

{\large Don't forget to share on \thisshare~for \href{http://foo.com}{foo}}


\end{document}

enter image description here

| improve this answer | |
  • Just one problem: calls to \gls within body of text get highlighted. See setup here. I guess this is the answer? – Erwann Sep 21 '19 at 1:03
  • Related question, how to retrieved hypersetup parameters, such as urlcolor? – Erwann Sep 23 '19 at 23:38
  • Don't ask new questions in comments. That pings only one person. Ask a new question. – Ulrike Fischer Sep 24 '19 at 6:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.