I would like to add gradient color for lines of words and long ones are just causing trouble.
Here is the code
\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usepackage{lipsum}
\usetikzlibrary{fadings}
\newcommand\fadingtext[3][]{%
\begin{tikzfadingfrompicture}[name=fading letter]
\node[text=transparent!0,inner xsep=0pt,outer xsep=0pt,#1] {#3};
\end{tikzfadingfrompicture}%
\begin{tikzpicture}[baseline=(textnode.base)]
\node[inner sep=0pt,outer sep=0pt,#1](textnode){\phantom{#3}};
\shade[path fading=fading letter,#2,fit fading=false]
(textnode.south west) rectangle (textnode.north east);%
\end{tikzpicture}%
}
\begin{document}
\pagestyle{plain}
\noindent
\fadingtext{left color=YellowOrange, right color = Cyan}{In physics, relativistic angular momentum refers to the mathematical formalisms and physical concepts that define angular momentum in special relativity (SR) and general relativity (GR). The relativistic quantity is subtly different from the three-dimensional quantity in classical mechanics.}
\
\noindent
\fadingtext{left color=YellowOrange, right color = Cyan}{In physics, relativistic angular momentum refers to the mathematical formalisms and} \fadingtext{left color=Green, right color = RawSienna}{physical concepts that define}
\
\noindent
In physics, relativistic angular momentum refers to the mathematical formalisms and physical concepts that define angular momentum in special relativity (SR) and general relativity (GR). The relativistic quantity is subtly different from the three-dimensional quantity in classical mechanics.
\end{document}
And apparently the line breaking is not working here
We can see that the colored text is going beyond the range of the margin.
Thanks in advance for anyone who helps.
While using
\parbox{\textwidth}
in the text really helps. But for text with different color gradient in same line, there would be trouble
\noindent
\fadingtext{left color=YellowOrange, right color = Cyan}{\parbox{\textwidth}{In physics,}} \fadingtext{left color=Black, right color = Red}{\parbox{\textwidth}{relativistic angular momentum refers}}
The output looks like