LaTeX forum ⇒ GeneralAdd the word Appendix to header

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

Add the word Appendix to header

Postby dacoz » Wed Nov 27, 2019 9:44 pm

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] [Expand/Collapse] [Download] ({untitled.tex})
  1. \documentclass[b5paper]{memoir}
  2. \usepackage[utf8]{inputenc}
  3. \usepackage{blindtext}
  4.  
  5. %%%%%%%%% HEADER AND FOOTER FORMAT %%%%%%%%%
  6.  
  7. \def\hffont{\sffamily\small}
  8. \makepagestyle{myruled}
  9. \makeheadrule{myruled}{\textwidth}{\normalrulethickness}
  10. \makeevenhead{myruled}{\hffont\thepage}{}{\hffont\leftmark}
  11. \makeoddhead{myruled}{\hffont\rightmark}{}{\hffont\thepage}
  12. \makeevenfoot{myruled}{}{}{}
  13. \makeoddfoot{myruled}{}{}{}
  14. \makepsmarks{myruled}{
  15. \nouppercaseheads
  16. \createmark{chapter}{both}{shownumber}{}{\space}
  17. \createmark{section}{right}{shownumber}{}{\space}
  18. \createplainmark{toc}{both}{\contentsname}
  19. \createplainmark{lof}{both}{\listfigurename}
  20. \createplainmark{lot}{both}{\listtablename}
  21. \createplainmark{bib}{both}{\bibname}
  22. \createplainmark{index}{both}{\indexname}
  23. \createplainmark{glossary}{both}{\glossaryname}
  24. }
  25. \pagestyle{myruled}
  26. \copypagestyle{cleared}{myruled} % When \cleardoublepage, use myruled instead of empty
  27. \makeevenhead{cleared}{\hffont\thepage}{}{} % Remove leftmark on cleared pages
  28. \makeevenfoot{plain}{}{}{} % No page number on plain even pages (chapter begin)
  29. \makeoddfoot{plain}{}{}{}
  30.  
  31. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  32.  
  33.  
  34. \begin{document}
  35.  
  36. \appendix
  37. \chapter{Test on header}
  38. \blindtext[10]
  39.  
  40. \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.

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

Postby Johannes_B » Thu Nov 28, 2019 7:40 am

Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \makeatletter
  2. \createmark{chapter}{both}{shownumber}{\@chapapp\ }{\space}
  3. \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

Postby dacoz » Thu Nov 28, 2019 9:51 am

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] [Expand/Collapse] [Download] ({untitled.tex})
  1. \documentclass[b5paper]{memoir}
  2. \usepackage[utf8]{inputenc}
  3. \usepackage{blindtext}
  4.  
  5. %%%%%%%%% HEADER AND FOOTER FORMAT %%%%%%%%%
  6.  
  7. \def\hffont{\sffamily\small}
  8. \makepagestyle{myruled}
  9. \makeheadrule{myruled}{\textwidth}{\normalrulethickness}
  10. \makeevenhead{myruled}{\hffont\thepage}{}{\hffont\leftmark}
  11. \makeoddhead{myruled}{\hffont\rightmark}{}{\hffont\thepage}
  12. \makeevenfoot{myruled}{}{}{}
  13. \makeoddfoot{myruled}{}{}{}
  14. %%%%%% Adds the word "Appendix" to appendices header %%%
  15. \makepagestyle{appruled}
  16. \makeheadrule{appruled}{\textwidth}{\normalrulethickness}
  17. \makeevenhead{appruled}{\hffont\thepage}{}{\hffont\appendixname~\leftmark}
  18. \makeoddhead{appruled}{\hffont\appendixname~\rightmark}{}{\hffont\thepage}
  19. \makeevenfoot{appruled}{}{}{}
  20. \makeoddfoot{appruled}{}{}{}
  21. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  22. \makepsmarks{myruled}{
  23. \nouppercaseheads
  24. \createmark{chapter}{both}{shownumber}{}{\space}
  25. \createmark{section}{right}{shownumber}{}{\space}
  26. \createplainmark{toc}{both}{\contentsname}
  27. \createplainmark{lof}{both}{\listfigurename}
  28. \createplainmark{lot}{both}{\listtablename}
  29. \createplainmark{bib}{both}{\bibname}
  30. \createplainmark{index}{both}{\indexname}
  31. \createplainmark{glossary}{both}{\glossaryname}
  32. }
  33. \pagestyle{myruled}
  34. \copypagestyle{cleared}{myruled} % When \cleardoublepage, use myruled instead of empty
  35. \makeevenhead{cleared}{\hffont\thepage}{}{} % Remove leftmark on cleared pages
  36. \makeevenfoot{plain}{}{}{} % No page number on plain even pages (chapter begin)
  37. \makeoddfoot{plain}{}{}{}
  38.  
  39. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  40.  
  41.  
  42. \begin{document}
  43.  
  44. \appendix
  45. \pagestyle{appruled}
  46. \chapter{Test on header}
  47. \blindtext[10]
  48.  
  49. \end{document}


It is not as easy and clean as yours, but it does what I want :)


Return to “General”

Who is online

Users browsing this forum: No registered users and 2 guests