3

I want to put an qedsymbol at the end of a non-proof environment such as

\begin{theorem}
This is a funny equation
\[
\begin{array}{rcl}
x+y&=&z,\\
a+b&=&c.
\end{array}
\]
\end{theorem}

and I want to put the symbol at the right side of the line of

a+b=c

but not the right side of the whole list of equations.

And also in a proof environment I want to make qedsymbol at the right side of the line of a+b=c but not the right side of the whole list of equations.

\begin{proof}
So we have
\[
\begin{array}{rcl}
x_1+y^2&=&z^3,\\
a^2+b_2&=&c^6.
\end{array}
\]
\end{proof}

QUESTION: Who has a good way to do these two things together?

All the codes of mine are as follows.

\documentclass[11pt,b5paper]{ctexbook}
\usepackage{amsmath,amsthm,amssymb,amsfonts,mathrsfs}
%%%change qedsymbol%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\qedsymbol}{\ensuremath\boxtimes}
%%%set theorems%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\theoremstyle{theorem}
\newtheorem{theorem}{定理}[section]
\newtheorem{lemma}[theorem]{引理}
\newtheorem{corollary}[theorem]{推论}
\newtheorem{proposition}[theorem]{命题}
\theoremstyle{definition}
\newtheorem{definition}[theorem]{定义}
\newtheorem{remark}[theorem]{评注}
\newtheorem{example}[theorem]{示例}
\newtheorem{exercise}[theorem]{习题}
\newtheorem{thesis}[theorem]{论题}
\newtheorem{conjecture}[theorem]{猜想}
\newtheorem{convention}[theorem]{约定}
\newtheorem{problem}[theorem]{问题}
\newtheorem{axiom}[theorem]{公理}    
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\begin{theorem} This is a funny equation [ \begin{array}{rcl} x+y&=&z,\ a+b&=&c.\qedhere \end{array} ] \end{theorem}

\begin{proof} So we have [ \begin{array}{rcl} x_1+y^2&=&z^3,\ a^2+b_2&=&c^6.\qedhere \end{array} ] \end{proof}

\begin{proof} So we have \begin{align} x+y&=z,\ a+b&=c.\qedhere \end{align} \end{proof}

\end{document}

The compiled PDF sample is also as follows.

enter image description here

NOTE: the new command \myqed I defined can only work in the equation environment (with only 1 line of equations), but can't work in the align* environment. So I still haven't solve the problem.

M. Logic
  • 4,214

2 Answers2

3
\documentclass{article}
\usepackage{amsmath,amsthm}
\newtheorem{thm}{Theorem}
\newenvironment{theorem}[1][]{\begin{thm}[#1]\pushQED{\qed}}{\popQED\end{thm}}
\begin{document}
\begin{theorem}
This is a funny equation
\begin{align*}
x+y&=z,\\
a+b&=c.\qedhere
\end{align*}
\end{theorem}

\begin{proof}
So we have
\begin{align*}
x+y&=z,\\
a+b&=c.\qedhere
\end{align*}
\end{proof}
\end{document}

enter image description here

  • But I use \usepackage{amsthm,amsmath,amssymb,amsfonts,mathrsfs} and so your method doesn't work. I don't know why. – M. Logic Dec 07 '17 at 08:29
  • @Kuttens amsthdoc page 2: "If the amsthm package is used with a non-AMS document class and with the amsmath package, amsthm must be loaded after amsmath, not before." –  Dec 07 '17 at 09:41
  • In fact, I define a new theorem environment and a new proof environment in my actual file, and so these codes don't work – M. Logic Dec 07 '17 at 09:54
  • Then you're doing something wrong. Some tips: Don't use array environment in this case. amsthm must be loaded after amsmath, not before. –  Dec 07 '17 at 10:31
  • @Kuttens -- if you're defining new theorem and proof environments, then there's little point in using amsthm at all. maybe there's a different package for theorems that would suit you better. – barbara beeton Dec 07 '17 at 14:33
  • @barbara beeton -- In my opinion, the problem is not the amsthm. Probably Kuttens doesn't apply well the solution in his/her code. –  Dec 07 '17 at 15:12
  • @tomacs -- it may be true that the solution is not applied well, but the statement "I define a new theorem environment and a new proof environment" strongly implies that nothing is left of the amsthm definitions, so it makes no sense to use it. since the redefinitions aren't shown, it's impossible to tell what's happening. (caveat: i'm responsible for maintaining the amsthm documentation, so i'm biased.) – barbara beeton Dec 07 '17 at 15:43
  • @barbara beeton -- Dear Barbara, of course you are right:) But I suppose that Kuttens defines the theorem environment with amsthm, as it is in his/her code. And the proof is not redefined in the code of question. –  Dec 07 '17 at 16:02
  • @tomacs -- fair enough. you've used the "push/pop" code from the amsthm proof environment (or close enough; i haven't checked) to add the qed trap to a theorem definition; this is the right approach. this is in the "pending" list, but when/if it's finally added, it will apply more generally. kuttens' statement about redefining theorem and proof isn't in the question, but in a comment to your answer. i think we don't know enough to give a definitive answer. – barbara beeton Dec 07 '17 at 16:38
  • @barbara beaten , I post all my codes. – M. Logic Dec 08 '17 at 02:20
  • @tomacs , I post all my codes. – M. Logic Dec 08 '17 at 02:29
  • @Kuttens -- I fixed your code in a new answer. You didn't apply well the solution! –  Dec 08 '17 at 09:24
1

I fixed your code:

\documentclass[11pt,b5paper]{ctexbook}
\usepackage{amsmath,amsthm,amssymb,amsfonts,mathrsfs}
%%%change qedsymbol%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\qedsymbol}{\ensuremath\boxtimes}
%%%set theorems%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\theoremstyle{theorem}
\newtheorem{theorem}{定理}[section]
\newtheorem{lemma}[theorem]{引理}
\newtheorem{corollary}[theorem]{推论}
\newtheorem{proposition}[theorem]{命题}
\theoremstyle{definition}
\newtheorem{definition}[theorem]{定义}
\newtheorem{remark}[theorem]{评注}
\newtheorem{example}[theorem]{示例}
\newtheorem{exercise}[theorem]{习题}
\newtheorem{thesis}[theorem]{论题}
\newtheorem{conjecture}[theorem]{猜想}
\newtheorem{convention}[theorem]{约定}
\newtheorem{problem}[theorem]{问题}
\newtheorem{axiom}[theorem]{公理}    
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\begin{theorem} This is a funny equation \begin{align} x+y&=z,\ a+b&=c.\qedhere \end{align} \end{theorem}

\begin{proof} So we have \begin{align} x_1+y^2&=z^3,\ a^2+b_2&=c^6.\qedhere \end{align} \end{proof}

\begin{proof} So we have \begin{align} x+y&=z,\ a+b&=c.\qedhere \end{align} \end{proof}

\end{document}

enter image description here

If array environment is the last object in the theorem or proof environment, then you should do this:

\begin{theorem}
This is a funny equation
\[
\begin{array}[b]{...}
....
\end{array}\qedhere
\]
\end{theorem}
M. Logic
  • 4,214