3

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?

Werner
  • 603,163

2 Answers2

3

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}

enter image description here

Gonzalo Medina
  • 505,128
1

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

enter image description here

\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
    #1\@addpunct{.}]\ignorespaces
}{%
  \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.

Werner
  • 603,163