# Make a rainbow line

I found a template for a title page: https://www.latextemplates.com/template/vertical-line-title-page

There's a piece of code that draws a vertical line:

\rule{1pt}{\textheight} % Vertical line


I've worked out that I can add color in the following way:

\textcolor{mycolor}{\rule{3pt}{\textheight}}


However, this makes the line only single color. The title of my book is "The Rainbow Book", so I'd like the line to be... well - a rainbow. Is there a simple way e.g. to define my color as a gradient or so ?

No gradient really yet, just a bunch of vertical lines with colors changing from red to violet in \foreach loop.

\documentclass{article}
\usepackage[named]{xcolor}
\usepackage{pgffor}
\begin{document}
\foreach \x in {red,orange,yellow,green,blue,violet} {%
\textcolor{\x}{\rule{3pt}{\textheight}}%
}
\end{document}


And another version with TikZ and a vertical shading with \pgfdeclareverticalshading, which is taken from the pgf manual (see page 1088 of current manual version). It starts from red to blue but the shading is different, so shading angle=270 is used in order to rotate the order of the direction, otherwise use shading angle=90. If a vertical shading is desired, omit the shading angle key.

\documentclass{article}
\usepackage[named]{xcolor}
\usepackage{pgffor}
\usepackage{tikz}


• ...what about indigo (I guess ...,blue,blue!50!violet,violet would work)? – Werner Jul 10 '17 at 23:58