Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question

marked as duplicate by lockstep, Joseph Wright Jan 8 '12 at 9:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Both lockstep's and simeonr's solutions work alright; simeonr's seems to reproduce the result exactly. –  Joseph Jan 8 '12 at 1:27
    
is this really a duplicate? Joseph wanted these rules and different positioning, so he couldn't use the solution from tex.stackexchange.com/questions/24362/… –  someonr Jan 9 '12 at 18:59

1 Answer 1

up vote 3 down vote accepted

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}
share|improve this answer

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