[l2h] tex counters cannot be used in html 4.0 for programming latex2html

Ross Moore ross at ics.mq.edu.au
Fri Jan 2 23:40:01 CET 2004


Hi again Peter,

On Fri, 2 Jan 2004, Peter Morling wrote:

> Dear Ross,
>
> another problem occoured using html 4.0. Everytime you refer to a counter it
> will be tagged with:
>
> <SPAN CLASS="arabic"> \thecounter </SPAN>
>
> ...meaning you cannot use LaTeX counters for your own anchors!
>
> e.g.,
>
> \newcommand{\ltopanchor}{
> \rawhtml
> <!-- Start of topanchor -->
> <A NAME="SEC\endrawhtml\thesection\rawhtml">
> <!-- End of topanchor -->
> \endrawhtml
> }

In LaTeX  \thesection  gives a "formatted representation" of the value
of the counter. It is *not* the numerical value of the counter.

For example, in chapter 3 of a book, \thesection might give  3.2
whereas the value of the counter is just 2 .

To get the number itself, use:
    \value{section}
In TeX, this will give you the internal (binary) representation
of the number, useful for calculations, or for passing to formatting
macros: e.g.
   \number{\value{section}}

In LaTeX2HTML, either of  \value{section}  or  \number{\value{section}}
should give the correct string, since Perl passes all (touchwood) data
around as strings, or pointers to strings.


>
> will produce in html 4.0
>
> <!-- Start of topanchor -->
> <A NAME="SEC<SPAN CLASS="arabic">1</SPAN>.<SPAN CLASS="arabic">0</SPAN>">
> <!-- End of topanchor -->

Yes; you're pretty much on your own, when you play with  rawhtml .
There's no guarantee of validity, or even correctness, when you
work with that.

You may find it easier to use  \HTMLcode to construct raw HTML,
using information from the document-body:

\HTMLcode[name=SEC\value{section}.\value{subsection}]{A}

>
>
> in html 3.2 everything works fine and will produce:
>
> <!-- Start of topanchor -->
> <A NAME="SEC1.0">
> <!-- End of topanchor -->

Just lucky, I guess.  :-)

HTML 4.0  is more complicated that 3.2, since you are *expected*
to use CSS styles --- much more so than with HTML 3.2.


>
>
> Is there a solution to this problem? (except for post-processing html for
> the excact span-tag ;) )

Try using  \value{<counter>}  rather than  \the<counter> .

Or try
\renewcommand{\thesection}{\number{\value{section}}.\number{\value{subsection}}}

 --- though this will affect the display within the body of your document
as well as in these artificially constructed NAME attributes.



Just to check my statements above are correct, from the latex2html script
we have the following Perl coding:

sub do_cmd_value {
   ... read the arguments correctly ...
    $val = &get_counter_value($ctr);
    if ($val) { $val.$_ }
    else { join(''," 0",$_) }
}

sub do_cmd_arabic {
    local($ctr, $val, $id, $_) = &read_counter_value($_[0]);
    $val = ($val ? &farabic($val) : "0");
    &styled_number_text('arabic', $val, $id);
}

where

sub read_counter_value {
   ... read the arguments correctly ...
    $val = &get_counter_value($ctr);
    ($ctr, $val, $br_id, $_)
}


So, the effective difference lies in the use of
 &styled_number_text  for the output value from the counter.


sub styled_number_text {
    local($num_style, $val, $txtID) = @_;
    if ($USING_STYLES) {
        $txt_style{$num_style} = " " unless ($txt_style{$num_style});
        join('',"<SPAN CLASS=\"$num_style\">", $val, "</SPAN>", $_);
    } else { $val.$_ }
}


With HTML3.2, the $USING_STYLES parameter is unset by default,
whereas with HTML4.0 it *is* set.
(You can turn it off, if you wish, in an init-file.)



>
> Best,
> Peter
>

Hopefully this makes it clear what options are available to you.
(There are many, at all levels:  (La)TeX, Perl, HTML/CSS .)


Cheers

	Ross

>
>
>
>
>
> Programmer Peter Morling, University of Southern Denmark
> Department of Statistics, Sdr. Boulevard 23A, DK-5000 Odense C
> Phone (+45) 6550 3399
>
> _______________________________________________
> latex2html mailing list
> latex2html at tug.org
> http://tug.org/mailman/listinfo/latex2html
>


More information about the latex2html mailing list