[l2h] Both \latex{} and \html{} blocks appear in images.tex

Ross Moore ross@ics.mq.edu.au
Sat, 8 Dec 2001 12:37:29 +1100 (EST)


> I just noticed that (in l2h v2k.1beta (1.55)) the defs
> 
> 	\latex{
> 	  latex-only block
> 	}
> 
> 	\html{
> 	  html-only block
> 	}
> 
> appear in images.tex as
> 
> 	\latex{
> 	  latex-only stuff
> 	}
> 
> 	html-only stuff
> 
> As a result, both blocks are compiled when processing images.tex.
> Is this a bug? (It seems to be causing me some trouble.)

It is generally not a good idea to be including large blocks
as the argument of \latex or \html .
These are intended for different words/phrases that are appropriate
to the output setting:  .dvi/paper-print  or  HTML/on-screen .

For whole environments that are different between the HTML/dvi 
versions, it is generally better to use the environments:

  \begin{htmlonly}
   ...
   ...
  \end{htmlonly}

and

  \begin{latexonly}
   ...
   ...
  \end{latexonly}

or conditional comments:

 %begin{latexonly}
   ...
   ...
 %end{latexonly}


> I would expect only the \latex{} block to appear.

This is not at all obvious.
The image is being created for an HTML document,
so one could easily argue that it is the  \html{.....}
block that should be included.


There is a problem with using the conditional environments
discussed above, within coding blocks that will end up
as part of the LaTeX source for generating an image.
The {latexonly} parts were removed at the very beginning
of the processing, so can *never* occur in the image.
But the LaTeX processing will skip the {htmlonly} environments
too; so you get *neither* version included.

LaTeX2HTML provides also an  {imagesonly} environment
that allows you to overcome precisely this type of issue.


Another use of {imagesonly} is for the coding within the *preamble*
of the LaTeX document.
This lets you adjust which packages are loaded, or the expansion
of various macros, when used within an image.

This gives you another way to tackle the problem that you describe:

  define a macro to expand to the coding that you want to appear
  in conditional contexts.

You can have 3 separate expansions, for the cases:

   1.  appearance when processed normally by LaTeX 

   2.  when as normal text in an HTML document

   3.  when included as part of an image in an HTML document.


It is definitely arguable that this is the *right* way to use conditional
constructions. That is, define a macro for each, so that there is no need
to edit in the main document body; make alterations by adjusting the
expansion of the macro.

(This is particularly applicable for URLs, for example, where the appearance
*must* be different in the HTML and .dvi cases.)
 

> Thanks,


Hope this helps,

	Ross Moore


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