How to create a new environment like proof in amsthm package which reads as ‘solution’ instead of ‘proof’

examplesnewtheoremproofstheorems

Using the \newtheorem command, I know how to create similar type of environments like 'Examples', 'Remarks', 'Lemma' etc. in class notes. For Theorems, we use \begin{proof} ......... \end{proof} to write the proof.

My query is how to create a new environment (with amsthm package) called 'solution' for writing solutions to worked examples and problems. I want this to begin and end with 'solution'. A \qed to complete the solution will be also a great help. Kindly help on how to do it in LaTeX.

For the enclosed code, how should adjust I the LaTeX preamble after \usepackage{amsthm}? Thanks a lot!

 \begin{example}
 Find the Laplace transform of $f(t) = 1$.
 \end{example}
 
 \begin{solution}
 The Laplace transform of $f(t)$ is obtained as
 $$
 F(s) = {\cal L}(f) = \int\limits_0^\infty e^{-s t} (1) dt = {1 \over s}
 $$
 \end{solution} 

Best Answer

Just define solution in terms of proof.

\documentclass{article}
\usepackage{amsthm}

\theoremstyle{definition}
\newtheorem{example}{Example}

\newenvironment{solution}{\begin{proof}[Solution]}{\end{proof}}

\begin{document}

\begin{example}
Find the Laplace transform of $f(t) = 1$.
\end{example}
 
\begin{solution}
The Laplace transform of $f(t)$ is obtained as
\[
 F(s) = \mathcal{L}(f) = \int\limits_0^\infty e^{-s t} (1) \, dt = \frac{1}{s}
\qedhere
\]
\end{solution} 

\end{document}

Since the particular solution ends with a display, you should use \qedhere as shown. Otherwise nothing is necessary to get the tombstone at the end.

enter image description here

Please, note the changes:

  1. {\cal L} has been deprecated for about 30 years and should be \mathcal{L}

  2. $$...$$ has never be advertised in LaTeX and should not be used

  3. {1\over s} is plain TeX syntax that should be avoided in LaTeX

  4. The differential should be preceded by \,

Related Question