2

I've just written in LaTeX my term notes and wanted to give it different look. I want that the page numbers get a blue shade around, and that shade should come from the border of the page. Sorry for my bad English, with the images it'll be easier.

Something like this:

What I want

This is the MWE for this in LaTeX:

\documentclass[11pt,a4paper,twoside,openany]{book}
\usepackage[utf8]{inputenc}
\usepackage[bottom=3cm,top=3cm,left=2.5cm,right=2.5cm]{geometry}
\usepackage{xcolor}
\colorlet{shadecolor}{blue!20}

\usepackage{framed}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyfoot{} % clear all footer fields
\fancyfoot[RO]{\parbox{3.95cm}{\begin{shaded*}\thepage \hspace*{3cm}\end{shaded*}}}
\fancyfoot[LE]{\hspace*{-3cm}\parbox{3.95cm}{\begin{shaded*}\hspace*{3cm}\thepage\hspace*{3cm}\end{shaded*}}}

\begin{document}
\newpage
.
\newpage
.
\end{document}

I defined right and left pages separately, and the result in left pages is the desired, but in the right pages I'm getting this:

Wrong

I've tried putting a \hspace*{length} before, but it refuses to read it and always put the shaded area in the same place.

I want the page number 2.5cm (right margin) from the right border, with the blue shade going from the number to the right border of the page.

1
  • Try using \llap{} and \rlap{}.
    – cfr
    Jan 3, 2017 at 3:22

1 Answer 1

3
\documentclass[11pt,a4paper,twoside,openany]{book}
\usepackage[utf8]{inputenc}
\usepackage[bottom=3cm,top=3cm,left=2.5cm,right=2.5cm,paperheight=10cm]{geometry}
\usepackage{xcolor}
\colorlet{shadecolor}{blue!20}

\usepackage{framed}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyfoot{} % clear all footer fields
\fancyfoot[RO]{\makebox[0pt][l]{\parbox{5cm}{\begin{shaded*}\thepage\end{shaded*}}}}
\fancyfoot[LE]{\makebox[0pt][r]{\parbox{5cm}{\begin{shaded*}\hfill\thepage\end{shaded*}}}}

\begin{document}
\null\newpage\null
\end{document}

output

1
  • Worked just as expected. Thank you son much
    – user39421
    Jan 3, 2017 at 8:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .