GeneralAdd the word Appendix to header

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
dacoz
Posts: 2
Joined: Wed Nov 27, 2019 9:37 pm

Add the word Appendix to header

Post by dacoz »

I am completing the template for my PhD thesis. Everything works as expected, except the appendix header :roll: .

So far, it only displays the title: "A Journal articles".
What I want instead is: "Appendix A Journal articles".

The document class is *memoir* and here is an MWE showing the problem:

Code: Select all

\documentclass[b5paper]{memoir}
    \usepackage[utf8]{inputenc}
    \usepackage{blindtext} 
    
    %%%%%%%%% HEADER AND FOOTER FORMAT  %%%%%%%%%
    
    \def\hffont{\sffamily\small}
    \makepagestyle{myruled}
    \makeheadrule{myruled}{\textwidth}{\normalrulethickness}
    \makeevenhead{myruled}{\hffont\thepage}{}{\hffont\leftmark}
    \makeoddhead{myruled}{\hffont\rightmark}{}{\hffont\thepage}
    \makeevenfoot{myruled}{}{}{}
    \makeoddfoot{myruled}{}{}{}
    \makepsmarks{myruled}{
        \nouppercaseheads
        \createmark{chapter}{both}{shownumber}{}{\space}
        \createmark{section}{right}{shownumber}{}{\space}
        \createplainmark{toc}{both}{\contentsname}
        \createplainmark{lof}{both}{\listfigurename}
        \createplainmark{lot}{both}{\listtablename}
        \createplainmark{bib}{both}{\bibname}
        \createplainmark{index}{both}{\indexname}
        \createplainmark{glossary}{both}{\glossaryname}
    }
    \pagestyle{myruled}
    \copypagestyle{cleared}{myruled}      % When \cleardoublepage, use myruled instead of empty
    \makeevenhead{cleared}{\hffont\thepage}{}{} % Remove leftmark on cleared pages
    \makeevenfoot{plain}{}{}{}            % No page number on plain even pages (chapter begin)
    \makeoddfoot{plain}{}{}{}  
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    
    
    \begin{document}
    
    \appendix
    \chapter{Test on header}
    \blindtext[10]
    
    \end{document}
I hope you can help me to fix this. Thanks in advance :D !
Last edited by dacoz on Thu Nov 28, 2019 11:46 am, edited 1 time in total.

Recommended reading 2024:

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

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

User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Add the word Appendix to header

Post by Johannes_B »

Code: Select all

\makeatletter
\createmark{chapter}{both}{shownumber}{\@chapapp\ }{\space}
\makeatother
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
dacoz
Posts: 2
Joined: Wed Nov 27, 2019 9:37 pm

Add the word Appendix to header

Post by dacoz »

I like the clean and short form, but unfortunately it doesn't work. To solve the problem I have been suggested to define a new header only for the appendix:

Code: Select all

\documentclass[b5paper]{memoir}
    \usepackage[utf8]{inputenc}
    \usepackage{blindtext} 
 
    %%%%%%%%% HEADER AND FOOTER FORMAT  %%%%%%%%%
 
    \def\hffont{\sffamily\small}
    \makepagestyle{myruled}
    \makeheadrule{myruled}{\textwidth}{\normalrulethickness}
    \makeevenhead{myruled}{\hffont\thepage}{}{\hffont\leftmark}
    \makeoddhead{myruled}{\hffont\rightmark}{}{\hffont\thepage}
    \makeevenfoot{myruled}{}{}{}
    \makeoddfoot{myruled}{}{}{}
    %%%%%% Adds the word "Appendix" to appendices header %%% 
    \makepagestyle{appruled}
    \makeheadrule{appruled}{\textwidth}{\normalrulethickness}
    \makeevenhead{appruled}{\hffont\thepage}{}{\hffont\appendixname~\leftmark}   
    \makeoddhead{appruled}{\hffont\appendixname~\rightmark}{}{\hffont\thepage}
    \makeevenfoot{appruled}{}{}{}
    \makeoddfoot{appruled}{}{}{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \makepsmarks{myruled}{
        \nouppercaseheads
        \createmark{chapter}{both}{shownumber}{}{\space}
        \createmark{section}{right}{shownumber}{}{\space}
        \createplainmark{toc}{both}{\contentsname}
        \createplainmark{lof}{both}{\listfigurename}
        \createplainmark{lot}{both}{\listtablename}
        \createplainmark{bib}{both}{\bibname}
        \createplainmark{index}{both}{\indexname}
        \createplainmark{glossary}{both}{\glossaryname}
    }
    \pagestyle{myruled}
    \copypagestyle{cleared}{myruled}      % When \cleardoublepage, use myruled instead of empty
    \makeevenhead{cleared}{\hffont\thepage}{}{} % Remove leftmark on cleared pages
    \makeevenfoot{plain}{}{}{}            % No page number on plain even pages (chapter begin)
    \makeoddfoot{plain}{}{}{}  
 
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 
    \begin{document}
 
    \appendix
    \pagestyle{appruled}
    \chapter{Test on header}
    \blindtext[10]
 
    \end{document}
It is not as easy and clean as yours, but it does what I want :)
Post Reply