
数日前から、ページのヘッダーを削除してページ番号を維持しようとしています。これが私の動作例です。問題は、次を使用してヘッダーを削除すると、 \thispagestyle{plain}
ページ番号も削除されることです。最初のページは、番号が欠落していることを除いて正常に動作しています。2 番目のページは正常です。
\documentclass[a4paper,11pt]{article}
\usepackage[ngerman]{babel}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\sectionmark}[1]{\markboth{#1}{}} % set the \leftmark
\fancyhf{}
\fancyhead[L]{\leftmark} % 1. sectionname
\fancyfoot[C]{\thepage}
\fancypagestyle{plain}{%
\fancyhf{}%
\renewcommand{\headrulewidth}{0.0pt}%
}
\begin{document}
\section{Titel}
\thispagestyle{plain}
\lipsum[2-10]
\end{document}
答え1
発行すると、\fancyhf{}
ヘッダーとフッターの両方がクリアされます。したがって、スタイルの再定義では、存在するヘッダーとフッターがすべてクリアされます。再定義の一部として以下をplain
含めることで、フッターを再確立します。\fancyfoot[C]{\thepage}
\documentclass{article}
\usepackage{lipsum,fancyhdr}
\pagestyle{fancy}
\renewcommand{\sectionmark}[1]{\markboth{#1}{}} % set the \leftmark
\fancyhf{}% Clear header/footer
\fancyhead[L]{\leftmark} % 1. sectionname
\fancyfoot[C]{\thepage}
\fancypagestyle{plain}{% Redefine plain pages tyle
\fancyhf{}% Clear header/footer
\renewcommand{\headrulewidth}{0.0pt}%
\fancyfoot[C]{\thepage}
}
\begin{document}
\section{Titel}
\thispagestyle{plain}
\lipsum[2-10]
\end{document}