Page Layout ⇒ chapter name in header
Re: chapter name in header
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
chapter name in header
As I already said, the package has already been included without options. So don't load it twice. Try this.komal wrote:[…] I have set the margin using the command
\usepackage[top=1.5in, bottom=1in, left=1.5in, right=1in]{geometry}
in the previously posted code but it gives an error saying
Error: Option clash for package geometry.
Code: Select all
\documentclass[11pt,a4paper,oneside,openany,english]{book}
\usepackage{etoolbox}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[includehead,nofoot,top=1.5in,bottom=1in,left=1.5in,right=1in]{geometry}
\usepackage[pagestyles,raggedright]{titlesec}
\usepackage{blindtext}
\author{Komal}
\title{The Title of the Document}
\makeatletter
\let\Title\@title
\let\Author\@author
\makeatother
\newpagestyle{front}{%
\sethead{\ifnumodd{\value{page}}{\Title}{\chaptertitle}}{}{\thepage}
\headrule
}
\newpagestyle{main}{%
\sethead{\ifnumodd{\value{page}}{\Title}{\thechapter\enspace\chaptertitle}}{}{\thepage}
\headrule
}
\newpagestyle{back}{%
\sethead{\ifnumodd{\value{page}}{\Title}{\chaptertitle}}{}{\thepage}
\headrule
}
\assignpagestyle{\chapter}{empty}
\begin{document}
\maketitle
\frontmatter
\pagestyle{front}
\tableofcontents
\listoffigures
\listoftables
\mainmatter
\pagestyle{main}
\blinddocument
\appendix
\blinddocument
\backmatter
\pagestyle{back}
\begin{thebibliography}{9}
\bibitem{key} Bibliography Item
\end{thebibliography}
\end{document}
In case you still prefer the version with the »report« class, you can try this.
Code: Select all
\documentclass[11pt,a4paper,english]{report}
\usepackage{etoolbox}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[includehead,nofoot,top=1.5in,bottom=1in,left=1.5in,right=1in]{geometry}
\usepackage[pagestyles,raggedright]{titlesec}
\usepackage{blindtext}
\author{Komal}
\title{The Title of the Document}
\makeatletter
\let\Title\@title
\let\Author\@author
\makeatother
\newpagestyle{front}{%
\sethead{\ifnumodd{\value{page}}{\Title}{\chaptertitle}}{}{\thepage}
\headrule
}
\newpagestyle{main}{%
\sethead{\ifnumodd{\value{page}}{\Title}{\thechapter\enspace\chaptertitle}}{}{\thepage}
\headrule
}
\newpagestyle{back}{%
\sethead{\ifnumodd{\value{page}}{\Title}{\chaptertitle}}{}{\thepage}
\headrule
}
\assignpagestyle{\chapter}{empty}
\begin{document}
\pagenumbering{roman}
\maketitle
\pagestyle{front}
\tableofcontents
\listoffigures
\listoftables
\pagenumbering{arabic}
\pagestyle{main}
\blinddocument
\appendix
\blinddocument
\pagestyle{back}
\begin{thebibliography}{9}
\bibitem{key} Bibliography Item
\end{thebibliography}
\end{document}
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: chapter name in header
