6

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}
  • Welcome to TeX.sx! Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Upvoting is the preferred way here to say "thank you" to users who helped you. – egreg Sep 24 '12 at 22:35
8

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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.