[l2h] Fix for relative image paths in includegraphics?

Ross Moore ross@ics.mq.edu.au
Sat, 14 Sep 2002 09:44:32 +1000 (EST)


> Hi,
> 
> I have had problems with relative paths in files like:
> 
> \documentclass{article}
> \usepackage{graphicx}
> \begin{document}
> \section{test}
> \includegraphics{./test.eps}
> \end{document}
> 
> (usually its a more complex relative path eg ../figs/test.eps)

The  graphicx package has a  \graphicspath  command, which allows
search paths for graphics to be given in the LaTeX source document.

Alternatively, you can set the  $GRAPHICS_PATH  variable in
an initialisation file.

Another possibility is to make symbolic links to the graphics
in the directory above from the directory in which LaTeX2HTML works.
This is particularly useful if you want to test  latex images.tex
after a run which did not succeed fully.
 
> I have patched latex2html-2002-1 using:
> 
> *** graphics-support.perl	2002/09/13 12:01:14	1.1
> --- graphics-support.perl	2002/09/13 13:08:56
> ***************
> *** 297,302 ****
> --- 297,305 ----
>     my $src;
>     if( $punt || ($ext && !$GRAPHICS_RULE{$ext}) ||
>        !($src=find_file($file,$GRAPHICS_PATH, $GRAPHICS_EXTENSIONS))){
> +       if( $file =~ /^\./ ) {
> + 	  $newfile="$texfilepath/$file";
                                ^----  should be  ${dd}  for portability
> + 	  $origcall =~ s|$file|$texfilepath/$file|;}
                                           ^----  should be  ${dd}
>       &fall_back_to_latex_image($src,$origcall,$save); }
>     # --------------------------------------------------
>     # We'll work with the web image.

Since the  &find_file  subroutine searches all the directories in the
argument that has been fed with  $GRAPHICS_PATH , it is better to add
paths in this argument rather than adjust the $file name.


> This fixes my problem.
> 
> Is this useful to anyone? Not sure if I have made a "safe" change,
> advice on consequence or a better place to put it would be appreciated!

The change is safe enough for your own use, but not for distribution
to all other platforms and Perl versions.
It's also not clear to me why it is necessary, as other mechanisms
are already available.


Hope this helps,

	Ross Moore

 
> Thanks,
> 
> Martin
> --
> Dr. M.J. Reed                               Room:          4SB.6.15
> Dept. Electronic Systems Engineering         Tel:+44 (0)1206 872479
> University of Essex, Colchester CO4 3SQ, UK  FAX:+44 (0)1206 872900
> mailto:mjreed@essex.ac.uk    Web: http://esewww.essex.ac.uk/~mjreed
> _______________________________________________
> latex2html mailing list
> latex2html@tug.org
> http://tug.org/mailman/listinfo/latex2html