[OS X TeX] Exercises

George Gratzer gratzer at me.com
Fri Apr 10 15:18:59 EDT 2009


Works with perfection, thanks.

GG

On 10-Apr-09, at 1:33 PM, Michael Sharpe wrote:

>
> On Apr 10, 2009, at 9:56 AM, George Gratzer wrote:
>
>> In my new book, I have exercises at the end of each section. I use  
>> the xcb environment from amsbook.cls:
>>
>> \newenvironment{xcb}{%
>> \setcounter{enumi}{0}%
>> \settowidth{\leftmargini}{\labelenumi\hskip\labelsep}%
>> \setcounter{enumii}{4}% letter d
>> \settowidth{\leftmarginii}{\labelenumii\hskip\labelsep}%
>> \@startsection{section}% counter name; ignored because of the
>>                               % * below
>> {1}% sectioning level
>> {\z@}% indent to the left of the section title
>> {18\p@\@plus2\p@}% vertical space above
>> {1sp}% Space below of 13pt base-to-base, so none needs to be added
>>     % here; but \z@ would cause the following text to be run-in, so  
>> we
>>     % use 1sp instead.
>> {\bfseries}% The font of the subsection title
>> *% always unnumbered
>> }{%
>> \par
>> }
>>
>>
>> modified as follows:
>>
>> \newenvironment{exercises}
>>    {
>>    \begin{xcb}{}\noindent\textbf{Exercises}
>>    \begin{enumerate}
>>    \renewcommand{\labelenumi}{\theenumi.}
>>    \settowidth{\leftmargini}{NN.\hskip\labelsep}
>>    }
>>    {\end{enumerate}\end{xcb}}
>>
>> and then
>>
>> \begin{exercises}
>>
>> \item
>>
>> \begin{exercises}
>>
>> works well.
>>
>> Problem: I want the difficult exercises marked with a *:
>>
>> 25*.
>>
>> How could I do that? How do I modify one number, without effecting  
>> the rest?
>>
>
> One way is to redefine the exercises environment as follows.
>
> \newenvironment{exercises}
>    {
>    \begin{xcb}{}\noindent\textbf{Exercises}
>    \begin{enumerate}
> \let\olditem\item
> \def\staritem{\let\exerstar\par\olditem }
> \renewcommand{\item}{\let\exerstar\empty\olditem }
> \renewcommand{\labelenumi}{\theenumi\ifx\exerstar\empty\else*\fi.}
>    \settowidth{\leftmargini}{NN.\hskip\labelsep}
>    }
>    {\end{enumerate}\end{xcb}}
>
> You might want to change the alignment of the numbers, or perhaps  
> place the * before the exercise number---that's a simple change.
>
> Michael
>
> ----------- Please Consult the Following Before Posting -----------
> TeX FAQ: http://www.tex.ac.uk/faq
> List Reminders and Etiquette: http://email.esm.psu.edu/mac-tex/
> List Archive: http://tug.org/pipermail/macostex-archives/
> TeX on Mac OS X Website: http://mactex-wiki.tug.org/
> List Info: http://email.esm.psu.edu/mailman/listinfo/macosx-tex
>




More information about the MacOSX-TeX mailing list