0

The close question was asked here. The question I need is in the comments (asked by LaRiFaRi) but never had the answer.

How to change "0.0.Intro" into simple "Intro" in the following MWE?

\documentclass[10pt]{book}%

\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage[english]{babel}
\usepackage[OT1]{fontenc}
\usepackage{euler,beton}


\usepackage[paperwidth=145mm, paperheight=215mm,inner=1.6cm,top=2.4cm,bottom=4cm,textwidth=7.4cm,marginparwidth=40mm]{geometry}

\usepackage{fancyhdr}
\pagestyle{fancy}

\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{1pt}

\fancypagestyle{style1}{
\fancyhf{}
\fancyhead[LE,RO]{\bfseries\thepage}
\fancyhead[LO]{\bfseries\rightmark}
\fancyhead[RE]{\bfseries\leftmark}
}
\fancypagestyle{style2}{
\fancyhf{}
\addtolength{\headwidth}{\marginparwidth}
\addtolength{\headwidth}{\marginparsep}
\fancyhead[LE,RO]{\bfseries\thepage}
\fancyhead[LO]{\bfseries\rightmark}
\fancyhead[RE]{\bfseries\leftmark}
}

% Redefine the PLAIN style
\fancypagestyle{plain}{%
    \fancyhead{} %Clean headers
    \fancyfoot{} %Clean footers
    \renewcommand{\headrulewidth}{1pt} % Header rule's width
    \fancyhead[LE,RO]{\bfseries\thepage}
    \fancyhead[LO]{\bfseries\rightmark}
    \fancyhead[RE]{\bfseries\leftmark}
}


\author{A. Uthor}
\title{What is the Title of This Book?}
\date{today}


\begin{document}

\newgeometry{top=24mm,bottom=40mm,inner=16mm,outer=3.2cm}
\pagestyle{style1}
\maketitle


\thispagestyle{empty}
{This page is intentionally left blank}

\newgeometry{top=24mm,bottom=40mm,inner=16mm,outer=3.2cm,marginparwidth=20mm}
\pagestyle{style2}
\tableofcontents
\clearpage{\pagestyle{empty}\cleardoublepage}


\section*{Intro}\sectionmark{Intro}
\addcontentsline{toc}{section}{\textbf{Intro}}

\lipsum

\end{document}

enter image description here enter image description here

  • 4
    Don't use \sectionmark but \markright{Intro} or \markboth{Intro}{Intro}. \sectionmark usually adds \thesection in front of the title given by the argument. Or put the into into the frontmatter and use \frontmatter\chapter{Intro}…\mainmatter. BTW: KOMA-Script class scrbook provides command \addchap{…} and \addsec{…}, that would not need additional commands to set the page header or a ToC entry. – Schweinebacke Dec 01 '17 at 13:38
  • 1
    Did you test \markboth in your minimal example above? – Ulrike Fischer Dec 01 '17 at 13:50
  • It works. Thank you. Can you please, convert the comment into the answer for me to accept it. – Sergey Belyaev Dec 01 '17 at 14:38
  • @Schweinebacke Would you like to write an answer? (Sergey: other commenters are generally not notified of comments unless you write an at-sign followed by the username, as I did here.) – Torbjørn T. Dec 05 '17 at 10:32
  • I'm very short in time, so I've added only a very short answer. – Schweinebacke Dec 05 '17 at 10:59

1 Answers1

2

As long as secnumdepth is greater than zero, \sectionmark adds the section number \thesection (followed by a period and a space) before its argument to build the running head in the page head. You can use \markright{INTRO} to set the running head of odd pages or \markboth{INTRO}{INTRO} to set the running heads of odd and even pages without section number.

However, I would recommend not to use \section*{Intro} but \chapter*{Intro}, because the topmost section level in book is chapter not section.

Because you are using book you could even use \frontmatter and \mainmatter. Chapters in the front matter are not numbered automatically. So you can just use \chapter{Intro} and will have the entry into the table of contents and the running head.

If you would switch to the KOMA-Script class scrbook you could also use \addchap or \addsec. They work like \chapter and \section but without a number.

Schweinebacke
  • 26,336