--- loncom/xml/londefdef.pm	2006/09/19 10:57:11	1.337
+++ loncom/xml/londefdef.pm	2006/11/06 11:39:02	1.341
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.337 2006/09/19 10:57:11 foxr Exp $
+# $Id: londefdef.pm,v 1.341 2006/11/06 11:39:02 foxr Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -1228,6 +1228,8 @@ sub start_br {
 	    $currentstring .= ' \vskip 0 mm ';
 	} elsif ($$tagstack[-2] ne 'sub' && $$tagstack[-2] ne 'sup') {
 	    $currentstring .= '\strut \\\\ \strut ';
+	} else {                   # Honor break in simple <sup></sup>
+	    $currentstring .= '}} \strut \\\\ \strut \ensuremath{^{'; 
 	}
     }
     return $currentstring;
@@ -1989,7 +1991,13 @@ sub start_table {
         $Apache::londefdef::table[-1]{'minlen'}=[];
         $Apache::londefdef::table[-1]{'content'}=[];
         $Apache::londefdef::table[-1]{'align'}=[];
-        $currentstring.='\keephidden{NEW TABLE ENTRY}';
+	if (&is_inside_of($tagstack, 'sup')) {
+	    $currentstring .= '}} \\\\ \ensuremath{^{ ';
+	}
+	if (&is_inside_of($tagstack, 'sub')) {
+	    $currentstring .= '}} \\\\ \ensuremath{_{ ';
+	}
+        $currentstring.=' \keephidden{NEW TABLE ENTRY}';
 
 
     }
@@ -2844,6 +2852,7 @@ sub start_img {
 	#if original gif/jpg/png file exist do following:
 	my $origsrc=$src;
 	my ($path,$file) = &get_eps_image($src);
+	# &Apache::lonnet::logthis("Image source: $src result: $path $file");
 	$src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
 	&Apache::lonxml::debug("path = $path file = $file src = $src");
 	if (-e $src) {
@@ -2857,6 +2866,13 @@ sub start_img {
 	    my $size;
 	    if ($width_param)  { $size.='width='.$width_param.' mm,'; }
 	    if ($height_param) { $size.='height='.$height_param.' mm]'; }
+	    # Default size if not able to extract that (e.g. eps image).
+	    
+	    # &Apache::lonnet::logthis("Size = $size");
+	    if ($size eq "0 mm") {
+		$size = "50 mm]";     # Default to 1 column width for 2 column.
+	    }
+	    
 	    $size='['.$size;
 	    $size=~s/,$/]/; 
 	    $currentstring .= '\graphicspath{{'.$destpath.'}}'
@@ -3412,6 +3428,9 @@ sub start_blockquote {
     if ($target eq 'web' || $target eq 'webgrade') {
 	$currentstring .= $token->[4];     
     } 
+    if ($target eq 'tex') {
+	$currentstring .= '\begin{quote}';
+    }
     return $currentstring;
 }
 
@@ -3421,6 +3440,9 @@ sub end_blockquote {
     if ($target eq 'web' || $target eq 'webgrade') {
 	$currentstring = $token->[2];    
     } 
+    if ($target eq 'tex') {
+	$currentstring = '\end{quote}';
+    }
     return $currentstring;
 }
 
@@ -4226,6 +4248,7 @@ sub get_eps_image {
     $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
     &Apache::lonxml::debug("Filelocation gives: $src");
     if (! -e $src) {
+	# &Apache::lonnet::logthis("$src does not exist...repcopying");
 	&Apache::lonxml::debug("$src does not exist");
 	if (&Apache::lonnet::repcopy($src) ne 'ok' ) {
 	    &Apache::lonxml::debug("Repcopy of $src failed (1)");
@@ -4237,6 +4260,7 @@ sub get_eps_image {
 	    &Apache::lonxml::debug("repcopy of $src ... $didrepcopy");
 	    if ( (not -e $src) ||
 		($didrepcopy ne 'ok')) {
+		# &Apache::lonnet::logthis("queuing $orig_src for dynamic eps gen");
 		&Apache::lonxml::debug("Failed to find or replicate $src");
 
 		#if replication failed try to produce eps file dynamically
@@ -4253,8 +4277,24 @@ sub get_eps_image {
 		if ($sext ne "") {	 # Put the ext. back in to uniquify.
 		    $src =~ s/\.eps$/$sext.eps/;
 		}
+
 	    }
 	}
+    } else {
+# 	&Apache::lonnet::logthis("$src exists. queueing for copy.");
+# 	&Apache::lonnet::logthis("Got eps already.. queue for copy");
+	# If the postscript file has spaces in its name,
+	# LaTeX will gratuitiously vomit.  Therefore
+	# queue such files for copy with " " replaced by "_".
+	# printout.pm will know them by their .ps  or .eps extensions.
+	my $newsrc = $orig_src;
+	$newsrc    =~  s|(.*)/res/|/home/httpd/html/res/|;
+	open(FILE,">>/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.dat");
+#	&Apache::lonnet::logthis("Queueing $newsrc for copy");
+	print FILE "$newsrc\n";
+	close FILE;
+	$src=~s|/home/httpd/html/res|/home/httpd/prtspool|;
+	$src=~s|/home/([^/]*)/public_html/|/home/httpd/prtspool/$1/|;
     }
     my ($path,$file)=($src=~m|(.*)/([^/]*)$|);
     &Apache::lonxml::debug("get_eps_image returning: $path / $file<BR />");