This question is on the basis of my last question: Define own class options relating to counter. With the help of egreg, here is a class file in which there is an environment named exercise
:
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{class}
\newcounter{exercounter}
\DeclareOption{withinchap}{\def\exercounter@within{chapter}}
\DeclareOption{withinsec}{\def\exercounter@within{section}}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}}
\ExecuteOptions{withinchap}
\ProcessOptions\relax
\LoadClass{report} % should go after processing options
\RequirePackage{indentfirst}
\counterwithin*{exercounter}{\exercounter@within}
\newenvironment{exercise}%
{\stepcounter{exercounter}\par\textbf{\theexercounter.}}%
{\ignorespacesafterend}
Now I want to rewrite the exercise
environment with an optional argument (in fact an positive integer), i.e.
\newenvironment{exercise}[1]{...
And then when I use exercise
environment like this:
\begin{exercise}[number]
...
\end{exercise}
The number of the current exercise is number
and the following exercise counter increases from number
+1. Any hint?