[OS X TeX] Reflecting numbering in the source

Berend Hasselman bhh at xs4all.nl
Tue Aug 14 21:21:49 CEST 2007


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

If you don't need to reference  example numbers with labels (\label)  
then you can use \stepcounter instead of \refstepcounter.

Also have a look at http://www.tex.ac.uk/cgi-bin/texfaq2html? 
label=addtoreset

success

Berend


------------------------- Helpful Info -------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/
List Reminders & Etiquette: http://www.esm.psu.edu/mac-tex/list/





More information about the macostex-archives mailing list