防止下一段落缩进

防止下一段落缩进

我定义了一个命令,用来添加几级节标题(还有更多具有不同属性的命令,但这里我只显示一个):

\newcommand{\myssssection}[1]{{\addcontentsline{toc}{subsubsection}{\hspace{1.6cm}{#1}}}%
                              {\vspace{1ex}\noindent\normalfont\large\sffamily{\bfseries{#1}}\newline}}

现在我想要做的是抑制接下来第一个段落的缩进,类似于常规 \section 命令的操作方式。

我知道我可以在第一段之前添加 \noindent,但将其包含在我定义的伪节命令中会更好。

答案1

您的定义没有正确涵盖部门单位所做的许多事情\myssssection。部​​门

  • 开始一个新段落;
  • 插入与 ToC 相关的条目设置标题;
  • 确保章节标题和下一段落的第一行之间没有(分页)分隔符;
  • 插入适当的标记(在标题中);
  • 通常可以防止下一段落缩进。

以上所有操作都是在使用时实现的\@startsection。具体操作如下:

在此处输入图片描述

在此处输入图片描述

\documentclass{article}

\usepackage{lipsum,pgffor}% Just for this example
\usepackage{etoolbox}

\newcounter{subsubsubsection}[subsubsection]
\renewcommand\thesubsubsubsection{\thesubsubsection.\arabic{subsubsubsection}}
\renewcommand\theparagraph{\thesubsubsubsection.\arabic{paragraph}}% Optional, if you're using numbered \paragraphs

\makeatletter

\newcommand\subsubsubsection{\@startsection{subsubsubsection}{4}{\z@}%
  {-1ex \@plus.2ex \@minus.2ex}% <space before>
  {1ex \@plus.2ex \@minus.2ex}% <space after>
  {\normalfont\large\bfseries\sffamily}}
% \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
\patchcmd{\paragraph}{{paragraph}{4}}{{paragraph}{5}}{}{}% Demote \paragraph
\patchcmd{\subparagraph}{{subparagraph}{5}}{{subparagraph}{6}}{}{}% Demote \subparagraph

\newcommand{\subsubsubsectionmark}[1]{}% An appropriate mark

\newcommand{\l@subsubsubsection}{\@dottedtocline{4}{7em}{4em}}
\renewcommand{\l@paragraph}{\@dottedtocline{5}{10em}{5em}}% Shift \paragraph entries one level lower
\renewcommand{\l@subparagraph}{\@dottedtocline{6}{14em}{6em}}% Shift \subparagraph entries one level lower

\makeatother

\setcounter{secnumdepth}{3}% Only number up to \subsubsection, not \subsubsubsection
\setcounter{tocdepth}{4}% Include up to \subsubsubsection in ToC

\begin{document}

% Create a dummy document with all levels of sectional units from \section to \paragraph
\tableofcontents

\foreach \SECTION in {First, Second, Third, Last} {
  \section{\SECTION{} section}\lipsum[1]
  \foreach \SUBSECTION in {First, Second, Third, Last} {
    \subsection{\SUBSECTION{} subsection}\lipsum[2]
    \foreach \SUBSUBSECTION in {First, Second, Third, Last} {
      \subsubsection{\SUBSUBSECTION{} subsubsection}\lipsum[3]
      \foreach \SUBSUBSUBSECTION in {First, Second, Third, Last} {
        \subsubsubsection{\SUBSUBSUBSECTION{} subsubsubsection}\lipsum[4]
        \foreach \PARAGRAPH in {First, Second, Third, Last} {
          \paragraph{\PARAGRAPH{} paragraph}\lipsum[5]
        }
      }
    }
  }
}

\end{document}

参考:

相关内容