3

This question already has an answer here:

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 Oberdiek Feb 4 '14 at 6:19

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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

  • 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
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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.