\documentclass[twoside]{book}
\usepackage{fancyhdr}
\makeatletter
\newenvironment{tablehere}
{\def\@captype{table}}
{}
\makeatother
\fancyhead{}
\fancyhead[RO, LE]{\framebox[9\width][s]{se separan}}
\fancyfoot{}
\fancyfoot[LE, RO]{\thepage}
\fancyfoot[LO, CE]{Chapter \thechapter}
\makeatletter
\let \ps@plain\ps@fancy
\makeatother
\pagestyle{fancy}
\begin{document}
% \input{title}
\chapter{Introduction}
...
\chapter{Background}
...
\chapter{Conclusion}
...
\newpage
afjdajf
\newpage
sagfajg
\end{document}
答案1
对于对角线,您需要 TikZ。此外,fancyhdr 往往会\headheight
从一页变为下一页,因此我改用了它\myheight
。(TikZ 略微超出了边界。)支柱用于对齐页码和“章节”。
不用说,您随时可以调整文本相对于 tikz 坐标的位置。
\documentclass[twoside]{book}
\usepackage{fancyhdr}
\usepackage{tikz}
\makeatletter
\newenvironment{tablehere}
{\def\@captype{table}}
{}
\makeatother
\newlength{\myheight}% fancyhdr changes \headheight from one page to the next.
\setlength{\myheight}{\dimexpr \ht\strutbox+\dp\strutbox+.666em}
\setlength{\headheight}{\dimexpr \myheight+0.5pt}% width of tikz lines
\fancyhead{}
\fancyhead[CE]{\begin{tikzpicture}
\path[draw=black,fill=orange]
(0,0) -- (.7\textwidth,0) -- (.8\textwidth,\myheight) -- (0,\myheight) -- cycle;
\path[draw=black,fill=gray]
(.7\textwidth,0) -- (\textwidth,0) -- (\textwidth,\myheight) -- (.8\textwidth,\myheight) -- cycle;
\path (0,0) node[above right] {\chaptername~\thechapter\strut}
(\textwidth,0) node[above left] {\thepage\strut};
\end{tikzpicture}}
\fancyhead[CO]{\begin{tikzpicture}\path[draw=black,fill=gray]
(0,0) -- (.3\textwidth,0) -- (.2\textwidth,\myheight) -- (0,\myheight) -- cycle;
\path[draw=black,fill=orange]
(.3\textwidth,0) -- (\textwidth,0) -- (\textwidth,\myheight) -- (.2\textwidth,\myheight) -- cycle;
\path (0,0) node[above right] {\thepage\strut}
(\textwidth,0) node[above left] {\chaptername~\thechapter\strut};
\end{tikzpicture}}
\makeatletter
\let \ps@plain\ps@fancy
\makeatother
\pagestyle{fancy}
\begin{document}
% \input{title}
\chapter{Introduction}
...
\chapter{Background}
...
\chapter{Conclusion}
...
\newpage
afjdajf
\newpage
sagfajg
\end{document}