I want to fill the area with different color within one page, and I find this question How to change the background color within a page.
After reading the answer of the above question, I think the format is this:
\fill[<the color I want to use>] ([xshift=<the offset in x dirction>,yshift=<the offset in y dirction>]<one vertex of diagnol of the rectangle>) rectangle ([xshift=<the offset in x dirction>,yshift=<the offset in y dirction>]<another vertex of the same diagnol of the rectangle>);
So I write the following code
\documentclass{article}
\usepackage{tikz}
\newcommand{\amount}{0.33\paperheight}
\begin{document}
\begin{tikzpicture}[remember picture,overlay]
\fill[green] (current page.north west) rectangle ([yshift=-\amount]current page.north east);
\fill[yellow] ([yshift=-\amount]current page.north west) rectangle ([yshift=-2\amount]current page.north east);
\fill[red]([yshift=-2\amount]current page.north west) rectangle ([yshift=-3\amount]current page.north east);
\end{tikzpicture}
\end{document}
to fill the page with three colors. But I get the error 'Dimension too large.'
\newlengthinstead of\newcommand). – Dr. Manuel Kuehner Sep 24 '17 at 15:23-2\amountis-20.33\paperheightwhich is a bigger shift than intended. so\newlength\amount\setlength\amount{0.33\paperheight}– David Carlisle Sep 24 '17 at 15:25yshift=2\amountbyyshift=2*\amount(and the same for the otheryshiftoptions). Then it will work with\newcommandtoo. – esdd Sep 24 '17 at 15:48\newlengthis semantically better. – Dr. Manuel Kuehner Sep 24 '17 at 15:52