Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I re-defined two environment

\newtheorem{exmp}{Example}
\newenvironment{examp}{\begin{exmp}}{\renewcommand{\proofname}{Sol.}\end{exmp}}
\newenvironment{pf}{\begin{proof}}{\renewcommand{\proofname}{Proof}\end{proof}}

to make sure that when the proofname which is right after the examp environment should change to Solution, while keep it be Proof for other environment(THEOREM, Lemma and so on).

But it seems that it is not worked as I expected. WHY?

share|improve this question
    
Please always post a complete document that demonstrates the problem and all packages used (there are several implementations of \newtheorem for example in different packages.) –  David Carlisle Jul 23 at 8:56
1  
I just want to ask the logic part, not the grammar part, so it seems useless to post the whole stuff here. –  user19832 Jul 23 at 8:59
3  
every question should have a complete example document if you expect people to actually test their answers. Without knowing how proof is defined (which depends on information you have not supplied) I don't see how it's possible to even guess an answer. –  David Carlisle Jul 23 at 9:03

1 Answer 1

up vote 4 down vote accepted

(I assume proof is the environment provided by amsthm.)

This can't work, because every environment forms a group and so \renewcommand{\proofname}{Sol.} is forgotten as soon as \end{exmp} is performed.

You may want to use global redefinitions:

\newtheorem{exmp}{Example}
\newenvironment{examp}
  {\begin{exmp}}
  {\gdef\proofname{Sol.}\end{exmp}}
\newenvironment{pf}[1][\proofname]
  {\begin{proof}[#1]}
  {\gdef\proofname{Proof}\end{proof}}

but, of course, you're not safe as a pf environment is mandatory after examp or the next proof after a theorem would be called “Sol.”.

I'd simply prefer using

\begin{exmp}
Something
\end{exmp}
\begin{proof}[Sol.]
The solution
\end{proof}

or also define a sol environment

\newenvironment{sol}
  {\begin{proof}[Sol.]}
  {\end{proof}}

Since this is a different logical unit than a proof, it deserves its own name.

share|improve this answer
3  
Thanks, I know the point now: because every environment forms a group and so \renewcommand{\proofname}{Sol.} is forgotten as soon as \end{exmp} is performed. –  user19832 Jul 23 at 9:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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