5

Consider the following example:

\documentclass{article}

\newenvironment{eparskip} {
  \parindent0pt
  \setlength{\parskip}{1em}
}{
  \vspace{1em}
}

\begin{document}

\begin{eparskip}
The paragraphs in this block will have single space and no indent, and will not have weird spacing issues.
\end{eparskip}

\begin{eparskip}
The paragraphs in this block will have single space and no indent, and will not have weird spacing issues.
\end{eparskip}

\begin{eparskip}
The paragraphs in this block will have single space and no indent, and will not
The paragraphs in this block will have single space and no indent, and will not
\end{eparskip}

\begin{eparskip}
The paragraphs in this block will have single space and no indent, and will not have weird spacing issues.
\end{eparskip}

\begin{eparskip}
The paragraphs in this block will have single space and no indent, and will not have weird spacing issues.
\end{eparskip}

\end{document}

which produces:

enter image description here

I know there's a stigma against adjusting the parskip parameter, but this behavior also happens with the parskip package itself. Is there a solution to this?

jwalk
  • 175

2 Answers2

5

The third example ends with

<space><space>\vspace{1em}<bookkeeping business><space>\par

where the <bookkeeping business> is done by \end{eparskip} and is irrelevant to the issue.

The relevant thing is that the horizontal spaces before \vspace are not removed and make for a third line in the paragraph.

Where do they come from? The first one is from the end-of-line after not; the second is from the end-of-line before \vspace in the environment's definition. There's another one, coming from the end-of-line after \end{eparskip}, which comes before the \par generated by the blank line. This one is removed by \par, the others aren't.

\documentclass{article}

\newenvironment{eparskip}
 {\par\setlength{\parindent}{0pt}\setlength{\parskip}{1em}}
 {\par\vspace{1em}}

\begin{document}

\begin{eparskip}
The paragraphs in this block will have single space and no 
indent, and will not have weird spacing issues.
\end{eparskip}

\begin{eparskip}
The paragraphs in this block will have single space and no 
indent, and will not have weird spacing issues.
\end{eparskip}

\begin{eparskip}
The paragraphs in this block will have single space and no indent, and will not
The paragraphs in this block will have single space and no indent, and will not
\end{eparskip}

\begin{eparskip}
The paragraphs in this block will have single space and no 
indent, and will not have weird spacing issues.
\end{eparskip}

\begin{eparskip}
The paragraphs in this block will have single space and no 
indent, and will not have weird spacing issues.
\end{eparskip}

\end{document}

enter image description here

Be careful with line endings in definitions; also ensure that \vspace is issued between paragraphs, unless you have special needs.

egreg
  • 1,121,712
  • This is great---thanks. Do you mind elaborating on your comment about issuing \vspace only between paragraphs? Specifically, what are some scenarios that you're presumably referring to be cautious about? – jwalk Apr 19 '16 at 00:33
4

the extra lines contain the spurious spaces you have added in the environment definition. Remove them and you get:

\documentclass{article}

\newenvironment{eparskip} {%
  \parindent0pt
  \setlength{\parskip}{1em}%
}{%
  \par
  \vspace{1em}
}

\begin{document}

\begin{eparskip}
The paragraphs in this block will have single space and no indent, and will not have weird spacing issues.
\end{eparskip}

\begin{eparskip}
The paragraphs in this block will have single space and no indent, and will not have weird spacing issues.
\end{eparskip}

\begin{eparskip}
The paragraphs in this block will have single space and no indent, and will not
The paragraphs in this block will have single space and no indent, and will not
\end{eparskip}

\begin{eparskip}
The paragraphs in this block will have single space and no indent, and will not have weird spacing issues.
\end{eparskip}

\begin{eparskip}
The paragraphs in this block will have single space and no indent, and will not have weird spacing issues.
\end{eparskip}

\end{document}
David Carlisle
  • 757,742