部分符号(§)不是彩色超链接 cleveref

部分符号(§)不是彩色超链接 cleveref

所有使用的包的列表:

\usepackage{caption}
\usepackage{blindtext}
\usepackage{pifont,mdframed}
\usepackage{enumitem}
\usepackage{amssymb}
\usepackage{amsmath} % For using \text in equations
\usepackage{hyperref} % Hyperlinks
\usepackage[nameinlink,noabbrev,capitalise]{cleveref} % Better in-doc refs
\usepackage[numbered]{bookmark}
\usepackage{endnotes}
\input{hyperendnotes.sty}
\usepackage{etoolbox}
\usepackage[title,toc,titletoc,page]{appendix}
\usepackage{multirow}
\usepackage[margin=2cm]{geometry}
\usepackage{graphicx}
\usepackage{float} % Better figure and table placements
\usepackage{tabularx}
\usepackage{csquotes} % For blockquote
\usepackage[labelfont=it, labelsep=period]{caption}
\usepackage{subcaption}
\usepackage{color}
\usepackage{xcolor,colortbl}
\usepackage[final]{pdfpages} % used to include pdf to appendicies
\usepackage{lipsum}
\usepackage{microtype} % Slightly tweak font spacing for aesthetics
\usepackage{lettrine}
\usepackage{longtable}
% \usepackage{ragged2e}
\usepackage[export]{adjustbox}
\usepackage{wrapfig}
\usepackage{float}
\usepackage{tabularray}
\usepackage{microtype} % Slightly tweak font spacing for aesthetics
\usepackage{xpatch}

其他设置:

\definecolor{purple}{RGB}{101,48,165}

\hypersetup{
  pdftitle={},
  pdfauthor={},
  pdfkeywords={},
  bookmarksnumbered=true,
  bookmarksopen=false,
  bookmarksopenlevel=1,
  colorlinks=true,
  breaklinks,
  linktoc=section,
  linkcolor=purple,
  linkbordercolor=white,
  citecolor=purple,
  urlcolor=purple,
  pdfborder = {0 0 1},
  pdfview={XYZ null 0 null}
}

\crefformat{section}{\S#2#1#3}
\crefformat{subsection}{\S#2#1#3}
\crefformat{subsubsection}{\S#2#1#3}

结果: §没有颜色。

在此处输入图片描述

答案1

它应该是

\crefformat{section}{#2\S#1#3}
\crefformat{subsection}{#2\S#1#3}
\crefformat{subsubsection}{#2\S#1#3}

因为#2代表“链接开始”和#3“链接结束”。

\documentclass{article}

\usepackage{xcolor}
\usepackage{hyperref} % Hyperlinks
\usepackage[nameinlink,noabbrev,capitalise]{cleveref} % Better in-doc refs

\definecolor{purple}{RGB}{101,48,165}

\hypersetup{
  pdftitle={},
  pdfauthor={},
  pdfkeywords={},
  bookmarksnumbered=true,
  bookmarksopen=false,
  bookmarksopenlevel=1,
  colorlinks=true,
  breaklinks,
  linktoc=section,
  linkcolor=purple,
  linkbordercolor=white,
  citecolor=purple,
  urlcolor=purple,
  pdfborder = {0 0 1},
  pdfview={XYZ null 0 null}
}

\crefformat{section}{#2\S#1#3}
\crefformat{subsection}{#2\S#1#3}
\crefformat{subsubsection}{#2\S#1#3}

\begin{document}

\section{Test section}\label{a}

\subsection{Test subsection}\label{b}

\subsubsection{Test subsubsection}\label{c}

\cref{a}

\cref{b}

\cref{c}

\end{document}

在此处输入图片描述

供您参考,您加载的任何包都不应放在 之后cleveref,而只bookmark应放在 之后hyperref

相关内容