有没有一种自动方法可以让较长的章节标题实现相同的缩进?自动的意思是,我不需要手动输入\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}