我想制作这种标题。
我的第一次尝试包括使用 fancyhdr 包,但我仍然无法弄清楚如何移动页边距中的页码并放置 | 粗体分隔符。有人知道 fancyhdr 是否能够进行这种自定义吗?或者我应该看看 titlesec – titleps 包吗?
\documentclass[a4paper, 12pt, twoside, openright, english]{book}
%
\usepackage{lipsum} % to produce dummy text
\usepackage[english]{babel}
%
\usepackage{fancyhdr}
\fancyhead{}
\fancyfoot{}
\pagestyle{fancy}
\renewcommand{\sectionmark}[1]{\markright{\sffamily \itshape \thesection\ #1}}
\renewcommand{\chaptermark}[1]{\markboth{\sffamily \itshape\thechapter\ #1}{}}
\fancyhf{}
\fancyhead[LE,RO]{\sffamily \bfseries \thepage}
\fancyhead[RE]{\footnotesize \leftmark}
\fancyhead[LO]{\footnotesize \rightmark}
\renewcommand{\headrulewidth}{0pt}
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\begin{document}
%
\chapter{Basic principles for multi camera systems}
\lipsum[3-15] % dummy text
\section{Introduction}
\lipsum[3-15] % dummy text
\subsection{Image processing}
\lipsum[3] % dummy text
%
\end{document}
答案1
\fancyhead[LE]{\leavevmode\smash{\llap{\sffamily \bfseries \thepage\ \rule[-1em]{5pt}{2em}}}}
\fancyhead[RO]{\leavevmode\smash{\rlap{\rule[-1em]{5pt}{2em}\ \sffamily \bfseries \thepage}}}
答案2
经过上述有用的评论和一些代码操作后,最终结果正是我想要的。毕竟,fancyhdr 可以提供这种定制,我想在这里分享它,以防其他人需要最终代码来实现更好的效果……
\documentclass[a4paper, 12pt, twoside, openright, english]{book}
%
\usepackage{lipsum} % to produce dummy text
\usepackage[english]{babel}
\usepackage{fancyhdr}
\fancyhead{}
\fancyfoot{}
\pagestyle{fancy}
\renewcommand{\sectionmark}[1]{\markright{\sffamily \itshape \thesection\ #1}{}}
\renewcommand{\chaptermark}[1]{\markboth{\sffamily \itshape\thechapter\ #1}{}}
\fancyhf{}
\fancyhead[LE]{\leavevmode\smash{\llap{\sffamily \bfseries \thepage\ ~\rule[-.5em]{2pt}{2em}} \leftmark}}
\fancyhead[RO]{\leavevmode\smash{\rightmark ~ \rlap{~\rule[-.5em]{2pt}{2em}\ ~\sffamily\bfseries\thepage}}}
\renewcommand{\headrulewidth}{0pt}
\setlength{\headheight}{15pt}
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\begin{document}
%
\tableofcontents % you can comment this one...
\chapter{Dummy Chapter Title with Many Words}
\lipsum[3-15] % dummy text
\section{Dummy Section Title with Many Words}
\lipsum[3-15] % dummy text
\subsection{Dummy Subsection}
\lipsum[3-5] % dummy text
\section{A Short Dummy Section}
\lipsum[3-10] % dummy text
%
\end{document}