2

I'd like to do some fading of my background page from the middle to top and bottom - so far as good. My Problem is that I don't want to start the fading immediatly (e.g. the upper third is faded, the middle third is background color, the lower third is faded).

So my suggestions are two ways: a) Manipulate somehow the fading speed (I read the corresponding thread but was not able to do the necessary adjustments) and work with "color top", "color bottom", and "color middle". b) Draw two rectangles at the top and the bottom which are faded in one direction.

My problem: While a) looks "good" but has no extended middle background color part, b) creates some mysterious lines in my output file at the boundaries (the lines are not printed in texmaker but in all of my pdf viewers):

boundaries at fading rectangles

Below a minimal working example for version b:

\documentclass{report}
\usepackage{tikz}
\usetikzlibrary{calc,fadings}
\definecolor{colorBackground}{RGB}{65,110,131}

\begin{document}

\begin{tikzpicture}[remember picture,overlay]
  \fill[color=colorBackground] (current page.north west) rectangle (current page.south east);
  \fill[top color=colorBackground!0, bottom color=colorBackground] (current page.north west) rectangle ($(current page.north west)+(\paperwidth,-10cm)$);
  \fill[top color=colorBackground, bottom color=colorBackground!0] (current page.south west) rectangle ($(current page.south west)+(\paperwidth,+10cm)$);
\end{tikzpicture}

\end{document}

Kind regards!

  • Welcome! Which thread? Please provide a link to what you read - it may help somebody else help you, even if it did not help you directly. – cfr Dec 16 '16 at 2:32
  • The lines may just be artefacts. Do they go away when you zoom? Do they print? I can't see them in my viewer ... – cfr Dec 16 '16 at 2:35
0

I cannot reproduce the lines you describe and they are likely a viewer artefact. If your document will be printed, that's not a big deal. Otherwise, you might see if this works any better. You will need to adjust the specific points at which the shading changes. I don't know what paper you are using, so I'm not sure what is needed for 10cm. However, I think that you want to change colour at (25bp-(10cm/\paperheight)*50bp) and (75bp-(10cm/\paperheight)*50bp). The shading should total 100bp by 100bp. Only the middle ninth of it will be used i.e. the middle third vertically and the middle third horizontally. So imagine a square divided into thirds horizontally and vertically. Your square needs to be 100bp in length and the middle square will be the bit actually used.

That is, that bit will be used in this case. If you were rotating it or something, it gets more complicated. But you're not rotating it, so it is (relatively!) straightforward.

\documentclass{report}
\usepackage{tikz}
\definecolor{colorBackground}{RGB}{65,110,131}

\begin{document}

\pgfdeclareverticalshading[colorBackground]{pageshade}{100bp}{%
  color(0bp)=(white);
  color(25bp)=(white);
  color(40bp)=(colorBackground);
  color(60bp)=(colorBackground);
  color(75bp)=(white);
  color(100bp)=(white)
}

\begin{tikzpicture}[remember picture, overlay]
  \shade [shading=pageshade] (current page.north east) rectangle (current page.south west);
\end{tikzpicture}


\end{document}

custom shading

  • Thanks for the anser - I although thought about some kind of an artefact but I was not sure about it because every viewer showed it, although considering differnt zooms. Anyway your approach works perfectly for me and now I although understand what is happening (the 10cm were only a suggestion :P) Thanks! – twister Dec 16 '16 at 7:47

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.