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

Travis Spencer travislspencer at gmail.com
Fri Jul 29 18:44:58 CEST 2005

On 7/29/05, Ross Moore <ross at ics.mq.edu.au> wrote:
> Have you seen the book:  "The LaTeX Web Companion"  ?

I've seen it, but I haven't read it yet.  I'll get it from the school
library.  Thanks for the tip.

> The chapter in there on LaTeX2HTML explains how to use an
> optional argument to  \begin  to do this.
> e.g.
>   \begin[mylist]{tabular}{....}
>   ...
>   \end{tabular}
> will produce    <TABLE class="mylist"> .... </TABLE>

That's really helpful to know; however, I would still like a way to produce

<TABLE id="mylist"> ... </TABLE>

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

But there isn't one if I run l2h with the `-style' option right?  Of
course I can run l2h without that option when I want to examine the
CSS, but I'm just wondering if I'm understanding l2h correctly.

> 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.

I don't see how that helps.  I can add stuff to the CSS file myself
(e.g., `H1.DocTitle {...}') since I've instructed l2h to use a
pre-existing stylesheet via the `-style' option.  What I need is a way
to tell l2h, "This H1 right here is special.  Give it an ID that is
unique, so I can attach a specific style rule (e.g., using
`H1#DocTitle { ...}') which I will write myself in an external
stylesheet that you don't need to worry about."

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

Are there any environment in LaTeX that don't actually apply any
formatting, structure, etc. kind of like HTML's span element?  If
there is, I could create a new environment and leave the document's
structure unaltered (unlike the previous tabular example of yours). 
For instance, is there something like

\being[mylist]{simple_container} ... \end{simple_container}

Which would produce some HTML like this:

<span class="mylist"> ... </span>

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

Yes, I agree that being able to associate a particular class with
LaTeX environments is helpful, but, without a similar way associate
IDs with specific sections of the LaTeX source document, the
flexibility of that control is limited significantly.

> Another thing that you may want to do is to use the following variable:
> For example, this page was done using LaTeX2HTML:
> http://www.maths.mq.edu.au/texdev/MATHS/MATH123/study_guide/

Wow! You've convinced me that Macquarie University is Australia's
innovative university and that l2h is very capable of rendering
beautiful HTML documents if you're willing to message it enough.

> To get the special banner, and styles, it access CSS files
> that are stored at a completely different location. (read the HTML
> source!)
> 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
>          );

Did you learn all that from "The LaTeX Web Companion"?  That is really
helpful to know.  Thanks!

> Hope this helps,

Yes it does.  I really appreciate the help, Ross.



Travis Spencer

More information about the latex2html mailing list