![如何為首頁目錄新增頁首?](https://rvso.com/image/420065/%E5%A6%82%E4%BD%95%E7%82%BA%E9%A6%96%E9%A0%81%E7%9B%AE%E9%8C%84%E6%96%B0%E5%A2%9E%E9%A0%81%E9%A6%96%EF%BC%9F.png)
如何為首頁目錄、圖表清單和表格清單新增標題?
\documentclass[10pt,a4paper]{book}
%%%%%%%%%%%%Tikz%%%%
\usepackage[left=2cm,right=2cm,top=3.25cm,bottom=3cm]{geometry}
%%%%%%%%%%%%%%%%%%%%
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{%
\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{%
\markright{\thesection\ #1}}
\fancyhf{} % delete current header and footer
\fancyhead[LE,RO]{\bfseries\thepage}
\fancyhead[LO]{\bfseries\rightmark}
\fancyhead[RE]{\bfseries\leftmark}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0pt}
\addtolength{\headheight}{0.5pt} % space for the rule
\fancypagestyle{plain}{%
\fancyhead{} % get rid of headers on plain pages
\renewcommand{\headrulewidth}{0pt} % and the line
}
\renewcommand{\theequation}{\arabic{equation}}
\begin{document}
\tableofcontents
\listoffigures
\listoftables
\chapter{Cha}
\section{Sec}
\end{document}
答案1
ToC等,並預設\chapter
使用pagestyle。plain
為了得到你想要的,你需要將其更改為fancy
目錄等的頁面樣式,但隨後需要\chapter
將plain
樣式恢復到其原始定義(當然,除非你想要\chapter
頁面上的標題,這是我不喜歡的。這是一個MWE 的修訂版本,可滿足多頁目錄的要求。
% tocheaderprob.tex SE 560800
\documentclass[10pt,a4paper]{book}
%%%%%%%%%%%%Tikz%%%%
\usepackage[left=2cm,right=2cm,top=3.25cm,bottom=3cm]{geometry}
%%%%%%%%%%%%%%%%%%%%
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{%
\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{%
\markright{\thesection\ #1}}
\fancyhf{} % delete current header and footer
\fancyhead[LE,RO]{\bfseries\thepage}
\fancyhead[LO]{\bfseries\rightmark}
\fancyhead[RE]{\bfseries\leftmark}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0pt}
\addtolength{\headheight}{0.5pt} % space for the rule
\fancypagestyle{plain}{%
\fancyhead{} % get rid of headers on plain pages
\renewcommand{\headrulewidth}{0pt} % and the line
}
\renewcommand{\theequation}{\arabic{equation}}
\usepackage{comment}
\makeatletter
\let\ps@originplain\ps@plain % save definition of plain pagestyle
\makeatother
\addtolength{\textheight}{-0.6\textheight} % short pages
\begin{document}
\fancypagestyle{plain}{} % change plain pagestyle to fancy
\tableofcontents
\listoffigures
\listoftables
\clearpage % make sure LoT typesetting is finished
\makeatletter
\let\ps@plain\ps@originplain % revert plain style to the original
\makeatother
% lots of chapters for a multi-page ToC
\chapter{Cha}
Text
\section{Sec}
Text
\subsection{Subsec}
Text
\chapter{Cha}
Text
\section{Sec}
Text
\subsection{Subsec}
Text
\chapter{Cha}
Text
\section{Sec}
Text
\subsection{Subsec}
Text
\chapter{Cha}
Text
\section{Sec}
Text
\subsection{Subsec}
Text
\end{document}