清除页眉(页码除外)

清除页眉(页码除外)

编辑:由于无法回答,我将问题分为简单和复杂两部分,以便更清楚地说明问题所涉及的内容。

简单问题:

对于以下 MWE,有没有办法清除附录第一页的页眉,但保留水平标尺和页码(就像第 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}

复杂问题:

这仅仅是一个由内置的暗示性使用所激发的附录\appedix

我避免这样做的原因\appendix是我需要一个具有不同水平级别的表格来显示章节和附录。尝试执行此操作的完整代码如下:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-------- 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
    }

请注意,此处\addcontentsline{toc}{chapter}{\protect\numberline{}\textbf{APPENDIX \theappendix\ -- #1}}将附录添加到目录中,并在章节前面添加所需的缩进(水平)。此外,它还APPENDIX A -- Appendix title在目录中进行了标记。

概括:

如果有一种方法\appendix可以让我改变它们的水平并在 ToC 中显示,那就很好了。

如果有办法使用\Appendix这里介绍的定义并清除页眉(水平标尺和页码除外),那也是可以的!

答案1

你所说的“回答失败”实际上是“未能一次性指定所有要求”。

无论如何——让我们通过回忆录来发明我们自己的轮子:;-)

\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}

第 1 页: 在此处输入图片描述

第2页: 在此处输入图片描述

第 3 页: 在此处输入图片描述

第 4 页: 在此处输入图片描述

第 5 页: 在此处输入图片描述

第 6 页: 在此处输入图片描述

第 7 页: 在此处输入图片描述

第 8 页: 在此处输入图片描述

第 9 页: 在此处输入图片描述

相关内容