TransWikia.com

Custom proof environment preserving optional argument

TeX - LaTeX Asked by Clement Yung on July 9, 2021

I basically want to obtain the result (replace Proof -> Solution, and mdframed around the environemnt) simply by the code:

begin{solution}
    Set Theory Best Theory.
    begin{align*}
        2 = {emptyset,{emptyset},{emptyset,{emptyset}}}
    end{align*}
end{solution}

![enter image description here

This can be easily done using renewenvironment. My main issue lies in preserving the optional argument in the proof environment, i.e. something like this would still work:

begin{solution}[Proof]
    Set Theory Best Theory.
    begin{align*}
        2 = {emptyset,{emptyset},{emptyset,{emptyset}}}
    end{align*}
end{solution}

enter image description here

Any help is greatly appreciated.

EDIT: To clarify, I do not have a working solution environment working. The first image above can be made possible by:

newenvironment{solution}
  {begin{mdframed}begin{proof}[Solution]}
  {end{proof}end{mdframed}}

But it will not accept any arguments (so the second image will not be obtained)

One Answer

Well, the answer is easy:

newenvironment{solution}[1][Solution]
  {begin{mdframed}begin{proof}[#1]}
  {end{proof}end{mdframed}}

If you call begin{solution}, you'll get “Solution” as the label; with begin{Solution}[Hint] you'll get “Hint” as the label.

Correct answer by egreg on July 9, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP