TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 3 down vote accepted

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

enter image description here

The code is:

% also works with oneside option and with non Koma Class like article

% Package used for custom page numbers

% package for drawing

% package used for tests

% Define lemon color

% Sep up Page numbering font

% create new custom page style "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
    \node at (\notblank{#1}{-}{}3mm,\textheight+\footskip-3pt)
    [minimum width=1.1cm,minimum height=1.1cm,
    below \notblank{#1}{left}{right}](n)
    \draw[color=lemon,line width=3pt] (n.north east) -- (n.north west);
    \draw[color=lemon,line width=1pt] (n.south east) -- (n.south west);


This is some text

Some more text.

share|improve this answer

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