--- loncom/xml/londefdef.pm	2004/09/15 20:30:43	1.231.2.3
+++ loncom/xml/londefdef.pm	2004/09/15 06:31:57	1.241
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.231.2.3 2004/09/15 20:30:43 albertel Exp $
+# $Id: londefdef.pm,v 1.241 2004/09/15 06:31:57 albertel Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -155,7 +155,7 @@ sub start_html {
 	    &Apache::lonxml::fontsettings();     
     } elsif ($target eq 'tex') {
 	@Apache::londefdef::table = ();
-	$currentstring .= '\documentclass[letterpaper]{article}';
+	$currentstring .= '\documentclass[letterpaper]{book}';
 	if ($ENV{'form.latex_type'}=~'batchmode') {$currentstring .='\batchmode';} 
 	$currentstring .= '\newcommand{\keephidden}[1]{}'.
                           '\renewcommand{\deg}{$^{\circ}$}'.
@@ -177,10 +177,10 @@ sub start_html {
 }
 
 sub end_html {
-    my ($target,$token) = @_;
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $currentstring = '';
     if ($target eq 'web') {
-	$currentstring = &Apache::lonxml::xmlend();
+	$currentstring = &Apache::lonxml::xmlend($target,$parser);
     }
     return $currentstring;
 }
@@ -2434,13 +2434,9 @@ sub start_img {
 	    $currentstring.='[IMAGE: '.$alttag.']';
 	}
     } elsif ($target eq 'tex') {
+	my $oldSRC=$src;
+        $oldSRC=~s/\.(gif|jpg|png)$/\.eps/;
 	$src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
-        #if uploaded restore the path
-	if ($src=~/^\/uploaded\/([^\/]+)\/([^\/]+)\/simplepage\/([^\/]+)$/) {
-	    $src=&Apache::loncommon::propath($1,$2).'/userfiles/simplepage/'.$3;
-	} elsif ($src=~/^\/uploaded\/([^\/]+)\/([^\/]+)\/aboutme\/([^\/]+)$/) {
-	    $src=&Apache::loncommon::propath($1,$2).'/userfiles/aboutme/'.$3;
-	}
 	#if original gif/jpg/png file exist do following:
 	if (-e $src) {
 	    #what is the image size?
@@ -2448,6 +2444,7 @@ sub start_img {
             my ($file,$path)=&file_path($src); 
 	    my $newsrc = $src;
 	    $newsrc =~ s/\.(gif|jpg|png)$/.eps/i;
+	    &Apache::lonnet::repcopy($oldSRC);
 	    $file=~s/\.(gif|jpg|png)$/.eps/i;
 	    #where can we find the picture?
 	    if (-e $newsrc) {
@@ -2493,6 +2490,8 @@ sub start_img {
 	$currentstring .=&Apache::edit::text_arg('height (pixel):','height',$token,5).'<br />';
 	$currentstring .=&Apache::edit::text_arg('TeXwidth (mm):','TeXwidth',$token,5);
 	$currentstring .=&Apache::edit::text_arg('TeXheight (mm):','TeXheight',$token,5);
+	$currentstring .=&Apache::edit::select_arg('Alignment:','align',
+						   ['','bottom','middle','top','left','right'],$token,5);
 	$currentstring .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
 	my $src=&Apache::lonxml::get_param('src',$parstack,$safeeval);
 	my $alt=&Apache::lonxml::get_param('alt',$parstack,$safeeval);
@@ -2506,7 +2505,7 @@ sub start_img {
 	my ($osrc,$owidth,$oheight)=
 	    ($token->[2]{'src'},$token->[2]{'width'},$token->[2]{'height'});
 	my $ctag=&Apache::edit::get_new_args($token,$parstack,
-					     $safeeval,'src','alt',
+					     $safeeval,'src','alt','align',
 					     'TeXwidth','TeXheight',
 					     'width','height');
 	my ($nsrc,$nwidth,$nheight)=
@@ -3714,7 +3713,11 @@ sub eps_generation {
 	$newsrc=~s/\/home\/httpd\/lonUsers//;
 	$newsrc=~s/\/([^\/]+)\/(\w)\/(\w)\/(\w)\//\/$1\//;
     }
-    return ' \graphicspath{{/home/httpd/prtspool'.$newsrc.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
+    if ($newsrc=~/\/userfiles\//) {
+	return ' \graphicspath{{'.$newsrc.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
+    } else {
+	return ' \graphicspath{{/home/httpd/prtspool'.$newsrc.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
+    }
 }
 
 sub file_path {