# Changing the shape of a text box in the header

I have a question regarding the following code:

    \documentclass[a4paper]{book}

\usepackage{xcolor}
\setlength{\topmargin}{-1.5cm}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand\chaptermark[1]{\markboth{\chaptername\ \thechapter:\enskip#1}{}}
\fancyhf{}

\makebox[0pt][r]{
}
\makebox[0pt][l]{%
}

\usepackage{blindtext}% dummy text

\fancypagestyle{plain}{
\fancyhf{}
\makebox[0pt][r]{
}
\makebox[0pt][l]{%
}
}
\usepackage{mathptmx}
\begin{document}
\blinddocument
\end{document}


The purpose of this code is to give a filled horizontal rectangle in the header of each page, which contains the page number (the side of the page the rectangle is on changes depending on whether the page is odd or even). I was wondering if anyone could suggest a slight amendment to the code, so that, instead of inside a rectangle, the page number sits inside a pentagon, as shown in the picture

A partial solution with a TikZ signal shape follows. You'll have to adjust signal length to reach page border.

    \documentclass[a4paper]{book}
\usepackage{tikz}
\usetikzlibrary{shapes.symbols}

\usepackage{xcolor}
\setlength{\topmargin}{-1.5cm}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand\chaptermark[1]{\markboth{\chaptername\ \thechapter:\enskip#1}{}}
\fancyhf{}

\makebox[0pt][r]{\tikz[baseline] \node[anchor=base, signal, font=\bfseries, text=white, signal to=east, fill=headbgcolor, text width=\marginparwidth, align=right]{\thepage};
\hspace*{1em}}%
}

\makebox[0pt][l]{%
\hspace*{1em}\tikz[baseline] \node[anchor=base, signal, font=\bfseries, text=white, signal to=west, fill=headbgcolor, text width=\marginparwidth, align=left]{\thepage};}%
}

\usepackage{blindtext}% dummy text

\fancypagestyle{plain}{
\fancyhf{}
\makebox[0pt][r]{
\tikz[baseline] \node[anchor=base, signal, font=\bfseries, text=white, signal to=east, fill=headbgcolor, text width=\marginparwidth, align=right]{\thepage};\hspace*{1em}}%
}
\makebox[0pt][l]{%
\hspace*{1em}\tikz[baseline] \node[anchor=base, signal, font=\bfseries, text=white, signal to=west, fill=headbgcolor, text width=\marginparwidth, align=left]{\thepage};}%
}
}
\usepackage{mathptmx}
\begin{document}
\blinddocument
\end{document}


• How does one change the signal length? – wrb98 Nov 22 '16 at 10:35
• @wrb98 In this case you can change the value of text width – Ignasi Nov 22 '16 at 10:45
• Thank you that works fine now. I've also wondered for a while how to change the font of the number in the green pentagon to (ideally) the \sffamily part of the font from the fourier package, whilst keeping the mathptmx fonts for the rest of the document. – wrb98 Nov 22 '16 at 11:22
• Scratch that. I've figured out a neat way of doing it, but thanks all the same. – wrb98 Nov 22 '16 at 15:53