# [OS X TeX] Reflecting numbering in the source

Alain Schremmer schremmer.alain at gmail.com
Tue Aug 14 19:40:46 EDT 2007

On Aug 14, 2007, at 3:21 PM, Berend Hasselman wrote:

>
> On 14 Aug 2007, at 18:40, Alain Schremmer wrote:
>
>> I am using
>>
>> 	\newcounter{eex}[chapter]
>> 	\newenvironment{EEXAMPLE}{\textsf{\bfseries{E\smaller{XAMPLE}
>> \hspace{1.5mm}}\refstepcounter{eex}\theeex.\hspace{2.5mm}}\small
>> \sffamily}{\par}
>>
>> along with the macro
>>
>> 	\begin{EEXAMPLE}%
>> 	#INS#
>> 	\end{EEXAMPLE}
>>
>> where, for ease of editing, I reflect the example number (eex)
>> after \begin{EEXAMPLE}%.
>>
>> But of course, when I add or remove example(s), I have to adjust
>> the example number by hand.
>>
>> Would there be a way to do this automatically?
>>
>
> In the document preamble do
>
> \newcounter{examplecounter}
>
> where examplecounter is the name of the counter you are defining.
> If it is necessary to reset the counter per chapter append
> [chapter] to the newcounter command (aftr the closing }).
>
> And include the following in the begin definition of EEXAMPLE
>
> \refstepcounter{examplecounter}Example~\theexamplecounter

Er, this is what I am already doing (see above) and not what I would
like which is for the source to show, commented out since it is after
the %, the number of the exercise as it will appear in the pdf.

But then of course, I don't see how this could possibly be done since
I can't see how the macro could keep track and I was just hoping I
was missing the obvious.

Best regards
--schremmer