[Tex/LaTex] Proof environment: problem with \popQED and \pushQED{\qed}

amsmaththeorems

I was trying to replace . with : in the proof environment and after trying a lot of answered questions here, I got [I'm using amsmath]

\makeatletter
\renewenvironment{proof}[1][\proofname]{\par
  \pushQED{\qed}
  \normalfont \topsep6\p@\@plus6\p@\relax
  \trivlist
  \item[\hskip\labelsep
        \itshape
    #1\@addpunct{:}]\ignorespaces}
    {\popQED\endtrivlist\@endpefalse}
\makeatother

but this isn't working very well for me. After dozens of tries, I came up with

\makeatletter
\renewenvironment{proof}[1][\proofname]{\par
  \normalfont \topsep6\p@\@plus6\p@\relax
  \trivlist
  \item[\hskip\labelsep
        \itshape
    #1\@addpunct{:}]\ignorespaces}
    {\endtrivlist\@endpefalse}
\makeatother

So, what is the problem with \pushQED{\qed} and \popQED? Without both of them, the code works, but I can't get the qed square.

Best Answer

This seems to work without any problem; note that you must load amsthm.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}

\usepackage{amsthm} % for the proof environment

\addto\captionsbrazil{\renewcommand{\proofname}{Demonstra\c{c}\~ao:}}

\begin{document}

\begin{proof}
Exercise for the reader.
\end{proof}

\end{document}

enter image description here

Alternative and perhaps better version:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}

\usepackage{amsthm} % for the proof environment

\makeatletter
\renewenvironment{proof}[1][\proofname]
  {\par\pushQED{\qed}%
   \normalfont \topsep6\p@\@plus6\p@\relax
   \trivlist
   \item[\hskip\labelsep
         \itshape
         #1\@addpunct{:}]\ignorespaces}
  {\popQED\endtrivlist\@endpefalse}
\makeatother

\begin{document}

\begin{proof}
Exercise for the reader.
\end{proof}

\end{document}

Another different version with patching (but it's just the same as the one before).

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}

\usepackage{amsthm} % for the proof environment

\usepackage{xpatch}
\makeatletter
\xpatchcmd{\proof}{\@addpunct{.}}{\@addpunct{:}}{}{}
\makeatother

\begin{document}

\begin{proof}
Exercise for the reader.
\end{proof}

\end{document}