0

Edit: Due to failure in answer, I will break the problem into two parts -- simple and complex with the intention of being more clear on what the question deals with.

Simple problem:

With respect to the following MWE, is there a way to clear the header from the first page of Appendix, but leaving the horizontal ruler and page number (just like it is for the very first page of Chapter 1)?

\documentclass[12pt, openright, twoside, a4paper, chapter=TITLE, english]{memoir}

\usepackage{lipsum}

\usepackage{titlesec}
\titleformat{\chapter}{\normalfont\normalsize\scshape\bfseries}{\thechapter}{1em}{}
\titleformat{\section}{\normalfont\normalsize\scshape\bfseries}{\thesection}{1em}{}

\usepackage{fancyhdr}
    \pagestyle{empty}
    \pagestyle{fancy}
    \fancyhf{} %... clears all headers and footers
    \fancyhead[LE, RO]{\thepage} %... left-even right-odd page numbering
    \fancyhead[LO]{\rightmark} %... left-odd page section title
    \fancyhead[RE]{\leftmark} %... right-even page subsection title
    \renewcommand{\headrulewidth}{0.4pt}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-------- STANDARD POS-TEXTUAL ELEMENTS ---------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-> Create counter for appendix
\newcounter{appendix}
\newcounter{appsection}[appendix]
\newcounter{appsubsection}[appsection]

%-> Change numbering format to capitalized alphabetic
\renewcommand{\theappendix}{\Alph{appendix}}

%-> Create appendix title command
\newcommand{\Appendix}[1]{%
    %... make sure an odd blank page will be created for the Bibliography environment
    \cleardoublepage

    %... increase appendix counter
    \refstepcounter{appendix}

    %... make sure the appendix pages will be fancy
    \fancyhf{} %... clears headers and footers
    \fancyhead[LE, RO]{\thepage} %... left-even right-odd page numbering
    \fancyhead[RE]{APPENDIX \theappendix.\hspace{1em}\uppercase{#1}}
    \fancyhead[LO]{\theappendix.\theappsection.\hspace{1em}\MakeUppercase{\appsecname}}
    % \def\thispagestyle##1{}

    %-> Format title font and positioning
    \rule{0cm}{0cm}\bigskip\vspace{3em}

    \noindent
    {\scshape\textbf{APPENDIX \theappendix\ -- #1}}

    \bigskip\vspace{3em}
    }

%-> Create appendix section command
\newcommand{\appsec}[1]{%
    \def\appsecname{#1}
    \refstepcounter{appsection}
    \bigskip
    \noindent
    {\scshape\textbf{\theappendix.\theappsection\hspace{1em}#1}}

    \bigskip
    }

%-> Create appendix subsection command
\newcommand{\appsubsec}[1]{%
    \refstepcounter{appsubsection}
    \bigskip
    \noindent
    {\scshape\textbf{\theappendix.\theappsection.\theappsubsection\hspace{1em} #1}}

    \bigskip
    }


%-----> BEGIN DOCUMENT <-----%
\begin{document}

\chapter{This is the first chapter} \thispagestyle{fancy}
\section{This is the first section}
\lipsum[1-5]

\section{This is the second section}
\lipsum[6-10]

\Appendix{This is one appendix} \thispagestyle{fancy}
\lipsum[11-12]

\appsec{This is an appendix section}
\lipsum[13-20]


\end{document}

Complex problem:

This is just an addendum motivated by the suggestive use of built-in \appedix.

The reason I avoid \appendix is that I need a table with different horizontal levels for chapters and appendices. The complete piece of code that attempt to do this is the following:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-------- STANDARD POS-TEXTUAL ELEMENTS ---------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-> Create counter for appendix
\newcounter{appendix}
\newcounter{appsection}[appendix]
\newcounter{appsubsection}[appsection]

%-> Change numbering format to capitalized alphabetic
\renewcommand{\theappendix}{\Alph{appendix}}

%-> Create the command to start pos-text
\def\startpostext{%
    %-> Format title font and positioning
    \titleformat{\chapter}{\normalfont\normalsize\scshape\bfseries}{APPENDIX \thechapter\ -- }{0em}{}
    }

%-> Create appendix title command
\newcommand{\Appendix}[1]{%
    %... make sure an odd blank page will be created for the Bibliography environment
    \cleardoublepage

    %... make sure the \leftmark and the \rightmark will be printed correctly
    % \phantomsection

    %... increase appendix counter
    \refstepcounter{appendix}

    %... mannualy add the appendix to the ToC
    \addcontentsline{toc}{chapter}{\protect\numberline{}\textbf{APPENDIX \theappendix\ -- #1}}

    %... make sure the appendix pages will be fancy
    \fancyhf{}
    \fancyhead[LE, RO]{\thepage} %... left-even right-odd page numbering
    \fancyhead[RE]{APPENDIX \theappendix.\hspace{1em}\uppercase{#1}}
    \fancyhead[LO]{\theappendix.\theappsection.\hspace{1em}\MakeUppercase{\appsecname}}

    %-> Format title font and positioning
    \rule{0cm}{0cm}\bigskip\vspace{3em}

    \noindent
    {\scshape\textbf{APPENDIX \theappendix\ -- #1}}
    \thispagestyle{empty}

    \bigskip\vspace{3em}
    }

%-> Create appendix section command
\newcommand{\appsec}[1]{%
    \def\appsecname{#1}
    \refstepcounter{appsection}
    \bigskip
    \noindent
    {\scshape\textbf{\theappendix.\theappsection\hspace{1em}#1}}

    \bigskip
    }

%-> Create appendix subsection command
\newcommand{\appsubsec}[1]{%
    \refstepcounter{appsubsection}
    \bigskip
    \noindent
    {\scshape\textbf{\theappendix.\theappsection.\theappsubsection\hspace{1em} #1}}

    \bigskip
    }

Observe here that \addcontentsline{toc}{chapter}{\protect\numberline{}\textbf{APPENDIX \theappendix\ -- #1}} adds the Appendices to the ToC with the desired indentation (horizontal level) ahead of the chapters. In addition, It is labeld, for instance, APPENDIX A -- Appendix title in the ToC.

Summary:

If there is a way of using \appendix that allows me to alter their horizontal level and display in ToC, that is fine.

If there is a way fo using the definition \Appendix as presented here and clear the header (except for horizontal ruler and page number), that is also okay!

1

What you call "failure in answer" actually is "failure in specifying all requirements at once".

Be that as it may—let's invent our own wheel by means of memoir: ;-)

\documentclass[12pt, openright, twoside, a4paper]{memoir}

\usepackage{lipsum}

%\usepackage{hyperref}

\makepagestyle{mypagestyle}
\makeevenhead{mypagestyle}{\thepage}{}{\leftmark}
\makeoddhead{mypagestyle}{\rightmark}{}{\thepage}
\makeevenfoot{mypagestyle}{}{}{}
\makeoddfoot{mypagestyle}{}{}{}
\makeheadrule{mypagestyle}{\textwidth}{0.4pt}
\pagestyle{mypagestyle}
\aliaspagestyle{chapter}{mypagestyle}

\makeatletter
\newcommand\chs@mychapterstyle{%
  \@chs@def@ult
  \chapterstyle{default}%
  \setlength{\beforechapskip}{3em}%
  \renewcommand*{\chapterheadstart}{\vtop to\baselineskip{}\vspace{\beforechapskip}}%
  \setlength{\afterchapskip}{3em}%
  \renewcommand{\printchaptername}{}%
  \renewcommand{\chapternamenum}{}%
  \renewcommand{\chaptitlefont}{\normalfont\normalsize\bfseries}%
  \renewcommand{\chapnumfont}{\chaptitlefont}%
  \renewcommand{\printchapternum}{\chapnumfont\thechapter\quad}%
  \renewcommand{\afterchapternum}{}%
}%
\newcommand\chs@myappendixstyle{%
  \@chs@def@ult
  \chapterstyle{default}%
  \setlength{\beforechapskip}{3em}%
  \renewcommand*{\chapterheadstart}{\vtop to\baselineskip{}\vspace{\beforechapskip}}%
  \setlength{\afterchapskip}{3em}%
  \renewcommand{\printchaptername}{\chaptitlefont\MakeTextUppercase{\appendixname}~}%
  \renewcommand{\chapternamenum}{}%
  \renewcommand{\chaptitlefont}{\normalfont\normalsize\bfseries}%
  \renewcommand{\chapnumfont}{\chaptitlefont}%
  \renewcommand{\printchapternum}{\chapnumfont\thechapter~--~}%
  \renewcommand{\afterchapternum}{}%
  \renewcommand\chaptermark[1]{%
    \@setclcnt{chapter}{@memmarkcntra}%
    \advance\c@@memmarkcntra\m@ne
    \markboth{%
               \memUChead{%
                 \ifnum\c@secnumdepth>\c@@memmarkcntra
                   \if@mainmatter
                     \@nameuse{chaptermarksn}%
                              {\@chapapp\ \@nameuse{thechapter}~--~}%
                   \fi
                 \fi
                 ##1%
               }
             }{}%
  }%
}%
\makeatother
\chapterstyle{mychapterstyle}%
\renewcommand\secheadstyle{\normalsize\bfseries\memRTLraggedright}%
\renewcommand\subsecheadstyle{\normalsize\bfseries\memRTLraggedright}%
\renewcommand\subsubsecheadstyle{\normalsize\bfseries\memRTLraggedright}%
\renewcommand\paraheadstyle{\normalsize\bfseries}%
\renewcommand\subparaheadstyle{\normalsize\bfseries}%
\newcommand\chapternumberlinetoappendixnumberline{%
  \renewcommand\chapternumberline[1]{\MakeTextUppercase{\appendixname}~##1~--~}%
  \advance\cftchapterindent by \cftchapternumwidth\relax
}%

%-----> BEGIN DOCUMENT <-----%
\begin{document}

\tableofcontents*

\chapter{This is the first chapter}
\section{This is the first section}
\lipsum[1-5]

\section{This is the second section}
\lipsum[6-10]

\appendix
\settocdepth{chapter}
\addtocontents{toc}{\protect\chapternumberlinetoappendixnumberline}%
\chapterstyle{myappendixstyle}%

\chapter{This is one appendix}
\lipsum[11-12]

\section{This is an appendix section}
\lipsum[13-20]

\end{document}

Page 1: enter image description here

Page 2: enter image description here

Page 3: enter image description here

Page 4: enter image description here

Page 5: enter image description here

Page 6: enter image description here

Page 7: enter image description here

Page 8: enter image description here

Page 9: enter image description here

  • Kkkkkk yes @UlrichDiez you are right. I didn't intend to minimize your contribution. But, as my defense, My question was precisely "How to clear header except for the page number and horizontal ruler using the presented MWE as reference". Your solution now works for me. Thank you again and excellent job! :) – Brasil Jun 13 at 15:14
  • 1
    My contribution is not that relevant. It merely consisted of skimming over the memoir-manual. The point is: The MWE presented in the initial release of your question did not exhibit in whatsoever way the desired appearance for entries within the table of contents. Statements regarding that came with your edit which took place when my first answer was already submitted. As a rule of thumb, when it comes to fiddling/struggling with LaTeX, it is good practice to state all requirements at once in order to avoid the need of (sometimes totally) reworking things... – Ulrich Diez Jun 13 at 15:28
  • Sure! I will pay attention next times! Thank you! – Brasil Jun 13 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.