节标题的边距

节标题的边距

我重新定义了一些命令以满足我基于“报告”的课程中的大学要求,这些命令基本上可以正常工作。此外,我需要更改章节/子章节标题边距规则。

我现在有:

    1.1 Very long section name Lorem ipsum dolor sit amet, consectetur adipisci veliturea
        adipiscing elit. Ut convallis pharetra augue at aliquet.

    Text text text Aliquam sem quam, euismod id consequat in, rutrum ac ipsum. Vestibulum 
pellentesque vitae lectus. Mauris feugiat lectus gravida nisi aliquam quis sodales eros. 

我需要的是:

    1.1 Very long section name Lorem ipsum dolor sit amet, consectetur adipisci veliturea
adipiscing elit. Ut convallis pharetra augue at aliquet.

    Text text text Aliquam sem quam, euismod id consequat in, rutrum ac ipsum. Vestibulum 
pellentesque vitae lectus. Mauris feugiat lectus gravida nisi aliquam quis sodales eros.

当前‘部分’命令:

\newcommand\section{%
      \renewcommand{\@seccntformat}[1]{%
      %% custom section caption
      \csname thesection\endcsname\hspace{0.5em}}%
      %% custom first line indent
      \@startsection {section}{1}{10mm}%
      {3.5ex \@plus 1ex \@minus .2ex}%
      {2.3ex \@plus.2ex}%
      %% disable hyphenation 
      {\normalfont\bfseries\raggedright}}

换句话说,我想保留我设置的首行缩进,但节/小节标题中的所有其他行都应显示零边距,就像章节标题一样。我该怎么做?

更新。我认为我们可以通过标准的“报告”类(相同的行为)看到它:

\documentclass{report}

\usepackage{indentfirst}

\begin{document}

\chapter{Very long chapter name Lorem ipsum dolor sit amet, consectetur adipisci veliturea
adipiscing elit. Ut convallis pharetra augue at aliquet.}

\section{Very long section name Lorem ipsum dolor sit amet, consectetur adipisci veliturea
adipiscing elit. Ut convallis pharetra augue at aliquet.}

Some text Lorem ipsum dolor sit amet, consectetur adipisci veliturea
adipiscing elit. Ut convallis pharetra augue at aliquet.

\end{document}

答案1

另一个选择是使用 TeX 原语,不需要额外的软件包\parshape

\newcommand\section{%
      \renewcommand{\@seccntformat}[1]{%
      \csname thesection\endcsname\hspace{0.5em}}%
      \@startsection {section}{1}{10mm}%
      {3.5ex \@plus 1ex \@minus .2ex}%
      {2.3ex \@plus.2ex}%
      {\normalfont\bfseries\raggedright\parshape 1 0cm \textwidth}}

一个例子:

\documentclass{book}

\makeatletter
\renewcommand\section{%
      \renewcommand{\@seccntformat}[1]{%
      \csname thesection\endcsname\hspace{0.5em}}%
      \@startsection {section}{1}{10mm}%
      {3.5ex \@plus 1ex \@minus .2ex}%
      {2.3ex \@plus.2ex}%
      {\normalfont\bfseries\raggedright\parshape 1 0cm \textwidth}}
\makeatother

\begin{document}
\chapter{Test Chapter}

\section{Very long section name Lorem ipsum dolor sit amet, consectetur adipisci veliturea
adipiscing elit. Ut convallis pharetra augue at aliquet.}

Some text Lorem ipsum dolor sit amet, consectetur adipisci veliturea
adipiscing elit. Ut convallis pharetra augue at aliquet.

\end{document}

在此处输入图片描述

答案2

我会使用该titlesec包重新格式化您的部分。以下是您想要的示例(我认为):

\documentclass{report}
\usepackage{titlesec}
\usepackage{indentfirst}
\titleformat{\section}[block]{\normalfont\bfseries\raggedright}{\hspace{10mm}\thesection}{0.5em}{}
\titlespacing*{\section}{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus.2ex}
\begin{document}

\chapter{}

\section{Very long section name Lorem ipsum dolor sit amet, consectetur adipisci veliturea
adipiscing elit. Ut convallis pharetra augue at aliquet.}

Some text Lorem ipsum dolor sit amet, consectetur adipisci veliturea
adipiscing elit. Ut convallis pharetra augue at aliquet.

\end{document}

代码输出

相关内容