2

Possible Duplicate:
Page numbers vertically centered in the outer page margin

I'd like to put the number on the page on the margin, but at some distance from the top margin (possibly with the rules as well). This figure shows an example (from MS Word...:

enter image description here

  • Both lockstep's and simeonr's solutions work alright; simeonr's seems to reproduce the result exactly. –  Jan 08 '12 at 01:27
  • is this really a duplicate? Joseph wanted these rules and different positioning, so he couldn't use the solution from http://tex.stackexchange.com/questions/24362/page-numbers-vertically-centered-in-the-outer-page-margin – someonr Jan 09 '12 at 18:59

1 Answers1

3

You can use tikz and scrpage2. I got the following result:

enter image description here

The code is:

\documentclass[twoside]{scrartcl}
% also works with oneside option and with non Koma Class like article

% Package used for custom page numbers
\usepackage{scrpage2}

% package for drawing
\usepackage{tikz}

% package used for tests
\usepackage{etoolbox}

% Define lemon color
\definecolor{lemon}{HTML}{cedead}

% Sep up Page numbering font
\renewcommand*{\pnumfont}{%
    \normalfont\sffamily\Large\color{black!40}}

% create new custom page style "fancy"
\newpagestyle{fancy}{%
    {} %head twoside even
    {} %head twoside odd
    {} %head oneside
    }{%
    {\tikzpagemark[e]} %foot twoside even
    {\hfill\tikzpagemark} %foot twoside odd
    {\hfill\tikzpagemark} %foot oneside}
} 

% This command creates the custom page numbers
% If optional parameter is used \tikzpagemark creates pagemark for the left side
\newcommand{\tikzpagemark}[1][]{%
    \begin{tikzpicture}[overlay]
    \node at (\notblank{#1}{-}{}3mm,\textheight+\footskip-3pt)
    [minimum width=1.1cm,minimum height=1.1cm,
    below \notblank{#1}{left}{right}](n)
    {\pagemark};
    \draw[color=lemon,line width=3pt] (n.north east) -- (n.north west);
    \draw[color=lemon,line width=1pt] (n.south east) -- (n.south west);
    \end{tikzpicture}}

\pagestyle{fancy}   

\usepackage{lipsum}
\begin{document}
This is some text

Some more text.

\lipsum[1-10]
\end{document}
someonr
  • 8,531