如何將 titlesec 程式碼轉換為 scrlayer-scrpage 程式碼

如何將 titlesec 程式碼轉換為 scrlayer-scrpage 程式碼

在我的 LaTeX 程式碼中,我使用 KOMA 腳本包的實際版本及其文檔類 scrbook。在這方面,我想知道如何將使用 titlesec 套件的程式碼轉換為應該使用與 KOMA 腳本更相容的 scrlayer-scrpage 套件的程式碼。請在下面找到相關程式碼。如果有人能幫助我,我將非常感激!

\usepackage{titlesec}
%modify part-page-style
\titleformat{\part}[display]
    {\huge\filcenter\bfseries}
    {\Huge{\MakeUppercase{\partname} \thepart}}
    {5pt}
    {\titlerule[3pt] \vspace{10pt}}
    []
%modify chapter-page-style
\titleformat{\chapter}[display]
    {\LARGE\filcenter\bfseries}
    {\titlerule[3pt] \vspace{3pt} \titlerule[1pt] \vspace{5pt} \huge{\MakeUppercase{\chaptertitlename} \thechapter}}
    {0pt}
    {\titlerule[1pt] \vspace{10pt}}
    []
\titlespacing*{\chapter}{0pt}{0pt}{40pt}

答案1

這裡有一個需要的建議KOMA腳本 3.17版本(CTAN 上的目前版本)或更新版本:

\documentclass{scrbook}[2015/04/23]
\usepackage{microtype}
% modify part
\setkomafont{part}{\normalfont\bfseries\huge}
\setkomafont{partnumber}{\normalfont\bfseries\Huge}
\RedeclareSectionCommand[innerskip=10pt]{part}
\renewcommand\partformat{%
  \strut\MakeUppercase{\lsstyle% Upper case sequences should be spaced
    \partname~\thepart}%
  \vspace{5pt}\hrule height 3pt%
}
% modify chapter
\KOMAoptions{chapterprefix}
\renewcommand\raggedchapter{\centering}
\setkomafont{chapter}{\normalfont\bfseries\LARGE}
\setkomafont{chapterprefix}{\huge}
\RedeclareSectionCommand[beforeskip=0pt,afterskip=40pt,innerskip=12pt]{chapter}
\renewcommand\chapterformat{%
  \hrule height 3pt\vspace{3pt}\hrule height 1pt\vspace{5pt}%
  \mbox{\strut\MakeUppercase{\lsstyle% Upper case sequences should be spaced
      \chapapp\nobreakspace\thechapter}}%
  \hrule height 1pt%
}

\usepackage{blindtext}% dummy text
\begin{document}
\tableofcontents
\part{Part title}
\blinddocument
\end{document}

在此輸入影像描述 在此輸入影像描述


請注意,該inner skip選項是在 KOMA-Script 版本 3.17 中引入的。所以與版本 3.15 或 3.16(MiKTeX 和 TeX Live 2014 中的目前版本)你必須使用

\renewcommand\partheadmidvskip{\vspace{10pt}}

\renewcommand\chapterheadmidvskip{\vspace{12pt}}

反而。這也適用於 3.17 或更高版本。

代碼:

\documentclass{scrbook}[2015/01/01]
\usepackage{microtype}
% modify part
\setkomafont{part}{\normalfont\bfseries\huge}
\setkomafont{partnumber}{\normalfont\bfseries\Huge}
\renewcommand\partheadmidvskip{\vspace{10pt}}
\renewcommand\partformat{%
  \strut\MakeUppercase{\lsstyle% Upper case sequences should be spaced
    \partname~\thepart}%
  \vspace{5pt}\hrule height 3pt%
}
% modify chapter
\KOMAoptions{chapterprefix}
\renewcommand\raggedchapter{\centering}
\setkomafont{chapter}{\normalfont\bfseries\LARGE}
\setkomafont{chapterprefix}{\huge}
\RedeclareSectionCommand[beforeskip=0pt,afterskip=40pt]{chapter}
\renewcommand\chapterheadmidvskip{\vspace{12pt}}
\renewcommand\chapterformat{%
  \hrule height 3pt\vspace{3pt}\hrule height 1pt\vspace{5pt}%
  \mbox{\strut\MakeUppercase{\lsstyle% Upper case sequences should be spaced
      \chapapp\nobreakspace\thechapter}}%
  \hrule height 1pt%
}

\usepackage{blindtext}% dummy text
\begin{document}
\tableofcontents
\part{Part title}
\blinddocument
\end{document}


\documentclass{scrbook}
\usepackage{microtype}
% modify part
\setkomafont{part}{\normalfont\bfseries\huge}
\setkomafont{partnumber}{\normalfont\bfseries\Huge}
\renewcommand\partheadmidvskip{\vspace{10pt}}
\renewcommand\partformat{%
  \strut\MakeUppercase{\lsstyle% Upper case sequences should be spaced
    \partname~\thepart}%
  \vspace{5pt}\hrule height 3pt%
}
% modify chapter
\KOMAoptions{chapterprefix}
\renewcommand\raggedchapter{\centering}
\setkomafont{chapter}{\normalfont\bfseries\LARGE}
\setkomafont{chapterprefix}{\huge}
\RedeclareSectionCommand[beforeskip=0pt,afterskip=40pt]{chapter}
\renewcommand\chapterheadmidvskip{\vspace{12pt}}
\renewcommand\chapterformat{%
  \hrule height 3pt\vspace{3pt}\hrule height 1pt\vspace{5pt}%
  \mbox{\strut\MakeUppercase{\lsstyle% Upper case sequences should be spaced
      \chapapp\nobreakspace\thechapter}}%
  \hrule height 1pt%
}

\usepackage{blindtext}% dummy text
\begin{document}
\tableofcontents
\part{Part title}
\blinddocument
\end{document}

答案2

AFAIK,KOMA-script 有一個\RedeclareSectionCommand提供與titlesec.請參閱手冊第 21 章。

相關內容