\clearpage 周围的换行

\clearpage 周围的换行

\begin{document}据我所知,在、\end{document}或周围换行\begin{section}不会改变结果,如下所示。

\documentclass{article}
                        % INSERTING OR DELETING THIS LINE DOESN'T AFFECT THE OUTCOME
\begin{document}
                        % INSERTING OR DELETING THIS LINE DOESN'T AFFECT THE OUTCOME
Hello, world!
                        % INSERTING OR DELETING THIS LINE DOESN'T AFFECT THE OUTCOME
\end{document}

我想知道 是否也是如此\clearpage。我认为 有七个可能的位置\clearpage似乎会产生相同的输出。它们之间没有逻辑差异吗?

第一点:位置紧接着第一段。

\documentclass{article}
\begin{document}
This is a sentence. This is a sentence. This is a sentence. This is a sentence. This is a sentence.\clearpage

This is a sentence. This is a sentence. This is a sentence. This is a sentence. This is a sentence.
\end{document}

第 2 点:位置就在下面第一段。

\documentclass{article}
\begin{document}
This is a sentence. This is a sentence. This is a sentence. This is a sentence. This is a sentence.
\clearpage

This is a sentence. This is a sentence. This is a sentence. This is a sentence. This is a sentence.
\end{document}

第 3 点: 两行之隔来自第一段和第二段。

\documentclass{article}
\begin{document}
This is a sentence. This is a sentence. This is a sentence. This is a sentence. This is a sentence.

\clearpage

This is a sentence. This is a sentence. This is a sentence. This is a sentence. This is a sentence.
\end{document}

第 4 点:位置正上方第二段。

\documentclass{article}
\begin{document}
This is a sentence. This is a sentence. This is a sentence. This is a sentence. This is a sentence.

\clearpage
This is a sentence. This is a sentence. This is a sentence. This is a sentence. This is a sentence.
\end{document}

第 5 点:位置就在之前第二段。

\documentclass{article}
\begin{document}
This is a sentence. This is a sentence. This is a sentence. This is a sentence. This is a sentence.

\clearpage This is a sentence. This is a sentence. This is a sentence. This is a sentence. This is a sentence.
\end{document}

第 6 点:在里面中间两个段落之间没有额外的换行符。

\documentclass{article}
\begin{document}
This is a sentence. This is a sentence. This is a sentence. This is a sentence. This is a sentence.
\clearpage
This is a sentence. This is a sentence. This is a sentence. This is a sentence. This is a sentence.
\end{document}

第 7 点:就在开始第二段,没有换行符。

\documentclass{article}
\begin{document}
This is a sentence. This is a sentence. This is a sentence. This is a sentence. This is a sentence.
\clearpage This is a sentence. This is a sentence. This is a sentence. This is a sentence. This is a sentence.
\end{document}

我认为现货 1或者现货 3比其他的更易读,并且现货 7是所有结果相同的候选代码中最短的代码。我想知道追求易读(或有时节省空间)的编码实践是否会意外地影响结果。

答案1

与 不同 \pagebreak\clearpage(通过\newpage)在\par处理前插入一个,因此处理后已经处于垂直模式。这意味着\par在之前或之后放置一个空行( )没有区别。但是,空行是段落分隔符的标准文档标记,因此我总是在段落之间添加一个空行(无论是在清除页之前还是之后都无关紧要),而不是依赖于\clearpage结束当前段落的技术细节。

\pagebreak如果您尝试使用而不是 来举例\clearpage,您会发现,在没有空行的版本被设置为单个段落而不是两个段落的情况下,情况有很大差异。

相关内容