Forcing qed symbol to stay on same page

I've made this enviroment:

\newenvironment{rjesenje}{
\emph{\textbf{Rješenje:}}}{\vspace{0.1cm}
\begin{flushright}
$\clubsuit$
\end{flushright}
}


And in my work I've got this output.

How do I force the symbol to stay on the same page?

• Your screenshot doesn't appear to be showing "Rješenje:" at the bottom of the page. Am I missing something? – Mico May 23 '16 at 18:45
• @Mico Is it OK now? – zermelovac May 23 '16 at 18:48
• Thanks for this update. The only way to guarantee that the entire environment, including the ending \clubsuit symbol, will be placed on one page is to place it inside a minipage environment. – Mico May 23 '16 at 18:56
• you've given this full encouragement to start a new page. flushright begins with a trivlist, which in turn is always considered a good place for a page break. what is needed is a mechanism similar to what is used for the qed symbol for the proof of a theorem. there's discussion of that topic at How to make all theorem-like environments have an ending symbol? – barbara beeton May 23 '16 at 19:02

Try using ntheorem and the nonumberplaintheorem style. The placement of endmarks is automatic (even if the environment ends up in displayed equations). Here is a possible code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{lipsum}

\usepackage{amsmath}
\usepackage[thmmarks, amsmath, thref]{ntheorem}

\theoremstyle{nonumberplain}
\theoremseparator{:}
\theorembodyfont{\normalfont}
\theoremsymbol{\ensuremath{\clubsuit}}
\newtheorem{rjesenje}{\hskip\parindent Rješenje}

\begin{document}

\begin{rjesenje}
\lipsum[2-6] So
\begin{equation*}
\{x  ∈ E: x = 2\} = \{2\}\text{.}
\end{equation*}
\end{rjesenje}

\end{document}


• It says: ! Package ntheorem Error: Theorem style plain already defined. – zermelovac May 23 '16 at 20:03
• Probably you're loading amsthm. You can't use it with ntheorem. However you have a compatibility mode for ntheoremwith the amsthm option. – Bernard May 23 '16 at 20:10