ヘッダーに現在のセクションタイトルを表示する方法

ヘッダーに現在のセクションタイトルを表示する方法

章のタイトルの代わりにヘッダーに現在のセクションのタイトルを表示するにはどうすればよいですか?

私は使用しておりbookfancychap

ムウェ

\documentclass [11pt,oneside,final]{book}
\usepackage[nohints]{minitoc}
\usepackage[round]{natbib}
\usepackage{longtable}
\usepackage[font={footnotesize,it}]{caption}
\usepackage{bookman} 
\usepackage[T1]{fontenc} 
\usepackage{setspace}
\doublespacing
%\onehalfspacing
\usepackage{multirow}
\usepackage[left=35mm,top=30mm,right=30mm,bottom=30mm]{geometry}
\pagenumbering{Roman}
\usepackage[small,compact]{titlesec}
\usepackage[Lenny]{fncychap}
\usepackage{arabtex}
\usepackage{cp1256}
\setcode{cp1256}
\usepackage{float}
\usepackage[final]{graphicx}
\usepackage{epstopdf}
\usepackage{array}

\setarab
\raggedbottom
\begin{document}
\chapter{introduction} \thispagestyle{empty}

\section{one}
bla bla bla bla bla

\section{two}
bla bla bla bla 

\end{document}

答え1

使用できますfancyhdr

\documentclass{book}

\usepackage{fancyhdr}
\usepackage{lipsum}% just to generate text for the example

\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\rightmark}
\fancyhead[R]{\thepage}
\renewcommand{\headrulewidth}{0pt}

\begin{document}
\chapter{Chapter title}
\section{section title}

\lipsum[1-20]

\end{document}
  • \pagestyle{fancy}ページ スタイルを、 で配信され編集可能なスタイルに設定しますfancyhdr
  • \fancyhf{}すべてのヘッド要素とフッター要素を空に設定します。
  • \fancyhead[L]{\rightmark}左のヘッド要素を に設定します\rightmark。これには現在のセクション (\leftmarkは現在の章) が含まれます。
  • \fancyhead[R]{\thepage}右のヘッド要素をページ番号に設定します。
  • \renewcommand{\headrulewidth}{0pt}ヘッドルールが消えます。

\fancyhead/のオプション引数に使用できるセレクターは、要素の位置を表す(left)、(center)、 (right) と、偶数ページと奇数ページを区別する(even) または(odd)\fancyfootです。/ を省略すると、要素はすべてのページに対して設定されます。LCREOEO

答え2

更新された回答

scrlayer-scrpage代わりに…を使用してください。

\documentclass{book}

\usepackage{scrlayer-scrpage}
\usepackage{lipsum}% just to generate text for the example

\pagestyle{scrheadings}
\clearpairofpagestyles
\ohead{\rightmark}
\cfoot[\pagemark]{\pagemark}

\begin{document}
\chapter{Chapter title}
\section{section title}

\lipsum[1-20]

\end{document}

\clearscrheadfoot{}が置き換えられることを除いて\clearpairofpagestyles、ユーザーにとって何も変更されていません。

私のドイツ語のブログもぜひ読んでみてください:Monats の TeX 例「レイアウト II: 頭と足のマーク」


元の回答

使用できますscrpage2KOMA-Scriptバンドルから

\documentclass{book}

\usepackage{scrpage2}
\usepackage{lipsum}% just to generate text for the example

\pagestyle{scrheadings}
\clearscrheadfoot{}
\ohead{\rightmark}
\cfoot[\pagemark]{\pagemark}

\begin{document}
\chapter{Chapter title}
\section{section title}

\lipsum[1-20]

\end{document}
  • \pagestyle{scrheadings}ページ スタイルを、 で配信され編集可能なスタイルに設定しますscrpage2
  • \clearscrheadfoot{}すべてのヘッド要素とフッター要素を空に設定します。
  • \ohead{\rightmark}外側のヘッド要素 ( o) を\rightmark、現在のセクション (\leftmarkは現在の章) を含む に設定します。
  • \cfoot[\pagemark]{\pagemark}ページ番号を中央のフッター要素 ( c) に設定します。optimal 引数はplainスタイルを定義します (章の開始ページで使用されます)。

この画像には、考えられるすべての要素が表示されています。

scrpage2 ヘッド/フット要素
出典: scrguien.pdf、p. 198

答え3

セクションでラベルを使用し、 で参照します\nameref{}。新しいセクションごとに、ヘッダーを新しいものに再定義する必要があると思います...

関連情報