[Tex/LaTex] How to draw a horizontal rule with a colour gradient

gradient

enter image description here

Look at the two blue coloured rules with a colour gradient. This is what I'm looking for. Thank You.

Best Answer

You can control the distance between the gradients and text changing the values 1em for example. Also, the height for rectangle could be changed 1.5em.

\documentclass{article}
\usepackage{lipsum}%dummy text only
\usepackage{tikz}
\usetikzlibrary{fadings}
\newcommand{\gradient}[1]{\noindent%
    \begin{tikzpicture}
    \fill[cyan,path fading=east] (0,1em) rectangle (\linewidth,1.5em);
    \node at (.5\linewidth,0) {\bfseries #1};
    \fill[cyan,path fading=west] (0,-1em) rectangle (\linewidth,-1.5em);
    \end{tikzpicture}%
}

\begin{document}
\lipsum[1]
\gradient{Thermodynamics}
\lipsum[2]
\end{document}

enter image description here