[l2h] Controlling generation of CLASS and ID attributes from within LaTeX files

Ross Moore ross at ics.mq.edu.au
Fri Jul 29 09:38:43 CEST 2005

On 29/07/2005, at 4:00 PM, Travis Spencer wrote:

> Hey,
> I have a few dozen LaTeX documents that I want to style the same way.
> To do this, I am invoking latex2html with the `-style' option, so they
> all use the same CSS stylesheet.  No problem there; however, I need
> some way to control how latex2html generates ID and CLASS attributes,

Have you seen the book:  "The LaTeX Web Companion"  ?

The chapter in there on LaTeX2HTML explains how to use an
optional argument to  \begin  to do this.



will produce    <TABLE class="mylist"> .... </TABLE>

Alternatively, specify CSS attributes directly:

\begin[border=2pt,solid,brown; color=maroon; padding:5pt]{tabular}{....}

and have a look at the resulting HTML coding.

You should also examine the automatically generated .css stylesheet,
to see how the attributes/values have been recorded, and are applied.

> so I have some "hooks" to grab onto when applying styles.  I read in
> the mailing list archive that any `\text' command will generate a
> unique ID.  I'm not sure what that means though. (My LaTeX still isn't
> that good, but I'm getting there.)

> What I would like is a way to instruct latex2html to give that first
> H1 an ID attribute with a value of DocTitle by inserting some LaTeX
> code like this:
> \title{Getting Started With Unix}\html_id{DocTitle}

The above doesn't help with this title, since there is no \begin .
However, you can do it using the special command:

    \htmlsetstyle[H1]{DocTitle}{<extra styles>}

which will add a line into the .css file.
(The <extra styles>  can be empty if the  class="DocTitle" already
handles everything. )

> Which would produce this HTML:
> <H1 ALIGN="CENTER" ID="DocTitle">Getting Started With Unix</H1>
> Similarly, it would be handy to be able to do the same thing for CLASS
> attribute and values.  This example seems like something latex2html
> should just do for me, but that is another issue I think.

These features are already present.

> All this said, I am open to other suggestions on how to style dozens
> of documents uni formally.  I've read about the \htmlsetstyle command,
> but that isn't really what I'm looking for I don't think.

It helps you build a .css  stylesheet.
But this is something that you could do by hand anyway, if you know how.

To apply the styles at appropriate places within your webpage,
you will also need the optional argument to  \begin  .

With both of these features working together, you can control CSS
styles quite effectively.

> Also, in case it helps, I invoke html2latex in a Makefile like so:
>         -discard \
>         -nofootnode \
>         -font_size 12pt \
>         -noaddress \
>         -nobottom_navigation \
>         -noinfo \
>         -local_icons \
>         -nonavigation \
>         -noshort_index \
>         -nosubdir \
>         -auto_prefix \
>         -show_section_numbers \
>         -split 0 \
>         -style $(STYLESHEET) \
>         -white \
>         -html_version "4.0" \
>         $< ;

This seems fine.

However, you may need to prepend the automatically generated
style information to your  $(STYLESHEET)  file.

Another thing that you may want to do is to use the following variable:

For example, this page was done using LaTeX2HTML:


To get the special banner, and styles, it access CSS files
that are stored at a completely different location. (read the HTML  

This is done using the following coding in  .latex2html-init :

,'<!-- start links -->'
,'<link title="Home page" href="http://www.mq.edu.au/" rel="start" />'
,'<link title="Access features of this site" href="http:// 
www.mq.edu.au/accessibility.html" rel="help" />'
,'<link href="http://rutherglen.ics.mq.edu.au/css/low.css" type="text/ 
css" rel="stylesheet" />'
,'<link href="http://rutherglen.ics.mq.edu.au/css/print.css"  
type="text/css" rel="stylesheet" media="print"
,'<!-- end links -->'
,'<style type="text/css" media="screen">'
,'  @import url("http://rutherglen.ics.mq.edu.au/css/import.css");'
,'  @import url("http://rutherglen.ics.mq.edu.au/css/departments.css");'
,' --></style>'

are the ways to adjust the META-information in the <HEAD> .... </HEAD>
section of the HTML pages produced by  LaTeX2HTML.

For example, the above-mention page also uses:

$FAVICON_URL = 'http://www.maths.mq.edu.au/favicon.ico';

$LATEX2HTML_META = join("\n"
         , '<META NAME="Generator" CONTENT="LaTeX2HTML v'. 
         , '<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">'
         , $FAVICON

> -- 
> Regards,
> Travis Spencer

Hope this helps,

     Ross Moore

> _______________________________________________
> latex2html mailing list
> latex2html at tug.org
> http://tug.org/mailman/listinfo/latex2html

Ross Moore                                         ross at maths.mq.edu.au
Mathematics Department                             office: E7A-419
Macquarie University                               tel: +61 +2 9850 8955
Sydney, Australia  2109                            fax: +61 +2 9850 8114

More information about the latex2html mailing list