Text FormattingProblem with heading

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
Ahnungsloser_Passant
Posts: 2
Joined: Wed Nov 18, 2015 6:00 pm

Problem with heading

Post by Ahnungsloser_Passant »

Hi,

I have got a problem with the heading on a page with \chapter* and using fancyhdr. There is a minimal example below. The header of the first page of the introduction is "Contents" instead of "Introduction". If I replace
"\chapter*{Introduction}" by "\chapter{Introduction}" then it is displayed correctly, but the introduction becomes chapter 1, what is not intended. Hopefully someone can offer some help with that issue. Since I am close to a deadline a quick and dirty fix will be fine too.

Best regards
Thomas

Code: Select all

\documentclass[a4paper,10pt]{book}
\usepackage{lipsum}
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[RO]{\slshape\nouppercase\rightmark}
\fancyhead[LE]{\slshape\nouppercase\leftmark}
\fancyhead[LO,RE]{\thepage}
\setlength{\headheight}{15pt}

\fancypagestyle{plain}{
 \fancyhf{}%
 \fancyhead[RO]{\slshape\nouppercase\rightmark}
 \fancyhead[LE]{\slshape\nouppercase\leftmark}
 \fancyhead[LO,RE]{\thepage}
 \setlength{\headheight}{15pt}
}

 
 
\begin{document}

\tableofcontents

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

\chapter{First Chapter}
\section{First Section}
\lipsum
\section{Second Section}
\lipsum

\chapter{Second Chapter}
\section{First Section}
\lipsum
\section{Second Section}
\lipsum

\end{document}
Last edited by cgnieder on Thu Nov 19, 2015 11:30 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

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

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Problem with heading

Post by Johannes_B »

The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Ahnungsloser_Passant
Posts: 2
Joined: Wed Nov 18, 2015 6:00 pm

Re: Problem with heading

Post by Ahnungsloser_Passant »

Thank you, it worked!
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Problem with heading

Post by Stefan Kottwitz »

Hi Thomas,

welcome to the forum!

Just want to say on top of the link to that commercial forum, you can get great help here, such as by Johannes. But you're also welcome to visit our German partner forum, actually maintained by us the same guys, TeXwelt.de. Some great LaTeX experts post there in German, because they don't like typing English so much, but as I said, experts, knowing much more than I do.

Stefan
LaTeX.org admin
Post Reply