# [texhax] Conditional control of paragraph spacing.

Uwe Lueck uwe.lueck at web.de
Thu Sep 21 22:03:00 CEST 2006

"Ben Whale" <ben.whale at anu.edu.au> schrieb am 19.09.2006 15:18:30:
>
> I want to produce an environment so that when it follows anything but a
> chapter( or section, subsection, etc...) command it inserts a \smallskip.  I
> have been unable to do this.  Help please!
>
> Here is a small example of code that I have tried, but that doesn't work
>
> \newboolean{indent}
> \setboolean{indent}{false}
>
> \newcommand{\bensection}[1]{\setboolean{indent}{false}\section{#1}}
>
> \newenvironment{Para}
> {\ifthenelse{\boolean{indent}}{\smallskip}{\setboolean{indent}{true}}
> \noindent\ignorespaces}
> {\ignorespacesafterend}

This seems to do the \smallskip before every Para occurence in a section
except the first one. Instead you need a Para that can find out whether
it is the first paragraph in the section. LaTeX uses \everypar for such
purposes; unfortunately in a way that doesn't allow the user to use
\everypar for her/his own purposes additionally. Quickly I can only
suggest the following hack using LaTeX's internal switch \if at nobreak:

\newenvironment{Para}
{\if at nobreak \smallskip \fi
\noindent\ignorespaces}
{\ignorespacesafterend}

It is quite probable that this fails with certain packages or classes
(like memoir!?) that give the user more flexibility than Standard LaTeX
does. Such a package or class may, on the other hand, provide a more
legal and stable alternative to that \if at nobreak.

Hope this helps,

Uwe Lueck.