请问我如何才能创建像本书第 7 页及以上的标题一样的精美标题:她
答案1
由于资料来源是网上的(例如这里)你可以将以下内容编写到你的序言中:
\documentclass{scrreprt}
\usepackage[svgnames]{xcolor}
\usepackage{geometry}
\geometry{papersize={180mm,210mm},%
includehead,includemp,reversemp,marginparwidth=4em,%
vmargin={1.5mm,3mm},hmargin=1.75mm}%
\usepackage{scrlayer-scrpage}%
\makeatletter
\clearpairofpagestyles
\ihead{%
\smash{%
\hspace*{.5em}\rule[-\dp\strutbox]{0pt}{\headheight}\leftmark
}%
}%
\ohead*{\smash{\pagemark\hspace{2mm}}}%
\colorlet{headbackground}{DarkBlue}%
\colorlet{headline}{white}%
\setkomafont{pageheadfoot}{\small\sffamily\bfseries\color{headline}}%
\setkomafont{pagenumber}{}%
\DeclareNewLayer[head,background,
hoffset=0pt,
width=\paperwidth,
addheight=\dimexpr \topmargin+1in+\dp\strutbox\relax,
addvoffset=2\dp\strutbox,
contents={%
\color{headbackground}\rule{\layerwidth}{\layerheight}}]
{headbackground}%
\AddLayersAtBeginOfPageStyle{scrheadings}{headbackground}%
\renewcommand*{\chaptermark}[1]{%
\markleft{\ifnumbered{chapter}{\chaptermarkformat}{}#1}%
}%
\renewcommand*{\chaptermarkformat}{%
\makebox[\dimexpr \oddsidemargin+1in-.5em][r]{%
\chapapp~\thechapter:~%
}%
}%
\renewcommand*{\chapterformat}{}%
\renewcommand*{\chapterpagestyle}{scrheadings}%
\setlength{\@tempdimc}{\oddsidemargin}%
\addtolength{\@tempdimc}{1in}%
\setheadwidth[-\@tempdimc]{paper}%
\renewcommand*{\chapterheadstartvskip}{}%
\makeatother
\usepackage{blindtext}
\begin{document}
\chapter{Test}
\blinddocument
\end{document}
答案2
谢谢。我测试了它,但对我不起作用。我使用了以下代码:
\fancyhf{}
\fancyhead[LE,RO]{{\noindent\hspace*{\dimexpr-\oddsidemargin-1in\relax}%
\colorbox{MidnightBlue}{\makebox[\dimexpr\paperwidth-2\fboxsep\relax]{
\textcolor{white}{\rightmark}}}}%
\hspace*{-\paperwidth}}
\fancyhead[LO,LE]{\leftmark}
它确实起作用了,但是,
1-我不能使用 \noindent :
fancyhead[LO,LE]{\leftmark}
2- 中心的 \rightmark,我希望它位于右侧。