# Square is not flushed-right at the end of newly defined \end environment

I write the following code,

\documentclass[10pt, twocolumn, twoside, journal]{IEEEtran}

\usepackage{amsmath, amsfonts, amssymb, color, enumerate, amsthm, graphicx}
\usepackage{tikz, subcaption, cite}
\usepackage{color, xcolor, soul, bm}
\usepackage{marginnote}
\usepackage[normalem]{ulem}
\newtheorem{problem}{Problem}
\newtheorem{theorem}{Theorem}
\newtheorem{corollary}{Corollary}
\newtheorem{assumption}{Assumption}
\newtheorem{proposition}{Proposition}
\newtheorem{lemma}{Lemma}
\newtheorem{remark}{Remark}
\newtheorem{definition}{Definition}
\newtheorem{example}{Example}
\usepackage{epsfig}
\usepackage{psfrag}
\DeclareMathOperator{\diag}{diag}
\usepackage{tcolorbox}
\newcommand{\JW}[1]{{\color{red}#1}}

\usepackage{algorithm}
\usepackage{algpseudocode}
\allowdisplaybreaks

\def\endtheorem{\hspace*{\fill}~\IEEEQEDopen\par\endtrivlist\unskip}
\def\endlemma{\hspace*{\fill}~\IEEEQEDopen\par\endtrivlist\unskip}
\def\endproposition{\hspace*{\fill}~\IEEEQEDopen\par\endtrivlist\unskip}
\def\endexample{\hspace*{\fill}~\IEEEQEDopen\par\endtrivlist\unskip}
\def\endremark{\hspace*{\fill}~\IEEEQEDopen\par\endtrivlist\unskip}
\def\enddefinition{\hspace*{\fill}~\IEEEQEDopen\par\endtrivlist\unskip}

\begin{document}
\title{My title}

\newcommand{\ty}{\color{yellow}}
\newcommand{\tb}{\color{blue}}
\newcommand{\tr}{\color{red}}
\newcommand{\tg}{\color{green}}

\maketitle

\thispagestyle{empty}
%\pagestyle{empty}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{abstract}
My abstract
\end{abstract}

\begin{IEEEkeywords}
key words
\end{IEEEkeywords}

\begin{lemma}
This is my lemma and when the text happens to end near the right margin the symbol will be flushed left, not right.
\end{lemma}

\end{document}


I do see that a same question has been answered here: How do I make all the theorem-alike environments have an ending symbol?

But I would like to know what the problem is with my \def commands and if I can fix them. If not please let me know an alternative.

• Does this answer your question? Square is not flushed-right at the end of newly defined \end environment – Vincent Dec 30 '19 at 19:40
• do you really want end of proof markers at ends of lemmas and remarks? readers will find that confusing won't they? – David Carlisle Dec 30 '19 at 19:48
• @DavidCarlisle I want the simple square (not the blacksquare) at the of lemmas and remarks. – Mohammad Dec 30 '19 at 21:11
• can you make an example using a standard class ieeeaccess isn't in the standard distributions and it seems unreasonable to have to install it just to try your example – David Carlisle Dec 30 '19 at 21:13
• @DavidCarlisle Done. – Mohammad Dec 30 '19 at 21:27