[OS X TeX] addcontentsline difficulty
Ross Moore
ross at ics.mq.edu.au
Mon Jul 6 12:58:01 CEST 2009
Hi David
On 06/07/2009, at 1:10 AM, David Arnold wrote:
> All,
>
> Using memoir and hyperref. I have a macro:
>
> \newenvironment{Exercises}
> {\openoutputfile{\jobname.backans}{backansout}%
> \addcontentsline{toc}{subsection}{Exercises}
> \noindent\rule{\linewidth}{1pt}
> \par\medskip\hfil{\Large\mylleaf\quad\mylleaf\quad\mylleaf\qquad
> \textbf{Exercises}\qquad\myrleaf\quad\myrleaf\quad\myrleaf}\hfil\par
> \noindent\rule{\linewidth}{1pt}}
> {\closeoutputstream{backansout}}
There is nothing in this definition that adjusts the target
for hyperlinks.
You'll need to define a new counter
\newcounter{exercises}
and advance it upon each exercise, using
\refstepcounter{exercises}
Not that it is not enough to just do
\stepcounter{exercises}
as this doesn't establish the location of the
exercise as being a target for hyperlinks.
Indeed, this may not be the full story yet,
as you are trying to leverage off the 'subsection' counter
for the ToC entry.
Probably you should be making your {Exercises} environment
start a new subsection, and adjust the appearance of
the headings for subsections --- assuming this doesn't
conflict with other usage of \subsection throughout your tome.
Otherwise you can have all sorts of other problems ...
>
> The result typeset like this:
>
> <pastedGraphic.tiff>
>
>
> There is no \subsection command used here, just what you see in the
> macro. The difficulty we are experiencing is the addcontentsline.
> Works OK, puts the correct page in the TOC.
>
> <pastedGraphic.tiff>
>
>
>
> But when we click on the link in the TOC, we land on a page or two
> earlier than we should. There is no error of "unnamed destination
> in the log file."
>
> The chapter toc file looks somewhat strange.
>
> \contentsline {chapter}{\chapternumberline {4}Fractions}{1}{chapter.4}
> \contentsline {section}{\numberline {4.1}Equivalent Fractions}{3}
> {section.4.1}
> \contentsline {subsection}{The Greatest Common Divisor}{6}{section*.1}
> \contentsline {subsection}{Reducing a Fraction to Lowest Terms}{7}
> {section*.2}
> \contentsline {subsection}{Reducing Fractions with Variables}{9}
> {section*.3}
> \contentsline {subsection}{A Word on Mathematical Notation.}{10}
> {section*.4}
> \contentsline {subsection}{Equivalent Fractions in Higher Terms}{11}
> {section*.5}
> \contentsline {subsection}{Negative Fractions}{12}{section*.6}
> \contentsline {subsection}{Exercises}{14}{example.4.1.10}
>
> This is the line of concern:
>
> \contentsline {subsection}{Exercises}{14}{example.4.1.10}
>
> This is where we wind up when we click Exercises in the TOC:
>
> <pastedGraphic.tiff>
>
>
> So, were being taken to the last "\label" just prior to the
> exercises on a consistent basis whenever we click on tany
> "Exercises" link in the TOC.
... such as this.
>
> Can someone shine some light on our difficulty?
Yes. Messing with just some parts of the sectioning structure,
but not using all of it, can be problematic when you need it
for more than just visual appearance.
>
> Thanks.
>
> David Arnold
> College of the Redwoods
Hope this helps,
Ross
------------------------------------------------------------------------
Ross Moore ross at maths.mq.edu.au
Mathematics Department office: E7A-419
Macquarie University tel: +61 (0)2 9850 8955
Sydney, Australia 2109 fax: +61 (0)2 9850 8114
------------------------------------------------------------------------
More information about the macostex-archives
mailing list