\fancypagestyle{myfancy}{
\fancyhf{}
\fancyhead[LE,RO]{\slshape\nouppercase{\leftmark}}
\fancyfoot[LE,RO]{\tikz[baseline={(0,0)},anchor=center] \node[label={center:\thepage}]{\includegraphics[scale=.25]{apple}};}%
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
}
上述代码为章节和节生成以下输出(如果需要):
第一个是页眉,第二个是页脚
但是,在初始化新章节时,这些设置不会出现。我不想出现页眉,但页脚是强制性的。如何在开始新章节时添加页脚,如图所示?
答案1
由于章节的第一页(按设计)使用了该plain
样式,因此您需要重新定义该样式:
\documentclass{book}
\usepackage[explicit]{titlesec}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{fancyhdr}
\usepackage{lipsum}
\fancypagestyle{plain}{
\fancyhf{}
\fancyfoot[LE,RO]{\tikz[baseline={(0,0)},anchor=center]
\node[label={center:\thepage}]{\includegraphics[scale=.25]{apple}};}%
\renewcommand{\footrulewidth}{0.4pt}
\renewcommand{\headrulewidth}{0.0pt}
}
\fancypagestyle{myfancy}{
\fancyhf{}
\fancyhead[LE,RO]{\slshape\nouppercase{\leftmark}}
\fancyfoot[LE,RO]{\tikz[baseline={(0,0)},anchor=center]
\node[label={center:\thepage}]{\includegraphics[scale=.25]{apple}};}%
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
}
\pagestyle{myfancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\titleformat{\chapter}[display]
{\bfseries\Large}
{}
{1ex}
{\titlerule\vspace{1ex}\filleft#1}
[\vspace{1ex}\titlerule]
\begin{document}
\chapter{Install Backtrack on an Android Device}
\section{What is Backtrack?}
\lipsum[1-40]
\end{document}