\usepackage{fontawesome} 图形列表中的双重符号

\usepackage{fontawesome} 图形列表中的双重符号

使用时(见答案https://tex.stackexchange.com/a/102724/67761来自问题“外部链接符号“):

\documentclass{article}
\usepackage{fontawesome}
\usepackage[hidelinks]{hyperref}

% Redefinition, symbol included in link:
\let\orighref\href
\renewcommand{\href}[2]{\orighref{#1}{#2\,\faExternalLink}}

\begin{document}
\href{http://example.com}{example web site}
\end{document}

为了在外部 URL 后实现特殊符号,一切正常。我可以用简单的 LaTeX 来编译它。

中的外部 URL\captionof{figure}{ABC. See \href{https://DEF}{GHI}.}也能正常工作并显示符号。

工作正常:

工作正常

问题是当你添加

\tableofcontents*
\listoffigures

然后突然间,图形列表中的符号变成了双重!

看到这里的问题:

双图标

答案1

不要像这样重新定义 hyperref 命令。首先它们应该是健壮的(这样您就不会像重新定义那样以双重字符结束),其次 hyperref 会努力处理 url 中的特殊符号,而您正在停用此功能。

您可以像这样定义自己的 href 命令:

\documentclass{article}
\usepackage{fontawesome}
\usepackage{caption}
\usepackage[hidelinks]{hyperref}

% Redefinition, symbol included in link:
\makeatletter
\DeclareRobustCommand*{\newhref}{\hyper@normalise\newhref@}
\newcommand\newhref@[2]{\hyper@linkurl{#2\,\faExternalLink}{#1}}
\makeatother
\begin{document}
\listoffigures

\captionof{figure}{ABC. See \newhref{https://DEF}{GHI}.}

\newhref{http://example.com}{example web site}

\end{document}

在此处输入图片描述

相关内容