我想知道如何制作像下图这样的书页样式,其中章节/部分标题根据页码在垂直规则旁边交替打印。
平均能量损失
\documentclass[
twoside=semi
]{scrbook}
\usepackage{lipsum}
\usepackage[automark,headsepline]{scrlayer-scrpage}
\pagestyle{scrheadings}
\clearscrheadfoot
\rehead{\rightmark}
\lohead{\leftmark}
\ohead{\pagemark}
\begin{document}
\chapter{Chapter 1}
\section{section 1}
\lipsum[1-20]
\end{document}
答案1
fancyhdr
这可以通过允许在其他地方写入页码和运行标题的包来完成。
\documentclass[a4paper,10pt,twoside]{book}
\usepackage[english]{babel}
\usepackage{xcolor,blindtext}
\usepackage{geometry}
\geometry{paperheight=239mm,paperwidth=169mm,tmargin=5mm,textwidth=124mm,textheight=195mm,
rmargin=22mm,heightrounded,includeheadfoot,headheight=5mm,headsep=8mm,foot=18mm,
marginparsep=2mm,marginparwidth=18mm}
\usepackage[color=red,cam,a4,center]{crop}
\usepackage{fancyhdr}
\colorlet{TitleBlue}{blue}
\DeclareRobustCommand\headingfont{\fontfamily\sfdefault\fontseries{b}\fontshape{n}\selectfont}
\fancyhf{}
\fancypagestyle{plain}{\fancyhf{}\def\headrulewidth{0pt}}
\fancyheadoffset[RO,LE]{30mm}
\fancyhead[LE]{\leavevmode\headingfont\smash{%
\setlength\fboxsep{0pt}%
\colorbox{black!80}{%
\makebox[22mm]{\hfill
\ifnum\value{chapter}>0
\textcolor{white}{\fontsize{18}{19}\selectfont\thechapter}\
\fi
\rule[-2.85pt]{2mm}{12mm}%
}%
}}%
\quad
\color{TitleBlue}%<========================================
\fontsize{9}{9}\selectfont\leftmark}%\MakeUppercase{\leftmark}}
\fancyhead[RO]{\leavevmode\fontsize{9}{9}\headingfont
\rightmark
\quad
\makebox[22mm]{}}
\fancyfoot[LE]{\leavevmode%
\small\headingfont
\llap{\thepage\ \rule[-13mm]{.6pt}{18mm}\hspace{1mm}}
\hfill{\normalfont\today}% %<------ svn
}
\fancyfoot[RO]{\leavevmode
\small\headingfont
{\normalfont\today}%<------ svn
~\hfill \rlap{\hspace{1mm}\rule[-13mm]{.6pt}{18mm}\ \thepage}%
}
\pagestyle{fancy}
\begin{document}
\tableofcontents
\chapter{foo}\blindtext[3]\par\blindtext[3]
\chapter{bar}\blindtext[7]
\chapter{baz}\blindtext[8]
\end{document}