
現在のセクション名を取得し、それを右側のヘッダーに追加しようとしています。
\documentclass[12pt,french]{report}
\renewcommand\chaptername{Chapitre}
\renewcommand\appendixname{Annexe}
\let\@oldmakechapterhead\@makechapterhead
\def\@makechapterhead#1{%
\vspace*{10\p@}%
{\parindent \z@
{\reset@font
\usefont{OT1}{phv}{m}{n}
\LARGE\@chapapp~\thechapter\par\nobreak}%
\par\nobreak
\vspace*{30\p@}
\interlinepenalty\@M
\usefont{OT1}{ptm}{b}{n}
{\raggedright \Huge #1}%
\par\nobreak
\vskip 20\p@
\hrule height 1pt
\par\nobreak
\vskip 45\p@
}}
\rhead{\nouppercase\rightmark}
\begin{document}
\addtocontents{toc}{\protect\thispagestyle{empty}}
\chapter{ABC}
\end{document}
現在のセクション名を取得し、それを TOC、TO 表、TO 図に追加せずにその行に挿入するにはどうすればよいでしょうか。
答え1
質問を正しく理解していれば、TOC、LOT、LOF ページに同じヘッダーを追加せずに、コンテンツ ページにヘッダーを追加しようとしていることになります。
これはfancyhdr
、パッケージを使用すると最も効果的に実現できます。パッケージを使用すると、通常のページに定義したヘッダーが付けられ、前書きページやその他の特別なページ (たとえば、章の最初のページなど) は、下部にページ番号があるだけの「プレーン」スタイルのままになります。
このコードはまさにそれを実現します:
\documentclass[12pt,french]{report}
\usepackage{blindtext} % For example
\usepackage{fancyhdr}
\fancyhead{} % Clear the headers
\renewcommand{\headrulewidth}{0pt} % Width of line at top of page
\fancyhead[R]{\slshape\leftmark} % Mark right [R] of page with Chapter name [\leftmark]
\pagestyle{fancy} % Set default style for all content pages (not TOC, etc)
\begin{document}
\tableofcontents
%\chapter{ABC}
\blinddocument
\end{document}
出力: