3

This is a follow-up question of QED symbol after statements without proof, and I am really not sure whether this is the right approach to solve the problem raised there. But it seems to solve all situations I encounter perfectly, so I will try...

The theorem environment has the usual version with numbering and a *'ed version without numbering. I would now like to have another **'ed (or something similar) version that puts something around the theorem environment.

Here is what I currently need to do:

\documentclass{amsart}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}[theorem]{Corollary}
\begin{document}
\begin{proof}[\unskip\nopunct]
\begin{theorem}
    $e^{2\pi i} = 1$. \qedhere
\end{theorem}
\end{proof}

\begin{proof}[\unskip\nopunct]
\begin{corollary}[{myref}]
    The expression $e^{2\pi i} - 1$ equals $0$. Moreover, there is more text to actually add here. \qedhere
\end{corollary}
\end{proof}
\end{document}

and I want to avoid adding the \begin{proof}[\unskip\nopunct] and the \end{proof} myself, but get this automatically using a double star in both situations.

It might actually be better to interchange the order of the proof and the theorem environment, so a solution that provides that version would also be appreciated!

That is

\begin{myXYZ**}[...]
    ...
\end{myXYZ**}

(with myXYZ defined as a theorem environment in the header) should simply translate into

\begin{proof}[\unskip\nopunct]
\begin{myXYZ}[...]
    ...
\end{myXYZ}
\end{proof}

Is this (or the ** replaced with something else, independent of using theorem or lemma or proposition) possible?

  • Have you tried \newenvironment{theorem**}[1][]{\begin{proof}[\unskip\nopunct]\begin{theorem}[#1]}{\end{theorem}\end{proof}}? – Werner Oct 18 '16 at 19:29
  • This does not seem to behave like the usual theorem environment with only having adding a proof environment around. More immportantly, I would actually also want this to be independent of theorem but it should work equally well with lemma and any other theorem-like environment in the very same way without having to define it for each of these independently. – Christian Oct 18 '16 at 19:35
  • 1
    How about providing the foundation to start from in the form of a minimal example that shows your setup, including the expected output (even if you have to hard-code it). – Werner Oct 18 '16 at 19:38
  • @Werner: I am not sure it is clearer now, but I tried to add a mwe. – Christian Oct 18 '16 at 19:57
  • I'm not sure what you're about. Doesn't the \addqed macro I proposed do the job without any additional proof environment around? One might add a further abstraction layer, but I don't think that \newtheorem{theorem}{Theorem}\addqed{theorem} is so long to type. Besides it was your request not to define environments with an additional *. – egreg Oct 18 '16 at 21:13
3

Maybe this solves your problem. I define a \varnewtheorem command with the same syntax as \newtheorem, but that creates four variants for each label we call. So with \varnewtheorem{foo}{Foo} we create the four environments

  • foo (theorem, proof follows)
  • foo* (unnumbered theorem, proof follows)
  • foo+ (theorem, no proof)
  • foo*+ (unnumbered theorem, no proof)

The syntax accepts the optional arguments as usual.

\documentclass{amsbook}
\usepackage{amsthm}
\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\varnewtheorem}{momo}
 {
  \IfValueTF{#4}
   {\newtheorem{#1}{#3}[#4]}
    {
     \IfValueTF{#2}
      {\newtheorem{#1}[#2]{#3}}
      {\newtheorem{#1}{#3}}
    }
  \newtheorem*{#1*}{#3}
  \newenvironment{#1+}
   {\pushQED{\qed}\begin{#1}}
   {\popQED\end{#1}}
  \newenvironment{#1*+}
   {\pushQED{\qed}\begin{#1*}}
   {\popQED\end{#1*}}
 }
\ExplSyntaxOff

\varnewtheorem{theorem}{Theorem}[chapter]
\varnewtheorem{proposition}[theorem]{proposition}

\begin{document}

\chapter{Test}

\begin{theorem}
A standard theorem statement
\end{theorem}

\begin{theorem*}
A standard unnumbered theorem statement
\end{theorem*}

\begin{theorem+}
A theorem statement without proof
\end{theorem+}

\begin{theorem*+}
An unnumbered theorem statement without proof
\end{theorem*+}


\begin{proposition}
A standard theorem statement
\end{proposition}

\begin{proposition*}
A standard unnumbered theorem statement
\end{proposition*}

\begin{proposition+}
A theorem statement without proof
\end{proposition+}

\begin{proposition*+}
An unnumbered theorem statement without proof
\end{proposition*+}

\end{document}

enter image description here

  • Many thanks, I really like this solution, I will use this and the one by @Werner to see which seems more natural to use. – Christian Oct 19 '16 at 7:26
2

For each \newtheorem{X}, you can call the below function \doublestarenv{X} to create an X** environment:

enter image description here

\documentclass{amsart}

\newcommand{\doublestarenv}[1]{%
  \newenvironment{#1**}[1][]
    {\proof[\unskip\nopunct]
     \csname #1\endcsname[##1]}
    {\csname end#1\endcsname
     \endproof}%
}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}[theorem]{Corollary}

\doublestarenv{theorem}
\doublestarenv{corollary}

\begin{document}

\begin{proof}[\unskip\nopunct]
\begin{theorem}
    $e^{2\pi i} = 1$. \qedhere
\end{theorem}
\end{proof}

\begin{proof}[\unskip\nopunct]
\begin{corollary}[{myref}]
    The expression $e^{2\pi i} - 1$ equals $0$. Moreover, there is more text to actually add here. \qedhere
\end{corollary}
\end{proof}

\begin{theorem**}
    $e^{2\pi i} = 1$. \qedhere
\end{theorem**}

\begin{corollary**}[{myref}]
    The expression $e^{2\pi i} - 1$ equals $0$. Moreover, there is more text to actually add here. \qedhere
\end{corollary**}

\end{document}

You can automate this process by updating \newtheorem to automatically execute \doublestarenv:

\newcommand{\doublestarenv}[1]{%
  \newenvironment{#1**}[1][]
    {\proof[\unskip\nopunct]
     \csname #1\endcsname[##1]}
    {\csname end#1\endcsname
     \endproof}%
}

\usepackage{xparse}

\let\oldnewtheorem\newtheorem
\RenewDocumentCommand{\newtheorem}{ m o m o }{%
  \IfValueTF{#2}
    {\edef\x{\noexpand\oldnewtheorem{#1}[#2]{#3}}}
    {\IfValueTF{#4}
       {\edef\x{\noexpand\oldnewtheorem{#1}{#3}[#4]}}
       {\edef\x{\noexpand\oldnewtheorem{#1}{#3}}}%
    }%
  \x\doublestarenv{#1}%
}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}[theorem]{Corollary}
  • Many thanks, this solution is closer to the actual question, but the outcome seems to be basically the same as in @egreg's solution. I will play with both to see which seems more natural to use. – Christian Oct 19 '16 at 7:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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