# Blocks at the End of a Solution Structure [duplicate]

so a couple of months ago I created my own package. Everything in it works great, and so far it does everything I need it to do, the way I need it to. But I want to change one thing. When I made the package, I found it necessary to create a structure declaration in the package that says

\newtheorem*{solution}{Solution}


Until now, I have been very happy with it. But I've decided (in order to separate the solutions from the surrounding text) that I want the structure to add a black square at the end every time the structure ends. Could somebody tell me how to modify my code to do this?

## marked as duplicate by Werner, ChrisS, Svend Tveskæg, Speravir, Heiko OberdiekFeb 4 '14 at 6:19

• I'm using amsmath. – Higgie2718 Feb 4 '14 at 2:43
• – Werner Feb 4 '14 at 2:43
• That's fine for the proof environment, but how do I force my created environment to do a similar practice? – Higgie2718 Feb 4 '14 at 2:46

Instead of \newtheorem*{solution}{Solution}, add the following lines:

\RequirePackage{thmtools}

\declaretheoremstyle[
qed=$\blacksquare$,
numbered=no,
bodyfont=\itshape
]{mystyle}
\declaretheorem[style=mystyle]{solution}


Since \blacksquare requires amssymb, you will also need this package (if you are not already loading it):

\RequirePackage{amssymb}


An example with a document:

\documentclass{article}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{lipsum}

\declaretheoremstyle[
qed=$\blacksquare$,
numbered=no,
bodyfont=\itshape
]{mystyle}
\declaretheorem[style=mystyle]{solution}

\begin{document}

\begin{solution}
\lipsum*[4]
\end{solution}

\end{document}


• What does the {mystyle} part do? – Higgie2718 Feb 4 '14 at 2:49
• mystyle is the name of the defined style. You can use any other name you like more. – Gonzalo Medina Feb 4 '14 at 2:50

You could make solution be similar to proof of amsthm by using the following construction:

\documentclass{article}
\usepackage{amsthm,amsmath,amssymb}% http://ctan.org/pkg/{amsthm,amsmath,amssymb}

\renewcommand{\qedsymbol}{$\blacksquare$}
\makeatletter
\newcommand{\solutionname}{\textbf{Solution}}
\newenvironment{solution}[1][\solutionname]{\par
\pushQED{\qed}%
\normalfont \topsep6\p@\@plus6\p@\relax
\trivlist
\item[\hskip\labelsep
}{%
\popQED\endtrivlist\@endpefalse
}
\makeatother

\begin{document}
\begin{solution}
\begin{equation*}
G(t)=L\gamma!\,t^{-\gamma}+t^{-\delta}\eta(t) \qedhere
\end{equation*}
\end{solution}
\end{document}


The above definition for solution is taken directly from amsclass.dtx where proof is defined. The only thing I've changed is the title.