Example/Solution Environment

In my document I wish to provide example questions with solutions. I am currently doing this using the amsthm package as follows:

\documentclass{article}

\usepackage{lmodern}
\usepackage{amssymb,amsthm}

\newtheoremstyle{examplesty}         % Name
{}                   % Above skip
{}                   % Below skip
{\upshape}           % Body font
{}                   % Indent

% Examples rejig the theorem environment
\theoremstyle{examplesty}
\newtheorem{example}{Example}[section]

% Solutions use a modified proof environment
\newenvironment{solution}
{\let\oldqedsymbol=\qedsymbol
\renewcommand{\qedsymbol}{$\blacktriangleleft$}
\begin{proof}[\bfseries\upshape Solution]}
{\end{proof}
\renewcommand{\qedsymbol}{\oldqedsymbol}}

\begin{document}
\section{Test Section}
\begin{example} This is an example problem \end{example}
\begin{solution} This is a solution to an example problem. \end{solution}
\end{document}


My problem is that the spacing between the headings and bodies is different for examples and solutions. Moreover, solutions have a period after them, which looks odd. Is it possible to rectify these issues or am I guilty of trying to hammer in a nail with an old shoe?

-
See tex.stackexchange.com/questions/49085/… as it uses the end mark well. –  sandu Nov 28 '12 at 10:56

You can use the thmtools front-end to easily interact with (for example) amsthm; this will easily give you consistency in the spacing. Here's an example showing how your definitions would look like:

\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{amsthm}
\usepackage{thmtools}

\declaretheoremstyle[
spaceabove=6pt, spacebelow=6pt,
notefont=\mdseries, notebraces={(}{)},
bodyfont=\normalfont,
numberwithin=section
]{exstyle}
\declaretheoremstyle[
spaceabove=6pt, spacebelow=6pt,
notefont=\mdseries, notebraces={(}{)},
bodyfont=\normalfont,
qed=$\blacktriangleleft$,
numbered=no
]{solstyle}
\declaretheorem[style=exstyle]{example}
\declaretheorem[style=solstyle]{solution}

\begin{document}

\section{Test section}

text text text
\begin{example}
text text text
\end{example}
text text text

text text text
\begin{solution}
text text text
\end{solution}
text text text

\end{document}

-
What a neat little package; perfect! –  Freddie Witherden Jun 5 '11 at 17:25

The remove the period:

\makeatletter
\newenvironment{solution}
{\let\oldqedsymbol=\qedsymbol%
\renewcommand{\qedsymbol}{$\blacktriangleleft$}%

\def\@addpunct##1{\hspace*{1em}}