7

How to create a coloured page border for a document using KOMA-Script scrbook class?

Something like this:

enter image description here

(image taken from the memoir tutorial)

vanden
  • 30,891
  • 23
  • 67
  • 87
yolo
  • 3,303

1 Answers1

9

You could use TikZ

This example can give an idea how to use it:

\documentclass[english]{scrbook}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel,blindtext}

\usepackage{scrpage2}
\usepackage{tikz}
\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)$);
        \node [fill=green, text width=1.5cm, align=center] at
            ($(current page.south)+(0,4cm)$) {\strut\pagemark};
            % \strut gives all page mark nodes the same hight.
    \end{tikzpicture}
}
% set page style
\cehead[\pageframe]{\pageframe}
\cohead[\pageframe]{\pageframe}
\pagestyle{scrheadings}

\begin{document}
\Blinddocument
\end{document}

When using different definitions of \cehead and \lefoot (or other heading-commads) you can define different borders for left and right pages. You can even “draw” the pagemark with the TikZ way.

Note that TikZ needs two latex-runs to get the right positions.

See PGF Manual, section 16.13.2 Referencing the Current Page Node – Absolute Positioning and the KOMA-Script Manual about using scrpage2.

Tobi
  • 56,353
  • As mentioned in “Tikz rectangle hiding text!” theres a problem when using the foot to define the border so I changed the example. No it uses the center head instead of left foot to draw the frame (an everything else) behind the text body. This makes it even easier to draw the frame cause we can use two overlaying rectangles instead of four arbors which gives us the opportunity to make the inner rectangle with rounded corners. – Tobi May 16 '11 at 09:05
  • +1 for \strut! – imnothere May 16 '11 at 09:32