我怎样才能将“\gtrsymBorn”符号显示为红色?

我怎样才能将“\gtrsymBorn”符号显示为红色?

我怎样才能将\gtrsymBorn符号显示为红色?他按照 MWE 返回LaTeX Error: Option clash for package xcolor.

\documentclass{article}

\usepackage{genealogytree}
\usepackage[dvipsnames]{xcolor}

\begin{document}

\color{Red}{Text \gtrsymBorn}

\end{document}

答案1

请参阅手册中的第 9.1.2 节genealogytree

\documentclass{article}

\usepackage[dvipsnames]{xcolor}
\usepackage{genealogytree}

\begin{document}

{\gtrSymbolsSetCreate{Red}\gtrsymBorn}
\gtrsymBorn{}
{\gtrSymbolsSetCreate{red}\gtrsymBorn}

\end{document}

xcolor之前加载过genealogytree,以前是需要的(现在不需要了)。或者你也可以这样做

\documentclass[dvipsnames]{article}
\usepackage{genealogytree}

\begin{document}

{\gtrSymbolsSetCreate{Red}\gtrsymBorn}
\gtrsymBorn{}
{\gtrSymbolsSetCreate{red}\gtrsymBorn}

\end{document}

在此处输入图片描述

请注意,genealogytree默认情况下不会让其符号遵循当前颜色。但您可以重新定义它们来做到这一点。恐怕您需要传递一个您想要使其“了解当前颜色”的符号名称列表。

\documentclass{article}

\usepackage[dvipsnames]{xcolor}
\usepackage{genealogytree}
\gtruselibrary{templates}

\ExplSyntaxOn
\NewDocumentCommand{\colorizegtrsymbols}{m}
 {
  \clist_map_function:nN { #1 } \__stucke_colorize:n
 }

\cs_new_protected:Nn \__stucke_colorize:n
 {% genealogytree symbols are simple macros
  \cs_set_eq:cc { __stucke_colorize_#1: } { #1 }
  \ExpandArgs{c}\RenewDocumentCommand{#1}{}
   {
    \gtrSymbolsSetCreate{.}\use:c { __stucke_colorize_#1: }
   }
 }
\ExplSyntaxOff

% make some symbols “color aware”, add to the list
\colorizegtrsymbols{gtrsymBorn,gtrsymDied}

\begin{document}

Text \gtrsymBorn{} \gtrsymDied{}

\textcolor{Red}{Text \gtrsymBorn{} \gtrsymDied{}}

\begin{tikzpicture} \genealogytree[template=signpost,timeflow=left,level size=3cm]
{
  parent[id=DoeJones]{
    g[id=Deir2012,female]{Deirdre\\\gtrsymBorn\,2012}
    parent[id=Jones]{
      g[id=Mary1988,female]{Aunt Mary\\\gtrsymBorn\,1988}
      p[id=JimJ1944,male]{\color{Red}Jim Jones\\\gtrsymDied\,1944}
      % the following node is going to be ignored
      p[ignore,id=Jenn1949,female]{Jenny Jones\\\gtrsymBorn\,1949}
    }
  }
}
\end{tikzpicture}

\end{document}

我从软件包文档中选取了一个例子来表明,至少在这个实验中,颜色符合预期。您可以随意扩充列表。

在此处输入图片描述

相关内容