[Tex/LaTex] `parskip` removes spacing before `amsthm` theorem environments

amsthmspacingtheorems

I have a spacing problem. Whenever I include a theorem environment, \begin{theorem}\end{theorem}, the theorem appears very close to the previous line. The spacing is much less than the normal spacing between lines. Do any one have any idea to change this? I don't just ad hoc add \vskip at each theorem environment.

Minimal not working example:

\documentclass[12pt,letterpaper]{article}

\usepackage{lmodern}
\usepackage[T1]{fontenc}

\usepackage{amsmath} % AMS mathmode stuff
\usepackage{amsthm}
\usepackage{parskip} % remove auto-indentation of paragraphs with \setlength{\parindent}{0pt}

\newtheorem{thm}{Theorem}
\newenvironment{theorem}[1][]{\begin{thm}[#1]\upshape}{\end{thm}}

\begin{document}

 \section{Test}

 Let there be nice spacing.

 \begin{theorem}
  No space for you!
 \end{theorem}

\end{document}

It produces the following as output:

enter image description here

Commenting out \usepackage{parskip} causes the following output to be produced:

enter image description here

Best Answer

Put the following code in the preamble:

\makeatletter
\def\thm@space@setup{%
  \thm@preskip=\parskip \thm@postskip=0pt
}
\makeatother

The problem is that amsthm sets \thm@preskip to \topsep, which is zeroed by parskip.