# Page number is centered even though it should be left/right

I'm sorry if this has been asked before, but I haven't found an answer anywhere.

I'm currently writing my bachelor's thesis in LATEX and I'm having problems with my pagenumbering.

I'm using the package fancyhdr in an article. The first few items like the acknowledgement and the ToC etc should be numbered with roman numerals on the left/right side in the footer, just like in books. I was able to get roman numerals, but it stays centered. When I remove the complete footer still an arabic pagenumber remains in the centre.

\documentclass[a4paper,12pt,twoside]{article}

\usepackage[super,square,sort&compress]{natbib}                 %Zitierstil
\setcitestyle{nature}                                           %Literaturstil
\bibliographystyle{unsrtnat}                                    %Literatur sortiert nach Auftreten im Text

\usepackage{hyperref}
\usepackage[usenames, dvipsnames]{color}
\usepackage{ghsystem}
\usepackage[ngerman]{babel}
\usepackage{subfiles}
\usepackage{chemmacros}
\usepackage{graphicx}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage[version=4]{mhchem}
\usepackage{pdfpages}
\usepackage[utf8x]{inputenc}
\usepackage[labelfont={color=text,bf}]{caption}
\usepackage{cancel, caption, mathtools, subcaption, amsthm}
\usepackage[margin={0.10\paperwidth,0.1\paperheight}, heightrounded, bindingoffset=1cm]{geometry}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{array}
\usepackage{microtype}
\usepackage{booktabs}
\usepackage{icomma}
\usepackage{bibgerm}
\usepackage{titling}
\usepackage[onehalfspacing]{setspace}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{float}
\usepackage{fancyhdr}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{tocloft}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%------optionale Packages-------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\numberwithin{equation}{section}
\usepackage{lipsum}                                             %Blindtext
\usepackage{blindtext}                                          %Blindtext

\graphicspath{{images}{../images}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%---------Zeilenabstand---------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\baselinestretch}{1.5}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%--------2. Listenebene---------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\labelitemii}{-}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%------------Farben-------------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\definecolor{text}{RGB}{0,0,0}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%----------Schriftart-----------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\renewcommand{\familydefault}{\sfdefault}

\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-----------Titelseite----------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\thispagestyle{empty}
\input{Sections/titlepage}

\newpage

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%----Fußzeile & Nummerierung----%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pagenumbering{roman}                                             %Römische Seitenzahlen
\setcounter{page}{1}                                              %Start der Nummerierung
\fancyfoot[C]{}
\fancyfoot[OR,EL]{\thepage}                                       %O=odd, E=even

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-----------Danksagung----------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\input{Sections/acknowledgement}


Later on I did the same thing for the main body of the thesis, which worked fine.

It would be great if someone had an answer for me :) thank you!

EDIT:

I found a solution for the page numbers being centered on the toc. That's because the command \tableofcontents automatically resets to the plain pagestyle. You have to redefine the plain pagestyle:

\fancypagestyle{plain}{
\fancyhf{}
\fancyfoot[OR]{\thepage}
\fancyfoot[EL]{\thepage}
}


In combination with the other answers I was able to get it right! Thanks everyone for your help!

• Welcome to TeX.SE! Off-topic: you are loadinghyperref way too early. it should be loaded last, cf. Which packages should be loaded after hyperref instead of before? – Troy May 2 '18 at 14:42
• Welcome to TeX.se. You need to issue a \pagestyle{fancy} after changing the footer. – Alan Munn May 2 '18 at 14:43
• Welcome to TeX.se. Your code is not minimal, please provide a minimal code for future questions. – Ali Shakiba May 2 '18 at 14:59
• I'm glad you were able to find a solution to your problem. But we generally prefer that answers get posted as such, and not as edits to the question. That lets us vote on them appropriately. – Teepeemm May 7 '18 at 13:47

The problem is that you did not change the pagestyle to fancy. Try this

\documentclass[a4paper,12pt,twoside]{article}
\usepackage{fancyhdr}
\usepackage{lipsum}

\begin{document}
\lipsum[6-10]
\clearpage
\newpage
\pagestyle{fancy} % this is what you miss
\pagenumbering{roman}
% \setcounter{page}{1}  % this is not needed as the \pagenumbering{roman} resets the page counter
\fancyhf{} % to clear the header and the footer simultaneously
\fancyfoot[OR,EL]{\thepage}
\renewcommand{\headrulewidth}{0pt} % to remove the rules
\renewcommand{\footrulewidth}{0pt} % to remove the rules
\lipsum[1-5]
\end{document}

• +1 You had the patience to turn this into a good MWE. :) – Alan Munn May 2 '18 at 15:00
• +1 The \pagenumbering commands resets page numbers, so \setcounter has nothing to do… – Bernard May 2 '18 at 15:32
• Thank you for your quick help! But the pagenumbers on even pages are still centered. I purposefully didn't write \pagestyle{fancy} because this creates headrules on some pages like the acknowledgement that I don't want there. Do you know how to fix that? Sorry that my example code is so long. This was my first time posting a question. I'll consider it in the future :) – C.Sch. May 2 '18 at 18:03
• @C.Sch. Your welcome. I have modified the answer accordingly. – Ali Shakiba May 2 '18 at 18:23
• I added your answer to my file, but still the pagenumbers on the even pages are centered instead of on the left side. Do you know a solution? Thank you so much for your help! – C.Sch. May 2 '18 at 18:47

For those who use titlesec it is easier to redefines the plainstyle with the companion package titleps (can also be used on its own):

\documentclass[a4paper,12pt,twoside]{article}
\usepackage{titleps}
\usepackage{lipsum}
\renewpagestyle{plain}{%
`