# How to put an qedsymbol at the end of an array environment?

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[top=3cm,bottom=2.2cm,left=2.3cm,right=2.3cm]{geometry}
\usepackage{amsmath,amsthm,amssymb,amsfonts,mathrsfs}
\usepackage{bm}
\usepackage{float}%允许figure、table命令使用[H]
%%%画图工具%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{tikz,tikz-cd}  %画图
\tikzset{>=stealth} %tikz宏包的箭头结尾处改为实心箭头
\tikzcdset{arrow style=tikz}%tikzcd宏包的箭头结尾处改为实心箭头
%%%修改英文字体%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\input{structure}
%%%行距设置%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%设置索引%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{imakeidx}%添加索引
\makeindex
%%%添加超链接%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bookmarks=true,bookmarksopen=true]{hyperref}
%该宏包必须在imakeidx之后，不然index页码无超链接
%%%符号索引%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeindex[name=symbol,title=符号索引]
%%%人名索引%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeindex[name=name,title=人名索引,options=-s mystyle.ist]
%%%三种索引都分两栏%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[columns=2,totoc=true,rule=0pt,indentunit=1em,columnsep=20pt]{idxlayout}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\myemph[1]{\emph{\bf #1}}%修改强调中文字体
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%编号相关%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\labelenumi}{(\theenumi)} %\labelenumii (2级enumerate item)
\renewcommand{\labelitemi}{$\bullet$}      %修改itemize二级编号
\renewcommand{\labelitemii}{$\circ$}      %修改itemize二级编号
\renewcommand{\labelitemiii}{$\diamond$}      %修改itemize二级编号
%%%证明结束符修改%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\qedsymbol}{\ensuremath\boxtimes}
%%%qed可放进公式环境%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\let\saveqed\qed
\renewcommand\qed{%
\ifmmode\displaymath@qed
\else\saveqed
\fi}
\newcommand{\myqed}{\makeatletter\displaymath@qed}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%设置定理%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\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]{公理}
%%%新符号和新算子%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\pozhe}{\rule{0.0em}{0pt}\rule[0.35em]{1.4em}{0.05em}\rule{0.2em}{0pt}}
\newcommand{\zyd}{·}
\newcommand{\pow}{\mathcal{P}}
%%%%new diamond %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{pict2e}
\DeclareRobustCommand{\newdiamond}{%
\begingroup
\setlength{\unitlength}{\fontcharht\fontT}%
\begin{picture}(1,1)
\polygon(.5,0)(1,.5)(.5,1)(0,.5)
\end{picture}%
\endgroup}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{\Huge\bf Template}
\author{Humanities}
\date{}
\begin{document}
\maketitle
\cleardoublepage
\frontmatter
\tableofcontents

\mainmatter
\chapter{非人类}
\section{完整}

\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}

%%%添加参考文献%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\cleardoublepage
\phantomsection
\bibliographystyle{plain}
\bibliography{liuref}
%%%显示符号索引%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\cleardoublepage
\phantomsection
\printindex[symbol]
%%%显示人名索引%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\cleardoublepage
\phantomsection
\printindex[name]
%%%显示术语索引%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\cleardoublepage
\phantomsection
\CTEXoptions[indexname={术语索引}]
\printindex
\end{document}


The compiled PDF sample is also as follows.

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.

• Try looking at \qedhere, in this post or this post for example. – Sandy G Dec 7 '17 at 4:58
• Also, when you post a question, please provide a "Minimal Working Example" (MWE) that starts with \documentclass, includes all relevant \usepackage commands, ends with \end{document} and compiles without errors, even if it does not produce your desired output. – Sandy G Dec 7 '17 at 5:02
• A working sample has been provided. \qedhere doesn't work – Mogic Dec 7 '17 at 6:09
• Replace the array witl align as in the example sin the linked posts. The way you are using array is giving you incorrect spacing. – Peter Grill Dec 7 '17 at 6:12
• It doesn't work either! @Peter Grill – Mogic Dec 7 '17 at 7:36

\documentclass[11pt,b5paper]{ctexbook}
\usepackage[top=3cm,bottom=2.2cm,left=2.3cm,right=2.3cm]{geometry}
\usepackage{amsmath,amsthm,amssymb,amsfonts,mathrsfs}
\usepackage{bm}
\usepackage{float}%允许figure、table命令使用[H]
%%%画图工具%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{tikz,tikz-cd}  %画图
\tikzset{>=stealth} %tikz宏包的箭头结尾处改为实心箭头
\tikzcdset{arrow style=tikz}%tikzcd宏包的箭头结尾处改为实心箭头
%%%修改英文字体%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\input{structure}
%%%行距设置%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%设置索引%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{imakeidx}%添加索引
\makeindex
%%%添加超链接%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bookmarks=true,bookmarksopen=true]{hyperref}
%该宏包必须在imakeidx之后，不然index页码无超链接
%%%符号索引%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeindex[name=symbol,title=符号索引]
%%%人名索引%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeindex[name=name,title=人名索引,options=-s mystyle.ist]
%%%三种索引都分两栏%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[columns=2,totoc=true,rule=0pt,indentunit=1em,columnsep=20pt]{idxlayout}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\myemph[1]{\emph{\bf #1}}%修改强调中文字体
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%编号相关%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\labelenumi}{(\theenumi)} %\labelenumii (2级enumerate item)
\renewcommand{\labelitemi}{$\bullet$}      %修改itemize二级编号
\renewcommand{\labelitemii}{$\circ$}      %修改itemize二级编号
\renewcommand{\labelitemiii}{$\diamond$}      %修改itemize二级编号
%%%证明结束符修改%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\qedsymbol}{\ensuremath\boxtimes}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%设置定理%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newtheorem{thm}{定理}[section]
\newenvironment{theorem}[1][]{\begin{thm}[#1]\pushQED{\qed}}{\popQED\end{thm}}
\newtheorem{lemma}[thm]{引理}
\newtheorem{corollary}[thm]{推论}
\newtheorem{proposition}[thm]{命题}
\theoremstyle{definition}
\newtheorem{defin}[thm]{定义}
\newenvironment{definition}[1][]{\begin{defin}[#1]\pushQED{\qed}}{\popQED\end{defin}}
\newtheorem{remark}[thm]{评注}
\newtheorem{example}[thm]{示例}
\newtheorem{exercise}[thm]{习题}
\newtheorem{thesis}[thm]{论题}
\newtheorem{conjecture}[thm]{猜想}
\newtheorem{convention}[thm]{约定}
\newtheorem{problem}[thm]{问题}
\newtheorem{axiom}[thm]{公理}
%%%新符号和新算子%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\pozhe}{\rule{0.0em}{0pt}\rule[0.35em]{1.4em}{0.05em}\rule{0.2em}{0pt}}
\newcommand{\zyd}{·}
\newcommand{\pow}{\mathcal{P}}
%%%%new diamond %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{pict2e}
\DeclareRobustCommand{\newdiamond}{%
\begingroup
\setlength{\unitlength}{\fontcharht\fontT}%
\begin{picture}(1,1)
\polygon(.5,0)(1,.5)(.5,1)(0,.5)
\end{picture}%
\endgroup}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{\Huge\bf Template}
\author{Humanities}
\date{}
\begin{document}
\maketitle
\cleardoublepage
\frontmatter
\tableofcontents

\mainmatter
\chapter{非人类}
\section{完整}

\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}

%%%添加参考文献%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\cleardoublepage
\phantomsection
\bibliographystyle{plain}
\bibliography{liuref}
%%%显示符号索引%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\cleardoublepage
\phantomsection
\printindex[symbol]
%%%显示人名索引%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\cleardoublepage
\phantomsection
\printindex[name]
%%%显示术语索引%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\cleardoublepage
\phantomsection
\CTEXoptions[indexname={术语索引}]
\printindex
\end{document}


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}

• @Kuttens -- Try this: $a+b+c=e.\qedhere$ – user91669 Dec 8 '17 at 13:16
• I don't know how to apply to definitions. – Mogic Dec 8 '17 at 13:34
\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}


• But I use \usepackage{amsthm,amsmath,amssymb,amsfonts,mathrsfs} and so your method doesn't work. I don't know why. – Mogic Dec 7 '17 at 8: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." – user91669 Dec 7 '17 at 9: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 – Mogic Dec 7 '17 at 9: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. – user91669 Dec 7 '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 7 '17 at 14:33