![如何防止 tikz 節點 [fill=black, text=white] 中的彩色引用連結(hyperref)將文字顏色重設為黑色?](https://rvso.com/image/357881/%E5%A6%82%E4%BD%95%E9%98%B2%E6%AD%A2%20tikz%20%E7%AF%80%E9%BB%9E%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%80%A3%E7%B5%90%EF%BC%88hyperref%EF%BC%89%E5%B0%87%E6%96%87%E5%AD%97%E9%A1%8F%E8%89%B2%E9%87%8D%E8%A8%AD%E7%82%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}