开发者

Using \parindent and \parskip with \paragraph{} has no effect

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, matti开发者_运维问答s 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


@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}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜