パーツページから派手なスタイルを削除する

パーツページから派手なスタイルを削除する

私は論文のヘッダーとフッターを設定するために fancyhdr パッケージを使用しています。最近 LaTeX を追加し\parts、この目的のために「partpagestyle」というページスタイルを定義しました。下の MWE が示すように、「onlycount」スタイルは各章の最初のページのヘッダーを正しく削除します。 の書式設定をクリアするために「partpagestyle」を定義しましたfancyhdrが、望みどおりの結果は得られませんでした。マニュアル (http://texdoc.net/texmf-dist/doc/latex/fancyhdr/fancyhdr.pdf) を試しても効果がありません。何が間違っているのでしょうか?

\documentclass[10pt]{report}
\usepackage{lipsum}
\usepackage{fancyhdr}

% Clear everything on part pages
\fancypagestyle{partpagestyle}
{
\fancyhf{}
}
% First page of chapter style
\fancypagestyle{onlycount}
{
\fancyhf{}
\renewcommand\headrulewidth{0pt}
\renewcommand\footrulewidth{0pt}
\fancyfoot[C]{\thepage}
}
\fancypagestyle{plain}{
\lhead[\rm\thepage]{\fancyplain{}{\nouppercase{\sl{\bf{\leftmark}}}}}
\rhead[\rm\thepage]{\fancyplain{}{\nouppercase{\sl{\bf{\rightmark}}}}}
\chead{}\lfoot{}\rfoot{}\cfoot{}
\renewcommand{\headrulewidth}{0.1mm}%
\fancyfoot[C]{\thepage}%
}
\pagestyle{plain}

\begin{document}

\begin{titlepage}
\huge \bfseries Thesis
\end{titlepage}

\chapter{Introduction}\thispagestyle{onlycount}
\lipsum[1-3]
\section{Motivation}
\lipsum[1-3]

\part{Some Part}
%\thispagestyle{partpagestyle}
%\thispagestyle{partpagestyle}

\chapter{Second Chapter}\thispagestyle{onlycount}
\lipsum[1-9]

\end{document}

答え1

のマクロの設定に\partreport.cls常に が含まれているため、ヘッダー ルールの太さを指定してスタイルを再定義すると、そのようなものが表示されます。\thispagestyle{plain}plain0.1mm

\fancyhf{}ヘッダーとフッターの個々のフィールドをクリアするだけですが、ないヘッダーまたはフッターのルール。これをクリアするために、定義\renewcommand{\headrulewidth}{0pt}に追加しましたpartpagestyle

このコードは、代わりに\part使用するコマンドを修正しますpartpagestyleplain

\documentclass[10pt]{report}
\usepackage{lipsum}
\usepackage{fancyhdr}

% Clear everything on part pages
\fancypagestyle{partpagestyle}
{%
  \fancyhf{}
  \renewcommand{\headrulewidth}{0pt}
}
% First page of chapter style
\fancypagestyle{onlycount}
{
  \fancyhf{}
  \renewcommand\headrulewidth{0pt}
  \renewcommand\footrulewidth{0pt}
  \fancyfoot[C]{\thepage}
}

\fancypagestyle{plain}{
  \lhead[\rm\thepage]{\fancyplain{}{\nouppercase{\textsl{\bfseries{\leftmark}}}}}
  \rhead[\rm\thepage]{\fancyplain{}{\nouppercase{\textsl{\bfseries{\rightmark}}}}}
  \chead{}\lfoot{}\rfoot{}\cfoot{}
  \renewcommand{\headrulewidth}{0.1mm}%
  \fancyfoot[C]{\thepage}%
}
\usepackage{xpatch}
% Patch the `\thispagestyle` code within `\part    
\xpatchcmd{\part}{\thispagestyle{plain}}{\thispagestyle{partpagestyle}}{}{}
\pagestyle{fancy}

\begin{document}

\begin{titlepage}
\huge \bfseries Thesis
\end{titlepage}

\chapter{Introduction}\thispagestyle{onlycount}
\lipsum[1-3]
\section{Motivation}
\lipsum[1-3]

\part{Some Part}


\thispagestyle{onlycount}
\chapter{Second Chapter}
\lipsum[1-9]

\end{document}

ここに画像の説明を入力してください

答え2

これは方法だ

\documentclass[10pt]{report}
\usepackage{lipsum}
\usepackage{fancyhdr}

\fancyhf{}
\lhead{\nouppercase{\textsl{\bfseries{\leftmark}}}}
\rhead{\nouppercase{\textsl{\bfseries{\rightmark}}}}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0.1mm}
\pagestyle{fancy}

\usepackage{xpatch}

\xpatchcmd{\part}{\thispagestyle{plain}}{\thispagestyle{empty}}{}{}

\begin{document}

\begin{titlepage}
\huge \bfseries Thesis
\end{titlepage}

\chapter{Introduction}
\lipsum[1-3]
\section{Motivation}
\lipsum[1-3]

\part{Some Part}

\chapter{Second Chapter}
\lipsum[1-9]

\end{document}

関連情報