Own proof environment: How to automatically add qed symbol

amsmathenvironments

How can I adjust the definition of the proof environment such that it automatically adds a filled black box at the end of a proof environment?

\RequirePackage{fix-cm}

\documentclass[a4paper,fontsize=12pt,egregdoesnotlikesansseriftitles]{scrartcl}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{fix-cm}
\usepackage[a4paper,left=3cm,right=3cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage[inline]{enumitem}


\setlength{\parindent}{0ex}
\setlength{\parskip}{1ex}
\setlength{\jot}{12pt}

\usepackage[onehalfspacing]{setspace}



\newtheoremstyle{my_proof_style}
  {20pt}{20pt}%
  {\upshape}{}%
  {\itshape}{.}%
  {.5em}{}%

\theoremstyle{my_proof_style}
\newtheorem*{my_proof}{Proof}



\newtheoremstyle{my_theorem_style}
  {20pt}{20pt}%
  {\itshape}{}%
  {\bfseries}{.}%
  {\newline}{}%

\theoremstyle{my_theorem_style}
\newtheorem{theorem}{Theorem}[section]



\begin{document}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pretium vulputate sapien nec sagittis aliquam malesuada bibendum.

\begin{theorem}
Aliquam ultrices sagittis orci a scelerisque purus semper eget. Eget sit amet tellus cras adipiscing enim eu turpis egestas:
\end{theorem}


\begin{my_proof}
%
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Pretium vulputate sapien nec sagittis aliquam malesuada bibendum. 

Amet nulla facilisi morbi tempus iaculis urna id volutpat. Adipiscing elit duis tristique sollicitudin nibh sit. Aliquam ultrices sagittis orci a scelerisque purus semper eget. 
%
\end{my_proof}

\end{document}

enter image description here

Best Answer

It's simpler to modify the standard proof environment with the (too) large spacing you seem to want.

\RequirePackage{fix-cm}

\documentclass[a4paper,fontsize=12pt,egregdoesnotlikesansseriftitles]{scrartcl}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[a4paper,left=3cm,right=3cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage[inline]{enumitem}


\setlength{\parindent}{0ex}
\setlength{\parskip}{1ex}
\setlength{\jot}{12pt}

\usepackage[onehalfspacing]{setspace}

\newtheoremstyle{my_theorem_style}
  {20pt}{20pt}%
  {\itshape}{}%
  {\bfseries}{.}%
  {\newline}{}%

\theoremstyle{my_theorem_style}
\newtheorem{theorem}{Theorem}[section]

\makeatletter
\renewenvironment{proof}[1][\proofname]{\par
  \pushQED{\qed}%
  \normalfont \topsep20\p@\@plus4\p@\relax % <--- changed here
  \trivlist
  \item[\hskip\labelsep
        \itshape
    #1\@addpunct{.}]\ignorespaces
}{%
  \popQED\endtrivlist\@endpefalse
}
\makeatother
\renewcommand{\qedsymbol}{\ensuremath{\blacksquare}}


\begin{document}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Pretium vulputate sapien nec
sagittis aliquam malesuada bibendum.

\begin{theorem}
Aliquam ultrices sagittis orci a scelerisque purus semper eget. Eget sit 
amet tellus cras adipiscing enim eu turpis egestas:
\end{theorem}


\begin{proof}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod 
tempor incididunt ut labore et dolore magna aliqua. Pretium vulputate 
sapien nec sagittis aliquam malesuada bibendum. 

Amet nulla facilisi morbi tempus iaculis urna id volutpat. Adipiscing 
elit duis tristique sollicitudin nibh sit. Aliquam ultrices sagittis 
orci a scelerisque purus semper eget. 
\end{proof}

\end{document}

enter image description here

If you want to keep my_proof, just add

\newenvironment{my_proof}{\proof}{\endproof}

Unrelated, but if you really want to use \parskip, employ the scrartcl specific option.