[l2h] \htmlsetstyle / css file question

Ross Moore Ross Moore <ross@ics.mq.edu.au>
Mon, 21 Feb 2000 20:14:56 +1100 (EST)

> This is something I thought I had figured out a while back, then put
> aside, and now I can't remember what I figured out.  I'm trying to add
> the line
> P	      {  line-height : 2.5ex  }
> to the .css file generated by latex2html (and we'll put aside that
> fact that I don't have a clue what the P stands for) by using the
> html.sty command
> \htmlsetstyle[P]{}{ line-height=2.5ex }

You can use:

 \htmlsetstyle{P}{ line-height=2.5ex }

since    .P      matches *every* <P> tag, however nested.

 \htmlsetstyle[BODY]{P}{ line-height=2.5ex }

since  BODY.P  matches all top-level <P> tags,

 \htmlsetstyle[P.]{}{ line-height=2.5ex }

which gives the line you say that you want
(see below for an explanation).

The mandatory argument is for the basic tag or class;  <P> in your case
while the optional argument is for sub-tags, when you wish
to apply a style only within a specific tag-hierarchy,
or when a specific CLASS is specified.

 \htmlsetstyle[P]{MATH}{ line-height=2.5ex }

gives:    P.MATH {  line-height : 2.5ex  }

being applied to tags:  <P CLASS="MATH" .... > 

> What I get is
> DIV.P	      {  line-height : 2.5ex  }
> Now, I don't really know Perl, but I traced through the latex2html
> source (99.2beta6) anyway, and found this block of code:

>     print "\n *** Adding document-specific styles *** ";
>     while (($env,$style) = each %env_style) {
>         if ($env =~ /\./) {
>             $env =~ s/\.$//;
>             print STYLESHEET "$env\t\t{ $style }\n";
>         } elsif ($env =~ /inline|^(text|math)?((tt|rm|sf)(family)?|(up|it|sl|sc)(shape)?|(bf|md)(series)?|normal(font)?)$/) {
>             print STYLESHEET "SPAN.$env\t\t{ $style }\n";
>         } elsif ($env =~ /\./) {
>             print STYLESHEET "$env\t\t{ $style }\n";
>         } elsif ($env =~ /^(preform|\w*[Vv]erbatim(star)?)$/) {
>             print STYLESHEET "PRE.$env\t\t{ $style }\n";
>         } elsif ($env =~ /figure|table|tabular|equation|$array_env_rx/) {
>             print STYLESHEET "TABLE.$env\t\t{ $style }\n";
>         } else {
>             print STYLESHEET "DIV.$env\t\t{ $style }\n";
>         }
>     }
> This is where the DIV comes from. 


The information that is filtered through this Perl code may have originated
with an option argument to  \begin :


LaTeX2HTML tries to guess what is the most sensible thing, from the context.
The general types, represented by the above code, are:

 DIV  <--->  TeX vertical mode
 SPAN <--->  inline environments, and font-family/shape switches
 PRE  <--->  verbatim-like environments
 TABLE <---> tabular constructions, incl. math-arrays, etc.
DIV is the default, since most environments that LaTeX2HTML cannot recognise
are vertical material, perhaps requiring an image anyway.
Almost certainly <DIV> .... </DIV> tags will have been used when
placing the contents into the HTML file.

> ............  I'm a bit confused by this, since the
> third "if" test is the same as the first.

Oops; that's a harmless redundancy.
At one stage during development the order was different,
but that was found to be inadequate.

>...  Further, the first case
> removes a trailing '.', but the sub process_htmlstyles already does that,
> via a fix that was discussed on the list 5/19/99.  Now if that fix
> was not in place, then the above latex code would result in $env="P.",
> which would be caught by the first line, have it's '.' stripped, and
> I'd get what I want.  But $env="P" doesn't match any of the cases,
> and the default DIV.P results.

Correct analysis. 
The \htmlsetstyle code constructs a key of:   <optional>.<mandatory> 
from the LaTeX arguments, whereas  \begin[<style-data>]{<env>}
uses the <env> as a key
 (unless the <style-data> also has '|' or is entirely class names).

The above code looks for the presence of a '.' , but removes a trailing '.'.
Hence \htmlsetstyles[P.]{}{....}  will give the line that you want.


 ... be careful that you may get unwanted effects with such a general rule.
LaTeX2HTML itself inserts some <P> tags, in some places;
i.e. with the translation of some environments.
This is mainly with code written pre-HTML4.0. 
(With pre-HTML3.2 code, liberal use of <P> and <BR> was the only way
to control vertical spacing.)

I've tried to include <DIV>...</DIV> tags in all the main vertical environments.
So  BODY.P  is probably the best pattern to match all of the outermost

There has been very little discussion on this list of this aspect of 
LaTeX2HTML translations.  It is one area where there is great potential for
further developments --- to design attractive stylesheets,
to be applied to documents produced from LaTeX source.
The style information along can reside either in a separate file, or in a part
of the preamble, to accompany the documents themselves.

> I can see several ways to change the code to get what I want, but I'd
> like to know if I'm missing something fundamental here, and if there
> is a "right" way to fix it.

The existing stucture allows you to get everything you should need.
The documentation is a little scanty 
 --- best reference is The LaTeX Web Companion, with examples in \S3.3.4 .

	Hope this helps,

		Ross Moore
> thanks,
> Dan Scholnik