[Tex/LaTex] \vspace inside a command to add space between paragraphs but not before sections

sectioningspacing

I'm using a custom command to typeset some phrases and I need to put some vertical space between them. Unfortunately, this adds vertical space also before section and subsection headings.

As I have to type a lot of quotes, it would be nice to have \vspace automatically removed before sectioning commands.

Is there anyway to prevent \vspace to behave like this?

\documentclass[]{article}

\usepackage{lipsum}

\newcommand{\philquote}[1]{\noindent ``#1'' \vspace{12pt}}

\begin{document}

\section{Section 1}

\philquote{Socrates asked questions but gave no replies: for he confessed he had no knowledge}

\philquote{Socrates asked questions but gave no replies: for he confessed he had no knowledge}

\section{Section 2} % Wrong vertical spacing

\lipsum[1]

\section{Section 3} % Correct vertical spacing

\end{document}

Best Answer

Instead of \vspace{12pt} you can use \par\addvspace{12pt}:

\documentclass[]{article}

\usepackage{lipsum}

\newcommand{\philquote}[1]{\noindent ``#1'' \par\addvspace{12pt}}

\begin{document}

\section{Section 1}

\philquote{Socrates asked questions but gave no replies: for he confessed he had no knowledge}

\philquote{Socrates asked questions but gave no replies: for he confessed he had no knowledge}

\section{Section 2} % Correct vertical spacing

\lipsum[1]

\section{Section 3} % Correct vertical spacing

\end{document}

enter image description here

Related Question