0

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} 
2
  • 1
    Do you know how to make your own environments? Commented Mar 11, 2022 at 12:28
  • For the placement of the qed symbol, the ntheorem package is much better.
    – Bernard
    Commented Mar 11, 2022 at 13:23

2 Answers 2

4

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 \,

1
  • Your solution works beautifully! Earlier I was getting a \bullet at the end of the solution & proof which I did not like. Later I checked & found that this is due to another *.mac file which defined "\def\qed{\ \hfill$\bullet$}" but I changed it to "\def\qed{\ \hfill$\blacksquare$}" - Now things are working very well!
    – Sundar
    Commented Mar 11, 2022 at 15:00
0

I tried many LaTeX commands & this one works:

\newenvironment{solution}{{\bf \emph{Solution.} }}{\hfill $\Box$ \\} 

Now I use \begin{solution} ...... \end{solution}

I was earlier usign $\blacksquare$ for the end of the proof and the solution but I now feel that $\Box$ is easy for the eyes!

2
  • These commands work well ! I tested! I am getting a \Box at the end of the 'solution' and not the 'dark bullet' as the case with other solution for me.. Just an update..
    – Sundar
    Commented Mar 11, 2022 at 14:55
  • 1
    There is no guarantee that the box will be at the end of the line; you also lose \qedhere.
    – egreg
    Commented Mar 14, 2022 at 8:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .