
Я работал над некоторыми уравнениями и хотел, чтобы у них был другой цвет гиперссылки по сравнению с остальными цветами ссылок, которые я установил в своем \hypersetup
. Теперь, похоже, этопочтаделает то, что я ищу, если бы не исключениеуравнение ()часть ссылки, которая все еще имеет исходный набор цветов в \hypersetup
.
Есть ли способ сделать весь текст в сине-зеленом (или любом другом цвете)? Спасибо заранее, ниже MWE и соответствующий вывод:
\documentclass[12pt]{report}
\usepackage[letterpaper,margin=1in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{subcaption}
\usepackage{caption}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{float}
\usepackage{hyperref}
\hypersetup{
colorlinks,
citecolor=electricultramarine,
filecolor=.,
linkcolor=maroon,
urlcolor=smokyblack,
linktoc=all
}
\definecolor{teal}{rgb}{0.0, 0.5, 0.5}
\definecolor{cobalt}{rgb}{0.0, 0.28, 0.67}
\definecolor{maroon}{rgb}{0.69, 0.19, 0.38}
\definecolor{coolblack}{rgb}{0.0, 0.18, 0.39}
\definecolor{lightgray}{rgb}{0.83, 0.83, 0.83}
\definecolor{smokyblack}{rgb}{0.06, 0.05, 0.03}
\definecolor{ceruleanblue}{rgb}{0.16, 0.32, 0.75}
\definecolor{electricultramarine}{rgb}{0.25, 0.0, 1.0}
\usepackage[noabbrev,nameinlink]{cleveref}
\crefname{subsection}{subsection}{subsections}
\creflabelformat{equation}{#2\textup{(\textcolor{teal}{#1})}#3}
\begin{document}
\chapter{Methods}
\dots
\section{Population genetics and Demographic Inference}
\dots
\subsection{PCA and other exploratory population genetic analyses} \label{exploratory}
This is the method subsection for exploratory analyses.
\chapter{Results}
\dots
\section{Exploratory population genetics analyses}
\dots This value, known as Watterson estimator (or $\theta$ Watterson) <citation>, is expressed by the following equation with the number of polymorphic sites set as K:
\begin{equation} \label{equation:1}
\widehat{\theta}_w = \frac{K}{a_n} \text{, with } a_n = \sum_{i=1}^{n-1} \frac{1}{i}
\end{equation}
When I use a normal \texttt{cleveref} I get the expected output in: \textbf{\Cref{exploratory}}; on the other hand, even following the example in the post, I cannot get rid of the maroon hyperlink color for the equation and brackets part of the text when linking an equation: \textbf{\cref{equation:1}}.
\end{document}
решение1
Используйте \crefformat
полную ссылку с префиксом, а не только метку:
\documentclass[12pt]{report}
\usepackage[letterpaper,margin=1in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{subcaption}
\usepackage{caption}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{float}
\usepackage{hyperref}
\hypersetup{
colorlinks,
citecolor=electricultramarine,
filecolor=.,
linkcolor=maroon,
urlcolor=smokyblack,
linktoc=all
}
\definecolor{teal}{rgb}{0.0, 0.5, 0.5}
\definecolor{cobalt}{rgb}{0.0, 0.28, 0.67}
\definecolor{maroon}{rgb}{0.69, 0.19, 0.38}
\definecolor{coolblack}{rgb}{0.0, 0.18, 0.39}
\definecolor{lightgray}{rgb}{0.83, 0.83, 0.83}
\definecolor{smokyblack}{rgb}{0.06, 0.05, 0.03}
\definecolor{ceruleanblue}{rgb}{0.16, 0.32, 0.75}
\definecolor{electricultramarine}{rgb}{0.25, 0.0, 1.0}
\usepackage[noabbrev,nameinlink]{cleveref}
\crefname{subsection}{subsection}{subsections}
\crefformat{equation}{\textcolor{teal}{equation~#2\textcolor{teal}{(#1)}#3}}
\begin{document}
\chapter{Methods}
\dots
\section{Population genetics and Demographic Inference}
\dots
\subsection{PCA and other exploratory population genetic analyses} \label{exploratory}
This is the method subsection for exploratory analyses.
\chapter{Results}
\dots
\section{Exploratory population genetics analyses}
\dots This value, known as Watterson estimator (or $\theta$ Watterson) <citation>, is expressed by the following equation with the number of polymorphic sites set as K:
\begin{equation} \label{equation:1}
\widehat{\theta}_w = \frac{K}{a_n} \text{, with } a_n = \sum_{i=1}^{n-1} \frac{1}{i}
\end{equation}
When I use a normal \texttt{cleveref} I get the expected output in: \textbf{\Cref{exploratory}}; o[![enter image description here][1]][1]n the other hand, even following the example in the post, I cannot get rid of the maroon hyperlink color for the equation and brackets part of the text when linking an equation: \textbf{\cref{equation:1}}.
\end{document}
Внешний \textcolor
изменяет общий цвет, но он перезаписывается ссылкой, hyperref
созданной #2
и #3
. Чтобы снова изменить этот цвет, внутренний \textcolor
между #2
и #3
также необходим. ~
Это неразрывный пробел между префиксом и ссылкой.
Если вы хотите, чтобы префикс был частью ссылки, вы можете использовать:
\crefformat{equation}{#2\textcolor{teal}{equation~(#1)}#3}
cleveref
Более подробную информацию о принципе работы см. в руководстве \crefformat
.