本地更改超链接的外观

本地更改超链接的外观

下面的代码借用自这个帖子。问题 #1:我原本以为foo会突出显示,但事实并非如此。由于无论如何我都希望更改是本地的,那么如何恢复默认设置?

\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:如果 FB 和 Tw 周围的框不互相重叠的话,那就没问题。

打印 打印

答案1

必须在序言中设置 colorlinks 选项。

\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}

在此处输入图片描述

相关内容