段落悬挂是在新段落开始时缩进上一个段落,很多小说都采用这种样式。
我目前正在使用以下方法创建它:
\chapter{Chapter}
The first line is never indented. The line continues on a new line, without an indent.
As you can see the second paragraph has an indent, so would have the following lines, but does not break into any whitespace.
\section*{}
Sometimes you do want to have whitespace. There won't be any indent again.
My question is: Is it possible to do this without extra new lines or par on the end of the line? And creating the whitespace just by the empty newline?
相反,我想使用下面的语法。
\chapter{Chapter}
The first line is never indented. The line continues on a new line, without an indent.
As you can see the second paragraph has an indent, so would have the following lines, but does not break into any whitespace.
Sometimes you do want to have whitespace. There won't be any indent again.
My question is: Is it possible to do this without extra new lines or par on the end of the line? And creating the whitespace just by the empty newline?
我可以创建基于行的“段落”并仍让它们悬挂吗?
答案1
我不建议实际使用它,它没有经过彻底的测试并且可能会产生可怕的副作用。
除了将宏放入\strangeparsyntax
中之外\AtBeginDocument
,您还可以在本地组中使用它(使用\begingroup\strangeparsyntax <your text>\endgroup
)。
此答案的工作原理是将 endlinechar 设为活动字符,并定义它来引入请求的空间。这样,一个新行将以通常的缩进开始一个新段落。每个额外的新行都会引入额外的垂直空间(这意味着两个额外的新行将使空间加倍,并且在标题后使用额外的新行也会增加空间)。
\documentclass[]{book}
\makeatletter
\newcommand\strangeparsyntax
{%
\catcode`\^^M\active
\begingroup\lccode`~=`\^^M
\lowercase
{\endgroup
\def~%
{%
\par
\@ifnextchar~%
{\bigskip\@afterindentfalse\@afterheading}%
{}%
}%
}%
}
\makeatother
\AtBeginDocument{\strangeparsyntax}
\begin{document}
\chapter{Chapter}
The first line is never indented. The line continues on a new line, without an indent.
As you can see the second paragraph has an indent, so would have the following lines, but does not break into any whitespace.
Sometimes you do want to have whitespace. There won't be any indent again.
My question is: Is it possible to do this without extra new lines or par on the end of the line? And creating the whitespace just by the empty newline?
This paragraph will not be indented and the space before it will be doubled compared to the paragraph before this one.
\section{Section}
Leaving no space in between a sectioning command and the following text will give the normal spacing.
\section{Section}
With an additional new line between a heading and the text there will also be additional space.
\end{document}
通过一些小的修改(在水平模式下不使用时忽略换行符),我们也可以修复空间加倍的问题。
\documentclass[]{book}
\makeatletter
\newcommand\strangeparsyntax
{%
\catcode`\^^M\active
\begingroup\lccode`~=`\^^M
\lowercase
{\endgroup
\def~%
{%
\ifhmode\expandafter\@secondoftwo\fi
\@gobble
{%
\par
\@ifnextchar~%
{\bigskip\@afterindentfalse\@afterheading}%
{}%
}%
}%
}%
}
\makeatother
\AtBeginDocument{\strangeparsyntax}
\begin{document}
\chapter{Chapter}
The first line is never indented. The line continues on a new line, without an indent.
As you can see the second paragraph has an indent, so would have the following lines, but does not break into any whitespace.
Sometimes you do want to have whitespace. There won't be any indent again.
My question is: Is it possible to do this without extra new lines or par on the end of the line? And creating the whitespace just by the empty newline?
This paragraph will not be indented and the space before it will be doubled compared to the paragraph before this one.
\section{Section}
Leaving no space in between a sectioning command and the following text will give the normal spacing.
\section{Section}
With an additional new line between a heading and the text there will also be additional space.
\end{document}
答案2
在基本的 TeX 中,空白行表示段落的结束。您似乎希望通过所需的语法让 TeX 将空白行视为非缩进段落的开始,但那么您如何表明文本的第一行实际上是两个段落呢?
你提到了小说。该类(和memoir
的超集)book
report
)提供了我称之为匿名突破由多个空白行和后跟非缩进的段落或类似的内容组成,但用一些装饰代替空白行。
% anonbreakprob.tex SE 595254
\documentclass{memoir}
\begin{document}
\chapter{Chapter}
This is the input you want to use.
The first line is never indented. The line continues on a new line,
without an indent.
As you can see the second paragraph has an indent, so would have the
following lines, but does not break into any whitespace.
Sometimes you do want to have whitespace. There won't be any indent again.
My question is: Is it possible to do this without extra new lines or par
on the end of the line? And creating the whitespace just by the empty newline?
\textbf{NO.}
\section{Section}
The first line is never indented. The line continues on a new line,
without an indent.
As you can see the second paragraph has an indent, so would have the
following lines, but does not break into any whitespace.
\plainbreak{1}
Sometimes you do want to have whitespace. There won't be any indent again.
My question is: Is it possible to do this without extra new lines or par
on the end of the line? And creating the whitespace just by the empty newline?
\fancybreak{{*}\\{* * *}\\{*}}
Above I have used \verb!\plainbreak{1}! after the second paragraph and
just before this one I used \verb!\fancybreak{{*}\\{* * *}\\{*}}!.
\end{document}
答案3
TeX 通常将换行符视为空格,我建议您保持这种状态。您可以不使用您请求的语法,而是对需要第二次格式化的少数段落使用一些手动格式化(通常在书中,与普通段落相比,这些段落很少)。
您可以使用以下内容:
\documentclass[]{book}
\begin{document}
\chapter{Chapter}
The first line is never indented. The line continues on a new line, without an
indent.
As you can see the second paragraph has an indent, so would have the following
lines, but does not break into any whitespace.
\bigskip
\noindent
Sometimes you do want to have whitespace. There won't be any indent again.
My question is: Is it possible to do this without extra new lines or par on the
end of the line? And creating the whitespace just by the empty newline?
\end{document}
\noindent
本段与下一段之间不能有空行。
您也可以创建一个存储这种格式的宏(这也使用了 LaTeX 使用的两个命令,这样下一个段落就不会缩进,您甚至可以在之后使用空行而不会出现问题。
\documentclass[]{book}
\makeatletter
\newcommand*\parspace{\par\bigskip\@afterindentfalse\@afterheading}
\makeatother
\begin{document}
\chapter{Chapter}
The first line is never indented. The line continues on a new line, without an
indent.
As you can see the second paragraph has an indent, so would have the following
lines, but does not break into any whitespace.
\parspace
Sometimes you do want to have whitespace. There won't be any indent again.
My question is: Is it possible to do this without extra new lines or par on the
end of the line? And creating the whitespace just by the empty newline?
\end{document}
两种情况下的输出: