代码实现如下:
\documentclass{scrbook}
\usepackage[
top=25mm, bottom=30mm,
inner=20mm, outer=70mm,
marginparsep=7mm, marginparwidth=45mm,
]{geometry}
\setlength\headheight{18pt}% suggested by scrlayer-scrpage
\setlength\footheight{18pt}% suggested by scrlayer-scrpage
\usepackage{tikz}% loads also xcolor
\definecolor{myviolet}{HTML}{4c0068}
\usepackage{microtype}
\usepackage[automark]{scrlayer-scrpage}% or the older scrpage2
\pagestyle{scrheadings}
\clearscrheadfoot
\lehead{%
\begin{tikzpicture}[overlay,remember picture]
\fill[myviolet!90] ([xshift=8.5ex]current page.north west) rectangle ([yshift=-7ex]current page.north east);
\node[anchor=west] at ([xshift=10ex,yshift=-3.5ex]current page.north west) {\leftmark};
\fill[myviolet] ([yshift=-7ex]current page.north west) rectangle ([xshift=8ex]current page.north west);
\node at ([xshift=4ex,yshift=-3.5ex]current page.north west) {\pagemark};
\end{tikzpicture}%
}
\rohead{%
\begin{tikzpicture}[overlay,remember picture]
\fill[myviolet!90] (current page.north west) rectangle ([xshift=-8.5ex,yshift=-7ex]current page.north east);
\node[anchor=east] at ([xshift=-8.5ex,yshift=-3.5ex]current page.north east){\rightmark};
\fill[myviolet] ([xshift=-8ex,yshift=-7ex]current page.north east)rectangle (current page.north east);
\node at ([xshift=-4ex,yshift=-3.5ex]current page.north east){\pagemark};
\end{tikzpicture}%
}
% font for the pagenumber and the head entries
\setkomafont{pagenumber}{\color{white}\bfseries\Large}
\setkomafont{pageheadfoot}{\color{white}\bfseries\Large}
\usepackage{lipsum}
\begin{document}
\chapter{Test Chapter}
\section{Test Section}
\lipsum[1-3]
\newpage
\section{Test Section 2}
\lipsum[1-3]
\newpage
\section{Test Section 3}
\lipsum[1-3]
\end{document}选自:http://tex.stackexchange.com/questions/191874/chaptermark-in-tikz-header-book-design


发表评论 取消回复