空的子段落不显示

空的子段落不显示

以下是 MWE:

\documentclass[12pt,letterpaper]{article}

\makeatletter
\newcounter{subsubparagraph}[subparagraph]
\renewcommand\thesubsubparagraph{%
  \thesubparagraph.\@arabic\c@subsubparagraph}
\newcommand\subsubparagraph{%
  \@startsection{subsubparagraph}    % counter
    {6}                              % level
    {\parindent}                     % indent
    {3.25ex \@plus 1ex \@minus .2ex} % beforeskip
    {-1em}                           % afterskip
    {\normalfont\normalsize\bfseries}}
\newcommand\l@subsubparagraph{\@dottedtocline{6}{10em}{5em}}
\newcommand{\subsubparagraphmark}[1]{}
\makeatother

\begin{document}

\begin{subsubparagraph}{Here is subsubparagraph A}
\leavevmode
\end{subsubparagraph}

\begin{subsubparagraph}{Here is subsubparagraph B}
\end{subsubparagraph}

\subsubparagraph{Here is subsubparagraph C}

\end{document}

只有子段落 A 和 C 可以实际呈现...我感兴趣的是了解为什么子段落 B 没有呈现。

答案1

内联标题保存在临时宏中并添加到部分中的第一个文本,以控制分页和缩进。

如果您使用环境形式,则该信息将在组结束时丢失。

节标题的环境形式实际上不受支持,但是如果您确实想使用它,并且它有可能为空,则需要定义环境的结束代码以刷新任何待处理的标题:

在此处输入图片描述

\documentclass[12pt,letterpaper]{article}

\makeatletter
\newcounter{subsubparagraph}[subparagraph]
\renewcommand\thesubsubparagraph{%
  \thesubparagraph.\@arabic\c@subsubparagraph}
\newcommand\subsubparagraph{%
  \@startsection{subsubparagraph}    % counter
    {6}                              % level
    {\parindent}                     % indent
    {3.25ex \@plus 1ex \@minus .2ex} % beforeskip
    {-1em}                           % afterskip
    {\normalfont\normalsize\bfseries}}
\newcommand\l@subsubparagraph{\@dottedtocline{6}{10em}{5em}}
\newcommand{\subsubparagraphmark}[1]{}
\def\endsubsubparagraph{\par
\if@noskipsec
\ifx\@svsechd\@undefined\else\leavevmode\fi
\fi}

\makeatother

\begin{document}

\begin{subsubparagraph}{Here is subsubparagraph A}
\leavevmode 
\end{subsubparagraph}


\begin{subsubparagraph}{Here is subsubparagraph B}

\end{subsubparagraph}


\subsubparagraph{Here is subsubparagraph C}


\end{document}

相关内容