[l2h] Bug in first hyperlink of TOC

Ross Moore ross@ics.mq.edu.au
Sat, 30 Mar 2002 18:14:43 +1100 (EST)


> Hi,
> 
> it seems to me that there is a bug in the table of contents (TOC) generated
> by LaTeX2HTML. I am using LaTeX2HTML version 2002 (1.62) on FreeBSD,
> downloaded from http://www.latex2html.org/~latex2ht/current
> as latex2html-2002.tar.gz (20-Mar-2002).
> 
> What I mean is that the generated hyperlink of the *first* TOC entry is
> missing the anchor part. The anchor is correct in all following TOC
> entries. Therefore clicking on the first hyperlink in the TOC brings you to
> the top of the document instead of to the start of the section.

Yes; that does happen when the TOC is on the first HTML page,
e.g. when using -split 0.

The current coding does not detect this as a special case.

In general, the coding is such that the  #<anchor>  part is *not* included
with the hyperlink to the 1st (sub)section on an HTML page.
(This way, the TOC link takes you to the top of the page, including
navigation and any text or images occurring above the title.)

However, with -split 0 then you *want* the #<anchor> part,
since everything is on one HTML page anyway, and the first link
in the TOC should not be to the page as a whole.


I'm implementing a patch to  latex2html.pin  as follows:

<     local($toc) = &add_child_links($title,'','',1,$keys[0],@keys);
---
>     local($toc,$on_first_page) = ('','');
>     $on_first_page = $CURRENT_FILE
>       unless ($MAX_SPLIT_DEPTH && $MAX_SPLIT_DEPTH <1000);
>     $toc = &add_child_links($title,$on_first_page,'',1,$keys[0],@keys);

This passes the name of the current file as the 2nd parameter
of the  &add_child_links  subroutine, in the  -split 0  case.
Now the Perl coding will append the <anchor> on the first link,
since it cannot tell that it *is* the first link.


Thanks for reporting the bug.

	Ross Moore


 
> For demonstration consider the following LaTeX document "tst.tex":
> 
>  \documentclass{article}
>  \begin{document}
>  \tableofcontents
>  \section{First Section}
>  \section{Second Section}
>  \section{Third Section}
>  \end{document}
> 
> After two runs of latex and then running latex2html with
> 
>  latex2html -split 0 tst
> 
> the resulting html file "tst/tst.html" contains the following
> html code for the TOC:
> 
>  <!--Table of Contents-->
>  <UL>
>  <LI><A NAME="tex2html6" HREF="tst.html">First Section</A>
>  <LI><A NAME="tex2html7" HREF="tst.html#SECTION00030000000000000000">Second Section</A>
>  <LI><A NAME="tex2html8" HREF="tst.html#SECTION00040000000000000000">Third Section</A>
>  <LI><A NAME="tex2html9" HREF="tst.html#SECTION00050000000000000000">About this document ...</A>
>  </UL>
>  <!--End of Table of Contents-->
> 
> Obviously the hyperlink to "First Section" should contain
> HREF="tst.html#SECTION00020000000000000000" instead of only HREF="tst.html".
> 
> Perhaps there is someone able to fix this?
> 
> Best regards
> Ulrich
> 
> -- 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>  Ulrich Gruenebaum (grueneba@zkom.de)
>  Tel. +49/(0)231/9700-337
>  FAX  +49/(0)231/9700-474
> 
>  ZKOM GmbH
>  State Diagnostic Systems and Computer Networks
>  Joseph-von-Fraunhofer-Str. 20
>  D-44227 Dortmund (Germany)
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> _______________________________________________
> latex2html mailing list
> latex2html@tug.org
> http://tug.org/mailman/listinfo/latex2html