Hi everyone,

Here is another of my mammoth emails.
This will attempt to provide answers to several
of the questions that have arisen this week-end,
and also add to last week's discussion.


Here goes.

Almost invariably document authors need definitions
for macros/environments that will be different for LaTeX
and LaTeX2HTML.

Such definitions, especially if they need to be reused in
more than one document, should go into a file(s) separate
from the main manuscript.

The \usepackage mechanism is one way to do this;
e.g.  \usepackage{mydefs}
which asks LaTeX to look for and load  mydefs.sty .
It asks LaTeX2HTML to looks for and load  mydefs.perl .

Another way is to include the package name as a class-option
for the documentstyle (using LaTeX2.09) class:
  \documentstyle[mydefs]{article}

Now for LaTeX2HTML this class-option causes 2 things:
 1. looks for  mydefs.perl  to load Perl macros
 2. looks for  mydefs.tex   to include more LaTeX-like code
as part of the current document.


Using  \documentclass[mydefs]{article}   (with LaTeX-2e )
should have the same dual effect, with LaTeX2HTML.
However it will not work quite as smoothly with LaTeX,
unless you induce it to recognise `mydefs` as an option to  article.cls .
 --- though I think the only bad effect may be a warning message.
Provided LaTeX doesn't stop, then this *is* an effective strategy.

However this latter strategy requires keeping 2 files
  mydefs.sty  and  mydefs.tex  up-to-date concurrently.
Many authors (myself included) don't like this approach,
preferring instead to use a single file only.
(See below for one way of doing this.)


Where does LaTeX2HTML look for the files to be loaded ?
Which directories are searched?
  $LATEX2HTMLSTYLES   is a list of directories for Perl code
  $TEXINPUTS  is a list of directories for more LaTeX code.

These variables have default values, set in the (system-installed)
file  latex2html.config .
Those values can be overridden within  .latex2html-init  files.

You can have one of these in your $HOME directory.
This will be read before one found in the current working directory.
e.g.
set  $TEXINPUTS and/or $LATEX2HTMLSTYLES within  $HOME/.latex2html-init
for directories that are used frequently...
... then modify its value in the local  .latex2html-init
for directories specific to the current job.

Extra initialisation files, having any name whatsoever,
can be loaded by specific request on the command-line
using the  -init_file  switch.
This can be used multiply, to load as many files as you please,
in the order of occurrence.


At 5:42 PM -0400 4/24/98, Fred L. Drake wrote:
>  Is there a way to tell l2h that latex created it's temporary files
>someplace other than the directory where l2h is run from?
>  What I want to do is this:  I have a whole bunch of .tex files in a
>directory, and then have the subdirs that l2h creates *and* separate
>directories for running latex for both letter and a4 paper.  If my

You should be able to adjust the $TEXINPUTS variable to include
the appropriate directories.

>  Is there a way to tell l2h "look over there" to get the *.aux files
>and anything else it uses that latex creates?  A command line switch
>would be great.

There is already the  -external_file  switch for this purpose;
but it can only be used for one file.



Another way to include conditional definitions is via
 \input  of a single file.

Thus typically a document that is intended to be processed
by both LaTeX and LaTeX2HTML might start:

        \documentclass[..options..]{article}
        \usepackage{mydefs}
        \input mydefsHTML.tex
        ...
        ...

The file  mydefsHTML.tex  is included in *both* the LaTeX and
LaTeX2HTML jobs. Its contents should thus use the `conditional'
environments defined in  html.sty .


Typically such a file will look something like:


%%%%%%%%  start of file: mydefs.tex %%%%%%%%%%%%%%%%

\usepackage{html}

% commands for LaTeX only

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

% commands for LaTeX2HTML only

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

% command definitions applicable to both LaTeX and HTML

...
...

%%%%%%% end of file:  mydefs.tex  %%%%%%%%%%%%%%


Notice that the \usepackage{html} can go inside this file.
This is a good reason to include `HTML' as part of its name.

Now what sort of definitions belong in such a file.
Well if we look ahead to the trend towards XML, then the following
type of definition is clearly desirable:


\newenvironment{codefigure}
 {\begin{figure}[htp]
  \begin{makeimage}
  \end{makeimage}}
 {\end{figure}}


Then your manuscript contains markup like:

\begin{codefigure}
\begin{verbatim}
 ....
\end{verbatim}
\caption{....}
\end{codefigure}


This works correctly in LaTeX, (provided html.sty is loaded,
which it will be) and correctly in LaTeX2HTML
since the \newenvironment definition gets replaced early,
so LaTeX2HTML sees the {figure} containing the empty {makeimage} environment.

Furthermore, if the same manuscript was to be translated into XML,
then it is clear to use tags  <codefigure>  ....  </codefigure> .
No editing should be needed to the body of the manuscript.
Perhaps a stylesheet will provide the complete layout for the
information presented in such an environment.


Dan Young wrote:
>Thanks for the pointer.  Inserting an empty \makeimage environment
>inside the figure does indeed generate <PRE> text instead of an image.
>I wrote a PERL script to insert them into any \figure...\verbatim
>environments, and it seems to be working fine.

If Dan's markup used a user-defined environment like  {codefigure},
rather than directly using  {figure}  environments,
then there would be no need for the PERL script to insert
the extra  {makeimage}  environments.
A simple adjustment to the definition of the user-defined environment
would suffice.


 ** Use more (user-definable) markup. **

This is the main lesson to be learned from XML.
It is a lesson already implicit in LaTeX, but which hasn't
been emphasised sufficiently in the existing literature.



The following would also work:

\newenvironment{codefigure}
 {\begin{figure}}
 {\begin{makeimage}
  \end{makeimage}\end{figure}}

allowing different placement specifiers to be used in the manuscript;
e.g.  \begin{codefigure}[p]
for LaTeX to put the float on a separate page.

Note that the following does *not* work:

\newenvironment{codefigure}[1]
 {\begin{figure}[htp]
  \begin{makeimage}
  \end{makeimage}
  \begin{verbatim}}
 {\end{verbatim}
  \caption{#1}
  \end{figure}}

expecting to have the manuscript simplified to look like:

\begin{codefigure}
{...caption-text...}
...
...
\end{codefigure}


The problem is in LaTeX (but *not* with LaTeX2HTML)
since the \end{codefigure} has not been replaced at the time
when LaTeX encouters it. Since it is still inside the {verbatim}
environment, there is no way to decide that the  \end{codefigure}
should be expanded, to obtain the  \end{verbatim} that is meant
to close this special environment.

With LaTeX2HTML the \newenvironment replacements have already been
made before this type of question may arise. So the results will
be as intended.


I include this previous example as a warning to be careful,...

...but also as an example of where LaTeX2HTML's replacement strategy
can actually be *superior* to that of (La)TeX.



Finally, please do *not* do things like:

\newenvironment{codefigure}[1]
 {\begin{figure}[htp]
  \begin{makeimage}
  \end{makeimage}
  \begin{verbatim}}
 {\caption{#1}
  \end{figure}}

with manuscript looking like:

\begin{codefigure}
{...caption-text...}
.....
\end{verbatim}
\end{codefigure}

Although this works for both LaTeX and LaTeX2HTML,
the apparently unbalanced  \begin...\end  structure
is highly distasteful. It could cause great confusion if
the manuscript was separated from its \input file containing
the definitions.



Hope this helps,

        Ross Moore



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ross Moore                             email: [EMAIL PROTECTED]
Mathematics Department                 phone:      +612 9850 8955
Macquarie University                     fax:      +612 9850 8114
Sydney, NSW 2109                      office:             E7A-419
Australia              WWW: http://www-math.mpce.mq.edu.au/~ross/

                ***************************

for the best in (La)TeX-nical typesetting and Web page production
join the  TeX Users Group (TUG) --- browse at  http://www.tug.org

                 <[EMAIL PROTECTED]>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Reply via email to