文書の特定のページのヘッダーとすべてのページのフッターは同じです

文書の特定のページのヘッダーとすべてのページのフッターは同じです

現在、プロジェクト レポート用のドキュメントを作成しようとしています。ヘッダーとフッターで問題が発生しています。

私は各ページのフッターフッターは下図のようになります。

fancyhdr パッケージを使用したフッター

このフッターを実現するために、私は現在fancyhdrファンシーページスタイル以下のコードスニペットに示すように。

\pagestyle{fancy}
%%  FOOTER
\fancyfoot[C]{\small \thepage} % PAGE NUMBER
\fancyfoot[L]{\small ENEL895 \\ Version 1.0} % PAPER CODE AND VERSION
\fancyfoot[R]{\small \today} % TODAY'S DATE
\renewcommand{\footrulewidth}{1pt} % FOOTER RULE LINE

フッターで私が遭遇している問題は、目次に関するものです(\thispagestyle{fancy}ヘッダーとフッターを取得するために目次とすべての章の横に配置してみました)。目次2ページにわたって最初のページにはフッターのページ番号のみが記載されていますが、2ページ目ヘッダーとフッターを修正する

両ページの目次ヘッダーとフッター下図のようになります。 目次ヘッダーとフッター

ヘッダーは複雑になります。ヘッダーには、フロントの問題(第1章以前のすべて)セクションタイトル右側ヘッダーの文字の大文字と小文字はタイトルの大文字と小文字とまったく同じである必要があります(つまり大文字ではないそして斜体ではない)。TOC ヘッダー (上記) は、私が言いたいことの一例です。章については、最初の章ページにはヘッダーを付けず、上記で指定したフッターのみにしたいと思います。章の残りのページについては、ヘッダーの左側に章 (形式: 章番号 - 章名)、右側にセクション (形式: # セクション名) を配置したいと思います。

ヘッダーとフッターは章の最初のページ下図のようになります。 章の最初のページのヘッダーとフッター

ヘッダーとフッターは章の残りのページ下図のようになるはずです (章の最初のページを示していることは無視してください)。

第1章の導入部は無視してください(これが章の残りのページです)

ヘッダーに関して私が遭遇したもう 1 つの問題は、付録のヘッダーに Appendix A ではなく Chapter A があることです。これをヘッダーの左側に配置し、付録の最初のページにはヘッダーがないようにします (章と同じように)。

付録ヘッダーの難易度:

付録の代わりに章

これまでの私のドキュメントの MWE は次のとおりです (コメントが多く、出力がこのスレッドに表示されている画像と同じではないことをお詫びします)。

\documentclass[12pt,a4paper]{report}

%----------------------------------------------------------------------------------------
%   PACKAGES
%----------------------------------------------------------------------------------------
%%  PAGE MARGINS
\usepackage[margin=1in]{geometry}

%%  RANDOM LOREM IPSUM TEXT TO FILL
\usepackage{blindtext}

%%  TOC BABEL
\usepackage[english]{babel}

%%  HYPERLINKING
\usepackage[colorlinks=true]{hyperref}
\hypersetup{%
    colorlinks,
    linkcolor={red!50!black},
    citecolor={blue!50!black},
    urlcolor={blue!80!black}
}

%%  HEADERS AND FOOTERS
\usepackage{fancyhdr}

%%  HEADING TITLES (TITLE SECTIONS)
\usepackage{titlesec}

%%  MAKES THE TOC WORK BETTER IMO (NOT SURE HOW)
\usepackage{tocloft}

%%  INCLUDE PDF PAGES
\usepackage{pdfpages}

%----------------------------------------------------------------------------------------
%   PAGE STYLE - HEADERS AND FOOTERS SETUP
%----------------------------------------------------------------------------------------
\pagestyle{fancy}

%%  HEADER
\fancyhead[L]{\leftmark} % SECTION NAME-FIRST SECTION/PREVIOUS SECTION

\fancyhead[R]{\nouppercase{\rightmark}} % CHAPTER NAME

%--------------------------------------------------------------------------

%%  FOOTER
\fancyfoot[C]{\small \thepage} % PAGE NUMBER

\fancyfoot[L]{\small ENEL895 \\ Version 1.0} % PAPER CODE AND VERSION

\fancyfoot[R]{\small \today} % TODAY'S DATE

\renewcommand{\footrulewidth}{1pt} % FOOTER RULE LINE

%--------------------------------------------------------------------------

%----------------------------------------------------------------------------------------
%   REDEFINING CHAPTER AND SECTION (LEFT AND RIGHT MARKS) TO BE THE     %   CHAPTER & SECTION NAMES AND NOT CAPITALISED.
%----------------------------------------------------------------------------------------

%%  CHAPTER DEFINED AS RIGHT MARK (Chapter # - Chapter Name)
\renewcommand{\chaptermark}[1]{%
\markboth{}{\chaptername
\ \thechapter ~- #1}}

%%  SECTION DEFINED AS LEFT MARK (# Section Name)
\renewcommand{\sectionmark}[1]{\markboth{\thesection\ #1}{}}

%----------------------------------------------------------------------------------------
%   REDEFINE THE CHAPTER HEADING FORMAT AND VERTICAL SPACING
%----------------------------------------------------------------------------------------

%%  SIZE AND FORMAT OF CHAPTER HEADING TITLE
\titleformat{\chapter}[display]
{\normalfont\Huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}

% ALTERS "BEFORE" SPACING (SECOND ARGUMENT) TO 0
\titlespacing*{\chapter}{0pt}{0pt}{20pt}

%----------------------------------------------------------------------------------------
%   EDITING THE TOC TITLE AND DOTTED LINE SEGMENTS FOR CHAPTERS
%----------------------------------------------------------------------------------------

%%  CHANGE TITLE TO "Table of Contents"
\addto\captionsenglish{% Replace "english" with the language you use
  \renewcommand{\contentsname}%
    {Table of Contents}%
}

%%  ADD DOTTED LINES FOR CHAPTERS IN TOC
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}} % for chapters, if you really want! 

%----------------------------------------------------------------------------------------
%   CHANGE LINE SPACING TO 1.5
%----------------------------------------------------------------------------------------

\renewcommand{\baselinestretch}{1.5}

%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
%----------------------------------------------------------------------------------------
%   END OF PREAMBLE AND START OF DOCUMENT
%----------------------------------------------------------------------------------------
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------

\begin{document}

%----------------------------------------------------------------------------------------
%   PDF TITLE PAGE (NOT INCLUDED FOR MWE)
%----------------------------------------------------------------------------------------

%-----------------------------PDF PAGE---------------------------------

\pagenumbering{roman}

%----------------------------------------------------------------------------------------
%   STATEMENT OF ORIGINALITY
%----------------------------------------------------------------------------------------

\section*{\LARGE\center{Statement of Originality\markboth{}{Statement of Originality}}}
\addcontentsline{toc}{chapter}{{Statement of Originality}}
\thispagestyle{fancy}

\newpage
%----------------------------------------------------------------------------------------
%   ACKNOWLEDGEMENTS
%----------------------------------------------------------------------------------------

\section*{\LARGE\center{Acknowledgements (optional)\markboth{}{Acknowledgements}}}
\addcontentsline{toc}{chapter}{{Acknowledgements}}
\thispagestyle{fancy}


\newpage
%----------------------------------------------------------------------------------------
%   ABSTRACT
%----------------------------------------------------------------------------------------

\section*{\LARGE\center{Abstract\markboth{}{Abstract}}}
\addcontentsline{toc}{chapter}{{Abstract}}
\thispagestyle{fancy}


\newpage
%----------------------------------------------------------------------------------------
%   ACRONYMS (OPTIONAL)
%----------------------------------------------------------------------------------------

\section*{\LARGE\center{Acronyms (optional)\markboth{}{Acronyms}}}
\addcontentsline{toc}{chapter}{{Acronyms}}
\thispagestyle{fancy}


\newpage
%----------------------------------------------------------------------------------------
%   SYMBOLS (OPTIONAL)
%----------------------------------------------------------------------------------------

\section*{\LARGE\center{Symbols (optional)\markboth{}{Symbols}}}
\addcontentsline{toc}{chapter}{{Symbols}}
\thispagestyle{fancy}


\newpage
%----------------------------------------------------------------------------------------
%   TABLE OF CONTENTS
%----------------------------------------------------------------------------------------

\begin{center}
\hypersetup{linkcolor=black} % Make Links Black
\vspace*{-40pt}
\tableofcontents\thispagestyle{fancy}\markboth{}{Table of Contents}
\addcontentsline{toc}{chapter}{Table of Contents}
\newpage
\vspace*{-40pt}
\listoffigures\thispagestyle{fancy}\markboth{}{}
\addcontentsline{toc}{chapter}{List of Figures}
\newpage
\vspace*{-40pt}
\listoftables\thispagestyle{fancy}\markboth{}{}
\addcontentsline{toc}{chapter}{List of Tables}
\end{center}

\newpage
\pagenumbering{arabic}

%----------------------------------------------------------------------------------------
%   MAIN TEXT (CHAPTERS)
%----------------------------------------------------------------------------------------

\chapter{Introduction}
\section{Introduction}\thispagestyle{fancy}
\Blindtext
\blindtext

\chapter{Literature Review}\thispagestyle{fancy}
\section{Background/Problem}
\blindtext 
\section{Analysis..}
\Blindtext 

\Blindtext

\chapter{Methodology}\thispagestyle{fancy}
\section{Procedure}
\blindtext\\

\blindtext \\

\blindtext\\

\blindtext
\section{Simulation?}
\blindtext\\

\blindtext \\
\blindtext

\chapter{Results and Discussion}\thispagestyle{fancy}
\section{Results Verification?}
\Blindtext

\chapter{Future Developments}\thispagestyle{fancy}
\section{Recommendations for Future Work}
\blindtext\\

\blindtext

\chapter{Conclusion}\thispagestyle{fancy}
\section{Conclusion}
\blindtext

%----------------------------------------------------------------------------------------
%   APPENDIX
%----------------------------------------------------------------------------------------
\begin{appendix}

\chapter{Example 1}\thispagestyle{fancy}
\section{Testing}
\Blindtext

\chapter{Example 2}\thispagestyle{fancy}
\section{Extra}
\blindtext

\end{appendix}

%----------------------------------------------------------------------------------------
%   BIBLIOGRAPHY/REFERENCES
%----------------------------------------------------------------------------------------

%-------------------------------REFS-----------------------------------

\end{document}

スレッドが長くなってしまい申し訳ありません。ただ、自分の問題と望む結果を徹底的に説明しようと思っただけです。現在、このfancyhdrパッケージを使用していますが、KOMA スクリプトと同等のものを使用すべきだと思われる場合は、使用方法についてお気軽にコメントを残してください (私はこれまで KOMA スクリプトを使用したことがありません)。

ありがとう。

答え1

クラス (およびクラスmemoirのスーパーセット)を使用する場合は、必要なヘッダー/フッターを取得できます。複雑に見えますが、多くのページスタイルとそれらが使用される場所を定義できます。bookreportmemoir

私には、ToC (おそらく LoT と LoF も)、おそらくタイトル ページ、章のタイトル ページ、一般的なドキュメント ページ、おそらく索引や参考文献など、複数の異なるページ スタイルが必要なように思えます。

以下の MWE は、目次と目次、章のタイトル ページ (付録を含む)、および一般的なページのページ スタイルを提供します。

% headersprob.tex  SE 562212
\documentclass{memoir}
\usepackage{lipsum}
\usepackage{comment}

% macro for details of the footer style
\newcommand{\enelf}[1]{%
\makeevenfoot{#1}{\small \parbox[t]{1in}{ENEL895 \\ Version 1.0}}{\small \thepage}{\small \today}
\makeoddfoot{#1}{\small \parbox[t]{1in}{ENEL895 \\ Version 1.0}}{\small \thepage}{\small \today}
\makefootrule{#1}{\textwidth}{1pt}{5pt}
}

\makepagestyle{ENELfoot}
\enelf{ENELfoot}


% pagestle for the ToC
\makepagestyle{ENELtoc}
\makeevenhead{ENELtoc}{}{}{Table of Contents}
\makeoddhead{ENELtoc}{}{}{Table of Contents}
\makeheadrule{ENELtoc}{\textwidth}{1pt}
\enelf{ENELtoc}

% pagestyle of the LoT
\makepagestyle{ENELlot}
\makeevenhead{ENELlot}{}{}{List of Tables}
\makeoddhead{ENELlot}{}{}{List of Tables}
\makeheadrule{ENELlot}{\textwidth}{1pt}
\enelf{ENELlot}

% pagestyle for chapter pages
\makepagestyle{chapter}
\enelf{chapter}

% don't uppercase chapter and section titles in headers
% (regular definition uses \MakeUppercase for titles)
\makeatletter
\renewcommand*{\chaptermark}[1]{%
  \markboth{\ifnum\c@secnumdepth > \m@ne
               \if@mainmatter
                 \@chapapp\ 
                  \thechapter \ %
               \fi
             \fi
              #1}{}}

\renewcommand*{\sectionmark}[1]{%
  \markright{\ifnum\c@secnumdepth > \z@
               \thesection \ %
              \fi
              #1}}
\makeatother

% The page style for the bulk of the document
\makepagestyle{ENELmain}
\makeevenhead{ENELmain}{\leftmark}{}{\rightmark}
\makeoddhead{ENELmain}{\leftmark}{}{\rightmark}
\enelf{ENELmain}

\begin{document}
\pagestyle{ENELfoot}

\frontmatter

\pagestyle{ENELtoc}
\copypagestyle{chapter}{ENELtoc} % the first page of the ToC uses the chapter pagestyle
\tableofcontents
\clearpage

\pagestyle{ENELlot}
\copypagestyle{chapter}{ENELlot} % the first page of the LoT uses the chapter page style
\listoftables

\mainmatter

% set the general page style
\pagestyle{ENELmain}
% first page of a chapter uses the chapter page style, so set it to be just the footer
\copypagestyle{chapter}{ENELfoot}
\chapter{One}

\lipsum

\section{A section}

\begin{table}
\centering
TABULATION
\caption{A table}
\end{table}

\lipsum

\addtocontents{toc}{\newpage} % make sure the ToC is more that one page
\section{Another section}
\lipsum

\appendix

\chapter{App}

\lipsum

\section{In appendix}

\lipsum
\end{document}

> texdoc memoir詳細については、ドキュメント(第 7 章)をお読みください。

答え2

fancyhdr のパッケージ ドキュメントで指摘されているように、コマンドは を\chapter発行します\thispagestyle{plain}。もこれと同じことが起こる
と思います。 したがって、ページ スタイルの再定義が必要になる場合があります。をプリアンブルに 追加することでこれを行うことができます。これにより、ページ スタイルが に設定されますが、ヘッダーは空になります。 その結果、新しい章が導入されるページには、ヘッダーはなくフッターのみになります。新しい章を作成するたびに を削除することを忘れないでください。\tableofcontents
plain
\fancypagestyle{plain}{\fancyhead{}\renewcommand{\headrule}{}}plainfancy

\thispagestyle{fancy}

ヘッダーがすべてのページに表示されないという問題は、定義とにあるようです\captionmark\sectionmark
が見つけた解決策は、これらの再定義を削除し、\nouppercase両方のヘッダーの定義を追加して、

\fancyhead[L]{\nouppercase\leftmark} % SECTION NAME-FIRST SECTION/PREVIOUS SECTION

\fancyhead[R]{\nouppercase\rightmark} % CHAPTER NAME

関連情報