I used \usepackage{fancyhdr} for headers in my work but I noticed that the length of the header line is not the same width as the body of my work.
This is what it looks like
This is the preamble of my code
\documentclass[a4paper,12pt,oneside]{book}
\usepackage{fancyhdr,blindtext}
\usepackage{fourier-orns}
\usepackage{fancyhdr}
\renewcommand{\headrule}{%
\vspace{-8pt}\hrulefill
\raisebox{-2.1pt}{\quad\decofourleft\decotwo\decofourright\quad}\hrulefill}
\title{Decorative line}
\author{Overleaf}
\date{August 2022}
\pagestyle{fancy}
\fancyhf{}
\fancyhead{\nouppercase{\rightmark\hfill\leftmark}}
\fancyfoot{\hfill\thepage\hfill}
\usepackage[margin=1.0in, headheight=30pt]{geometry}
\usepackage[cmex10]{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\newtheorem{mydef}{Definition}
\newtheorem{mytherm}{Theorem}
\usepackage{algorithm}
\usepackage{algpseudocode}
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\usepackage{xcolor}
\definecolor{codegreen}{rgb}{0,0.6,0.1}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codeblue}{rgb}{0.10,0.00,1.00}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{1.0,1.0,1.0}
\lstdefinestyle{mystyle}{
backgroundcolor=\color{backcolour},
commentstyle=\color{codegreen},
keywordstyle=\color{codeblue},
numberstyle=\tiny\color{codegray},
stringstyle=\color{codepurple},
basicstyle=\ttfamily\footnotesize,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=left,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=2,
frame=none
}
\lstset{style=mystyle}
\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{caption}
\usepackage{lipsum}
\usepackage{multirow}
\usepackage{rotating}
\usepackage{makecell}
\usepackage{booktabs}
\usepackage [autostyle, english = american]{csquotes}
\MakeOuterQuote{"}
\usepackage{enumitem}
\newlist{abbrv}{itemize}{1}
\setlist[abbrv,1]{label=,labelwidth=1in,align=parleft,itemsep=0.1\baselineskip,leftmargin=!}
\usepackage[hidelinks]{hyperref}
\usepackage[comma,authoryear]{natbib}
\renewcommand{\bibname}{References}
\usepackage[toc]{appendix}
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries\centering}{\centering\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titlespacing*{\chapter}
{0pt}{50pt}{40pt}
I would prefer it if the rule length was this long (same width as the body)
Thanks in advance.


\usepackage[margin=1.0in, headheight=30pt]{geometry}before\usepackage{fancyhdr}– Simon Dispa Jan 06 '23 at 21:35