I'm trying to draw a band with a shading over a whole page. This band should have a small angle of 15° from west to east. But I seem to be unable to give the shading the "correct" angle too. How can it be done? It should look like this only with a tilt:

\documentclass{report}
\usepackage{tikz}
{color(0cm)=(red); color(0.5cm)=(blue); color(3cm)=(yellow)}

\begin{document}
\begin{tikzpicture}[overlay,remember picture]

]([yshift=4cm]current page.west)--++(15:1.2\paperwidth)--++(0,-2cm) --([yshift=2cm]current page.west)--cycle;

top color=yellow,
bottom color=blue,
%middle color=red,
](current page.west)--++(15:1.2\paperwidth)--++(0,-2cm) --([yshift=-2cm]current page.west)--cycle;
\end{tikzpicture}
\mbox{}
\end{document}


• Rotating and clipping? Apr 22 '19 at 16:07
• @egreg rotating is not so easy either: you seem to need a transform canvas and with it I lost the current page nodes. Apr 22 '19 at 16:14

Shade always uses the bounding rectangle, so "rotating and clipping" as suggested by egreg is a way to go. transform canvas also works but has sometimes weird side effects.

\documentclass{report}
\usepackage{tikz}
{color(0cm)=(red); color(0.5cm)=(blue); color(3cm)=(yellow)}
\begin{document}
top color=yellow,
bottom color=blue] (0,0) rectangle (2\paperwidth+3cm,2cm);}}
\begin{tikzpicture}[overlay,remember picture]
\begin{scope}
\clip      ([yshift=4cm]current page.west)--++(15:1.2\paperwidth)--++(0,-2cm) --([yshift=2cm]current page.west)--cycle;
\path ([yshift=3cm]current page.west) +(15:0.6\paperwidth)
\end{scope}
\begin{scope}
\clip(current page.west)--++(15:1.2\paperwidth)--++(0,-2cm) --([yshift=-2cm]current page.west)--cycle;
\path ([yshift=-1cm]current page.west) +(15:0.6\paperwidth)
\end{scope}
\end{tikzpicture}
\mbox{}
\end{document}


P.S. I am not sure I understand the purpose of the dimension you chose in \documentclass{report} \usepackage{tikz} \pgfdeclareverticalshading{titlepage}{....

P.P.S. A visual explanation of what's going on. If you look at

\documentclass{report}
\usepackage{tikz}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[overlay,remember picture]
top color=yellow,
bottom color=blue,
%middle color=red,
](current page.west)--++(15:1.2\paperwidth)--++(0,-2cm) --([yshift=-2cm]current page.west)--cycle;

top color=yellow,
bottom color=blue,
%middle color=red,
([yshift={2cm+sin(15)*1.2\paperwidth}]current page.south west)
rectangle (current page.south east);
\draw ([yshift=2cm]current page.south west)
--++(15:1.2\paperwidth)--++(0,-2cm) --(current page.south west)--cycle;
\end{tikzpicture}
\mbox{}
\end{document}


then you see what you get: the region bounded by the solid line of the full rectangle. The shading angle refers to the shading angle of the full rectangle, which gets distorted by the dimensions of the embedding rectangle compared to what you need. This also explains that you do not get the full spectrum of colors, simply because you cut out a bit of the "big picture". You can rectify this as above or by using transform canvas, which I will be happy to add to the answer but I hesitate because it can do harm in other applications.

• Buh. I'm never hash ;-). But it looks as if I at least didn't overlook a simple solution. Apr 22 '19 at 16:23
• @UlrikeFischer This comment was not meant for you. ;-) BTW, don't you have a marmot living with you? She will have a better solution.
– user121799
Apr 22 '19 at 17:59
• For a reason that I don't understand I get in my example a rather good output with shading angle=38 (the yellow is missing a bit but at least the direction is correct. Do you have an explanation why this value seems to work? Apr 22 '19 at 21:34
• @UlrikeFischer The shading is applied to the full bounding rectangle, whose sides are parallel to the sides of the page. 38 is an accident. And you cut out a lot of shading, which is why the top and bottom colors do not match what you put in.
– user121799
Apr 22 '19 at 21:41
• @UlrikeFischer I added a visual explanation hoping it makes things clearer.
– user121799
Apr 22 '19 at 21:55