KOMA-script:缩进章节标题并采用斜体

KOMA-script:缩进章节标题并采用斜体

在脚本中,我想要

  1. “章节”一词和章节号连续两行(已实现)
  2. 要缩进的“章节”一词和章节编号(已实现)
  3. “章节”一词和章节编号采用不同的样式(已实现)
  4. 要缩进的章节标题
  5. 章节标题采用斜体

我已经实现了 1、2 和 3,但不知道如何实现 4 和 5

梅威瑟:

\documentclass[chapterprefix=true]{scrreprt}

\usepackage{lmodern}
\usepackage[english]{babel}

\usepackage{xcolor}
\usepackage{lipsum}

%%%--chapter no. underneath the word "chapter" and in different styles

\renewcommand*{\chapterformat}{%
    \hskip 2cm \mychaptername{\chaptername}\\*\vskip 0.5\baselineskip
    \hskip 2cm \mychapternumber{\thechapter}%
}

\newcommand{\mychaptername}[1]{%
    \usekomafont{chapter}%
    {\color{black}\bfseries\fontsize{20}{20}\selectfont#1}%
}%

\newcommand{\mychapternumber}[1]{%
    \usekomafont{chapter}%
    {\color{blue}\bfseries\fontsize{40}{40}\selectfont#1}%
}%

%%%--chapter title indented and in italics

\renewcommand*{\chapterlinesformat}[3]{%
    \hskip 2cm \mychaptertitle{#3}%
    #2%
}

\newcommand{\mychaptertitle}[1]{%
    \usekomafont{chapter}%
    {\itshape#1}%
}

\begin{document}
    
\chapter{General Introduction}

\lipsum[1]    

\end{document}

在此处输入图片描述

答案1

您设置了选项chapterprefix,因此必须重新定义\chapterlineswithprefixformat

\documentclass[chapterprefix=true]{scrreprt}
\usepackage{lmodern}
\usepackage[english]{babel}

\usepackage{xcolor}
\usepackage{lipsum}% only for dummy text

\addtokomafont{chapter}{\itshape}
\addtokomafont{chapterprefix}{\upshape}
\newkomafont{chapternumber}{\usekomafont{chapterprefix}\color{blue}\fontsize{40}{40}\selectfont}

\newlength{\chapterindent}
\setlength{\chapterindent}{2cm}

\renewcommand*{\chapterformat}{%
  \IfUsePrefixLine
    {%
      \hskip\chapterindent\chapapp\\*\vskip 0.5\baselineskip
      \hskip\chapterindent {\usekomafont{chapternumber}\thechapter}%
    }{%
      \thechapter\autodot\enskip
    }%
}

\makeatletter
\renewcommand*{\chapterlineswithprefixformat}[3]{%
  #2%
  \@hangfrom{\hskip \chapterindent}{#3}%
}
\makeatother

\begin{document}
\tableofcontents
\chapter{General Introduction}
\lipsum[1]
\chapter{Long chapter title which fills more than one line}
\lipsum[2]
\end{document}

在此处输入图片描述

相关内容