%\iffalse -*- doctex -*- \fi
%
%% \RCS$Id: pmn-qed.sty,v 1.2 2004/08/29 06:57:12 turtle Exp $
%% \RCS$Revision: 1.2 $
%% \RCS$Date: 2004/08/29 06:57:12 $
%
%\iffalse metacomment
% -*- latex-mode -*-
% % $Id: pmn-qed.sty,v 1.2 2004/08/29 06:57:12 turtle Exp $
% % (C) 2003 Peter Møller Neergaard
%%  
%%   This program may be distributed and/or modified under the
%%   conditions of the LaTeX Project Public License, either version 1.2
%%   of this license or (at your option) any later version.
%%   The latest version of this license is in
%%     http://www.latex-project.org/lppl.txt
%%   and version 1.2 or later is part of all distributions of LaTeX 
%%   version 1999/12/01 or later.
%
% This program consists of the file pmn-qed.sty.
% 
% To print the documentation (which for the moment is uninteresting)
% remove (or comment out) the line
%
%   \endinput
%
% occurring immediately after
%
%   %<*documentation>
% 
%\fi
%
% \CheckSum{10}
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% \MakeShortVerb{\"}
%
% \title{The \package{pmn-qed} package\thanks
%   {This file has CVS revision \RCSRevision, dated \RCSDate.}}
% \author{Peter Møller Neergaard}
% \maketitle
%
% \begin{abstract}
%   This style enhances the \cmd{\qed} command of for instance
%   \package{amsmath} so it can be used inside a display without
%   leaving to large a gap between the display and the following text.
% \end{abstract}
%
% \section{Package identification}
% 
% We identify ourselves.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{pmn-qed}[2004/08/15 Allow qed in display]
%    \end{macrocode}
%
% \begin{macro}{\qed}
%   \cmd{\qed} is our modified \cmd{\qed}.
%    \begin{macrocode}
\let\pq@savedqed\qed
\renewcommand{\qed}{%
  \ifmmode
  \expandafter\@firstoftwo
  \else\expandafter\@secondoftwo\fi
  \pq@qedmathchanges\pq@savedqed}
%    \end{macrocode}
% We saves the existing \cmd{\qed} command and modify \cmd{\qed} to
% use \cmd{\pn@qedmathchanges} when in display mode.
%
% \begin{macro}{\pq@qedmathchanges}
%   \cmd{\pq@qedmathchanges} changes the display ending to the qed ending.
%    \begin{macrocode}
\def\pq@qedmathchanges{%
  \ifmmode
    \let\pq@savedenddisplay\]
    \let\]\pq@enddisplay
    \aftergroup\pq@qedmathchanges
  \fi}
%    \end{macrocode}
%   We use \cmd{\aftergroup} to allow some nesting.  Currently this
%   does not work with environments enside display.
% \end{macro}^^A \pq@qedmathchanges
%
% \begin{macro}{\pq@enddisplay}
%   \cmd{\pq@enddisplay} ends a display and inserts the qed.  We
%   change the skipping to reduce the space.
%    \begin{macrocode}
\def\pq@enddisplay{%
  \belowdisplayskip0pt%
  \belowdisplayshortskip0pt%
  \pq@savedenddisplay
  \pq@savedqed
  \let\]\pq@savedenddisplay}
%    \end{macrocode}
% \end{macro} ^^A \pq@enddisplay
% \StopEventually{}
% 
% And the commands to typeset the documentation.  All enclosed in
% "<*documentation>"$\ldots$"</documentation>" so we exclude it if we
% ever make a docstrip file.  For now, we simply stop input with
% \cmd{\endinput} so the file can be used directly as a package file.
%    \begin{macrocode}
%<*documentation>
\endinput
\documentclass{pmn-ldoc} 
\usepackage[latin1]{inputenc}
\newcommand{\docdate}{2003/11/02}
 % \OnlyDescription
 % \DisableCrossrefs
\begin{document}
  \DocInput{pmn-qed.sty}
\end{document}
%</documentation>
%    \end{macrocode}
% \Finale \sloppy \PrintChanges
