将 \parindent 和 \parskip 与 \paragraph{} 一起使用没有任何效果

发布于 2024-09-07 10:02:26 字数 1935 浏览 8 评论 0原文

我正在使用 XeLaTeX 中的 memoir 类创建文档。我在创建正确的段落演示时遇到问题,特别是当我使用 \paragraph{}lorem ipsum 创建段落时,LaTeX 会忽略 \parskip\parindent 设置。

例如,如果我有一个文档,

\documentclass[oneside,11pt]{memoir}
\usepackage{fontspec}% font selecting commands 
\usepackage{xunicode}% unicode character macros 
\usepackage{xltxtra} % some fixes/extras 

\begin{document}
\setlength{\parskip}{0pt} % 1ex plus 0.5ex minus 0.2ex}
\setlength{\parindent}{0pt}
\pagestyle{plain}

\paragraph{}orem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam enim
urna, mattis eu aliquet eget, condimentum id nibh. In hac habitasse platea
dictumst.
\paragraph{}ipsum dolor sit amet, consectetur adipiscing elit. Aliquam enim urna,
mattis eu aliquet eget, condimentum id nibh. In hac habitasse platea dictumst.
\end{document}

它的排版如下:

orem ipsum dolor sat amet,consectetur adipiscing elit。阿里夸姆恩尼姆 urna,马蒂斯 eu aliquet eget,调味品 id nibh。在哈克栖息地高原 断言。

ipsum dolor sat amet,consectetur adipiscing elit。 Aliquam enim urna, 马蒂斯·欧盟aliquet eget,调味品id nibh。在 hach​​abitasseplatea dictumst 中。

尽管 \parskip\parindent 设置为零,但它错误地同时具有段落缩进和跳过。

人们会期望排版输出看起来像这样(这是一种丑陋的段落格式选择,但说明了问题):

orem ipsum dolor sat amet,consectetur adipiscing elit。阿里夸姆恩尼姆 urna,马蒂斯 eu aliquet eget,调味品 id nibh。在哈克栖息地高原 格言。
ipsum dolor sat amet,consectetur adipiscing elit。 Aliquam enim urna, 马蒂斯·欧盟aliquet eget,调味品id nibh。在 hach​​abitasseplatea dictumst 中。

我注意到,当我用两个换行符分隔段落时(即不使用 \paragraph{} 和) \parskip\parindent设置受到尊重。

我很高兴知道为什么在使用 \paragraph{} 时,\parskip\parindent 命令不被遵守,并且如何让这些命令生效,或者哪些命令可以对使用 \paragraph{} 创建的段落达到相同的效果。

感谢您的阅读。

布莱恩

I'm creating documents using the memoir class in XeLaTeX. I'm having trouble creating proper paragraph presentation, and in particular my when I create paragraphs with \paragraph{}lorem ipsum LaTeX ignores the \parskip and \parindent settings.

For example, if I have a document

\documentclass[oneside,11pt]{memoir}
\usepackage{fontspec}% font selecting commands 
\usepackage{xunicode}% unicode character macros 
\usepackage{xltxtra} % some fixes/extras 

\begin{document}
\setlength{\parskip}{0pt} % 1ex plus 0.5ex minus 0.2ex}
\setlength{\parindent}{0pt}
\pagestyle{plain}

\paragraph{}orem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam enim
urna, mattis eu aliquet eget, condimentum id nibh. In hac habitasse platea
dictumst.
\paragraph{}ipsum dolor sit amet, consectetur adipiscing elit. Aliquam enim urna,
mattis eu aliquet eget, condimentum id nibh. In hac habitasse platea dictumst.
\end{document}

This typesets like so:

    orem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam enim
urna, mattis eu aliquet eget, condimentum id nibh. In hac habitasse platea
dictumst.

   ipsum dolor sit amet, consectetur adipiscing elit. Aliquam enim urna,
mattis eu aliquet eget, condimentum id nibh. In hac habitasse platea dictumst.

This incorrectly has both paragraph indentation and skip, in spite of \parskip and \parindent being set to zero.

One would expect the typeset output to look like this (which is an ugly choice of paragraph formatting, but illustrates the issue):

orem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam enim
urna, mattis eu aliquet eget, condimentum id nibh. In hac habitasse platea
dictumst.
ipsum dolor sit amet, consectetur adipiscing elit. Aliquam enim urna,
mattis eu aliquet eget, condimentum id nibh. In hac habitasse platea dictumst.

I note that when I separate paragraphs by two newlines (i.e. don't use \paragraph{}, and) the \parskip and \parindent settings are honoured.

I'd be very grateful to know why, when using \paragraph{}, the \parskip and \parindent commands are not honoured, and how one might either have these commands honoured or alternatively what commands would achieve the same effect with paragraphs created with \paragraph{}.

Thank you for reading.

Brian

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

℡寂寞咖啡 2024-09-14 10:02:26

@Brian——在您对 Norman Gray 的回复发表评论后,我开始将其放入评论中,但代码示例使其太大。 \paragraph{} 不会改变常规段落的排版。只是与直觉相反,以 \paragraph{} 命令开头的段落不是常规段落;它是文档中的一个节元素。使用下面的代码来查看 \parskip 和 \parindent 如何影响常规段落,但不影响“\paragraph”部分元素。 (实际上, \parskip 甚至影响 \paragraph{} 项,但计算出 \paragraph{} 项之前的间距始终略大于 \parskip,这就是为什么 \paragraph{} 元素之间始终存在空格,即使 \ parskip 是 0。)

我认为 99% 的 LaTeX 文档可能从未使用过 \paragraph{} 部分命令。 LaTeX 中的常规段落由 (1) 空行(下面的“常规段落”1 和 2)或 (2) \par 命令(下面的“常规段落”3 和 4)分隔。

\documentclass[oneside,11pt]{memoir}
\usepackage{fontspec}% font selecting commands 
%\usepackage{xunicode}% unicode character macros 
%\usepackage{xltxtra} % some fixes/extras 

\begin{document}
\setlength{\parskip}{0pt} % 1ex plus 0.5ex minus 0.2ex}
\setlength{\parindent}{0pt}
\pagestyle{plain}

\paragraph{paragraph section 2}adorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam enim
urna, mattis eu aliquet eget, condimentum id nibh. In hac habitasse platea
dictumst.

regular paragraph 1 -- orem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam enim
urna, mattis eu aliquet eget, condimentum id nibh. In hac habitasse platea
dictumst.

regular paragraph 2 -- orem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam enim
urna, mattis eu aliquet eget, condimentum id nibh. In hac habitasse platea
dictumst.

\paragraph{paragraph section 2}ipsum dolor sit amet, consectetur adipiscing elit. Aliquam enim urna,
mattis eu aliquet eget, condimentum id nibh. In hac habitasse platea dictumst.
\par regular paragraph 3 -- orem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam enim urna, mattis eu aliquet eget, condimentum id nibh. In hac habitasse platea
dictumst.
\par regular paragraph 4 -- orem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam enim urna, mattis eu aliquet eget, condimentum id nibh. In hac habitasse platea
dictumst.

\end{document}

@Brian -- I started putting this in a comment following your comment to Norman Gray's response, but the code sample made it too large. \paragraph{} doesn't change the typesetting of regular paragraphs. It's just that, counter-intuitively, the paragraph begun by the \paragraph{} command is not a regular paragraph; it's a section element in the document. Play with the code below to see how the \parskip and \parindent affects the regular paragraphs but not the "\paragraph" section element. (Actually, \parskip affects even the \paragraph{} items but the spacing before a \paragraph{} item is calculated to always be slightly more than \parskip, which is why there's always a space between \paragraph{} elements even if \parskip is 0.)

I think 99% of LaTeX docs probably never use the \paragraph{} section command. Regular paragraphs in LaTeX are separated by (1) a blank line ("regular paragraphs" 1 and 2 below) or (2) by the \par command ("regular paragraphs" 3 and 4 below).

\documentclass[oneside,11pt]{memoir}
\usepackage{fontspec}% font selecting commands 
%\usepackage{xunicode}% unicode character macros 
%\usepackage{xltxtra} % some fixes/extras 

\begin{document}
\setlength{\parskip}{0pt} % 1ex plus 0.5ex minus 0.2ex}
\setlength{\parindent}{0pt}
\pagestyle{plain}

\paragraph{paragraph section 2}adorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam enim
urna, mattis eu aliquet eget, condimentum id nibh. In hac habitasse platea
dictumst.

regular paragraph 1 -- orem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam enim
urna, mattis eu aliquet eget, condimentum id nibh. In hac habitasse platea
dictumst.

regular paragraph 2 -- orem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam enim
urna, mattis eu aliquet eget, condimentum id nibh. In hac habitasse platea
dictumst.

\paragraph{paragraph section 2}ipsum dolor sit amet, consectetur adipiscing elit. Aliquam enim urna,
mattis eu aliquet eget, condimentum id nibh. In hac habitasse platea dictumst.
\par regular paragraph 3 -- orem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam enim urna, mattis eu aliquet eget, condimentum id nibh. In hac habitasse platea
dictumst.
\par regular paragraph 4 -- orem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam enim urna, mattis eu aliquet eget, condimentum id nibh. In hac habitasse platea
dictumst.

\end{document}
无人问我粥可暖 2024-09-14 10:02:26

这看起来是正确的行为。您认为 \paragraph 应该做什么?提示:它不是为了分隔段落。

根据回忆录文档,\paragraph 是分段命令之一,位于 \subsubsection 之后和 \subparagraph 之前。该命令的参数(在示例中将其设置为空)用于段落的标题。

您可以使用空行将段落彼此分开(您发现在这种情况下,尊重 \parskip\parindent 维度),或者在某些情况下使用 \par 的情况稍微有点特殊。

That looks like correct behaviour. What do you think \paragraph should do? Hint: it's not for separating paragraphs.

According to the memoir docs, \paragraph is one of the sectioning commands, after \subsubsection and before \subparagraph. The argument to the command, which you're making empty in your example, is for the title of the paragraph.

You separate paragraphs from each other by using a blank line (and this is the case you've found where the \parskip and \parindent dimensions are honoured), or in some slightly more exotic cases by using \par.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文