0

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[header]{appendix}
\usepackage{tocloft}
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%------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}
\renewcommand{\headrulewidth}{0pt} 
}

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

C.Sch.
  • 3

2 Answers2

4

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}
  • 3
    +1 You had the patience to turn this into a good MWE. :) – Alan Munn May 02 '18 at 15:00
  • 1
    +1 The \pagenumberingcommands resets page numbers, so\setcounter` has nothing to do… – Bernard May 02 '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 02 '18 at 18:03
  • @C.Sch. Your welcome. I have modified the answer accordingly. – Ali Shakiba May 02 '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 02 '18 at 18:47
  • Maybe there are some conflicts with other packages. Have you run the minimal example code in a separate file? – Ali Shakiba May 02 '18 at 19:52
  • Yes I have and it works fine... – C.Sch. May 03 '18 at 07:28
  • It's just the toc, the lof and the lot where the pagenumber remains centered. – C.Sch. May 03 '18 at 08:24
  • You need to change the pagestyle before the \tableofcontents. I have checked the solution and it worked correctly. \fancyhf{} \fancyfoot[OR,EL]{\thepage} \renewcommand{\headrulewidth}{0pt} \renewcommand{\footrulewidth}{0pt} \tableofcontents \cleardoublepage \newpage \listoffigures \cleardoublepage \newpage \listoftables – Ali Shakiba May 03 '18 at 09:36
  • Somehow it doesn't work for me. But thank you, I will try to work around it. – C.Sch. May 04 '18 at 07:57
2

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}{%
\sethead{}{}{}
\setfoot[\thepage][][]{}{}{\thepage}
}%

\begin{document}

    \lipsum[6-10]
    \clearpage
    \pagenumbering{roman}
    \pagestyle{plain}
    \lipsum

\end{document} 
Bernard
  • 271,350