1

I need to suppress the page number on the first page of the chapter. I read this and used their advice. It does its job. But fancyhdr inserts the header and footer line in the 'contents' page.

If I remove the recommended line \fancypagestyle{plain}{\fancyhf{}} after \usepackage{fancyhdr} the header and footer lines disappear on the content page, but the page number appears on the Chapter page. I do not understand why. 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}
%\fancypagestyle{plain}{\fancyhf{}}
\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}
}
\fancypagestyle{style3}{
\fancyhf{}
\setlength{\headwidth}{\textwidth}
\addtolength{\headwidth}{\marginparwidth}
\addtolength{\headwidth}{\marginparsep}
\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}
%\thispagestyle{empty}
\tableofcontents
\clearpage{\pagestyle{empty}\cleardoublepage}


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

\lipsum

\clearpage{\pagestyle{empty}\cleardoublepage}



\newgeometry{inner=1.6cm,top=2.4cm,bottom=4cm,textwidth=7.4cm,marginparwidth=40mm}

\pagestyle{style3}
\chapter{The First Chapter}
\section{Section about everything}
\lipsum[1-2]\marginpar{\lipsum[1]}\lipsum[1-5]

\end{document}

Output: enter image description here

My goal is to have different styles for the introduction and for the main part (wider margins for graffiti.

Contents preferably with page number (as they are now), but absolutely no rulers.

Introduction: rulers

Chapter: Absolutely blank first page. The text is narrower, no rulers. The following pages are with rulers and same (narrow) width of the text.

Thanks for help.

1

I added these two lines to style 3, and i think it did the job:

\renewcommand{\headrulewidth}{0pt} %<- ADDED
\renewcommand{\footrulewidth}{0pt} %<- ADDED

Full code:

\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}
\fancypagestyle{plain}{\fancyhf{}}
\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}
}
\fancypagestyle{style3}{
\fancyhf{}
\setlength{\headwidth}{\textwidth}
\addtolength{\headwidth}{\marginparwidth}
\addtolength{\headwidth}{\marginparsep}
\fancyhead[LE,RO]{\bfseries\thepage}
\fancyhead[LO]{\bfseries\rightmark}
\fancyhead[RE]{\bfseries\leftmark}
\renewcommand{\headrulewidth}{0pt} %<- ADDED
\renewcommand{\footrulewidth}{0pt} %<- ADDED
}

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


\begin{document}

\pagestyle{style1}
\maketitle

\newgeometry{top=24mm,bottom=40mm,inner=16mm,outer=3.2cm}
\thispagestyle{empty}
{This page is intentionally left blank}


\thispagestyle{empty}
\tableofcontents
\clearpage{\pagestyle{empty}\cleardoublepage}

\newgeometry{top=24mm,bottom=40mm,inner=16mm,outer=3.2cm,marginparwidth=20mm}
\pagestyle{style2}
\section*{Intro}
\addcontentsline{toc}{section}{\textbf{Intro}}

\lipsum

\clearpage{\pagestyle{empty}\cleardoublepage}



\newgeometry{inner=1.6cm,top=2.4cm,bottom=4cm,textwidth=7.4cm,marginparwidth=40mm}

\pagestyle{style3}
\chapter{The First Chapter}
\section{Section about anything}
\lipsum[1-2]\marginpar{\lipsum[1]}\lipsum[1-5]

\end{document}

output: enter image description here

EDIT::

If you want to empty style for the first page of the chapter you can add

\thispagestyle{empty} 

after the chapter exactly.

following is the new output:

enter image description here

The New Code:

    \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}
    \fancypagestyle{plain}{\fancyhf{}}
    \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}
    }
    \fancypagestyle{style3}{
        \fancyhf{}
        \setlength{\headwidth}{\textwidth}
        \addtolength{\headwidth}{\marginparwidth}
        \addtolength{\headwidth}{\marginparsep}
        \fancyhead[LE,RO]{\bfseries\thepage}
        \fancyhead[LO]{\bfseries\rightmark}
        \fancyhead[RE]{\bfseries\leftmark}
    %   \renewcommand{\headrulewidth}{0pt} %<- ADDED
    %   \renewcommand{\footrulewidth}{0pt} %<- ADDED
    }

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


    \begin{document}

        \pagestyle{style1}
        \maketitle

        \newgeometry{top=24mm,bottom=40mm,inner=16mm,outer=3.2cm}
        \thispagestyle{empty}
        {This page is intentionally left blank}


        \thispagestyle{empty}
        \tableofcontents
        \clearpage{\pagestyle{empty}\cleardoublepage}

        \newgeometry{top=24mm,bottom=40mm,inner=16mm,outer=3.2cm,marginparwidth=20mm}
        \pagestyle{style2}
        \section*{Intro}
        \addcontentsline{toc}{section}{\textbf{Intro}}

        \lipsum

        \clearpage{\pagestyle{empty}\cleardoublepage}



        \newgeometry{inner=1.6cm,top=2.4cm,bottom=4cm,textwidth=7.4cm,marginparwidth=40mm}

        \pagestyle{style3}
        \chapter{The First Chapter}
            \thispagestyle{empty} %<-- ADDED
        \section{Section about anything}
        \lipsum[1-2]\marginpar{\lipsum[1]}\lipsum[1-5]

    \end{document}
  • Thank you for your response. Unfortunately, I cannot accept it as the answer since it gets rid of the rulers on the following pages. To keep them is another problem as I don't understand how and where to change the style back. So more new questions than answers. Thanks anyway. – Sergey Belyaev Dec 1 '17 at 13:10
  • I edited the solution to meet your requirements. – Sari Dec 1 '17 at 21:07
0

I did not find the answer to the question but took into consideration that the reader also wants to know what page the chapter starts (for search and for navigation), so I ended up with the following.

\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}
%\fancypagestyle{plain}{\fancyhf{}}
\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}
}
\fancypagestyle{style3}{
\fancyhf{}
\setlength{\headwidth}{\textwidth}
\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}
}
% Define the DEFAULT style
\fancypagestyle{MyStyle}{%
    \fancyhead{} %Clean headers
    \fancyfoot{} %Clean footers
    \renewcommand{\headrulewidth}{1pt} % Header rule's width
        \setlength{\headwidth}{\textwidth}
        \addtolength{\headwidth}{\marginparwidth}
        \addtolength{\headwidth}{\marginparsep}
    \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}
%\thispagestyle{empty}
\tableofcontents
\clearpage{\pagestyle{empty}\cleardoublepage}


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

\lipsum

\clearpage{\pagestyle{empty}\cleardoublepage}



\newgeometry{inner=1.6cm,top=2.4cm,bottom=4cm,textwidth=7.4cm,marginparwidth=40mm}

\pagestyle{MyStyle}
\chapter{The First Chapter}
\section{Section about everything}
\lipsum[1-2]\marginpar{\lipsum[1]}\lipsum[1-5]

\end{document}

This link helped. This MWE has another follow up question.

  • I edited the solution to meet your requirements. – Sari Dec 1 '17 at 21:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.