TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I was hoping to create a custom proof environment where along with the qed symbol it also mentions what was the claim that was proved. I thought the following would work:

{\vspace{1ex}\noindent{\em Pf.}\hspace{0.5em}}%
{\hfill{\tiny \qed (#1)}\vspace{1ex}}

I thought \begin{myproof}{Claim 42} ..\end{myproof} would work but it doesn't. After some googling I figured that it was because the argument is not passed on to \endmyproof.

Is there any fix to this? Or is this just bad TeX?

PS: FWIW, I was writing down a proof and had a small claim inside. The QED on the claim was a bit misleading that the proof of the Theorem was done. So this seemed like a natural(?) thing to do.

share|improve this question

marked as duplicate by clemens, Maarten Dhondt, Stefan Pinnow, Kurt, Seamus May 25 at 11:08

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Oh, I did not realise. I searched briefly for a similar question here and couldn't find this one. I should have searched a bit more before posting this perhaps. Sorry about the repost. – Ramprasad Aug 17 '11 at 15:24
No problem, some (not too many) duplicates are good - they help others to find the right answer. I found it in the list of "Related" questions at the right. – Paŭlo Ebermann Aug 17 '11 at 15:26
up vote 4 down vote accepted

The \newenvironment{myproof} command behind the scenes actually defines two macros: \myproof and \endmyproof. These will be called by the \begin and \end commands to do the job. By the way of how \begin and \end work, only \begin can pass any arguments to the underlying macro, and thus \newenvironment only defines arguments for \myproof.

You can work around this by defining a temporary macro in \myproof and using its value in \endmyproof:

{\vspace{1ex}\noindent{\em Pf.}\hspace{0.5em}\def\myproofname{#1}}%
{\hfill{\tiny \qed (\myproofname)}\vspace{1ex}}

(If you put this environment definition in a package file, you could name this temporary macro \myproof@name, to avoid usage in the document and clashes.)

share|improve this answer
I think that needs to be a \gdef to make it work... – Seamus Aug 17 '11 at 14:54
Why? \myproof and \endmyproof will be executed in the same group (created by \begin and \end), if you don't manually stop and restart the group between. – Paŭlo Ebermann Aug 17 '11 at 14:56
That worked like a charm! Thanks a lot! – Ramprasad Aug 17 '11 at 14:57
You're right. I was doing this earlier and I had the \def inside another environment and the use of the macro outside it... – Seamus Aug 17 '11 at 15:01

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