长章节标题后的 KOMA 悬挂缩进

长章节标题后的 KOMA 悬挂缩进

有没有一种自动方法可以让较长的章节标题实现相同的缩进?自动的意思是,我不需要手动输入\newline章节标题。

在此处输入图片描述

梅威瑟:

\documentclass[10pt, oneside, bibliography=totoc, captions=tableheading, numbers=noenddot, headinclude, listof=totoc, toc=indentunnumbered]{scrbook}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{microtype}
\usepackage[osf]{newpxtext}

\makeatletter
    \renewcommand{\sectionlinesformat}[4]{\Ifstr{#1}{section}{\formatsectionnumber{#3}\hspace{\marginparsep}\MakeLowercase{#4}}{\Ifstr{#1}{subsection}{\formatsectionnumber{#3}\hspace{\marginparsep}#4}}}
    \newcommand*{\formatsectionnumber}[1]{{\scshape#1}}
\makeatother

\setkomafont{section}{\large\fontfamily{qpl}\selectfont\normalfont\lsstyle\scshape}

\begin{document}
    \chapter{test}
    \section{Präsentation über die Anforderungen der Medical Device Regulation}
\end{document}

答案1

使用\@hangfrom

\documentclass[10pt, oneside, bibliography=totoc, captions=tableheading, numbers=noenddot, headinclude, listof=totoc, toc=indentunnumbered]{scrbook}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{microtype}
\usepackage[osf]{newpxtext}

\makeatletter
\renewcommand{\sectionlinesformat}[4]{%
  \Ifstr{#1}{section}
    {\@hangfrom{\formatsectionnumber{#3}\hspace{\marginparsep}}{\MakeLowercase{#4}}}
    {\Ifstr{#1}{subsection}
      {\@hangfrom{\formatsectionnumber{#3}\hspace{\marginparsep}}{#4}}
      {}% argument added, but what should be done for subsubsections and similar headings?
    }%
}
\newcommand*{\formatsectionnumber}[1]{{\scshape#1}}
\makeatother

\setkomafont{section}{\large\fontfamily{qpl}\selectfont\normalfont\lsstyle\scshape}

\begin{document}
    \chapter{test}
    \section{Präsentation über die Anforderungen der Medical Device Regulation}
\end{document}

在此处输入图片描述

相关内容