我让一位朋友帮我修改了\paragraph
部分内容,在部分标题结束后添加了换行符。但最终结果却是部分内容不整齐,没有对齐,如果标题太长,需要多行,它就会偏离边距。
有没有更好的方法来实现带有换行符的对齐\paragraph
(或\subparagraph
),另一方面,有没有办法控制\paragraph
和文本之间的行距?
梅威瑟:
\documentclass{scrreprt}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage{setspace}
\usepackage{kpfonts}
\usepackage[T1]{fontenc}
\usepackage[left=2.5cm,right=2.5cm,top=3cm,bottom=3cm]{geometry}
\doublespacing
\setcounter{secnumdepth}{5} %
\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
{-3.25ex \@plus -1ex \@minus -0.2ex}%
{0.01pt}%
{\raggedsection\normalfont\sectfont\nobreak\size@paragraph}%
}
\makeatother
\begin{document}
\chapter{Testing begins}
\section{Going deeper}
\paragraph{Testing an unnecessarily long title to see what happens with the end of the paragraph margin, whether it aligns to the text margin or not}
\lipsum[1]
\end{document}
答案1
\raggedsection
只需从您的定义中删除即可。
平均能量损失
\documentclass{scrreprt}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage{setspace}
\usepackage{kpfonts}
\usepackage[T1]{fontenc}
\usepackage[left=2.5cm,right=2.5cm,top=3cm,bottom=3cm]{geometry}
\doublespacing
\setcounter{secnumdepth}{5} %
\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
{-3.25ex \@plus -1ex \@minus -0.2ex}%
{0.01pt}%
{\normalfont\sectfont\nobreak\size@paragraph}%
}
\makeatother
\begin{document}
\chapter{Testing begins}
\section{Going deeper}
\paragraph{Testing an unnecessarily long title to see what happens with the end of the paragraph margin, whether it aligns to the text margin or not}
\lipsum[1]
\end{document}
答案2
拥有最新的KOMA 脚本版本(3.15 或更新版本)您可以使用\RedeclareSectionCommand
并\RedeclareSectionCommands
更改各部分的外观。
\RedeclareSectionCommands[
beforeskip=-3.25ex plus -1ex minus -0.2ex,
afterskip=1sp
]{paragraph,subparagraph}
\RedeclareSectionCommand[indent=0pt]{subparagraph}
如果所有部分都应该对齐,你可以使用
\let\raggedsection\relax
请注意,部分字体过大可能会出现问题\chapter
。如果我使用长标题作为参数,\chapter
我会得到一个过满的\hbox
。所以也许最好还是使用不规则的\chapter
部分。
\documentclass{scrreprt}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage{setspace}
\usepackage{kpfonts}
\usepackage[T1]{fontenc}
\usepackage[left=2.5cm,right=2.5cm,top=3cm,bottom=3cm]{geometry}
\doublespacing
\setcounter{secnumdepth}{5}
\RedeclareSectionCommands[
beforeskip=-3.25ex plus -1ex minus -0.2ex,
afterskip=1sp
]{paragraph,subparagraph}
\RedeclareSectionCommand[indent=0pt]{subparagraph}
\let\raggedsection\relax% -> justified sections
%\let\raggedchapter\raggedright% -> still ragged chapter
\newcommand\dummytext{Testing an unnecessarily long title to see
what happens with the end of the paragraph margin,
whether it aligns to the text margin or not}
\begin{document}
\chapter{Test begins}
%\chapter{\dummytext}
\section{\dummytext}
\paragraph{\dummytext}
\subparagraph{\dummytext}
\lipsum[1]
\end{document}