In my lecture notes I want to leave some work as exercises and plan to give solutions later in the text. For example,
"The proof of this theorem is left as an exercise (Exercise 1.2)".
It must also have a label so that it could be referred later. I think I need an inline exercise environment.
This post answers my question. In the last answer in this post Werner has proposed that it could done in a better way may be with macros. I have too many of them so would be very difficult to do it with \lipsum \begin \end
every single time. Can this be done with a single command?
Best Answer
Here is an implementation that provides a
\exinline
command, taking a label argument to produce the relevant text.Note in this example Exercises and Theorems share the same counter. If that is not the case, you need to replace the
theorem
counter in definition with the appropriate counter, and change\thetheorem
correspondingly. E.g. if exercises have their own number, declared via\newtheorem{exercise}{Exercise}[section]
, the command definition should readIf you are using
cleveref
for references then a small modification is needed to therefstepcounter
command so\cref
picks up the correct name.This produces the same output as the first example, with
cleveref
correctly providing the names.