Page LayoutHow to restore header of appendix to APPENDIX again

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
yoyoimut
Posts: 120
Joined: Mon Oct 19, 2009 6:58 am

How to restore header of appendix to APPENDIX again

Post by yoyoimut »

Hi everyone,

I use book class, modify the header-footer using fancyhdr and customize cleardoublepage. The only thing that works bad is the header of the appendix.

Now the header of appendix becomes Chapter A, Chapter B, etc instead of Appendix A, Appendix B, etc.

Code: Select all

\documentclass[a4paper,twoside,11pt]{book}
\usepackage[margin=30mm]{geometry}
\usepackage[colorlinks,bookmarksnumbered,bookmarksopen]{hyperref}
\usepackage{xcolor,bera}
\usepackage{lipsum}
\usepackage{makeidx}
\makeindex

%------------------------ Header & Footer ------------------------
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
%\fancyheadoffset[LE,RO]{\marginparsep+\marginparwidth}
\renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter.\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\fancyhead[RO,LE]{\small\sf\color{black}\rightmark}
\fancyhead[LO,RE]{\small\tt\color{black}\leftmark} %chapter label
\fancyfoot[RO,LE]{\thepage}
\renewcommand{\headrulewidth}{2pt}
\addtolength{\headheight}{\headrulewidth}
\renewcommand{\headrule}{{\color{gray}%
\vskip\headrulewidth\hrule width\headwidth height\headrulewidth \vskip-\headrulewidth}}

\fancypagestyle{plain}{%
\fancyhf{}%
\fancyfoot[RO,LE]{\thepage}%
\renewcommand{\headrulewidth}{0pt}%
}

%------------------------ ClearDoublePage ------------------------
\makeatletter
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}
\vspace*{\fill}
\begin{center}
{\bf\huge\ Intentionally left blank.}%
\end{center}
\vspace{\fill}
\thispagestyle{empty}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi}
%
\renewcommand\part{%
  \if@openright
    \cleardoublepage
  \else
    \clearpage
  \fi
  \thispagestyle{empty}%
  \if@twocolumn
    \onecolumn
    \@tempswatrue
  \else
    \@tempswafalse
  \fi
  \null\vfil
  \secdef\@part\@spart}
  %
  \renewcommand\@endpart{
  \if@twoside
    \if@openright
      \ifodd\c@page\else
        \cleardoublepage
      \fi
    \fi
  \fi
  \if@tempswa
    \twocolumn
  \fi%
}
\makeatother

%----------------------- Parskip -----------------------
\setlength{\parskip}{0.5em}



\begin{document}
	\frontmatter
			\title{I love \LaTeXe}
			\author{yoyoimut}
			\date{\today}
			\maketitle
			\tableofcontents
	\mainmatter
			\part{Getting started}
					
					\chapter{Introduction to Lipsum}
					\section{Lipsum One}
					\lipsum[1-10]
					\section{Lipsum Two}
					\lipsum[1-10]
							
			\appendix
			\part{Appendix}
					\chapter{What is Lipsum?}
					\section{Lipsum Appendix 1}
					\lipsum[1-10]
					\section{Lipsum Appendix 2}
					\lipsum[1-10]
	\backmatter
			\printindex
\end{document}

I attach my complete source code (but not so complicated) here so you can easily try it. Actually the code of redefining cleardoublepage is taken from this forum. But I no longer remember where the link is. I don't know the mechanism of the code as well. So please help me to solve this problem.

Thank you in advance.


regards,

Yoyoimut

Recommended reading 2024:

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

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

wheely_chairs
Posts: 26
Joined: Mon Jun 16, 2008 1:22 pm

How to restore header of appendix to APPENDIX again

Post by wheely_chairs »

You just need to redefine the \chaptername which is called in the header definition:

Code: Select all

\renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter.\ #1}{}}
Simply renew it in the appendix:

Code: Select all

\appendix
\renewcommand{\chaptername}{Appendix}
\part{Appendix}
HTH,

Chris
yoyoimut
Posts: 120
Joined: Mon Oct 19, 2009 6:58 am

Re: How to restore header of appendix to APPENDIX again

Post by yoyoimut »

Thank you, Chris.

It works the way I want.


regards,

yoyo
yoyoimut
Posts: 120
Joined: Mon Oct 19, 2009 6:58 am

Re: How to restore header of appendix to APPENDIX again

Post by yoyoimut »

Hi anyone,

If we use the hard-coded solution given by Chris, we cannot get the benefit of localization given in babel package.

As I am using Bahasa language in babel, I can follow the Chris' solution by simply changing the hard-coded literal "Appendix" to "apendiks".

Thank you in advance.

regards,

yoyo
wheely_chairs
Posts: 26
Joined: Mon Jun 16, 2008 1:22 pm

How to restore header of appendix to APPENDIX again

Post by wheely_chairs »

you could substitute

Code: Select all

Appendix
for

Code: Select all

\appendixname
Chris
yoyoimut
Posts: 120
Joined: Mon Oct 19, 2009 6:58 am

How to restore header of appendix to APPENDIX again

Post by yoyoimut »

wheely_chairs wrote:you could substitute

Code: Select all

Appendix
for

Code: Select all

\appendixname
Chris

Thanks Chris for this information. Well done. :D

Anyway, how to mark my first post in this topic as SOLVED ? :?:
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

How to restore header of appendix to APPENDIX again

Post by localghost »

yoyoimut wrote:[…] Anyway, how to mark my first post in this topic as SOLVED ? […]
Time for edition has run out. No surprise since the feedback comes more than one month later and half a year since opening of the thread. So I did that.
yoyoimut
Posts: 120
Joined: Mon Oct 19, 2009 6:58 am

How to restore header of appendix to APPENDIX again

Post by yoyoimut »

yoyoimut wrote:[…] Anyway, how to mark my first post in this topic as SOLVED ? […]
localghost wrote: Time for edition has run out. No surprise since the feedback comes more than one month later and half a year since opening of the thread. So I did that.

OK. Thank you. :P
Post Reply