headings

代码样式如下

\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage{geometry}
\usepackage{etoolbox,fancyhdr}

\usetikzlibrary{calc}

\definecolor{ultramarine}{RGB}{0,45,97}
\definecolor{mybluei}{RGB}{0,173,239}
\definecolor{line}{RGB}{70,160,216}
\definecolor{fillh}{RGB}{225,233,251}

\renewcommand{\headrulewidth}{0pt}
\newcommand\hdheight{1in}

% uncomment this to see the distances are the same for evena nd odd pages.
%\tikzset{
%   every node/.style={draw}
%}

\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\fancyhf{}
\fancyhead[E]{%
\begin{tikzpicture}[overlay, remember picture]%
   \fill[fillh] (current page.north west) rectangle ($(current page.north east)+(0,-\hdheight)$);
   \draw[line] ([yshift=-\hdheight]current page.north west) -- ([yshift=-\hdheight]current page.north east);
   \node[anchor=south west, font=\sffamily, text width=1cm] (evenpagenum) at ($(current page.north west)+(.5\hdheight,-\hdheight)$) {\thepage};
   \node[anchor=south west, text width=1.5cm, text=white, font=\fontsize{2cm}{5.5cm}\selectfont] (chapter) at (evenpagenum.south east) {\thechapter};
   \node[anchor=south west] at (chapter.south east) {\leftmark};
\end{tikzpicture}
}%
\fancyhead[O]{%
\begin{tikzpicture}[overlay, remember picture]%
   \fill[fillh] (current page.north west) rectangle ($(current page.north east)+(0,-\hdheight)$);
   \draw[line] ([yshift=-\hdheight]current page.north west) -- ([yshift=-\hdheight]current page.north east);
   \node[align=right, anchor=south east, font=\sffamily, text width=1cm] (evenpagenum) at ($(current page.north east)+(-.5\hdheight,-\hdheight)$) {\thepage};
   \node[align=right, anchor=south east, text width=1.5cm, text=white, font=\fontsize{2cm}{5.5cm}\selectfont] (chapter) at (evenpagenum.south west) {\thechapter};
   \node[align=right, anchor=south east] at (chapter.south west) {\leftmark};
\end{tikzpicture}
}
\fancyfoot[CE]{}
\fancyfoot[CO]{}
\setlength{\headheight}{12pt}

\begin{document}
\chapter{Problems}
\section{Problem 1}
\subsection{Problem 1}
\lipsum[1]  %产生一个随机段落
\subsection{Solution 1}
\lipsum[1-7] %产生1到10个随机段落
\cleardoublepage

\appendix
\chapter{Appendix \thechapter}
\lipsum[1-20]

\end{document}

选自:http://tex.stackexchange.com/questions/328323/fancy-headers-on-even-and-odd-pages

点赞(4)

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部