
相互参照の色を変更するにはどうすればいいですか。画像のようにラベルを黒、数字を青にしたいのですが
\documentclass{article}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{caption}
\begin{document}
Insert cross reference \autoref{figure}
\begin{figure}%h!
\centering
\includegraphics[]{example-image-a}
\caption{Validation procedure for LR model}\label{figure}
\end{figure}
\end{document}
答え1
次の 3 つのことを行う必要があると思います。
- あなたの青色を定義します。
linkcolor
定義した青色をhyperref の -key に割り当てます。\HyRef@testreftype
参照の名前/タイプを配信する前に、現在のテキストカラーを使用するパッチ。
\documentclass{article}
\usepackage{graphicx}
\usepackage{xcolor}
\definecolor{mylinkcolor}{rgb}{0.561, 0.667, 0.863}
\usepackage[colorlinks=true, linkcolor=mylinkcolor]{hyperref}
\makeatletter
\newcommand\MyAutoefPhrasecolorGroup[1]{%
\color@begingroup\color{MyCurrentcolor}#1\endgroup
}%
\def\HyRef@testreftype#1.#2\\{%
\colorlet{MyCurrentcolor}{.}%
\ltx@IfUndefined{#1autorefname}{%
\ltx@IfUndefined{#1name}{%
\HyRef@StripStar#1\\*\\\@nil{#1}%
\ltx@IfUndefined{\HyRef@name autorefname}{%
\ltx@IfUndefined{\HyRef@name name}{%
\def\HyRef@currentHtag{}%
\Hy@Warning{No autoref name for `#1'}%
}{%
\edef\HyRef@currentHtag{%
\noexpand\MyAutoefPhrasecolorGroup{%
\expandafter\noexpand\csname\HyRef@name name\endcsname
}%
\noexpand~%
}%
}%
}{%
\edef\HyRef@currentHtag{%
\noexpand\MyAutoefPhrasecolorGroup{%
\expandafter\noexpand
\csname\HyRef@name autorefname\endcsname
}%
\noexpand~%
}%
}%
}{%
\edef\HyRef@currentHtag{%
\noexpand\MyAutoefPhrasecolorGroup{%
\expandafter\noexpand\csname#1name\endcsname
}%
\noexpand~%
}%
}%
}{%
\edef\HyRef@currentHtag{%
\noexpand\MyAutoefPhrasecolorGroup{%
\expandafter\noexpand\csname#1autorefname\endcsname
}%
\noexpand~%
}%
}%
}%
\makeatother
\usepackage{caption}
\begin{document}
{\bfseries\verb|\autoref|-references with hyperlink:}
Textcolor unchanged: Insert cross reference \autoref{figure}
Textcolor sawitched to green: \textcolor{green}{Insert cross reference \autoref{figure}}
{\bfseries\verb|\autoref*|-references without hyperlink:}
Textcolor unchanged: Insert cross reference \autoref*{figure}
Textcolor sawitched to green: \textcolor{green}{Insert cross reference \autoref*{figure}}
\begin{figure}%h!
\centering
\includegraphics[]{example-image-a}
\caption{Validation procedure for LR model}\label{figure}
\end{figure}
\end{document}
ハイパーリンク付きの参照では\autoref
、「図」という語句は周囲のテキストと同じ色で表示され、ハイパー参照のlinkcolor
キーで示される色で表示される数字のようにクリック可能です。