1

I tried to use a header and footer layout I found here on this website. But I have some problems with changing the code to what I want. I want the pagenumbering to be like page x of y in the footer. It would be nice with this layout (just with page x of y instead of just page x):

\cfoot{\parbox{\textwidth}{\hrulefill\kern-0.6ex\raisebox{-0.5ex}{$\Bigl[$\makebox[2em][c]{\thepage}$\Bigr]$}\kern-0.5ex\hrulefill}}

But the pagenumbering is in the header and there aren't a space between the letters and the numbers as you can see in my minimal work example:

\documentclass[12pt,a4paper]{book}%generelt
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{} % clear all headers and footers
\renewcommand{\headrulewidth}{0pt} % remove rule between header and text
\fancyhead[LE, RO]{\thepage of \pageref{LastPage}} % put page number in left header on even pages,
                            % right header on odd pages
\fancyhead[RE]{\nouppercase{\leftmark}} % remove uppercase on chapter title
\renewcommand{\chaptermark}[1]{\markboth{#1}{}} % remove "Chapter N." prefi
\usepackage{lastpage}

Another problem is that I would like to have a chapter numbering in the header. The design is really nice, but I would like to have the chapter number too, just like "CHAnumber| name of the chapter".

Is it possible to make this two changes? And how? Thank you very much for help!

1
  • Instead of using fancyhdr, how about scrlayer-scrpage?
    – Johannes_B
    Jun 12 '14 at 8:26
2

An alternate solution with scrlayer-scrpage. Thanks @Pouya for providinig the solution for the footer, i copied that.

\documentclass{book}
\usepackage{blindtext}
\usepackage{lastpage}
\usepackage{scrlayer-scrpage}
\clearscrheadfoot
\ohead{\headmark}
\usepackage{calc}
\newcommand\footy{\parbox{\textwidth}{\hrulefill\kern-0.6ex\raisebox{-0.5ex}{$\Bigl[$\makebox[\widthof{1.2{\thepage\,
of \pageref{LastPage}}}][c]{\thepage\, of \pageref{LastPage}}$\Bigr]$}\kern-0.5ex\hrulefill}}
%Thanks to Pouya
\cfoot[\footy]{\footy}
\begin{document}
\blinddocument
\blinddocument
\blinddocument
\blinddocument
\end{document}

a sample output

0
2

Here are some tweaks of your own code. Does it satisfies what you need?

\documentclass[12pt,a4paper]{book}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyhead[LO]{\leftmark}
\fancyhead[RE]{\rightmark}                           
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\usepackage{lastpage}
\usepackage{lipsum}
\usepackage{calc}
\cfoot{\parbox{\textwidth}{\hrulefill\kern-0.6ex\raisebox{-0.5ex}{$\Bigl[$\makebox[\widthof{\thepage\, of \pageref{LastPage}}][c]{\thepage\, of \pageref{LastPage}}$\Bigr]$}\kern-0.5ex\hrulefill}}

\begin{document}

\chapter{Chapter Title}
\section{Section Title}

\lipsum[1-100]
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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