在任何我想要的地方换行和分页,并设置合理的边距

在任何我想要的地方换行和分页,并设置合理的边距

我正在寻找两个命令:

  1. \mylinebreak
  2. \mypagebreak

第一个命令应该在命令设置的位置换行使上一行对齐(而不是像通常的换行命令那样右对齐)让下面的新行不缩进。

第二个命令与第一个命令类似,目的是在命令设置的位置分页使上一行(即上一页的最后一行)对齐(而不是像通常的换行命令那样右对齐)让接下来的新行(即新页面的第一行)不缩进。

我想我知道一些分行(\newline\\\par)或分页(\newpage\clearpage)的方法,我也知道如何使一行不缩进(\noindent),但我怎样才能平等地填充单词间的空间,以便前一行对齐而不是参差不齐呢?

附加问题:我还刚刚意识到,当我添加\\\newline之前所有行的单词间距都会重新排列。应该避免这种情况。我希望我正在寻找的这两个命令能够像普通的换行符或普通的分页符一样运行,并具有所有常见的边距对齐方式。

有任何想法吗?

梅威瑟:

% !TEX TS-program = lualatex
\documentclass{scrartcl}
\frenchspacing
\newcommand{\mylinebreak}{\\}
\newcommand{\mypagebreak}{\newpage\noindent}
\begin{document}
But I must explain to you how all this mistaken idea of denouncing pleasure  and
praising pain was born and I will give you a complete account of the system, and
expound the actual teachings of the great explorer of the truth, the\mylinebreak master-builder
of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it
is pleasure, but because those who do not know how to pursue pleasure rationally
encounter consequences that are extremely painful. Nor again is there anyone who
loves or pursues or desires to obtain pain of itself, because it is pain, but because
occasionally circumstances occur in which toil and pain can procure him some great
pleasure. To take a trivial example, which of us ever undertakes\mypagebreak laborious physical
exercise, except to obtain some advantage from it? But who has any right to find fault
with a man who chooses to enjoy a pleasure that has no annoying consequences, or
one who avoids a pain that produces no resultant pleasure?
\end{document}

答案1

您想要的命令已经提供,它们被\linebreak称为\pagebreak

\documentclass{scrartcl}
\frenchspacing

\begin{document}
But I must explain to you how all this mistaken idea of denouncing pleasure  and
praising pain was born and I will give you a complete account of the system, and
expound the actual teachings of the great explorer of the truth, the master-builder
\linebreak
of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it
is pleasure, but because those who do not know how to pursue pleasure rationally
encounter consequences that are extremely painful. Nor again is there anyone who
loves or pursues or desires to obtain pain of itself, because it is pain, but because
occasionally circumstances occur in which toil and pain can procure him some great
pleasure.
\pagebreak
To take a trivial example, which of us ever undertakes laborious physical
exercise, except to obtain some advantage from it? But who has any right to find fault
with a man who chooses to enjoy a pleasure that has no annoying consequences, or
one who avoids a pain that produces no resultant pleasure?
\end{document}

图像

这两个命令有对应部分\nolinebreak\nopagebreak;这四个命令中的每一个都可以采用一个可选参数,该参数应该是 0 到 4(含)之间的数字,表示是否需要中断。

所以只是一个建议,\linebreak[0]相当于是一个热情的邀请,更紧迫一点,更引人注目,相当于就此打住,不要再讨论了。\nolinebreak[0]\linebreak[1]\linebreak[2]\linebreak[3]\linebreak[4]\linebreak

如果你想两个都换行符和分页符,同时使用:

\pagebreak\linebreak

但在这种情况下,前面不要留空格\pagebreak

occasionally circumstances occur in which toil and pain can procure him some great
pleasure.%
\pagebreak\linebreak
To take a trivial example, which of us ever undertakes laborious physical
exercise, except to obtain some advantage from it? But who has any right to find fault

相关内容