Page LayoutRemove Chapter Prefix from Foreword and Afterword Headers

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Remove Chapter Prefix from Foreword and Afterword Headers

Post by Johannes_B »

I was thinking about your problem and finally I really understood what you want.
Please be aware of the differences between foreword, preface, and introduction.

I've been asking google and found this: Creating unnumbered chapters/sections (plus adding them to the ToC and/or header).

Please take a look at it, read it, understand it, test it, be satisfied and then post a minimal working example containing the solution.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

AleCes
Posts: 286
Joined: Sat Nov 13, 2010 9:54 pm

Remove Chapter Prefix from Foreword and Afterword Headers

Post by AleCes »

Johannes_B wrote:I was thinking about your problem and finally I really understood what you want.
Please be aware of the differences between foreword, preface, and introduction.
Oops... for me they're all the same :o
Johannes_B wrote:I've been asking google and found this: Creating unnumbered chapters/sections (plus adding them to the ToC and/or header).

Please take a look at it, read it, understand it, test it, be satisfied and then post a minimal working example containing the solution.
Making the foreword/afterword unnumbered is of no use to me, because I do want them to be added to the table of contents. Instead, \markboth is what I need. So:

Code: Select all

    \documentclass[12pt,a4paper]{book}
    \usepackage{fancyhdr}
    \pagestyle{fancy}
    \fancyhead{}
    \fancyhead[LE]{\leftmark}
    \fancyhead[RO]{\rightmark}
    \usepackage{fontspec}
    \defaultfontfeatures{Mapping=tex-text}
    \setmainfont{Linux Libertine G}
    \usepackage{polyglossia}
    \setmainlanguage{english}
    \usepackage{xunicode}
    \usepackage{xltxtra}
    \usepackage{bookmark}

    \begin{document}

    \frontmatter
   
    \tableofcontents 
 
    \chapter{Foreword}
   
    \markboth{FOREWORD}{} % Right pages left without header because there are no sections

    \mainmatter

    \chapter{Bees}

    \chapter{Wasps}

    \chapter{Flies}

    \chapter{Mosquitoes}

    \chapter{Butterflies}

    \chapter{Hornets}

    \chapter{Midges}

    \backmatter

    \chapter{Afterword}

    \markboth{AFTERWORD}{} % Right pages left without header because there are no sections

    \end{document}
One problem could arise from the need of having sections in the headers, which I currently don't need. Should I use \markright manually for every section?

Thank you anyway for your essential advice.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Remove Chapter Prefix from Foreword and Afterword Headers

Post by Johannes_B »

AleCes wrote:Should I use \markright manually for every section?
.

No, I don't think so. Just give it a try.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
AleCes
Posts: 286
Joined: Sat Nov 13, 2010 9:54 pm

Remove Chapter Prefix from Foreword and Afterword Headers

Post by AleCes »

Johannes_B wrote:
AleCes wrote:Should I use \markright manually for every section?
.

No, I don't think so. Just give it a try.
You're right, no need to do so. Thank you very much.
Post Reply