I'm writing a workbook for students with homework exercises and their solutions contained. For the ´´homework-exercise´´ and homework-exercise-solution
I defined custom environments using amsthm
.
Ultimately, I'm looking for a way to solve this my other question myself, by wrapping the ´´homework-exercise´´ and homework-exercise-solution
into colorbox environments from tcolorbox
package using the options invisible
to have empty phantom boxes displayed by a custom package switch. (I'll answer my own question once I got everything more polished.)
Right now, this means that homework exercises and solutions are scattered throughout the workbook, which is okay since they are placed next to the relevant content.
However, I would like to additionaly print pages with duplicates of all the homework-exercise
and homework-exercise-solution
environments at the end of the document, to ensure students have a nice short overview over which tasks have to be done (and my tutors have a nice short way of checking the filled-in solution sheets).
How can I produce copies of all the environments of certain types, while keeping the numbers they were assigned on their first occurrance? (However, the labels of the duplicates must be adapted as to not rewrite references to the originally placed environments)
Attached is a MWE with a screenshot of the output produced
%
%
%
\documentclass{article}
\begin{filecontents*}{testpackage.sty}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mw88-script}[2021/08/25 LaTeX package for toggling solutions]
\RequirePackage{tcolorbox}
\newcommand{\visibility}{invisible}
\DeclareOption{showsolutions}{\renewcommand{\visibility}{visible}}
\DeclareOption*{\PackageWarning{examplepackage}{Unknown ‘\CurrentOption’}}
\ProcessOptions\relax
\tcolorboxenvironment{exercise-homework}{
}
\tcolorboxenvironment{exercise-homework-solution}{
\visibility
}
\end{filecontents*}
\usepackage{mwe}
\usepackage{amssymb, amsmath, amsthm, mathtools}
% \usepackage{testpackage}
\usepackage[showsolutions]{testpackage}
\theoremstyle{plain}{
\newtheorem{exercise-homework}{Hausaufgabe}
}
\theoremstyle{plain}{
\newtheorem{exercise-homework-solution}{Lösung}
}
%
%
%
\begin{document}
\section{This is the guided workflow}
Here are explanatory things and prerequisites necessary to solve the exercise.
\begin{exercise-homework}
Show that $(\mathbb{R}, +, \cdot)$ is a field.
\end{exercise-homework}
\begin{exercise-homework-solution}%
Let $a, b, c \in \mathbb{R}$ arbitrary. Then, we show the following properties:
\begin{description}
\item[Commutativity of addition] $a + b = b+ a$.
\item[Associativity of addition] $a +(b + c) = (a+b) +c$.
\item[Additive identity] $0 \in \mathbb{R}$, and $a +0 = a $.
\item[Additive inverse] for each $a \in \mathbb{R}$, there exists $-a \in \mathbb{R}$, sch that $a + (-a) = 0$.
\item[Commutativity of multiplication] $a \cdot b = b \cdot a$.
\item[Associativity of multiplications] $a \cdot (b \dot c) = (a \cdot b) \cdot c$.
\item[Multiplicative identity] $1 \in \mathbb{R}$, such that $1 \cdot a = a$.
\item[Multiplicative inverse] for each $a \in \mathbb{R}$, there exists $a^{-1}\in \mathbb{R}$, such that $a \cdot a^{-1} = 1$.
\item[Distributivity] $a\cdot (b + c) = (a \cdot b) + (a \cdot c)$.
\end{description}
These are the necessary and sufficient properties of a field, hence $(\mathbb{R}, +, \cdot)$ is a field.
\end{exercise-homework-solution}
From here, the workbook content continues. There are going to be more exercises and solutions.
\section*{Appendix}
Here I want duplicates of the exercise and solutions from above.
\end{document}
The display of solution contents can be toggled within the package option.
Update 1:
Further investigation revealed, that I should be able to use the thm-restate
package from thmtools
to restate theorem-like environments. However, thm-restate
does not play nicely with tcolorbox
out of the box. See the MWE and attached screenshots below: The restated environment is not wrapped inside a tcolorbox.
\documentclass[a4paper]{article}
\usepackage{thmtools}
\usepackage{thm-restate}
\usepackage[dvipsnames]{xcolor}
\usepackage[many]{tcolorbox}
\declaretheorem[name=Exercise, style=remark]{exercise}
\tcolorboxenvironment{exercise}{colframe=red!75!black}
\begin{document}
\noindent We start using the {\ttfamily exercise}-environment:
\begin{exercise}[restate=restatekey]
This is a demonstrational exercise.
\end{exercise}
\noindent and try to restate this:
\restatekey*
\noindent then follow it up with a {\ttfamily restatable}-environment
\begin{restatable}{exercise}{extest}\label{ex:test}
This is a restatable exercise.
\end{restatable}
\noindent In the following, there's the restated {\ttfamily restatable}-exercise:
\extest*
\end{document}