1

I'm trying to format my thesis and I got to a pre-textual element (acronyms list) that has two pages. The first page has the correct "plain" heading, but the second page doesn't, because it's following the "fancy" heading.

I couldn't figure out how to fix this without messing with the \maintmatter part, which by now is correct. The Chapter page has "plain" style and the second page has "fancy" style.

How can I guarantee all pages to plain style in frontmatter and keep the distinction between chapter page and text pages in mainmatter?

\documentclass[oneside, 12pt]{book}
\usepackage{fancyhdr}
\usepackage{lipsum}
\usepackage{fancyhdr}

%Heading definition----------------------------
%Frontmatter and chapter page?
\fancypagestyle{plain}{%
  \fancyhf{}%
  \fancyhead[R]{\thepage}
  \renewcommand{\headrulewidth}{0pt}%
  \renewcommand{\footrulewidth}{0pt}%
  \setlength{\headheight}{15pt}
}

%overall?
\pagestyle{fancy}
\fancyhf{} 
\fancyhead[L]{\nouppercase \leftmark}
\fancyhead[R]{\thepage}
\setlength{\headheight}{15pt}


\begin{document}

\frontmatter

\chapter{A two-page pre-textual chapter}
\lipsum[1-5]

\mainmatter

\chapter{A two-page textual Chapter}
\lipsum[1-5]

\end{document}
4
  • 1
    replace \mainmatter with \thispagestyle{plain} \mainmatter \thispagestyle{fancy}
    – Samjith
    Oct 1, 2019 at 10:36
  • Yep, that's it. Is this logical? I mean, that's how usually one deals with \frontmatter or this standard behaviour (e.g. line headers) is supposed to be everywhere and not just in the \mainmatter section? And idk, If you make this as an answer I'd vote too. Oct 1, 2019 at 10:46
  • plain style is only for title page, if you need more page to style it as plain, you should specifically say by \thispagestyle{plain}. i think \thispagestyle{fancy} is not necessary, it will work even if it is not given.
    – Samjith
    Oct 1, 2019 at 10:53
  • @TVMBoy Chaper pages use pagestyle plain too. Your \thispagestyle{plain} before \mainmatter only affects the last page of frontmatter. If the chapter in front matter has three or more pages your suggestion will fail.
    – esdd
    Oct 1, 2019 at 11:09

2 Answers 2

1

You could do something like this:

\documentclass[oneside, 12pt]{book}
\usepackage{fancyhdr}
\usepackage{lipsum}
\usepackage{fancyhdr}

%Heading definition----------------------------
%Frontmatter and chapter page?
\fancypagestyle{plain}{%
  \fancyhf{}%
  \fancyhead[R]{\thepage}
  \renewcommand{\headrulewidth}{0pt}%
  \renewcommand{\footrulewidth}{0pt}%
  \setlength{\headheight}{15pt}%
}

%overall?
\fancypagestyle{myfancy}{%
\fancyhf{} %
\fancyhead[L]{\nouppercase \leftmark}%
\fancyhead[R]{\thepage}%
\setlength{\headheight}{15pt}%
}

\let\oldfrontmatter\frontmatter
\let\oldmainmatter\mainmatter
\gdef\frontmatter{\oldfrontmatter\pagestyle{plain}}
\gdef\mainmatter{\oldmainmatter\pagestyle{myfancy}}

\begin{document}

\frontmatter

\chapter{A two-page pre-textual chapter}
\lipsum[1-5]

\mainmatter

\chapter{A two-page textual Chapter}
\lipsum[1-5]

\end{document}
3
  • 1
    That's good, I just had to add \renewcommand{\headrulewidth}{0.4pt}% in "myfancy" definitions to show the line headers, maybe the code before set everything to 0, but it solved my problem anyway Oct 1, 2019 at 11:03
  • the \headheight that you set as 15pt there ... is not the line's (rule's) height but the header's height that I thought you would like to have like this for some reason. Try changing the \headrulewidth like: \renewcommand{\headrulewidth}{0.2pt} instead of setting the \headheight there
    – koleygr
    Oct 1, 2019 at 11:05
  • 1
    Ok... you found that before I answer .. nice catch ... Happy TeXing!
    – koleygr
    Oct 1, 2019 at 11:07
1
\documentclass[oneside, 12pt]{book}
\usepackage{fancyhdr}
\usepackage{lipsum}
\usepackage{fancyhdr}

%Heading definition----------------------------
%Frontmatter and chapter page?
\fancypagestyle{plain}{%
  \fancyhf{}%
  \fancyhead[R]{\thepage}
  \renewcommand{\headrulewidth}{0pt}%
  \renewcommand{\footrulewidth}{0pt}%
  \setlength{\headheight}{15pt}
}

%overall?
\pagestyle{fancy}
\fancyhf{} 
\fancyhead[L]{\nouppercase \leftmark}
\fancyhead[R]{\thepage}
\setlength{\headheight}{15pt}


\begin{document}

\frontmatter

\chapter{A two-page pre-textual chapter}
\lipsum[1-5]

\thispagestyle{plain}
\mainmatter
\thispagestyle{fancy}

\chapter{A two-page textual Chapter}
\lipsum[1-5]

\end{document}

Hope this helps

1
  • The \thispagestyle{plain} before \mainmatter only affects the last page of frontmatter. If the chapter in front matter has three or more pages your suggestion will fail. Replace \lipsum[1-5] by \lipsum[1-10]. Additionally the \thispagestyle{fancy} after the chapter command can be removed.
    – esdd
    Oct 1, 2019 at 11:18

You must log in to answer this question.

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