[l2h] Image generation bug?

Ross Moore ross at ics.mq.edu.au
Mon Feb 14 20:06:16 CET 2005


Hi Igor,

On 15/02/2005, at 5:09 AM, Igor Pechtchanski wrote:

> Hi,
>
> I'm attempting to convert a LaTeX file that has custom picture commands
> into HTML.  The images in the file should ideally be generated from the
> LaTeX version of the commands.  However, latex2html includes the HTML 
> (!)
> versions of the commands, which results in invalid images.  Manually
> editing images.tex to include the LaTeX versions of the commands does
> produce the correct images.
>
> Below is the minimal example (with the actual command definition, FWIW,
> but that's largely irrelevant, I think).  Yes, I realize that it's 
> LaTeX
> hackery, and that LaTeX2HTML can't be expected to parse that,


Firstly, you need to:
   \usepackage{html}
then use the special environment:

   \begin{imagesonly}
    ...
   \end{imagesonly}

as follows:


\documentclass{article}
\usepackage{html}
%begin{latexonly}
\makeatletter
% Define \ovalbox (an oval framebox)
\def\ovalbox{%
   \@ifnextchar[\@valbox\@valb at x}
\def\@valb at x{\@valbox[]}
\newlength{\s at veunitlength}%
\long\def\@valbox[#1]#2{%
   \@begin at tempboxa\vbox{%
     \vskip\fboxsep
     \hbox{%
     \color at begingroup
       \kern\fboxsep{#2}\kern\fboxsep
     \color at endgroup}%
     \vskip\fboxsep
   }%
   \ifx\\#1\\\setlength{\s at veunitlength}{\totalheight}\else%
     \setlength{\s at veunitlength}{\unitlength}%
     \multiply\s at veunitlength#1\fi%
   \def\hgt{\strip at pt\s at veunitlength}%
   \setlength{\unitlength}{1pt}%
   \oval(\strip at pt\width,\hgt)\makebox(0,0){\box\@tempboxa}%
   \@end at tempboxa%
}
\makeatother
%end{latexonly}

\begin{imagesonly}
\makeatletter
% Define \ovalbox (an oval framebox)
\def\ovalbox{%
   \@ifnextchar[\@valbox\@valb at x}
\def\@valb at x{\@valbox[]}
\newlength{\s at veunitlength}%
\long\def\@valbox[#1]#2{%
   \@begin at tempboxa\vbox{%
     \vskip\fboxsep
     \hbox{%
     \color at begingroup
       \kern\fboxsep{#2}\kern\fboxsep
     \color at endgroup}%
     \vskip\fboxsep
   }%
   \ifx\\#1\\\setlength{\s at veunitlength}{\totalheight}\else%
     \setlength{\s at veunitlength}{\unitlength}%
     \multiply\s at veunitlength#1\fi%
   \def\hgt{\strip at pt\s at veunitlength}%
   \setlength{\unitlength}{1pt}%
   \oval(\strip at pt\width,\hgt)\makebox(0,0){\box\@tempboxa}%
   \@end at tempboxa%
}
\makeatother
\end{imagesonly}

\begin{document}
\begin{figure}
\begin{picture}(100,20)(0,0)
\put(50,10){\ovalbox{Testing \string\ovalbox}}
\end{picture}
\end{figure}
\end{document}


Alternatively, put your definitions into a  .sty  file,
  mydefs.sty  say, and then  \usepackage{mydefs} .
You will need to place mydefs.sty  in a place where it
can be found by LaTeX when needed.


>  but I
> thought that's exactly what image generation was all about -- passing 
> the
> bits that LaTeX2HTML doesn't understand to the actual LaTeX for
> processing...

The \begin{latexonly}  and  %begin{latexonly}  environments
are only included when LaTeX is in control of the complete
document. These are *not* included as part of images.tex .

The  \begin{imagesonly}  environment passes extra material
to  images.tex  but should be ignored by LaTeX when doing
the whole document.
In this case it means duplicating your definitions, but
this isn't the only use for such an environment.



>
> I'm also attaching the generated images.tex file.  Please let me know 
> if
> more detail is needed.  Thanks,
> 	Igor


Hope this helps,

	Ross


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



More information about the latex2html mailing list