我想生成类似下图的内容。我已经得到了蓝线和编号。现在我还想在左页显示章节名称,在右页显示最新章节的章节名称。
我已经尝试在页码中使用 \leftmark。但它会显示在行的错误一侧。
我该怎么做?欢迎提供任何提示 :)
感谢所有贡献者:)
- - 编辑
下面是展示我如何进行实际设计的最少代码:
\documentclass[twoside=true,a4paper,1.5pt,titlepage=on,]{scrreprt}
\usepackage{fancyhdr}
\usepackage{xcolor}
\definecolor{chaptercolor}{rgb}{0.36,0.73,0.82}
\fancypagestyle{plain}{%
\fancyhf{}
\fancyfootoffset[OR]{1.85cm}
\fancyfoot[OR]{%
{\ }%\tgherosfont%
{\color{chaptercolor}\rule[-90pt]{0.8mm}{100pt}}%
\hspace*{10pt}\begin{minipage}[b]{1.5cm}%
\color{chaptercolor}\normalsize\textbf{\thepage}%
\end{minipage}%
}
\fancyfootoffset[EL]{1.85cm}
\fancyfoot[EL]{%
%\tgherosfont%
\begin{minipage}[b]{1.5cm}%
\raggedleft\color{chaptercolor}\normalsize\textbf{\thepage \leftmark}%
\end{minipage}%
\hspace*{10pt}{\color{chaptercolor}\rule[-90pt]{0.8mm}{100pt}}%
}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}
\fancypagestyle{maincontentstyle}{%
\pagestyle{plain}
\fancyhf{}
\fancyfootoffset[OR]{1.85cm}
\fancyfoot[OR]{%
{\ }\tgherosfont\footnotesize%
\rightmark%
\hspace*{0.75cm}{\color{ctcolorfooterline}\rule[-90pt]{1.25pt}{100pt}}%
\hspace*{10pt}\begin{minipage}[b]{1.5cm}%
\color{chaptercolor}\normalsize\textbf{\thepage }%
\end{minipage}%
}
\fancyfootoffset[EL]{1.85cm}
\fancyfoot[EL]{%
\tgherosfont\footnotesize%
\begin{minipage}[b]{1.5cm}%
\raggedleft\color{chaptercolor}\normalsize\textbf{\thepage }%
\end{minipage}%
\footnotesize%
\hspace*{10pt}{\color{chaptercolor}\rule[-90pt]{1.25pt}{100pt}}%
\hspace*{0.75cm}\leftmark%
}
}
\pagestyle{fancy}
\fancyhf{}
\fancyfootoffset[OR]{1.85cm}
\fancyfoot[OR]{%
{\ }%\tgherosfont%
{\color{chaptercolor}\rule[-90pt]{0.8mm}{100pt}}%
\hspace*{10pt}\begin{minipage}[b]{1.5cm}%
\color{chaptercolor}\normalsize\textbf{\thepage}%
\end{minipage}%
}
\fancyfootoffset[EL]{1.85cm}
\fancyfoot[EL]{%
%\tgherosfont%
\begin{minipage}[b]{1.5cm}%
\raggedleft\color{chaptercolor}\normalsize\textbf{\thepage}%
\end{minipage}%
\hspace*{10pt}{\color{chaptercolor}\rule[-90pt]{0.8mm}{100pt}}%
}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\usepackage{blindtext}
\begin{document}
\tableofcontents
\Blinddocument
\end{document}
答案1
请注意,不建议fancyhdr
与 KOMA-Script 类一起使用。因此,建议使用scrlayer-scrpage
(KOMA-Script 包的一部分):
\documentclass[
twoside=true,
%a4paper,% default
%%1.5pt,% unknown option!
titlepage=on
]{scrreprt}
\usepackage{blindtext}% only for dummy text
\usepackage{xcolor}
\definecolor{chaptercolor}{rgb}{0.36,0.73,0.82}
\colorlet{ctcolorchapterline}{chaptercolor}
\colorlet{ctcolorchapternum}{chaptercolor}
\colorlet{ctcolorfooterline}{chaptercolor}
\colorlet{ctsectiontitles}{chaptercolor}
\colorlet{ctcolorfootertitle}{chaptercolor}
\colorlet{ctcolorfootermark}{black}
\usepackage[automark]{scrlayer-scrpage}% sets pagestyle scrheadings automatically
\clearpairofpagestyles
\lefoot*{\hspace{10pt}\leftmark}
\rofoot*{\rightbotmark\hspace{10pt}}
%\rofoot*{\ifstr{\rightmark}{}{\rightbotmark}{\rightmark}\hspace{10pt}}% alternative
\addtokomafont{pagefoot}{\normalfont\usekomafont{disposition}\color{ctcolorfootertitle}}
\renewcommand\chaptermarkformat{\textcolor{ctcolorfootermark}{\chapapp~\thechapter\autodot\enskip}}
\renewcommand\sectionmarkformat{\textcolor{ctcolorfootermark}{\thesection\autodot\enskip}}
\AddLayersToPageStyle{scrheadings}{pagenumber.odd,pagenumber.even}
\AddLayersToPageStyle{plain.scrheadings}{pagenumber.odd,pagenumber.even}
\DeclareNewLayer[
foreground,
oddpage,
foot,
contents={%
\hfill
\makebox[0pt][l]{%
\pagenumberrule
\hspace*{10pt}%
\pagemark
}%
}
]{pagenumber.odd}
\DeclareNewLayer[
clone=pagenumber.odd,
evenpage,
contents={%
\makebox[0pt][r]{%
\pagemark
\hspace*{10pt}%
\pagenumberrule
}%
}
]{pagenumber.even}
\newcommand*\pagenumberrule{%
{\color{ctcolorfooterline}\rule[\dimexpr-10cm+\ht\strutbox\relax]{1.25pt}{10cm}}%
}
\addtokomafont{pagenumber}{\usekomafont{disposition}}
\begin{document}
\tableofcontents
\Blinddocument
\end{document}
结果: