
Gostaria de alterar a fonte de todos os links produzidos por hyperref
, por exemplo, para sffamily
. Para esse fim, usei o etoolbox
pacote para corrigir o \Hy@colorlink
comando da seguinte forma:
\usepackage{etoolbox}
\makeatletter
\patchcmd{\Hy@colorlink}{\begingroup}{\begingroup\sffamily}{}{}%
\makeatother
Isso funciona para todos os tipos de links, exceto notas de rodapé. Não tenho ideia de por que esse é o caso. Um exemplo mínimo de trabalho está incluído abaixo para sua conveniência.
Agradeço antecipadamente por sua ajuda!
\documentclass{article}
\usepackage[colorlinks]{hyperref}
\usepackage{etoolbox}
% This throws an error
%\AtBeginDocument{%
% \makeatletter
% \patchcmd{\Hy@colorlink}{\begingroup}{\begingroup\sffamily}{}{}%
% \makeatother
%}
\begin{document}
\makeatletter
\patchcmd{\Hy@colorlink}{\begingroup}{\begingroup\sffamily}{}{}%
\makeatother
\tableofcontents
\section{A section}\label{sec:toto}
\begin{enumerate}
\item Pageref: page~\pageref{sec:toto}.
\item All links have the new font except footnotes: One\footnote{One} two\footnote{Two} three.\footnote{Three}
\end{enumerate}
\end{document}
Responder1
O comando padrão para criar notas de rodapé contém um comando \normalfont. Se você removê-lo, funciona.
\documentclass{article}
\usepackage[colorlinks]{hyperref}
\usepackage{etoolbox}
\makeatletter
\AtBeginDocument{%
\patchcmd{\Hy@colorlink}{\begingroup}{\begingroup\sffamily}{}{}%
\patchcmd{\@makefnmark}{\normalfont}{\selectfont}{}{}%
}
\makeatother
\begin{document}
\tableofcontents
\section{A section}\label{sec:toto}
\begin{enumerate}
\item Pageref: page~\pageref{sec:toto}.
\item All links have the new font except footnotes: One\footnote{One} two\footnote{Two} three.\footnote{Three}
\end{enumerate}
\end{document}