# problem with scrpage2 and coloured borders

I'm trying to do this

\usepackage{scrpage2}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{calc}
%\usetikzlibrary{intersections}
%\tikzset{variable/.default=}
\newcommand{\pageframe}{%
\begin{tikzpicture}[remember picture, overlay]
% page frame
\fill[red](current page.north west) rectangle (current page.south east);
\fill[white,rounded corners=1cm]($(current page.north west)+%(1cm,-1cm)$) rectangle ($(current page.south east)+(-1cm,4cm)$);
%       \node[fill=green,text width=1.5cm,text centered]
%           at ($(current page.south)+(0,4cm)$){\strut\pagemark};
%%       \strut gives all page mark nodes the same hight.
\end{tikzpicture}
}
% set page style


but it fails to compile:

! Argument of \tikz@cc@parse@factor has an extra }.


I don't get it; if I comment the last line, \pagestyle{scrheadings}, it compiles, though output remains unmodified...

-
The reason for it not compiling is because of the incomplete second \fill command. In (La)TeX, % represents a comment character, implying that everything after (to the right of) it will be disregarded. You either remove/comment the entire line or understand the command structure of \fill to modify it accordingly. Finally, it compiles fine when you comment \pagestyle{scrheadings} because the \pageframe macro (containing the problematic \fill) is only executed once you set the page style to scrheadings. If you don't set these headings, the incomplete code is never executed. – Werner Feb 25 '12 at 15:23

Remove the percent sign % in the second fill line. Here's a compilable version:

\documentclass{scrbook}
\usepackage{scrpage2}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{calc}
\newcommand{\pageframe}{%
\begin{tikzpicture}[remember picture, overlay]
% page frame
\fill[red](current page.north west) rectangle (current page.south east);
\fill[white,rounded corners=1cm]($(current page.north west) +(1cm,-1cm)$) rectangle ($(current page.south east)+(-1cm,4cm)$);
\end{tikzpicture}
}
% set page style