0

I have a problem centering the page number only on the FIRST page of Bibliography. Following is my code:

\documentclass[12pt,a4paper,twoside]{report} % "openright" starts each chapter on an odd-page, remove if not needed
\usepackage[top=2.54 cm, bottom=2.54 cm, left=2.54 cm, right=2.54 cm]{geometry}

\usepackage{fancyhdr}
\usepackage{apacite}
\usepackage[hidelinks]{hyperref} % put before apacite

% define two styles : prelim and main
\fancypagestyle{prelim}{
\fancyhf{} %clear all headers and footers fields
\cfoot{\thepage} %prints the page number on the center side of the footer
\renewcommand{\headrulewidth}{0pt}
}

\fancypagestyle{main}{
\fancyhf{} %clear all headers and footers fields
\chead{\thepage} %prints the page number on the center side of the header
\renewcommand{\headrulewidth}{0pt}
}

\fancypagestyle{plain}{\pagestyle{prelim}}

    \begin{document}
% apply prelim styles for table of contentsl

\pagestyle{prelim} % roman page number from this page
\pagenumbering{roman} % roman page number from this page
\thispagestyle{empty} % no roman page number on this page

\tableofcontents
\cleardoublepage
\addcontentsline{toc}{chapter}{List of Tables}
\listoftables % if necessary
\clearpage
\addcontentsline{toc}{chapter}{List of Figures}
\listoffigures % if necessary
\newpage

% apply main style for chapter and reference
\pagestyle{main} 
\pagenumbering{arabic}
        \include{chp1}
        \newpage

        \bibliographystyle{apacite}
            \bibliography{mybib} % this is mybib 

    \end{document}

% chp1.txt is

\chapter{Introduction}
\thispagestyle{main}
  Text for Introduction.
  • I can't compile your code as is, obviously. When I hacked it in order to make it usable, it worked fine. The page number is in the centre of the footer, just as you've defined. – cfr Feb 15 '16 at 3:33
  • Thanks. For table of contents, I want it to be in the center of the footer, but for other I want it to be on the center of the header. It works for all, but the first page of the Bibliography. I can't add Bibliography here so there was an error. But, even with that you can still see that page number is in the bottom for the first page, while I want it at the top. – Metrics Feb 15 '16 at 14:17
1

Adding \def\thispagestyle#1{} solves the problem

\newpage
\def\thispagestyle#1{} % add this 
        \bibliographystyle{apacite}
            \bibliography{mybib} % this is mybib 
  • And now \thispagestyle will no longer work for the rest of your document. – cfr Feb 15 '16 at 20:23
  • Thanks @cfr. It's fine for my problem. But, it may not be a good solution for other problems. – Metrics Feb 16 '16 at 14:00
  • Just redefine the plain style again before the bibliography. – cfr Feb 16 '16 at 14:12
  • Please feel free to update the answer. – Metrics Feb 16 '16 at 15:09

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.