# Problem formatting header and footer with fancyhdr

I am writing my thesis using

\documentclass[12pt, oneside]{book}


Using the document class 'book', I am automatically getting 'Chapter #' headlines which I don't want and have removed using titlesec by the following command

\usepackage[pagestyles]{titlesec}
\titleformat{\chapter}[display]{\normalfont\bfseries}{}{0pt}{\Huge}


So now I want to have my page number on the bottom right corner and I want a header named after the given chapter or section it is under. I have tried doing this by the following command

\documentclass[12pt, oneside]{book}
\pagestyle{plain}


Latex code

% The \usepackage{} command will import predefined fonts, symbols, environments, etc.  For example, the ams packages below come from the American Mathematical Society and include all kinds of useful math symbols like integrals
\usepackage{amscd}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{verbatim}
\usepackage[utf8]{inputenc}
\usepackage{geometry}                       % See geometry.pdf to learn the layout options. There are lots.
\geometry{a4paper}                          % ... or a4paper or a5paper or ...
%\geometry{landscape}                       % Activate for for rotated page geometry
\usepackage[pdftex]{graphicx}               % Use pdf, png, jpg, or eps with pdflatex; use eps in DVI mode
\usepackage{setspace}
\usepackage{physics}
\usepackage{subcaption}
\usepackage[numbers]{natbib}
\usepackage{pdfpages}
\usepackage{bm}
\usepackage{wrapfig}                % enables the use of \wrapfig, for figures with text wrapped around them
\usepackage{afterpage}
\newcommand\blankpage{%
\null
\thispagestyle{empty}%
\newpage}

\usepackage{bibentry} % for list of publications
\usepackage{hyperref}

% \usepackage[english]{babel}
\graphicspath{{images/}{{\subfix{images/}}}}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{shapes,calc,positioning}
\tdplotsetmaincoords{70}{120}
\usepackage{siunitx}
\usepackage{xcolor} %% Text color
\usepackage{blindtext}
\usepackage{subfiles} % Best loaded last in the preamble
\usepackage{multicol,multirow}  %% Figure in two columns
\usepackage{mathtools, nccmath}

\usepackage{lipsum}         % gives access to \lipsum, which dumps some latin text into your document as filler if you want to check formatting

%\usepackage[parfill]{parskip}          % Activate to begin paragraphs with an empty line rather than an indent

\usepackage{graphicx}
\usepackage{fancyhdr, graphicx}
\usepackage[pagestyles]{titlesec}
\titleformat{\chapter}[display]{\normalfont\bfseries}{}{0pt}{\Huge}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[R]{\thepage}
\fancypagestyle{plain}{
\fancyhf{}
\fancyfoot[R]{\thepage}
}

% Here we set the page dimensions to match the standard thesis format.  These values should not be changed.
%%% SET LENTGH AND WIDTH %%%
\setlength{\textwidth}{6.5in}
\setlength{\textheight}{8.5in}
\setlength{\oddsidemargin}{0pt}
\setlength{\evensidemargin}{0pt}
\setlength{\topmargin}{0pt}
\setlength{\marginparsep}{0pt}
\setlength{\marginparwidth}{1in}

%\begin{document} starts LaTeX looking for actual content.  Everything above this point is purely formatting.

\begin{document}
\begin{titlepage}
\begin{center}

% \vspace* creates some vertical white space on the page to make the title page look more pleasing.  \vspace would do much the same thing, but would not insert the white space if we were at the top of a fresh page.  As this is the start of the document we're obviously at the beginning of a page, so the asterisk is necessary to ensure we still put in two cm of white space.

\vspace{1cm}

\large{Master's thesis}

\vspace{0.5cm}

{\huge \textbf{Title}} % \huge sets the font size.  Other options include things like \large, \Large, \small, \tiny, etc.

\noindent\rule{16cm}{0.5pt}

\vspace{1 cm}

% \vfill creates an arbitrary amount of vertical white space as necessary to fill the page
\vfill

% \vspace*{3cm}

\end{center}
\end{titlepage}

%_____________________________________________________________

% \frontmatter defines the pieces of the thesis which will use roman numerals for page numbering
\frontmatter

% \chapter{} and/or \chapter*{} will create a chapter in your thesis.  Including the asterisk will cause the chapter to not appear in the table of contents.

\chapter{Preface}
\input{Chapters/Preface}

%\tableofcontents will create a table of contents.  By default it will include entries for any \chapter, \section, and \subsection command that appears in your thesis unless you have called the tag with an asterisk
\tableofcontents
\listoftables
\listoffigures
%_____________________________________________________________

% The \mainmatter command defines the main body of the thesis and indicates where regular numbering starts
\mainmatter

\newpage

\chapter{Introduction}
\input{Chapters/Introduction}

%_____________________________________________________________

% the \appendix tag tells LaTeX where it should start labelling chapters with letters (denoting appendices) rather than numbers (denoting main chapters)
\appendix

% \bibliographystyle command to choose the format of your bibliography. More examples of bibliography styles can be found at https://www.overleaf.com/learn/latex/Bibtex_bibliography_styles
\bibliographystyle{naturemag}

% \bibliography is the command for the actual file containing your bibliographic data. This file can be produced manually or automatically using software such as BibTeX. Both options can work, however, learning to use BibTex is beneficial in the long run. An example of the format needed to generate your own bibliography file can be found as the bibliography.bib file here provided.

\bibliography{references}
\end{document}

• Welcome to SE. Please provide a compilable version of your code that generates the problem. It's hard to know which package conflict you get if you don't say which packages you're using. The code you're currently showing doesn't yield any error message. May 20 at 12:50
• I have updated it with the entire latex code, thanks! May 20 at 13:08
• Since you load titlesec with option [pagestyles], you should use its companion package titleps, which has a \renewpagestyle command. May 20 at 13:55

It is not recommended to use titleps (as implied by the pagestyles option) and fancyhdr together. With some caution it is possible, however. But then fancyhdr should not be loaded before \usepackage[pagestyles]{titlesec} because they both define \headrule. However, fancyhdr checks for this, so it can be loaded after.

So remove the line \usepackage{fancyhdr, graphicx} and remove the option pagestyles:

\usepackage{titlesec}

Then it may work.

Another issue: Don't just define your page dimensions:

% Here we set the page dimensions to match the standard thesis format.  These values should not be changed.
%%% SET LENTGH AND WIDTH %%%
\setlength{\textwidth}{6.5in}
\setlength{\textheight}{8.5in}
\setlength{\oddsidemargin}{0pt}
\setlength{\evensidemargin}{0pt}
\setlength{\topmargin}{0pt}
\setlength{\marginparsep}{0pt}
\setlength{\marginparwidth}{1in}


Instead use the geometry package to define them, and do it before loading fancyhdr. Otherwise you get inconsistencies in the page layout, like the header being too small.