--- loncom/xml/londefdef.pm	2004/07/20 15:05:32	1.231
+++ loncom/xml/londefdef.pm	2004/08/20 18:43:36	1.235
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.231 2004/07/20 15:05:32 sakharuk Exp $
+# $Id: londefdef.pm,v 1.235 2004/08/20 18:43:36 sakharuk Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -154,7 +154,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}$}'.
@@ -176,10 +176,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;
 }
@@ -1134,13 +1134,15 @@ sub end_p {
 	$currentstring .= $token->[2];
     } elsif ($target eq 'tex') {
 	my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1);
-	if ($align eq 'center') {		
+	if (not defined $align) {
+	    $currentstring.='\strut\\\\\strut ';
+	} elsif ($align eq 'center') {		
 	    $currentstring .= '\end{center}';
 	} elsif ($align eq 'right') {
 	    $currentstring .= '}}';
 	} elsif ($align eq 'left') {
 	    $currentstring .= '}\hfill}';
-	}
+	} 
     }
     return $currentstring;
 }
@@ -2420,8 +2422,13 @@ sub start_img {
     } elsif ($target eq 'tex') {
 	$src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
         #if uploaded restore the path
+	my $old_src=$src;
 	if ($src=~/^\/uploaded\/([^\/]+)\/([^\/]+)\/simplepage\/([^\/]+)$/) {
 	    $src=&Apache::loncommon::propath($1,$2).'/userfiles/simplepage/'.$3;
+	    if (not -e $src) {
+		$old_src=~/^\/uploaded\/(.*)$/;
+		$src=$Apache::lonnet::perlvar{'lonDocRoot'}.'/userfiles/'.$1;
+	    }
 	} elsif ($src=~/^\/uploaded\/([^\/]+)\/([^\/]+)\/aboutme\/([^\/]+)$/) {
 	    $src=&Apache::loncommon::propath($1,$2).'/userfiles/aboutme/'.$3;
 	}
@@ -2477,6 +2484,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);
@@ -2490,7 +2499,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)=