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

1 Answer 1

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

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

You must log in to answer this question.

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