
hyperref
によって生成されたすべてのリンクのフォントを、たとえば に変更したいと思いますsffamily
。このために、パッケージを使用して、次のようにコマンドetoolbox
にパッチを適用しました。\Hy@colorlink
\usepackage{etoolbox}
\makeatletter
\patchcmd{\Hy@colorlink}{\begingroup}{\begingroup\sffamily}{}{}%
\makeatother
これは、脚注を除くすべてのタイプのリンクで機能します。なぜそうなるのかはわかりません。便宜上、最小限の動作例を以下に示します。
ご協力をよろしくお願いいたします!
\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}
答え1
脚注マークを作成するための標準コマンドには、\normalfont コマンドが含まれています。これを削除すれば機能します。
\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}