I am working with the following code
\documentclass[12pt]{scrreprt}
\usepackage{atveryend}
\usepackage{etoolbox}
\usepackage{titlesec}
\usepackage{fancyhdr}
\usepackage{enumitem}
\usepackage{fancyhdr}
\titleformat{\chapter}{\normalfont\Large\bfseries}{\thechapter}{1em}{}
\titleformat{\section}{\normalfont\large\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}{\normalfont\bfseries}{\thesubsection}{1em}{}
\titleformat{\subsubsection}{\normalfont\fontsize{10}{0}\bfseries}{\thesubsubsection}{1em}{}
\titleformat{\paragraph}{\normalfont\fontsize{10}{0}\bfseries}{\theparagraph}{1em}{}
\titlespacing*{\chapter}{0pt}{0pt}{14pt}
\titlespacing*{\section}{0pt}{14pt}{7pt}
\titlespacing*{\subsection}{0pt}{14pt}{0pt}
\titlespacing*{\subsubsection}{0pt}{7pt}{0pt}
\titlespacing*{\paragraph}{0pt}{14pt}{0pt}
\titlespacing*{\bhead}{0pt}{14pt}{0pt}
\makeatletter
\newlength{\secnumwidth}
\setlength{\secnumwidth}{0pt}
\providecommand*{\usesecnumwidth}{0pt}
\newcommand*{\secnumwidthbox}[1]{%
\begingroup
\sbox0{#1}%
\ifdim\wd0>\secnumwidth
\global\secnumwidth=\wd0\relax
\fi
\endgroup
\leavevmode
\hbox to
\ifdim\usesecnumwidth>\secnumwidth
\usesecnumwidth
\else
\secnumwidth
\fi
{#1\hfil}%
}
\let\org@chapterformat\chapterformat
\renewcommand*{\chapterformat}{%
\secnumwidthbox{\org@chapterformat}%
}
\renewcommand*{\othersectionlevelsformat}[3]{%
\secnumwidthbox{#3\autodot\hfill\enskip}%
}
% Patch for titlesec
\patchcmd\ttlh@hang{%
\sbox\z@{#2\strut\ttl@calc\hspace{#3}}%
}{%
\sbox\z@{\secnumwidthbox{#2\strut\ttl@calc\hspace{#3}}}%
}{}{\errmessage{Cannot patch \string\ttlh@hang}}
\AfterLastShipout{%
\if@filesw
\immediate\write\@mainaux{%
\string\gdef\string\usesecnumwidth{\the\secnumwidth}%
}%
\fi
\ifdim\usesecnumwidth=\secnumwidth
\else
\@latex@warning@no@line{Rerun LaTeX, because \noexpand \usesecnumwidth
has changed}
\fi
}
\makeatother
\begin{document}
\chapter{Chapter}
\section{Section}
\subsection{Subsection}
\newpage
Hi
\newpage
Hi
\end{document}
I wish to use the fancyhdr package to add a basic header to each page, which would consist of the page number on the right hand side of the page for odd numbered pages, and the page number on the left hand side for even numbered pages, but I would also like to have the same style of header on chapter pages. I cannot seem to get this to work, ending up with the numbers all on the left, or all on the right. I'd appreciate it if anyone can find a working code.