我正在使用scrreprt
KOMA,但兼容性有问题。我曾经使用过titlesec
和 ,fancyhdr
但据我所知,它们对 KOMA 来说很糟糕。我将其更改fancyhdr
为scrlayer-scrpage
,现在我的页眉和页脚就如我想要的那样了。但是当我将它们实现到我的文档中时,我遇到了 问题titlesec
。特别是titleformat
和titlespacing
部分。我也不知道caption
和booktabs
是否兼容,但这不是什么大问题。我想我应该专注于其他软件包,但现在我在这里。也许有人可以帮忙?
\documentclass[12pt, a4paper]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[ngerman, english]{babel}
\usepackage[T1]{fontenc}
\setlength{\parindent}{0em}
\usepackage{lmodern}
\usepackage{amsmath}
\usepackage{graphicx, epstopdf}
\usepackage{booktabs}
\usepackage{gensymb}
\usepackage{hyperref}
\usepackage[onehalfspacing]{setspace}
\usepackage{chemstyle}
\usepackage[labelfont=bf, textformat=period, textfont=singlespacing, justification=justified]{caption}
\usepackage[raggedright]{titlesec}
\usepackage{xcolor}
%\usepackage{fancyhdr}
\usepackage{lipsum}
\begin{document}
\thispagestyle{empty}
%\input{titlepage}
\newpage
\thispagestyle{empty}
\quad
\newpage
\pagenumbering{Roman}
\titlespacing*{\chapter} {0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\clearpage
\phantomsection
\addcontentsline{toc}{section}{Declaration of Authorship}
%\input{declaration}
\clearpage
\phantomsection
\addcontentsline{toc}{section}{Abstract}
%\input{abstract}
\clearpage
\phantomsection
\addcontentsline{toc}{section}{List of Abbreviations}
%\input{abbreviations}
\clearpage
\phantomsection
\addcontentsline{toc}{section}{\contentsname}
\tableofcontents
\clearpage
\phantomsection
\addcontentsline{toc}{section}{\listfigurename}
\listoffigures
\clearpage
\phantomsection
\addcontentsline{toc}{section}{\listschemename}
\listofschemes
\clearpage
\phantomsection
\addcontentsline{toc}{section}{\listtablename}
\listoftables
\clearpage
\pagenumbering{arabic}
\definecolor{ultramarineblue}{rgb}{0.25, 0.4, 0.96}
%\pagestyle{fancy} % Turn on the style
%\fancyhf{}
%\renewcommand{\headrule}{{\color{ultramarineblue}%
% \hrule width\headwidth height\headrulewidth \vskip-\headrulewidth}}
%\renewcommand{\headrulewidth}{0.4pt} % optional
%\fancyhead[R]{\textsl{\leftmark}}
%\fancyfoot[R]{\vfootline\hspace{\linepagesep}\thepage}
%\fancypagestyle{plain}{%
% \fancyhf{} % clear all header and footer fields
% \fancyfoot[R]{\vfootline\hspace{\linepagesep}\thepage}
% \renewcommand{\headrulewidth}{0pt}
% \renewcommand{\footrulewidth}{0pt}}
%\newlength\linepagesep
%\setlength{\linepagesep}{5pt}
%\newcommand*\vfootline{\textcolor{ultramarineblue}{\rule[-2pt]{1pt}{2\ht\strutbox}}}
\titlespacing*{\chapter} {0pt}{50pt}{40pt}
\newcommand{\chapnumfont}{% % define font for chapter number
\usefont{T1}{pnc}{b}{n}% % choose New Chancery, bold, normal shape
\fontsize{130}{100}% % font size 100pt, baselineskip 100pt
\selectfont% % activate font
}
\colorlet{chapnumcol}{gray!75} % color for chapter number
\titleformat{\chapter}[display]
{\filleft\bfseries}
{\filleft\chapnumfont\textcolor{chapnumcol}{\thechapter}}
{-24pt}
{\Huge}
\chapter{ChapterTitle}
\lipsum
\section{SectionTitle}
\lipsum
\end{document}
如上所述,fancyhdr 不是问题。这是我的解决方案。
\documentclass[12pt, a4paper,foot lines=2]{scrreprt}
\usepackage{lipsum}% only for dummy text
\usepackage{xcolor}
\definecolor{ultramarineblue}{rgb}{0.25, 0.4, 0.96}
\renewcommand\chaptermarkformat{\chaptername\ \thechapter\autodot\ \ }
\usepackage[automark,headsepline,markcase=upper]{scrlayer-scrpage}
\clearpairofpagestyles
\ohead{\leftmark}
\rofoot*{\vfootline\hspace{\linepagesep}\pagemark}
\lefoot*{\pagemark\hspace{5pt}\vfootline}% for twosided document
\addtokomafont{headsepline}{\color{ultramarineblue}}
\newlength\linepagesep
\setlength{\linepagesep}{5pt}
\newcommand*\vfootline{{\usekomafont{headsepline}\rule[-2pt]{1pt}{2\ht\strutbox}}}
\begin{document}
\chapter{CTitle}
\lipsum
\section{STitle}
\lipsum
\end{document}
答案1
建议:
\documentclass[
12pt,
a4paper,% <- default
listof=totoc,% <- added
footlines=2,% <- typo fixed
ngerman,english% <- moved
]{scrreprt}
\setuptoc{toc}{totoc}% <- added
\usepackage[utf8]{inputenc}
\usepackage{babel}% <-languages moved to the class options
\usepackage[T1]{fontenc}
\setlength{\parindent}{0em}% really? and no parskip option?
\usepackage{lmodern}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{gensymb}
\usepackage[onehalfspacing]{setspace}
\usepackage{scrhack}% <- added before chemstyle
\usepackage{chemstyle}
\usepackage[labelfont=bf, textformat=period, textfont=singlespacing, justification=justified]{caption}
\usepackage{xpatch}% <- added
\usepackage{xcolor}
\definecolor{ultramarineblue}{rgb}{0.25, 0.4, 0.96}
\colorlet{chapnumcol}{gray!75} % color for chapter number
\renewcommand\chaptermarkformat{\chaptername\ \thechapter\autodot\ \ }
\usepackage[automark,headsepline,markcase=upper]{scrlayer-scrpage}
\clearpairofpagestyles
\ohead{\leftmark}
\rofoot*{\vfootline\hspace{\linepagesep}\pagemark}
\lefoot*{\pagemark\hspace{5pt}\vfootline}% for twosided document
\addtokomafont{headsepline}{\color{ultramarineblue}}
\newlength\linepagesep
\setlength{\linepagesep}{5pt}
\newcommand*\vfootline{{\usekomafont{headsepline}\rule[-2pt]{1pt}{2\ht\strutbox}}}
\RedeclareSectionCommand[
beforeskip=-3.5ex plus -1ex minus -.2ex,
afterskip=2.3ex plus .2ex,
font=\rmfamily\Huge
]{chapter}
\let\originaladdchaptertocentry\addchaptertocentry
\xpatchcmd{\addchaptertocentry}{chapter}{section}{}{\PatchFailed}
\newcommand\startnumberedchapters{%
\cleardoubleoddpage
\pagenumbering{arabic}%
\RedeclareSectionCommand[
beforeskip=-100pt,
afterskip=40pt
]{chapter}%
\renewcommand*\chapterformat{{%
\usefont{T1}{pnc}{b}{n}% % choose New Chancery, bold, normal shape
\fontsize{130}{100}% % font size 100pt, baselineskip 100pt
\selectfont
\textcolor{chapnumcol}{\thechapter}%
}}%
\makeatletter
\renewcommand*\chapterlinesformat[3]{%
\ifstr{##1}{chapter}
{\raggedleft##2\\##3\par}% changes for chapters
{\@hangfrom{##2}##3}% original definition
}%
\makeatother
\let\addchaptertocentry\originaladdchaptertocentry
}
\usepackage{lipsum}% <- only for dummy text
\usepackage{hyperref}% <- this package should be the last one
\begin{document}
\pagenumbering{roman}
\begin{titlepage}
\null \vfill
{\centering\Huge My Title\par}
\vspace{\stretch{3}}
\end{titlepage}
\clearpage\null\thispagestyle{empty}
\cleardoublepage
\pagenumbering{Roman}
\addchap{Declaration of Autorship}
\lipsum[1]
\addchap{Abstract}
\lipsum[2]
\addchap{List of Abbreviations}
\lipsum[3]
\tableofcontents
\listoffigures
\listofschemes
\listoftables
\startnumberedchapters
\chapter{ChapterTitle}
\lipsum[4-6]
\section{SectionTitle}
\lipsum[7-10]
\end{document}
示例页面: