Preferred way of creating problem and solution environments

I know we can create problem-solution pairs using the exercise package but I am looking for something that is much simpler and similar to theorem and proof environments. I have solved this problem in two different ways.

Using 'theorem' and 'proof' environments

Here is one way to write a problem statement followed by a solution.

\documentclass{article}
\usepackage{amsthm}
\newtheorem*{theorem}{Problem}
\renewcommand{\qedsymbol}{}

\begin{document}

\begin{theorem}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc quis
volutpat tellus. Morbi dapibus dolor quis ligula porta eget adipiscing
nibh consectetur. Nulla fringilla dolor id elit vulputate ac posuere
ligula auctor.
\end{theorem}

\begin{proof}[Solution]
Ut at turpis felis. Donec venenatis fermentum volutpat.
Aliquam erat volutpat. Nulla fringilla adipiscing metus, eget porta
turpis facilisis vel. Nulla facilisi. Vivamus tristique ultricies
imperdiet. Cras non sapien erat, et tincidunt enim. Praesent vel ipsum
elit. Donec tincidunt, sem vitae scelerisque volutpat, diam dui
elementum est, quis ullamcorper libero sapien laoreet sem.
\end{proof}

\end{document}


The output is shown below.

Using custom 'problem' and 'solution' environments

This problem can also be solved by defining my own environments as follows.

\documentclass{article}

\newenvironment{problem}[1][Problem]
{\begin{trivlist} \item[\hskip \labelsep {\bfseries #1.}] \itshape}
{\end{trivlist}}

\newenvironment{solution}[1][Solution]
{\begin{trivlist} \item[\hskip \labelsep {\itshape #1.}]}
{\end{trivlist}}

\begin{document}

\begin{problem}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc quis
volutpat tellus. Morbi dapibus dolor quis ligula porta eget adipiscing
nibh consectetur. Nulla fringilla dolor id elit vulputate ac posuere
ligula auctor.
\end{problem}

\begin{solution}[Solution]
Ut at turpis felis. Donec venenatis fermentum volutpat.
Aliquam erat volutpat. Nulla fringilla adipiscing metus, eget porta
turpis facilisis vel. Nulla facilisi. Vivamus tristique ultricies
imperdiet. Cras non sapien erat, et tincidunt enim. Praesent vel ipsum
elit. Donec tincidunt, sem vitae scelerisque volutpat, diam dui
elementum est, quis ullamcorper libero sapien laoreet sem.
\end{solution}

\end{document}


The output is shown below.

1. What is the preferred way of solving this problem? Which one of the two methods above is a better way of solving this problem?
2. Would you suggest any improvements or modifications to the problem and solution environments I have defined in the second method?
3. The two outputs are very similar but they are not exactly similar. If you open the first output image and the second output image in two different tabs of the browser and switch between them, you can see some differences. Why do these differences occur?
• Different spacing between characters in the italicized text.
• Different vertical space between the problem and solution.
• I prefer the 1st option. You can also use \theoremstyle provided by amsthm package to format you block. – Sigur Sep 11 '12 at 21:53

• Semantically it is somehow ambiguous since you are using a proof environment and have to change the default name used in the label; I think it's better to have a dedicated environment with a name solution (or closer to solution than proof).
• Using the defalut proof environment from amsthm, you need to redefine \qedsymbol so that the end mark won't appear in your modified environment.

Your second approach has one potential drawback illustrated by the vertical spacing issue you noticed; if you use the \trivlist approach for these two environments but eventually use some environments from the amsthm package, the spacing might result inconsistent.

I would probably opt for a mixture of your approaches; I would use \theoremstyle from the amsthm package to define a style for solutions:

\documentclass{article}
\usepackage{amsthm}

\newtheorem*{problem}{Problem}
\newtheoremstyle{solution}%
{\topsep}{\topsep}{\normalfont}{}%
{\itshape}{.}{5pt}{}
\theoremstyle{solution}
\newtheorem*{solution}{Solution}

\begin{document}

\begin{problem}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc quis
volutpat tellus. Morbi dapibus dolor quis ligula porta eget adipiscing
nibh consectetur. Nulla fringilla dolor id elit vulputate ac posuere
ligula auctor.
\end{problem}

\begin{solution}
Ut at turpis felis. Donec venenatis fermentum volutpat.
Aliquam erat volutpat. Nulla fringilla adipiscing metus, eget porta
turpis facilisis vel. Nulla facilisi. Vivamus tristique ultricies
imperdiet. Cras non sapien erat, et tincidunt enim. Praesent vel ipsum
elit. Donec tincidunt, sem vitae scelerisque volutpat, diam dui
elementum est, quis ullamcorper libero sapien laoreet sem.
\end{solution}

\end{document}


Regarding your third question, when I ran your example codes, I couldn't reproduce any different spacing between characters in the italicized text (but the images you linked effectively show a difference, so that makes me wonder how did you run your examples?). The difference in spacing comes from the default settings for vertical spacing around a theorem-structure defined using amsthm.