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

2

6

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

Manicurist answered 25/6, 2010 at 16:46 Comment(0)
B
5

@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}
Bridge answered 25/6, 2010 at 19:20 Comment(6)
@Herbert: Thank you kindly for the response. I am using \paragraph because on occasion, the paragraphs must be both numbered and counted, which I understand is a fine solution, though perhaps not the only, based on this question: stackoverflow.com/questions/543208Manicurist
Brian -- That makes sense, but the \paragraph{} section command is not the one I would choose. Using the 'enumerate' list environment is probably best choice, although even then there could be some counter-intuitive formatting changes you may need. If you wanted to continue with the \paragraph{} section you could use the "sectsty" package to add numbering and change formatting (read the sectsty docs for more info), or just switch and go with the enumerate list.Bridge
No, notwithstanding the advice in the other answer you pointed to (and agreeing with Herbert), \paragraph isn't what you want here, because it's just an odd way of spelling \subsubsubsection, so it only makes sense if it's used within a \subsubsection. It's a sectioning command -- nothing to do with paragraphs. The definition of \N in your original question is the best solution here. I've had to do this myself, found no package which did it, and resorted to (something similar to) this solution. For fairly fundamental LaTeX reasons, numbering paragraphs is hard to do automatically.Maxim
@Brian -- Was there some problem with the \N macro solution in your orignal post? It looks like simplest and most elegant way to get what you want. Why were you even looking for something else?Bridge
@Norman -- Yes, you're right, I hadn't noticed that Brian wanted the numbering to continue incrementing across higher level sections. And enumerate environment is not going to work well for that either.Bridge
@Herbet, @Norman: Thank you both for your help - I think it's resolved to stop using \paragraph{} for paragraph numbering; with luck the \N solution will work fine.Manicurist
M
1

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.

Maxim answered 25/6, 2010 at 16:54 Comment(2)
Thanks for the reply. I'd think \paragraph would provide sectioning based on paragraphs, without changing the typesetting of the paragraph - ie honour \par{indent,skip} and/or just not introduce its own paragraph indentation (to a certain degree) and skip. I'd be grateful for thoughts on how to remove any formatting associated with the paragraph sectioning command.Manicurist
@Brian -- I think the best cure, in your case, is not to use the \paragraph{} command at all. You seem to have no use for it. Why are you using it?Bridge

© 2022 - 2025 — McMap. All rights reserved.