1

Maybe a bit unoriginal, but I'd like to change a single page number or header on a page (page 42 in this case) to say "Answer to the Ultimate Question of Life, the Universe, and Everything". If the number is changed, it should be without disrupting the page numbering, so 43 follows this page. This is for my Ph.D. dissertation, and I'm using the PhDThesisPSnPDF template.

I found a veeery similar question/answer, but the template was different enough that I couldn't get it to work (Change header on a specific page)

I'm also not very Latex savvy, so a layman's answer would be appreciated!

1

1 Answer 1

1

My personal take on this is the following.

The PhDThesisPSnPDF class has three different page styles. Since you didn't mention any of them, I'll assume you're going to use the default one.

Looking in the .cls file, the page style is defined with fancyhdr, so we can borrow the definition of the default style and adapt it to your needs. The desired outcome at page 42 is obtained with a simple conditional

\ifnum\value{page}=42{<print the HG2G sentence>}\else <does nothing> \fi

Since the HG2G sentence is very long, on page 42 I changed the header to print it in place of the \leftmark. In the default style, the \leftmark is the title of the chapter. In this way, the sentence title will not overlap with the chapter title.

From the MWE below, you have to copy in your preamble the page style

\fancypagestyle{hg2g}{
    \renewcommand{\chaptermark}[1]{\markboth {##1}{}}
    \renewcommand{\sectionmark}[1]{\markright{\thesection\ ##1}}
    \fancyhf{}
    \fancyhead[LO]{\nouppercase \rightmark}
    \fancyhead[RO,LE]{\bfseries\thepage}
    \fancyhead[RE]{
        \ifnum\value{page}=42{Answer to the Ultimate Question of Life, the Universe, and Everything }\else {\nouppercase \leftmark} \fi
    }
}

and then use it with the \pagestyle{hg2g} command.

If compiled, the MWE will produce three pages, starting from page 41; the second page will be page 42, with the header you wanted.

\documentclass{PhDThesisPSnPDF}

\fancypagestyle{hg2g}{
    \renewcommand{\chaptermark}[1]{\markboth {##1}{}}
    \renewcommand{\sectionmark}[1]{\markright{\thesection\ ##1}}
    \fancyhf{}
    \fancyhead[LO]{\nouppercase \rightmark}
    \fancyhead[RO,LE]{\bfseries\thepage}
    \fancyhead[RE]{
        \ifnum\value{page}=42{Answer to the Ultimate Question of Life, the Universe, and Everything }\else {\nouppercase \leftmark} \fi
    }
}
\pagestyle{hg2g}

\begin{document}
\setcounter{page}{41} % only for this MWE, remove it from the tex file of your thesis
\chapter{Use of towels}
\newpage
You can wave your towel when writing your PhD thesis as a distress signal!
\newpage
\section{Stay warm with a towel}
\end{document}

I'm pasting only the screenshot of the header:

enter image description here

Another important assumption is that chapters will begin only on odd pages. The class is based on the book class, which has this behavior by defautl. That said, you should not use the openany option, that allows chapters to begin on even pages. Should a chapter begin on page 42, you'd lose the effect, because the pagestyle in this case does not print the page number.

You must log in to answer this question.

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