linkcolor 被目录颜色覆盖
Closed this issue · 3 comments
Theigrams commented
在使用模板时发现 交叉引用的颜色都是黑色,觉得很奇怪,查看 elegantbook.cls
后发现这个可能是个 BUG。
问题描述
在设置 hyperref 宏包时,模板已经将 linkcolor 设为 winered 颜色。
Line 101 in a7e5c03
但在后面设置目录颜色时,这一步把所有的 linkcolor 都覆盖了,导致后面交叉引用的颜色都是黑色。
Line 1105 in a7e5c03
最小实现
测试环境:Win10 TeXLive 2019 和 Overleaf TeXLive 2020
\documentclass{elegantbook}
\begin{document}
\tableofcontents
\begin{equation}\label{eq1}
1+1=2
\end{equation}
For equation (\ref{eq1})
\end{document}
但如果将 \tableofcontents
注释掉,则得到的颜色为酒红色。
解决方案
在尾部把 linkcolor 改回来
\renewcommand\tableofcontents{%
\hypersetup{linktoc=all, linkcolor=black}
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\chapter*{\contentsname
\@mkboth{%
\MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
\ifdefstring{\ELEGANT@toc}{twocol}{
\setlength{\columnsep}{2em}
\begin{multicols}{2}%
\@starttoc{toc}
\end{multicols}}{
\@starttoc{toc}}
\if@restonecol\twocolumn\fi
\hypersetup{linkcolor=winered}}
EthanDeng commented
没注意,确实酒红色消失了,谢谢反馈,还提供了解决方案,赞!
EthanDeng commented
作为问题的解决者,你方便提供一个 pr 吗?这样记录你对于这个问题的贡献。