如何在空白行或 dinkus 等视觉分隔符之后将 parindent 设为零(但第二段和后续段落的 parindent 为正常)?

如何在空白行或 dinkus 等视觉分隔符之后将 parindent 设为零(但第二段和后续段落的 parindent 为正常)?

这是一份极简的 LaTeX 文档,它显示(描述)了我想要实现的目标:parindent章节或节标题后的宽度为零(这种情况会发生),parindent同一节中的后续段落的宽度为一点(这种情况也会发生),但parindent在可视分隔符(如 dinkus 或空白行)后不显示/显示为零。这些分隔符使得正数变得parindent不必要,而且看起来也不好看。

\dinkus我在和 的命令中尝试了几种方法\blank,但都没有结果。由于 body 的主体是以 Markdown 形式提供的,因此我不想parindent在文档源中包含命令。我猜(或希望)解决方案可以应用于\dinkus\blank命令,而不是 body。

(为了区分我的描述和 lorem ipsum 文本,我将后者标记为斜体。就这样。)

\documentclass[]{memoir}

\usepackage{lipsum}
\usepackage{parskip}

% Page style.
\pagestyle{plain}
\setlrmarginsandblock{1.5in}{1.5in}{*} % FIX Fore-edge and spine margins equal (especially for B5 page size).
\setulmarginsandblock{1in}{1in}{*} % FIX Make top and bottom margin larger (especially for B5 page size).
\checkandfixthelayout

% Chapter style.
\chapterstyle{section}

% Create command to insert dinkus on request: * * *.
\newcommand{\dinkus}{
  \vspace{0.5\baselineskip}
  \begin{center}
  {{*\hspace{0.5em}*\hspace{0.5em}*}} % Dinkus to end section.
  \end{center}
  \vspace{0\baselineskip}

  %Insert some `parindent` magic here?
}

% Create command to insert blank line on request.
\newcommand{\blank}{
  \vspace{2.0\baselineskip}

  %Insert similar `parindent` magic here?
}

% Paragraph indenting.
% For stories, make skip less.
\setlength{\parskip}{0\baselineskip}
% For stories, theres no parskip, so a parindent is appropriate.
\setlength{\parindent}{1em}

% Begin of document.
\begin{document}

\chapter{Pay attention to parindents}

This paragraph has zero parindent because it is the
first after a chapter title.
\emph{\lipsum[1][1-3]}

This section has a parindent of 1em, as is common for
novels: no or limited parskip but a parindent to show
a new paragraph started.
\emph{\lipsum[1][1-3]}

\section{Wish: no parindents after a dinkus}

This paragraph does not have parindent since it is the
first after a section title. Fine.
\emph{\lipsum[2][1-3]}

\dinkus

But then, after a dinkus separator, Id like to see no
parindent because the new paragraph start does not need 
to be visually separated; it started after a clear separator.
\emph{\lipsum[3][1-3]}

That this paragraph has a parindent is okay, to show that
a new paragrpah started.
\emph{\lipsum[3][1-3]}

\section{And: no parindents after a blank line}

Again, this paragraph has a zero parindent. Great.
\emph{\lipsum[4][1-3]}

This paragraph has a 1em parindent, to visually separate
it from the previous one. Nice.
\emph{\lipsum[5][1-3]}

\blank

But then, after a blank line, again no parindent is necessary.
\emph{\lipsum[6][1-3]}

\end{document}

答案1

\chapter您可以使用与和相同的机制\section,即\@afterheading

\documentclass[]{memoir}

\usepackage{lipsum}

% Page style.
\pagestyle{plain}
\setlrmarginsandblock{1.5in}{1.5in}{*}
\setulmarginsandblock{1in}{1in}{*}
\checkandfixthelayout

% Chapter style.
\chapterstyle{section}

\makeatletter
% Create command to insert dinkus on request: * * *.
\newcommand{\dinkus}{% <--- IMPORTANT
  \par\nopagebreak\nointerlineskip
  \vspace{\baselineskip}%
  \noindent\makebox[\columnwidth]{$*$\enspace$*$\enspace$*$}% Dinkus to end section.
  \par\nointerlineskip\vspace{\baselineskip}%
  \@afterindentfalse\@afterheading % <---
}

% Create command to insert blank line on request.
\newcommand{\blank}{% <--- IMPORTANT
  \vspace{2.0\baselineskip}%
  \@afterindentfalse\@afterheading % <---
}
\makeatother

\begin{document}

\chapter{Pay attention to parindents}

This paragraph has zero parindent because it is the
first after a chapter title.
\emph{\lipsum[1][1-3]}

This section has a parindent of 1em, as is common for
novels: no or limited parskip but a parindent to show
a new paragraph started.
\emph{\lipsum[1][1-3]}

\section{Wish: no parindents after a dinkus}

This paragraph does not have parindent since it is the
first after a section title. Fine.
\emph{\lipsum[2][1-3]}

\dinkus

But then, after a dinkus separator, Id like to see no
parindent because the new paragraph start does not need 
to be visually separated; it started after a clear separator.
\emph{\lipsum[3][1-3]}

That this paragraph has a parindent is okay, to show that
a new paragrpah started.
\emph{\lipsum[3][1-3]}

\section{And: no parindents after a blank line}

Again, this paragraph has a zero parindent. Great.
\emph{\lipsum[4][1-3]}

This paragraph has a 1em parindent, to visually separate
it from the previous one. Nice.
\emph{\lipsum[5][1-3]}

\blank

But then, after a blank line, again no parindent is necessary.
\emph{\lipsum[6][1-3]}

\end{document}

\dinkus我对和的定义做了一些修正\blank。在第一种情况下,我使用了数学星号,它位于行的中央,也是\nointerlineskip为了更好地控制上下间距。 也\nopagebreak很重要,或者您可以将 放在\dinkus新页面的开头(您喜欢吗?)。

不要加载parskipmemoir该类有它自己的方法来模拟它。

在此处输入图片描述

答案2

LaTeX 已经有类似的分段命令机制。这些命令可以这样定义:下一段从无缩进开始(参见内部命令\@startsection,如果其afterskip参数值为负数,则下一段从无缩进开始)。

在内部,宏\@afterheading与布尔值结合使用@afterindent,需要将其设置为 false 以抑制缩进。

添加以下内容(它使用内部命令,因此将所有内容移动到 .sty 文件中或用 make at letter/其他命令将其包围):

\newcommand{\suppressfollowingindent}{%
  \par %\nobreak % 取消注释 \nobreak 以避免分页
  \@afterindentfalse
  \@afterheading
}

并在“parindent magic”所在的位置添加这个新命令。

相关内容