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

Brian M. Hunt picture Brian M. Hunt · Jun 25, 2010 · Viewed 63k times · Source

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

Answer

Herbert Sitz picture Herbert Sitz · Jun 25, 2010

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