问题:我目前正在编写一份文档,其中包含附录中的流程图。在流程图中,我希望能够在节点内包含引文TikZ
(这非常技术性,需要指向不同的软件/方法等)。我想更改图表中引文编号的颜色,但看不到使用包\includestandalone
TikZ
本地更改颜色的方法。当我单独编译 MWE 文件时,我得到(出于某种原因,背景在我的系统上看起来是黑色的,在预览中是白色的):\hypersetup
hyperref
standalone
我偶然发现了 Heiko Oberdiek 对这个问题的回答在自己的包中使用 hypersetup似乎\hypersetup
需要设置前 hyperref
使用它。如何更改文件中TikZ
standalone
仅适用于该图表的引用颜色?
平均能量损失:
\begin{filecontents}[overwrite]{stand_alone.tex}
\documentclass[tikz,border=0pt]{standalone}
\usepackage[backend=biber]{biblatex}
\addbibresource{bibb.bib}
\usepackage{hyperref}
\hypersetup{hidelinks,colorlinks=true,linkcolor=blue,citecolor=blue}
\begin{document}
\begin{tikzpicture}
\node [anchor=west] (Test) at (0, 0) {\cite{a1}};
\end{tikzpicture}
\end{document}
\end{filecontents}
%------------------------------------------------------------------------------------------
\begin{filecontents}[overwrite]{bibb.bib}
@article{a1,author = {Author, One and Lorem, Ipsum},title={Random title}}
\end{filecontents}
%------------------------------------------------------------------------------------------
\documentclass[oneside]{book}
\usepackage{tikz}
\usepackage{standalone}
\usepackage[backend=biber]{biblatex}
\usepackage[hidelinks]{hyperref}
\addbibresource{bibb.bib}
\begin{document}
This citation should have no colour: \cite{a1}
\bigskip
\begin{figure}[h]
\begin{center}
\includestandalone{stand_alone}
\caption{The citation number in this figure should be blue}
\end{center}
\end{figure}
\bigskip
This citation should also have no colour: \cite{a1}
\end{document}
目前的情况:
我正在编译:
% arara: lualatex
% arara: biber
% arara: lualatex
我对这两者都不熟悉standalone
,并且TikZ
我搜索了 TeX.SE,但这超出了我对这两个包/类的了解,而且我不确定我是否知道要搜索的正确术语,如果这是重复的,请见谅。
答案1
我自己设法解决了这个问题,通过编辑biblatex
我正在使用的样式(numeric-comp
):
\AtBeginEnvironment{tikzpicture}{%
\DeclareCiteCommand{\cite}
{\color{blue}\usebibmacro{cite:init}%
\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{cite:comp}}
{}%
{\usebibmacro{cite:dump}%
\usebibmacro{postnote}}%
}
\cite
可以从样式文件中找到每种样式的定义。biblatex
现在的输出:
\begin{filecontents}[overwrite]{stand_alone.tex}
\documentclass[tikz,border=0pt]{standalone}
\usepackage[backend=biber]{biblatex}
\addbibresource{bibb.bib}
\usepackage{hyperref}
\hypersetup{hidelinks,colorlinks=true,linkcolor=blue,citecolor=blue}
\begin{document}
\begin{tikzpicture}
\node [anchor=west] (Test) at (0, 0) {\cite{a1}};
\end{tikzpicture}
\end{document}
\end{filecontents}
%------------------------------------------------------------------------------------------
\begin{filecontents}[overwrite]{bibb.bib}
@article{a1,author = {Author, One and Lorem, Ipsum},title={Random title}}
\end{filecontents}
%------------------------------------------------------------------------------------------
\documentclass[oneside]{book}
\usepackage{tikz}
\usepackage{standalone}
\usepackage{etoolbox} % --- Added
\usepackage[backend=biber,style=numeric-comp]{biblatex}
\usepackage[hidelinks]{hyperref}
\AtBeginEnvironment{tikzpicture}{%
\DeclareCiteCommand{\cite}
{\color{blue}\usebibmacro{cite:init}%
\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{cite:comp}}
{}%
{\usebibmacro{cite:dump}%
\usebibmacro{postnote}}%
}
\addbibresource{bibb.bib}
\begin{document}
This citation should have no colour: \cite{a1}
\bigskip
\begin{figure}[h]
\begin{center}
\includestandalone{stand_alone}
\caption{The citation number in this figure should be blue}
\end{center}
\end{figure}
\bigskip
This citation should also have no colour: \cite{a1}
\end{document}
不确定这是否是最好的解决方案,或者是否是最佳解决方案,standalone
但hyperref
它有效。