8

I have a theorem environment called question, and I would like to use a proof-like environment that prints "Solution" instead of "Proof"

\documentclass[a4paper,11pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsthm}

\newtheorem{question}{Question}

\begin{document}

\begin{question}
Some question here
\end{question}

\begin{solution}
Here goes the solution to the question
\end{solution}

\begin{theorem}
Some theorem or formula to derive here
\end{theorem}

\begin{proof}
Here goes the proof to the question
\end{proof}

\end{document}

I have used the command $\renewcommand{\proofname}{Solution}$ as a temporary fix, but that replaces the name for all instances, and sometimes I will actually need to use the regular proof environment, with "Proof" as its name.

10

Package amsthm has three styles: plain (title is in \bfseries and body is in \itshape), definition (title is in \bfseries and body is in \rmfamily) and remark (title is in \itshape and body is in \rmfamily). All of them come with starred versions, which do not use a counter.

\documentclass[a4paper,11pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage{amsthm}

\newtheorem{theorem}{Theorem}
\newtheorem{question}{Question}
\theoremstyle{remark}
\newtheorem*{solution}{Solution}


\begin{document}

\begin{question}
Some question here
\end{question}

\begin{solution}
Here goes the solution to the question
\end{solution}

\begin{theorem}
Some theorem or formula to derive here
\end{theorem}

\begin{proof}
Here goes the proof to the question
\end{proof}

\end{document}

Here is another way if you like to see the QED symbol at the end of the solution.

\documentclass[a4paper,11pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage{amsthm}

\newtheorem{theorem}{Theorem}
\newtheorem{question}{Question}

\newenvironment{solution}{\renewcommand{\proofname}{Solution}\begin{proof}}{\end{proof}}


\begin{document}

\begin{question}
Some question here
\end{question}

\begin{solution}
Here goes the solution to the question
\end{solution}

\begin{theorem}
Some theorem or formula to derive here
\end{theorem}

\begin{proof}
Here goes the proof to the question
\end{proof}

\end{document}

enter image description here

1
  • I didn't know I could renew a command inside another one, that's really useful
    – Mahoma
    Sep 8 '16 at 6:51
5

Original proof copied and modified:

\documentclass[a4paper,11pt]{book}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsthm}

\newtheorem{theorem}{Theorem} % PS
\newtheorem{question}{Question}

\makeatletter
\newenvironment{solution}[1][\solutionname]{\par
  \pushQED{\qed}%
  \normalfont \topsep6\p@\@plus6\p@\relax
  \trivlist
%<amsbook|amsproc>  \itemindent\normalparindent
  \item[\hskip\labelsep
%<amsbook|amsproc>        \scshape
%<amsart|amsthm>        \itshape
\itshape 
    #1\@addpunct{.}]\ignorespaces
}{%
  \popQED\endtrivlist\@endpefalse
}
%    \end{macrocode}
%    Default for \cn{proofname}:
%    \begin{macrocode}
\providecommand{\solutionname}{Solution}

\makeatother


\begin{document}

\begin{question}
Some question here
\end{question}

%\begin{proof}
\begin{solution} % PS
Here goes the solution to the question
%\end{proof}
\end{solution} % PS

\begin{theorem}
Some theorem or formula to derive here
\end{theorem}

\begin{proof}
Here goes the proof to the question
\end{proof}

\end{document}

enter image description here

2
  • It's really interesting for me to see the original code. Can I find this code in the package documentation? I would like to get more familiar with latex internal workings
    – Mahoma
    Sep 8 '16 at 6:50
  • @Mahoma You can find it in amsthm.sty, a file called in your code. Modifying original macros is for me much better approach than using macros in nonstandard way. Sep 8 '16 at 9:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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