1

I am writing my thesis, and for the Introduction chapter I wanted to remove the prefix "Chapter 1" from the chapter tilte while still having the header saying "Introduction". This is what I have right now enter image description here

I have tried the code:

 \chapter*{Introduction}
 \addcontentsline{toc}{chapter}{Introduction}

It removes "Chapter 1" from the chapter title, but it messes up the header and leave it blank. How can I remove "Chapter 1" from this chapter, but still have "Introduction" as heading for the rest of the pages of this chapter?

Edit: I forgot to mention I'm using report documentclass

Edit2: Minimum working code:

\documentclass[a4paper,12pt]{report}
\usepackage[english]{babel}
\usepackage{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fancyhdr} 
\pagestyle{fancy}
\usepackage{blindtext}
\fancyhead{}
\fancyhead[L]{\nouppercase{\leftmark}}
\fancyfoot{}
\fancyfoot[C]{\thepage}
\begin{document}
\chapter{Introduction}
\Blindtext
\end{document}
2
  • Welcome to TeX SX! It is easy to obtain with titleps, a companion package of titlesec, but making it work also depends on your document class. Could you post a minimal, yet complete, code?
    – Bernard
    Commented May 27, 2020 at 21:15
  • @Bernard, I added the code at my original post.
    – Nobody
    Commented May 27, 2020 at 21:48

3 Answers 3

0

This answer is a modification of Bernard's to address the issue where the chapter to be hidden is not the first one.

The changes are:

  1. Introducing a new boolean variable haschapter to test for whether the chapter number should be printed, to replace the check using \ifthechapter. The conditional header is written using this boolean toggle.
  2. Incorporating the toggle into the chapter commands; so \chapter is overwritten to set the toggle to true, and a new command \NHchapter is defined to set the toggle to false while also setting the table of contents and the chapter mark.

Code below:

\documentclass[a4paper,12pt]{report}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{etoolbox}
\usepackage{blindtext}

\newtoggle{haschapter}

\usepackage[pagestyles]{titlesec}
\newpagestyle{mine}{%
    \headrule
    \sethead{\iftoggle{haschapter}{\chaptername\ \thechapter\quad}{}\chaptertitle}{}{}%
    \setfoot{}{\thepage}{}
    }%
\pagestyle{mine}

\let\oldchapter\chapter
\renewcommand{\chapter}[1]{\oldchapter{#1}\toggletrue{haschapter}}
\newcommand{\NHchapter}[1]{\oldchapter*{#1}\togglefalse{haschapter} \addcontentsline{toc}{chapter}{#1}\chaptermark{#1}}


\begin{document}

\NHchapter{Introduction}
\Blindtext
\newpage
\Blindtext
\chapter{A First Chapter}
\Blindtext

\newpage
\Blindtext
\NHchapter{Conclusion}
\Blindtext
\newpage
\Blindtext

\end{document} 
1

Here is a solution with titlesec + option [pagestyles]. Don't load fancyhdr in this case,as it will conflict with titleps.

Unrelated: needless to load inputenc as, sice 2018, the default input encoding for latex is utf8.

\documentclass[a4paper,12pt]{report}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{blindtext}

\usepackage[pagestyles]{titlesec}
    \newpagestyle{mine}{%
    \headrule
    \sethead{\ifthechapter{\chaptername\ \thechapter\quad}{}\chaptertitle}{}{}%
    \setfoot{}{\thepage}{}
    }%
    \pagestyle{mine}

\begin{document}

\chapter*{Introduction}
 \addcontentsline{toc}{chapter}{Introduction}
 \chaptermark{Introduction}
\Blindtext
\newpage
\Blindtext
\chapter{A First Chapter}
\Blindtext

\end{document} 
5
  • tthat worked exactly as I wanted. However, when I added a Conclusion chapter to have the same layout as the Introduction, it didn't work. I just added before the last line \chapter*{Conclusion} \addcontentsline{toc}{chapter}{Conclusion} \chaptermark{Conclusion}
    – Nobody
    Commented May 27, 2020 at 22:41
  • Did you compile twice?
    – Bernard
    Commented May 27, 2020 at 22:42
  • Yes, I did compile twice.
    – Nobody
    Commented May 27, 2020 at 22:44
  • I'll try to see whether there's a solution for this case tomorrow (it's getting late here…), but I'm afraid it might require defining chapters formatting with titlesec.
    – Bernard
    Commented May 27, 2020 at 23:14
  • I have tried to do this page style only for the specific chapters, by using '\begingroup' and '\endgroup'. It didn't work.
    – Nobody
    Commented May 28, 2020 at 12:59
0

Okay, so I've been trying different thing and I got it to work exactly as I wanted. There are probably better solution to this, but I got it to work with my basic knowledge of Latex.

\documentclass[a4paper,12pt]{report}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{blindtext}

\usepackage{fancyhdr} 
\pagestyle{fancy}
\begin{document}
    \tableofcontents
\begingroup
    \fancyhead{}
    \fancyhead[L]{Introduction}
    \fancyfoot{}
    \fancyfoot[C]{\thepage}
    \chapter*{Introduction}
     \addcontentsline{toc}{chapter}{Introduction}
    \Blindtext
    \endgroup
    \newpage
    \begingroup
    \fancyhead{}
    \fancyhead[L]{\nouppercase{\leftmark}}
    \fancyfoot{}
    \fancyfoot[C]{\thepage}
    \chapter{A First Chapter}
    \Blindtext
    \endgroup
    \newpage
    \begingroup
    \fancyhead{}
    \fancyhead[L]{Conclusion}
    \fancyfoot{}
    \fancyfoot[C]{\thepage}
    \chapter*{Conclusion}
     \addcontentsline{toc}{chapter}{Conclusion}
    \Blindtext
    \endgroup
\end{document} 

You must log in to answer this question.

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