[OS X TeX] Two issues -- need help

M. Tamer =?ISO-8859-1?B?1g==?=zsu tozsu at sympatico.ca
Sun Aug 7 16:38:17 EDT 2005


Thanks much. I can't believe I missed the \refstepcounter. However, changing
\stepcounter to \refstepcounter as follows gives an error:

\newcounter{exmp}[chapter]
\newcommand{\bex}{\renewcommand{\theexmp}{\refstepcounter{exmp}\thechapter.a
rabic{exmp}}\vspace{11pt}\par\noindent{\bf Example
\theexmp}\vspace{11pt}\par\noindent\begin{inpar}\parskip=2pt plus 0.5pt}

However, if I do the following (pulling \refstepcounter{exmp} out of the
definition of \renewcommand)

\newcounter{exmp}[chapter]
\newcommand{\bex}{\refstepcounter{exmp}\renewcommand{\theexmp}{\thechapter.\
arabic{exmp}}\vspace{11pt}\par\noindent{\bf Example
\theexmp}\vspace{11pt}\par\noindent\begin{inpar}\parskip=2pt plus 0.5pt}

works without giving an error, assigns the correct example number, but the
first \ref gives only the value of the example number, without the chapter
prefix, i.e.,

\bex\label{ex1}
...
\eex

generates (correctly)
    Example 4.1 ...

but "In Example \ref{ex1}" generates

    In Example 1

References to subsequent examples work properly, i.e., I do get

    Example 4.2 ...

    In Example 4.2

Any further suggestions would be very much appreciated.
-- 
M. Tamer Ozsu
University of Waterloo


> From: Ross Moore <ross at ics.mq.edu.au>
> Reply-To: TeX on Mac OS X Mailing List <MacOSX-TeX at email.esm.psu.edu>
> Date: Sun, 7 Aug 2005 17:40:10 +1000
> To: TeX on Mac OS X Mailing List <MacOSX-TeX at email.esm.psu.edu>
> Subject: Re: [OS X TeX] Two issues -- need help
> 
> 
> On 07/08/2005, at 3:49 AM, M. Tamer Özsu wrote:
> 
>> ---
>> I wonder if someone can help me with two issues:
> 
>> \newcounter{exmp}[chapter]
>> \newcommand{\bex}{\renewcommand{\theexmp}{\stepcounter{exmp}
>> \thechapter.\a
>> rabic{exmp}}\vspace{11pt}\par\noindent{\bf Example
>> \theexmp}\vspace{11pt}\par\noindent\begin{inpar}\parskip=2pt plus
>> 0.5pt}
>> 
>> but this did not work either. The numbering is OK, but \ref{...}
>> simply
>> generates the number of the section within which the example occurs.
> 
> Try using  \refstepcounter  instead of  \stepcounter .
> 
>> 
>> I would appreciate any help in changing the \bex definition so that it
>> generates the numbers prefixed with chapter numbers and also
>> handles the
>> references right.
> 
> 
> Hope this helps,
> 
>      Ross Moore
> 
> 
>> Thanks for any suggestions.
>> -- 
>> M. Tamer Ozsu
>> University of Waterloo
>> 
> 
> ------------------------------------------------------------------------
> Ross Moore                                         ross at maths.mq.edu.au
> Mathematics Department                             office: E7A-419
> Macquarie University                               tel: +61 +2 9850 8955
> Sydney, Australia  2109                            fax: +61 +2 9850 8114
> ------------------------------------------------------------------------
> 
> 
> --------------------- Info ---------------------
> Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
>            & FAQ: http://latex.yauh.de/faq/
> TeX FAQ: http://www.tex.ac.uk/faq
> List Post: <mailto:MacOSX-TeX at email.esm.psu.edu>
> 


--------------------- Info ---------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
           & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Post: <mailto:MacOSX-TeX at email.esm.psu.edu>





More information about the MacOSX-TeX mailing list