In general, I would like to have my sections in the same two-colored, fading style. I already found the TikZ and the \fadingtext command, which works very well whilst using "LaTeX" or "PDFlatex" for compiling.
Unfortunately, I need to use "XeLaTeX" for my document and I have the problem, that the name just duplicates. I also tried this minimal example and I have the same problem with the sentences. They're colored, but the sentences are just a copy of the first section name. For my sections I just need one fading color (from green to gray) and I also don't have numbered sections, the different colors in this example are just for better understanding.

%!TEX TS-program = xelatex
\tikzset{fading text/.style={}}

  \begin{tikzfadingfrompicture}[name = fading letter]
    \node[text = transparent!0, inner xsep = 0pt, outer xsep = 0pt] {#2};
  \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);% 


\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.}
\fadingtext[left color = orange, right color = green]{This is another colored sentence.}

\section{\fadingtext[left color = red, right color = blue]{Very Important}}


Compiled text using: top picture) XeLaTeX and bottom picture) PDFlatex. Both sections and sentences are colored but with XeLaTeX the first sentence/word is always copied.

Thank you for your help :)

  • 1
    with xetex you would have to declare a new fading for each text. See tex.stackexchange.com/a/445321/2388. Can't you use lualatex instead? – Ulrike Fischer Jan 27 at 17:02
  • Thank you @Ulrike Fischer, I didn't know I can try Lualatex! Obviously I can use Lualatex and it works well. – Franzi Jan 27 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.