--- loncom/xml/londefdef.pm	2006/12/05 02:55:54	1.345
+++ loncom/xml/londefdef.pm	2007/01/17 10:09:26	1.351
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.345 2006/12/05 02:55:54 albertel Exp $
+# $Id: londefdef.pm,v 1.351 2007/01/17 10:09:26 foxr Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -1559,17 +1559,6 @@ sub start_a {
 	my $href=&Apache::lonxml::get_param('href',$parstack,$safeeval,
 					    undef,1);
 	$currentstring=&Apache::lonenc::encrypt_ref($token,{'href'=>$href});
-    } elsif ($target eq 'tex') {
-	my $a=&Apache::lonxml::get_param('href',$parstack,$safeeval,undef,1);
-	my $b=&Apache::lonxml::get_param('name',$parstack,$safeeval,undef,1);
-	if ($a=~/\S/) {
-	    $a=~s/([^\\])%/$1\\\%/g;
-	    $currentstring .= '\ref{URI: '.$a.'}';
-	} elsif ($b=~/\S/) {
-	    $currentstring .= '\ref{Anchor: '.$b.'}';
-	} else {
-	    $currentstring.='';
-	}
     }
     return $currentstring;
 }
@@ -1580,6 +1569,18 @@ sub end_a {
     if ($target eq 'web' || $target eq 'webgrade') {
 	$currentstring .= $token->[2];
     }
+    if ($target eq 'tex') {
+	my $a=&Apache::lonxml::get_param('href',$parstack,$safeeval,undef,1);
+	my $b=&Apache::lonxml::get_param('name',$parstack,$safeeval,undef,1);
+	if ($a=~/\S/) {
+	    $a=~s/([^\\])%/$1\\\%/g;
+	    $currentstring .= ' ({\tt URI:'.&Apache::lonxml::latex_special_symbols($a).'})';
+	} elsif ($b=~/\S/) {
+	    $currentstring .= ' ({\tt Anchor:'.&Apache::lonxml::latex_special_symbols($b).'})';
+	} else {
+	    $currentstring.='';
+	}	
+    }
     return $currentstring;
 }
 
@@ -2251,6 +2252,12 @@ sub end_table {
 		    }
 		    $have_rowspan++;
 		    $output .= '\multirow{'.$rowspan.'}[0]{*}{';
+		    
+		    $Apache::londefdef::table[-1]{'content'}[$in][$jn] =~
+			s{^\s*\\par\s*}{};
+		    $Apache::londefdef::table[-1]{'content'}[$in][$jn] =~
+			s{\s*\\vskip\s*0pt\s*$}{};
+
 		    #
 		    # If we did not throw in a multicolumn to align, then add 
 		    # an extra {
@@ -2887,17 +2894,26 @@ sub start_img {
 	    } elsif ($align eq "left")   { 
 		if ($latex_rendering eq "parpic") { 
 		    $currentstring = '\parpic[l]{'.$currentstring.'}';
-		} else {    	                                 # wrapfig render
-		    $currentstring = '\begin{wrapfigure}{l}{'.$width_param.'mm}'
+		} elsif ($latex_rendering eq "parbox") {
+		    $currentstring = '\begin{minipage}[l]{'.$width_param.'mm}'
+			.$currentstring.'\end{minipage}';
+		} elsif ($latex_rendering eq "wrapfigure"
+			 || $latex_rendering ne 'none') {  # wrapfig render
+		    $currentstring = 
+			'\begin{wrapfigure}{l}{'.$width_param.'mm}'
 			.'\scalebox{1.0}{'.$currentstring.'}\end{wrapfigure}';
 		}
 	    } elsif ($align eq "right")  {   
 		if ($latex_rendering eq "parpic") {
 		    $currentstring = '\parpic[r]{'.$currentstring.'}';
-		} else {	                                 # wrapfig rendering
-		    $currentstring = '\begin{wrapfigure}{r}{'.$width_param.'mm}'
+		} elsif ($latex_rendering eq "parbox") {
+		    $currentstring =  '\begin{minipage}[r]{'.$width_param.'mm}'
+			.$currentstring.'\end{minipage}';
+		} elsif ($latex_rendering eq "wrapfigure"
+			 || $latex_rendering ne 'none') {  # wrapfig render
+		    $currentstring = 
+			'\begin{wrapfigure}{r}{'.$width_param.'mm}'
 			.'\scalebox{1.0}{'.$currentstring.'}\end{wrapfigure}';
-
 		}
 	    } else {		# Bottom is also default.
 		# $currentstring = '\raisebox{'.$height_param.'mm}{'.$currentstring.'}';
@@ -2929,7 +2945,7 @@ sub start_img {
 	$currentstring .=&Apache::edit::select_arg('Alignment:','align',
 						   ['','bottom','middle','top','left','right'],$token,5);
 	$currentstring .=&Apache::edit::select_arg('TeXwrap:', 'TeXwrap',
-						   ['', 'parbox', 'parpic'], $token, 2);
+						   ['', 'none','parbox', 'parpic', 'wrapfigure'], $token, 2);
 	$currentstring .=&Apache::edit::select_arg('Encrypt URL:','encrypturl',
 						   ['no','yes'], $token, 2);
 	$currentstring .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();