总的来说,我希望我的部分采用相同的双色渐变样式。我已经找到了 TikZ 和 \fadingtext 命令,在使用“LaTeX”或“PDFlatex”进行编译时,它们工作得很好。
不幸的是,我需要为我的文档使用“XeLaTeX”,但我遇到了一个问题,即名称重复。我也尝试了这个最小示例,但句子也出现了同样的问题。它们是彩色的,但句子只是第一个部分名称的副本。对于我的部分,我只需要一个渐变颜色(从绿色到灰色),而且我也没有编号部分,本例中的不同颜色只是为了更好地理解。
%!TEX TS-program = xelatex
\documentclass[border=10pt,varwidth]{standalone}
\usepackage{tikz}
\usetikzlibrary{fadings}
\tikzset{fading text/.style={}}
\newcommand\fadingtext[2][]{%
\begin{tikzfadingfrompicture}[name = fading letter]
\node[text = transparent!0, inner xsep = 0pt, outer xsep = 0pt] {#2};
\end{tikzfadingfrompicture}%
\begin{tikzpicture}[baseline = (textnode.base)]
\node[inner sep = 0pt, outer sep = 0pt] (textnode) {\phantom{#2}};
\shade[path fading = fading letter, fading text, #1, fit fading = false]
(textnode.south west) rectangle (textnode.north east);%
\end{tikzpicture}%
}
\begin{document}
\tikzset{fading text/.style = {left color = red, right color = green}}
\section{\fadingtext[left color = orange, right color = green]{Important}}
For testing the alignment:
\fadingtext[left color = red, right color = blue]{Here is a colored sample sentence.}
And
\fadingtext[left color = orange, right color = green]{This is another colored sentence.}
\section{\fadingtext[left color = red, right color = blue]{Very Important}}
\end{document}
感谢您的帮助 :)