5

I am trying to add the chapter number to the footer using fancyhdr. What I would like to do is have the chapter number in roman numbers and the page number in arabic together like so:

VI - 8

This is the code I have right now:

\documentclass[a4paper]{book}
\usepackage{fancyhdr}

\begin{document}
\pagenumbering{Roman}
\clearpage
\pagestyle{fancy}
\cfoot{\thepage}
\renewcommand{\headrulewidth}{0pt}
\fancyhead[LE,RO]{}
\fancyhead[LO,RE]{\slshape \leftmark}
%\tableofcontents

\clearpage
\pagenumbering{arabic}
\input{Chapter_1.tex}
\input{Chapter_2.tex}
\input{Chapter_3.tex}
\input{Chapter_4.tex}
\input{Chapter_5.tex}
\input{Chapter_6.tex}

\end{document}

Could anyone please help me??

THank you in advance!

  • possible duplicate of Add chapter numbering to page header – Crissov Mar 3 '14 at 22:25
  • \cfoot{\Roman{\thechapter} -- \thepage}? – cfr Mar 3 '14 at 22:32
  • 1
    @Crissov I disagree; this shouldn't be closed as a duplicate of the linked question. The other answer doesn't show how to change the counter representation, and most importantly, doesn't address the necesary redefinition of plain which was not needed there, but it has to be done here. – Gonzalo Medina Mar 3 '14 at 23:55
  • Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. – jub0bs Aug 5 '14 at 22:05
6

Simply add

\fancyfoot[C]{\Roman{chapter}\,--\,\thepage}

to your current settings. Since, for consistency's sake this should also apply to the first page of each chapter (in ehich the plain style is used), a redefinition of plain will also be needed:

\fancypagestyle{plain}{%
  \fancyhf{}
  \fancyfoot[C]{\Roman{chapter}\,--\,\thepage}
  \renewcommand{\headrulewidth}{0pt}
}

A complete example:

\documentclass[a4paper]{book}
\usepackage{fancyhdr}
\usepackage{lipsum}

\pagestyle{fancy}

\fancyhf{}
\fancyhead[LE,RO]{}
\fancyhead[LO,RE]{\slshape \leftmark}
\fancyfoot[C]{\Roman{chapter}\,--\,\thepage}
\renewcommand{\headrulewidth}{0pt}

\fancypagestyle{plain}{%
  \fancyhf{}
  \fancyfoot[C]{\Roman{chapter}\,--\,\thepage}
  \renewcommand{\headrulewidth}{0pt}
}

\begin{document}

\chapter{Test chapter one}
\lipsum[1-40]
\chapter{Test chapter two}
\lipsum[1-40]
\chapter{Test chapter three}
\lipsum[1-40]

\end{document}

Some images of some of the footers in different chapters:

enter image description here

enter image description here

Of course, activate these settings from the point in which chaters will be numbered on. Since this applies particularly for the redefinition of plain, you could conditionally make the redefinition of the footer depending on wheter you are on the \mainmatter or not:

\makeatletter
\fancypagestyle{plain}{%
  \fancyhf{}
  \if@mainmatter
    \fancyfoot[C]{\Roman{chapter}\,--\,\thepage}
  \else
    \fancyfoot[C]{\thepage}
  \fi
  \renewcommand{\headrulewidth}{0pt}
}
\makeatother

The code:

\documentclass[a4paper]{book}
\usepackage{fancyhdr}
\usepackage{lipsum}

\pagestyle{fancy}

\fancyhf{}
\fancyhead[LE,RO]{}
\fancyhead[LO,RE]{\slshape \leftmark}
\fancyfoot[C]{\Roman{chapter}\,--\,\thepage}
\renewcommand{\headrulewidth}{0pt}

\makeatletter
\fancypagestyle{plain}{%
  \fancyhf{}
  \if@mainmatter
    \fancyfoot[C]{\Roman{chapter}\,--\,\thepage}
  \else
    \fancyfoot[C]{\thepage}
  \fi
  \renewcommand{\headrulewidth}{0pt}
}
\makeatother

\begin{document}

\frontmatter
\tableofcontents

\mainmatter
\chapter{Test chapter one}
\lipsum[1-40]
\chapter{Test chapter two}
\lipsum[1-40]
\chapter{Test chapter three}
\lipsum[1-40]

\end{document}

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.