在文档报告中局部改变 \Cref 的颜色

在文档报告中局部改变 \Cref 的颜色

你好,我正在处理一份 LaTex 报告文档,恰好需要更改\Cref文档中某个部分的引用颜色。但是,出于某种原因,我无法这样做,显示的颜色是我在中设置的颜色,\hypersetup栗色

请参阅下文了解所有使用的软件包:

\documentclass[12pt]{report}

\usepackage{float}
\usepackage[newfloat]{minted}
\usepackage{graphicx} % for inserting images
\usepackage[inkscapearea=page]{svg} %for SVG import

\usepackage[letterpaper,margin=1in]{geometry}
\usepackage[acronym,toc]{glossaries}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{titlesec}
\usepackage{textcomp}
\usepackage{setspace}
\usepackage{csquotes}
\usepackage{listings}
\usepackage{authblk}
\usepackage{xurl}

\usepackage{hyperref}
\hypersetup{
    colorlinks,
    citecolor=electricultramarine,
    filecolor=.,
    linkcolor=maroon,
    urlcolor=smokyblack,
    linktoc=all
}
\usepackage[nameinlink]{cleveref}

\usepackage{caption}
\usepackage{orcidlink}
\usepackage{subcaption}

%\captionsetup[table]{font=small}
\captionsetup[figure]{font=small}
\renewcommand{\thefigure}{\arabic{figure}}
\captionsetup[listing]{labelformat=empty,labelsep=none,justification=raggedright,singlelinecheck=false}

\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{amsmath}
\usepackage{tocloft}
\usepackage{tocbasic}
\usepackage[nottoc]{tocbibind} % automatically insert LOF and LOT to TOC
\numberwithin{figure}{chapter} % figure numbering follows a chater-first, figure-second style

\renewcommand{\cftdot}{}
\renewcommand{\baselinestretch}{1.5}
\renewcommand{\cftchapfont}{\Large\bfseries\color{cobalt}}
\renewcommand{\cfttoctitlefont}{\Large\bfseries\color{black}}
\renewcommand{\cftloftitlefont}{\Large\bfseries\color{black}}
\renewcommand{\cftsecfont}{\large\bfseries\color{ceruleanblue}}
\renewcommand{\cftsubsecfont}{\normalsize\bfseries\color{coolblack}}

\makeatletter
\renewcommand\@dotsep{10000}
\makeatother

\DeclareTOCStyleEntry[
  entrynumberformat=\entrynumberwithprefix{\figurename},
  dynnumwidth,
  numsep=1em
]{tocline}{figure}
\newcommand\entrynumberwithprefix[2]{#1\enspace#2:\hfill}

\title{\Huge\bfseries{title}}
\author{\LARGE{author}}
\date{}

\usepackage{microtype}
\usepackage[main=english]{babel}
\usepackage[sorting=ynt, backend=biber, giveninits]{biblatex}
\addbibresource{references.bib}
\DeclareNameAlias{author}{family-given}

\titleformat{\chapter}[hang]{\Large\bfseries\color{cobalt}}{\thechapter}{1em}{}
\titleformat*{\section}{\large\bfseries\color{ceruleanblue}}
\titleformat*{\subsection}{\normalsize\bfseries\color{coolblack}}

\usepackage{comment}

\begin{document}

...

I aligned short reads for the 279 samples of the SGDP, extracted as per \textbf{\Cref{reads}}, ...

...

\end{document}

我希望这能提供足够的背景信息来进行重现;基本上,我希望将我用于章节标题的颜色(天蓝色)叠加到\Cref您在上面看到的特定情况上,但似乎没有任何效果......

任何帮助是极大的赞赏!

答案1

本地更改linkcolor

\documentclass[12pt]{report}

\usepackage{xcolor}
\usepackage{hyperref}
\hypersetup{
    colorlinks,
    citecolor=electricultramarine,
    filecolor=.,
    linkcolor=maroon,
    urlcolor=smokyblack,
    linktoc=all
}
\usepackage[nameinlink]{cleveref}

\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}

\begin{document}

\section{test}\label{reads}

I aligned short reads for the 279 samples of the SGDP, extracted as per 
{\hypersetup{linkcolor=ceruleanblue}\textbf{\Cref{reads}}}

\Cref{reads} should be maroon

\end{document}

在此处输入图片描述

你的前言很乱。首先加载软件包,然后加载hyperref最后cleveref。然后进行设置。

相关内容