4

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?

Christian
  • 515
  • 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
  • Thanks for your solutions there and here, and sorry about not being exact enough in what I would like to have! Indeed, after playing with your old solution, I realized that I basically look like the theorem environment to behave like the ams proof environment, so that's the reason for this second question. – Christian Oct 19 '16 at 07:24

3 Answers3

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

egreg
  • 1,121,712
  • 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 07: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}
Werner
  • 603,163
  • 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 07:26
1

Here is @egreg's theorem+ approach done with the package create-theorem. Take the environment theorem as an example, it begins by creating theorem and its starred variant via the key create starred version, and then uses copy existed to copy their definitions respectively and qed to add the QED symbol.

You may of course name the theorem+ as theorem** and theorem*+ as theorem***, it's your call.

\documentclass{book}

\usepackage{amsthm} \usepackage{create-theorem} \CreateTheorem { theorem } { parent counter = chapter, create starred version } \CreateTheorem { theorem+ } { copy existed = theorem, qed } \CreateTheorem { theorem+ } { copy existed = theorem, qed } \CreateTheorem { proposition } { shared counter = theorem, create starred version } \CreateTheorem { proposition+ } { copy existed = proposition, qed } \CreateTheorem { proposition+ } { copy existed = proposition, qed }

\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

Note that create-theorem does not work very well with amsbook, in that:

  1. The \qedsymbol in amsbook somehow shows as \Lambda. This is not a big issue through, you can explicitly write the option as qed = \square (provided that \square is defined, for example via amssymb).
  2. The big issue is that create-theorem loads cleveref internally, which is known to be incompatible with the class amsbook. A workaround can be seen in this answer -- however, the theorem styles would be broken.
Jinwen
  • 8,518