3
votes

Bookdown allows for a table of contents, list of figures, list of tables, and preface. When using the first three and generating a PDF, the heading correctly reflects "Contents", "List of Figures", or "List of Tables". However, with an unnumbered preface one would expect to see "Preface" added to the heading but it does not appear and instead the last heading persists, so the preface, even if spanning multiple pages, will have the header "Contents", for example.

If I take the minimal book example found at https://github.com/rstudio/bookdown-demo and add # Preface {-} in index.Rmd I also have to manually add the following to get the desired behaviour:

# Preface {-}
\renewcommand{\chaptermark}[1]{\markboth{\uppercase{#1}}{\uppercase{#1}}}
\chaptermark{Preface}

Blah blah blah

\renewcommand{\chaptermark}[1]{\markboth{\uppercase{\thechapter. \ #1}}{}}

i.e., in order to get "Preface" to appear in the headings and then for the remaining headings to alternate section and chapter titles.

I suspect this is a glitch but before reporting this to the author of bookdown he asks that this first be posed here, so any insight would be most welcome.

1
This issues appears related? github.com/rstudio/bookdown/issues/309Michael Harper
can you mark my answer as accepted if you are happy?Michael Harper

1 Answers

4
votes

This issue has already been flagged as an issue here: https://github.com/rstudio/bookdown/issues/309

More Detailed Explanation

As stated in the answer, this is less of a problem of bookdown, but more of how LaTeX treats unnumbered chapters. When pandoc does the conversion for markdown to LaTeX, it creates a chapter header \chapter*{Preface}, which LaTeX does not automatically add to the header.

Potential Workarounds:

There are several posts highlighting some solutions here: