# page number in a diamond box

I have the following code I need to put the page number at the top of the page resulted in a diamond box. I would be grateful for any help or if you can indicate to me the code to generate it.

There is something I forgot, the page number should be on the left for the even pages and on the right for the odd pages.

-
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. –  Marco Daniel Jul 7 '13 at 18:05
Where is your code? Please add a minimal working example (MWE). –  Marco Daniel Jul 7 '13 at 18:05
Should the position alternate from left to right in even and odd-numbered pages or should it always be to the left? –  Gonzalo Medina Jul 7 '13 at 18:08
I dont have any code. I want you give me the code see the picture –  user32944 Jul 7 '13 at 18:18
alternate from left to right .odd number at left. –  user32944 Jul 7 '13 at 18:21

One option using the fancyhdr and tikzpagenodes packages:

\documentclass{book}
\usepackage[a6paper]{geometry}
\usepackage{fancyhdr}
\usepackage{tikzpagenodes}
\usetikzlibrary{shapes.geometric}
\usepackage{lipsum}

\pagestyle{fancy}
\fancyhf{}
\node[diamond,draw,font=\small\itshape] at (current page header area.south west) (dia) {\thepage};
\draw[double=white] (dia.east) -- (current page header area.south east);
\end{tikzpicture}}
\node[diamond,draw,font=\small\itshape] at (current page header area.south east) (dia) {\thepage};
\draw[double=white] (dia.west) -- (current page header area.south west);
\end{tikzpicture}}

\begin{document}

\chapter{Test chapter}
\lipsum[2]
\section{Test section}
\lipsum[2]\lipsum[2]\lipsum[2]\lipsum[2]\lipsum[2]

\end{document}


If the horizontal rules are not to be of the same width:

\documentclass{book}
\usepackage[a6paper]{geometry}
\usepackage{fancyhdr}
\usepackage{tikzpagenodes}
\usetikzlibrary{shapes.geometric}
\usepackage{lipsum}

\pagestyle{fancy}
\fancyhf{}
\node[diamond,draw,font=\small\itshape] at (current page header area.south west) (dia) {\thepage};
\draw (dia.3) -- (current page header area.south east|-dia.3);
\draw (dia.357) -- ([xshift=-7pt]current page header area.south east|-dia.357);
\end{tikzpicture}}
\node[diamond,draw,font=\small\itshape] at (current page header area.south east) (dia) {\thepage};
\draw (dia.177) -- (current page header area.south west|-dia.177);
\draw (dia.183) -- ([xshift=7pt]current page header area.south west|-dia.183);
\end{tikzpicture}}

\begin{document}

\chapter{Test chapter}
\lipsum[2]
\section{Test section}
\lipsum[2]\lipsum[2]\lipsum[2]\lipsum[2]\lipsum[2]

\end{document}


-
there is something i forgot . in the even pages at left be chapter's name .and in odd pages at right , season's .thank you for code –  user32944 Jul 7 '13 at 18:53
@user32944 please see my updated answer. Don't forget (noe that you've received some answers) that you can accept the one you consider best solved your problem by clicking the checkmark to its left. In case of doubt, please see How do you accept an answer?. –  Gonzalo Medina Jul 7 '13 at 19:20

Borrowing from Gonzalo Medina's solution, but making it free of tikz, and with the double line of different lengths:

\documentclass{book}
\usepackage[a6paper]{geometry}% just for the example
\usepackage{fancyhdr}
\usepackage{stackengine}
\usepackage{graphicx}
\usepackage{lipsum}% just to generate text for the example

\pagestyle{fancy}
\fancyhf{}
\def\stackalignment{c}%
\topinset{\itshape\thepage}{\scalebox{5}{$$\diamond$$}}{1.5ex}{}%
\rule{-.2ex}{0ex}%
\def\stackalignment{l}%
\stackon[1pt]{\rule[2.8ex]{2.5in}{.1ex}}{\rule{2.55in}{.1ex}}}
\topinset{\itshape\thepage}{\scalebox{5}{$$\diamond$$}}{1.5ex}{}}