--- loncom/xml/londefdef.pm	2003/05/22 16:00:53	1.135
+++ loncom/xml/londefdef.pm	2003/06/27 14:01:19	1.145
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.135 2003/05/22 16:00:53 sakharuk Exp $
+# $Id: londefdef.pm,v 1.145 2003/06/27 14:01:19 albertel Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -157,8 +157,9 @@ sub start_html {
 	    &Apache::lonxml::fontsettings();     
     } elsif ($target eq 'tex') {
 	@Apache::londefdef::table = ();
-	$currentstring .= '\documentclass[letterpaper]{article}
-                           \newcommand{\keephidden}[1]{}
+	$currentstring .= '\documentclass[letterpaper]{article}'.
+                           #'\batchmode'.
+                           '\newcommand{\keephidden}[1]{}
                            \renewcommand{\deg}{$^{\circ}$}
                            \usepackage{textcomp}
                            \usepackage[dvips]{graphicx}
@@ -501,9 +502,7 @@ sub start_center {
 	$currentstring = $token->[4];     
     } elsif ($target eq 'tex') {
 	$currentstring = '\begin{center}';  
-    }  elsif ($target eq 'latexsource') {
-	$currentstring = '\begin{center}';  
-    } 
+    }
     return $currentstring;
 }
 
@@ -514,9 +513,7 @@ sub end_center {
 	$currentstring = $token->[2];     
     } elsif ($target eq 'tex') {
 	$currentstring = '\end{center}';  
-    }  elsif ($target eq 'latexsource') {
-	$currentstring = '\end{center}';  
-    } 
+    }
     return $currentstring;
 }
 
@@ -528,8 +525,6 @@ sub start_b {
 	$currentstring = $token->[4];     
     } elsif ($target eq 'tex') {
 	$currentstring = '\textbf{';  
-    }  elsif ($target eq 'latexsource') {
-	$currentstring = '\textbf{';  
     } 
     return $currentstring;
 }
@@ -541,8 +536,6 @@ sub end_b {
 	$currentstring = $token->[2];     
     } elsif ($target eq 'tex') {
 	$currentstring = '}';  
-    } elsif ($target eq 'latexsource') {
-	$currentstring = '}';  
     } 
     return $currentstring;
 }
@@ -555,8 +548,6 @@ sub start_strong {
 	$currentstring = $token->[4];     
     } elsif ($target eq 'tex') {
 	$currentstring = '\textbf{';  
-    } elsif ($target eq 'latexsource') {
-	$currentstring = '\textbf{';  
     } 
     return $currentstring;
 }
@@ -569,9 +560,7 @@ sub end_strong {
 	$currentstring = $token->[2];     
     } elsif ($target eq 'tex') {
 	$currentstring = '}';  
-    }  elsif ($target eq 'latexsource') {
-	$currentstring = '}';  
-    } 
+    }
     return $currentstring;
 }
 
@@ -847,9 +836,7 @@ sub start_cite {
 	$currentstring .= $token->[4];
     } elsif ($target eq 'tex') {
 	$currentstring .= "\\textit{";
-    }  elsif ($target eq 'latexsource') {
-	$currentstring .= "\\textit{";
-    } 
+    }
     return $currentstring;
 }
 
@@ -860,9 +847,7 @@ sub end_cite {
 	$currentstring .= $token->[2];
     } elsif ($target eq 'tex') {
 	$currentstring .= "}";
-    }  elsif ($target eq 'latexsource') {
-	$currentstring .= "}";
-    } 
+    }
     return $currentstring;
 }
 
@@ -874,9 +859,7 @@ sub start_i {
 	$currentstring .= $token->[4];
     } elsif ($target eq 'tex') {
 	$currentstring .= '\textit{';
-    }  elsif ($target eq 'latexsource') {
-	$currentstring .= '\textit{';
-    } 
+    }
     return $currentstring;
 }
 
@@ -887,8 +870,6 @@ sub end_i {
 	$currentstring .= $token->[2];
     } elsif ($target eq 'tex') {
 	$currentstring .= '}';
-    } elsif ($target eq 'latexsource') {
-	$currentstring .= '}';
     } 
     return $currentstring;
 }
@@ -901,9 +882,7 @@ sub start_address {
 	$currentstring .= $token->[4];
     } elsif ($target eq 'tex') {
 	$currentstring .= "\\textit{";
-    } elsif ($target eq 'latexsource') {
-	$currentstring .= "\\textit{";
-    } 
+    }
     return $currentstring;
 }
 
@@ -914,8 +893,6 @@ sub end_address {
 	$currentstring .= $token->[2];
     } elsif ($target eq 'tex') {
 	$currentstring .= "}";
-    } elsif ($target eq 'latexsource') {
-	$currentstring .= "}";
     }
     return $currentstring;
 }
@@ -928,8 +905,6 @@ sub start_dfn {
 	$currentstring .= $token->[4];
     } elsif ($target eq 'tex') {
 	$currentstring .= "\\textit{";
-    } elsif ($target eq 'latexsource') {
-	$currentstring .= "\\textit{";
     } 
     return $currentstring;
 }
@@ -941,9 +916,7 @@ sub end_dfn {
 	$currentstring .= $token->[2];
     } elsif ($target eq 'tex') {
 	$currentstring .= "}";
-    } elsif ($target eq 'latexsource') {
-	$currentstring .= "}";
-    } 
+    }
     return $currentstring;
 }
 
@@ -955,9 +928,7 @@ sub start_tt {
 	$currentstring .= $token->[4];
     } elsif ($target eq 'tex') {
 	$currentstring .= '\texttt{';
-    } elsif ($target eq 'latexsource') {
-	$currentstring .= '\texttt{';
-    } 
+    }
     return $currentstring;
 }
 
@@ -968,8 +939,6 @@ sub end_tt {
 	$currentstring .= $token->[2];
     } elsif ($target eq 'tex') {
 	$currentstring .= '}';
-    } elsif ($target eq 'latexsource') {
-	$currentstring .= '}';
     }
     return $currentstring;
 }
@@ -982,9 +951,7 @@ sub start_kbd {
 	$currentstring .= $token->[4];
     } elsif ($target eq 'tex') {
 	$currentstring .= "\\texttt";
-    } elsif ($target eq 'latexsource') {
-	$currentstring .= "\\texttt{";
-    } 
+    }
     return $currentstring;
 }
 
@@ -995,9 +962,7 @@ sub end_kbd {
 	$currentstring .= $token->[2];
     } elsif ($target eq 'tex') {
 	$currentstring .= "}";
-    } elsif ($target eq 'latexsource') {
-	$currentstring .= "}";
-    } 
+    }
     return $currentstring;
 }
 
@@ -1032,9 +997,7 @@ sub start_em {
 	$currentstring .= $token->[4];
     } elsif ($target eq 'tex') {
 	$currentstring .= '\emph{';
-    } elsif ($target eq 'latexsource') {
-	$currentstring .= '\emph{';
-    } 
+    }
     return $currentstring;
 }
 
@@ -1045,9 +1008,7 @@ sub end_em {
 	$currentstring .= $token->[2];
     } elsif ($target eq 'tex') {
 	$currentstring .= '}';
-    } elsif ($target eq 'latexsource') {
-	$currentstring .= '}';
-    }  
+    } 
     return $currentstring;
 }
 
@@ -1059,8 +1020,6 @@ sub start_q {
 	$currentstring .= $token->[4];
     } elsif ($target eq 'tex') {
 	$currentstring .= "\\emph{";
-    }  elsif ($target eq 'latexsource') {
-	$currentstring .= "\\emph{";
     }
     return $currentstring;
 }
@@ -1072,9 +1031,7 @@ sub end_q {
 	$currentstring .= $token->[2];
     } elsif ($target eq 'tex') {
 	$currentstring .= "}";
-    } elsif ($target eq 'latexsource') {
-	$currentstring .= "}";
-    }  
+    } 
     return $currentstring;
 }
 
@@ -1085,10 +1042,8 @@ sub start_p {
     if ($target eq 'web') {
 	$currentstring .= $token->[4];
     } elsif ($target eq 'tex') {
-	$currentstring .= '{\par ';
-    } elsif ($target eq 'latexsource') {
-	$currentstring .= '{\par ';
-    } 
+	$currentstring .= '\par ';
+    }
     return $currentstring;
 }
 
@@ -1097,10 +1052,6 @@ sub end_p {
     my $currentstring = '';
     if ($target eq 'web') {
 	$currentstring .= $token->[2];
-    } elsif ($target eq 'tex') {
-	$currentstring .= '}';
-    } elsif ($target eq 'latexsource') {
-	$currentstring .= '}';
     }
     return $currentstring;
 }
@@ -1115,9 +1066,7 @@ sub start_br {
 	if ($$tagstack[-2] ne 'sub' && $$tagstack[-2] ne 'sup') {
 	    $currentstring .= '\vskip 0.2 mm';
 	}
-    } elsif ($target eq 'latexsource') {
-	$currentstring .= '\\';
-    } 
+    }
     return $currentstring;
 }
 
@@ -1137,10 +1086,8 @@ sub start_big {
     if ($target eq 'web') {
 	$currentstring .= $token->[4];
     } elsif ($target eq 'tex') {
-	$currentstring .= '\large{';
-    } elsif ($target eq 'latexsource') {
-	$currentstring .= '{\Large ';
-    }  
+	$currentstring .= '{\large ';
+    } 
     return $currentstring;
 }
 
@@ -1151,8 +1098,6 @@ sub end_big {
 	$currentstring .= $token->[2];
     } elsif ($target eq 'tex') {
 	$currentstring .= '}';
-    } elsif ($target eq 'latexsource') {
-	$currentstring .= '}';
     }
     return $currentstring;
 }
@@ -1165,9 +1110,7 @@ sub start_small {
 	$currentstring .= $token->[4];
     } elsif ($target eq 'tex') {
 	$currentstring .= '{\footnotesize ';
-    } elsif ($target eq 'latexsource') {
-	$currentstring .= '{\footnotesize ';
-    } 
+    }
     return $currentstring;
 }
 
@@ -1178,8 +1121,6 @@ sub end_small {
 	$currentstring .= $token->[2];
     } elsif ($target eq 'tex') {
 	$currentstring .= '}';
-    } elsif ($target eq 'latexsource') {
-	$currentstring .= '}';
     }
     return $currentstring;
 }
@@ -1700,11 +1641,11 @@ sub end_dd {
 #-- <table> tag
 sub start_table {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
-    my $textwidth;
+    my $textwidth='';
     if (not defined @Apache::londefdef::table) {
 	$textwidth=&recalc($ENV{'form.textwidth'});
-	$textwidth=~/(\d+)/;
-	$textwidth=$1;
+	$textwidth=~/(\d+\.?\d*)/;
+	$textwidth=0.95*$1;
     } else {
 	$textwidth=&Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);
     }
@@ -1746,7 +1687,7 @@ sub start_table {
 	    $Apache::londefdef::table[-1]{'vvinc'} = '';
 	}
 	$Apache::londefdef::table[-1]{'output'} = ' \noindent \begin{tabular} ';
-	$currentstring = '\keephidden{NEW TABLE ENTRY '.$textwidth.'}';
+	$currentstring = '\keephidden{NEW TABLE ENTRY}';
     }
     return $currentstring;
 }
@@ -1824,6 +1765,7 @@ sub end_table {
 	} else {
 	    $currentstring .= $Apache::londefdef::table[-1]{'output'};
 	    pop @Apache::londefdef::table;
+	    undef @Apache::londefdef::table;
 	}
     }
     return $currentstring;
@@ -1911,7 +1853,7 @@ sub end_td {
 		$Apache::londefdef::table[-1]{'TeXlength'} .= '0,';
 	    }        
 	}
-	for (my $in=0; $in<=$#{$Apache::londefdef::table[-1]{'include'}};$in++) {                                
+	for (my $in=0; $in<=$#{$Apache::londefdef::table[-1]{'include'}};$in++) {         
 	    $data=~s/\\keephidden\{NEW TABLE ENTRY\}/$Apache::londefdef::table[-1]{'include'}[$in]/;
 	}
 	@{ $Apache::londefdef::table[-1]{'rowdata'} }[$current_row] .= '\parbox{TOBECHANGEDONNUMBER}{'.$data.'} '.$Apache::londefdef::table[-1]{'vinc'};
@@ -2198,7 +2140,8 @@ sub start_allow {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
     my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1);
     $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
-    $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=$src;
+    $Apache::lonxml::extlinks[$#Apache::lonxml::extlinks+1]=
+	&Apache::lonnet::clutter($src);
     &image_replication($src);
     my $result;
     if ($target eq 'edit') {
@@ -2271,9 +2214,7 @@ sub start_pre {
     if ($target eq 'web') {
 	$currentstring .= $token->[4];
     } elsif ($target eq 'tex') {
-	my $width = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);
-	if (not defined $width) {$width ='\textwidth';}
-	$currentstring .= '\parbox['.$width.']{\begin{verbatim}';
+	$currentstring .= '\begin{verbatim}';
     } 
     return $currentstring;
 }
@@ -2284,7 +2225,7 @@ sub end_pre {
     if ($target eq 'web') {
 	$currentstring .= $token->[2];
     } elsif ($target eq 'tex') {
-	$currentstring .= '\end{verbatim}}';
+	$currentstring .= '\end{verbatim}';
     }
     return $currentstring;
 }