0

everyone,

I'm using this particular type of header. I like it, except for the fact that it adds the expression 'Chapter #.', which is a nuisance. I don't want the expression because on the preface and acknowledgements of my thesis it says 'Chapter 0.' and in the conclusions it says 'Chapter 3.', though that section is not really a chapter. Do you have any ideas of how get ride of it?

\documentclass[12pt, letterpaper, twoside, openright]{book}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage[T1]{fontenc}
\usepackage{amsmath}

\usepackage{fancyhdr}
\pagestyle{fancy}

\makeatletter
\DeclareRobustCommand{\format@sec@number}[2]{{\normalfont\upshape#1}#2}
\renewcommand{\chaptermark}[1]{%
  \markboth{\format@sec@number{\ifnum\c@secnumdepth>\m@ne\@chapapp\ \thechapter. \fi}{#1}}{}}
\renewcommand{\sectionmark}[1]{%
  \markright{\format@sec@number{\ifnum\c@secnumdepth>\z@\thesection. \fi}{#1}}}
\makeatother
\fancyhf{}
\fancyhead[RE]{\itshape\nouppercase{\leftmark}}
\fancyhead[LO]{\itshape\nouppercase{\rightmark}}
\fancyhead[LE,RO]{\thepage}
%\renewcommand{\headrulewidth}{1pt}

\begin{document}

\chapter{Introduction}
\blindtext
\blindtext
\blindtext
\section{subsection}
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext

\end{document} 

Thanks!

5
  • Welcome toTeX SX! Could you post a full compilable code, not just a fragment? Also, do you absolutely code your headers with fancyhdr?
    – Bernard
    Feb 19, 2019 at 23:55
  • Thanks, @Bernand! Yeah, I've changed the code and I don't have problems with using a package other than fancyhdr. I'm only interested in how it looks. Feb 19, 2019 at 23:59
  • Your code is not complete yet. What's your document class?
    – Bernard
    Feb 20, 2019 at 0:00
  • @Bernard You are right. It's 'book'. Feb 20, 2019 at 0:06
  • I would try \chapter*. The * form is conventionally used to suppress numbering of sectioning headers. Feb 20, 2019 at 2:26

2 Answers 2

1

Here is a much simpler code with titleps, a package companion to titlesec:

\documentclass{book}

\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage[T1]{fontenc}
\usepackage{amsmath}

\usepackage{titleps}
\newpagestyle{custom}{%
\headrule\setheadrule{1pt}
\sethead[\thepage][][\thechapter.~\itshape\chaptertitle]{\thesection~\itshape\sectiontitle}{}{\thepage}%
\setfoot{}{}{}
}
\pagestyle{custom}

\begin{document}

\chapter{Introduction}
\blindtext
\blindtext
\blindtext
\section{subsection}
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext

\end{document} 

enter image description here

1

The pagestyle fancy header definition need not be so complex as mentioned (until there is a specific purpose).

Here is a simple definition of fancy header fulfilling your requirement:

\documentclass[12pt, letterpaper, twoside, openright]{book}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage[T1]{fontenc}
\usepackage{amsmath}

\usepackage{fancyhdr}

\pagestyle{fancy}
\fancypagestyle{FancyStyle}{
\fancyhead{}
\fancyhead[RE]{\itshape\nouppercase{\leftmark}}
\fancyhead[LO]{\itshape\nouppercase{\rightmark}}
\fancyhead[LE,RO]{\thepage}
\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\thechapter. {##1}}}{}}
}


\begin{document}

\pagestyle{FancyStyle}
\chapter{Introduction}
\blindtext
\blindtext
\blindtext
\section{subsection}
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext

\end{document} 

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .