![如何防止 tikz 节点 [fill=black, text=white] 中的彩色引用链接(hyperref)将文本颜色重置为黑色?](https://linux22.com/image/357881/%E5%A6%82%E4%BD%95%E9%98%B2%E6%AD%A2%20tikz%20%E8%8A%82%E7%82%B9%20%5Bfill%3Dblack%2C%20text%3Dwhite%5D%20%E4%B8%AD%E7%9A%84%E5%BD%A9%E8%89%B2%E5%BC%95%E7%94%A8%E9%93%BE%E6%8E%A5%EF%BC%88hyperref%EF%BC%89%E5%B0%86%E6%96%87%E6%9C%AC%E9%A2%9C%E8%89%B2%E9%87%8D%E7%BD%AE%E4%B8%BA%E9%BB%91%E8%89%B2%EF%BC%9F.png)
以下 MWE 应该可以证明该问题:
\documentclass[12pt]{article}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{companion,
author = {Goossens, Michel and Mittelbach, Frank and Samarin, Alexander},
title = {The {LaTeX} Companion},
date = 1994,
edition = 1,
publisher = {Addison-Wesley},
location = {Reading, Mass.},
pagetotal = 528,
langid = {english},
langidopts = {variant=american},
sorttitle = {LaTeX Companion},
indextitle = {LaTeX Companion, The},
shorttitle = {LaTeX Companion},
}
\end{filecontents}
\usepackage[english]{babel}
\usepackage[autolang=other,
style=alphabetic,
backend=biber,
%backref=true,
]{biblatex}
\addbibresource{\jobname.bib}
\usepackage{tikz}
\usepackage[pdfencoding=auto,
final=true,
colorlinks=true,
citecolor=yellow,
% linkcolor=blue,
% anchorcolor=purple,
% urlcolor=green,
]{hyperref}
\begin{document}
\begin{tikzpicture}
\node[draw, rectangle,
minimum height=100mm,
text width=10cm,
align=center,
fill=black,
text=white,] {\huge
%\hypersetup{citecolor=green}
Hello World!
\cite[p. 100]{companion}
Where am I? %you are there, but invisible due to wrong text color
\textcolor{white}{Ahh, hello again!}
};
\end{tikzpicture}
\noindent
I have two problems:
\begin{enumerate}
\item
Manually resetting the textcolor is inefficient and
\item
even if the textcolor is reset right after the cite command the text until the cite's closing bracket ', p. 100]' is not affected (it remains invisible).
\end{enumerate}
Question: Is there a comfortable solution to get the cite mark colored?
\printbibliography
\end{document}
我做错了什么?我的构建环境:Win7-64,Texlive 2017,luaLaTeX
答案1
使用该包(TeXLive-2017、MiKTeX)生成的 OCG 彩色链接ocgx2
似乎解决了两个报告的问题,另外还额外提供了以当前文本颜色打印在纸上的 OCG 彩色链接white
。
\documentclass[12pt]{article}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{companion,
author = {Goossens, Michel and Mittelbach, Frank and Samarin, Alexander},
title = {The {LaTeX} Companion},
date = 1994,
edition = 1,
publisher = {Addison-Wesley},
location = {Reading, Mass.},
pagetotal = 528,
langid = {english},
langidopts = {variant=american},
sorttitle = {LaTeX Companion},
indextitle = {LaTeX Companion, The},
shorttitle = {LaTeX Companion},
}
\end{filecontents}
\usepackage[english]{babel}
\usepackage[autolang=other,
style=alphabetic,
backend=biber,
%backref=true,
]{biblatex}
\addbibresource{\jobname.bib}
\usepackage{tikz}
\usepackage[pdfencoding=auto,
final=true,
% colorlinks=true,
citecolor=yellow,
% linkcolor=blue,
% anchorcolor=purple,
% urlcolor=green,
]{hyperref}
\usepackage[ocgcolorlinks]{ocgx2}
\begin{document}
\begin{tikzpicture}
\node[draw, rectangle,
minimum height=100mm,
text width=10cm,
align=center,
fill=black,
text=white,] {\huge
%\hypersetup{citecolor=green}
Hello World!
\cite[p. 100]{companion}
Where am I?
%\textcolor{white}{Ahh, hello again!}
Ahh, hello again!
};
\end{tikzpicture}
%\noindent
%I have two problems:
%\begin{enumerate}
%\item
%Manually resetting the textcolor is inefficient and
%
%\item
%even if the textcolor is reset right after the cite command the text until the cite's closing bracket ', p. 100]' is not affected (it remains invisible).
%\end{enumerate}
%
%Question: Is there a comfortable solution to get the cite mark colored?
\printbibliography
\end{document}