--- loncom/interface/lonprintout.pm	2002/07/22 20:04:16	1.40
+++ loncom/interface/lonprintout.pm	2002/07/26 18:40:43	1.43
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.40 2002/07/22 20:04:16 sakharuk Exp $
+# $Id: lonprintout.pm,v 1.43 2002/07/26 18:40:43 sakharuk Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -284,7 +284,7 @@ ENDPART
 	$first_comment = index($result,'<!--',$first_comment);
     }
     $result =~ s/^\s+$//gm; #remove empty lines
-    $result =~ s/%/\\%/g;   #corrects %
+    $result =~ s/([^\\])%/\$1\%/g;   #corrects %
     $result =~ s/(\s)+/$1/g; #removes more than one empty space
     $result =~ s/\\\\\s*\\vskip/\\vskip/gm;
     $result =~ s/ (<|>|) / \$$1\$ /g; #corrects < or >
@@ -292,11 +292,13 @@ ENDPART
     $result =~ s/{\\par }\s*\\\\/\\\\/gm;
 	$result =~ s/\\\\\s+\[/ \[/g;
     $result =~ s/&#952;/\$\\theta\$/g; #converts theta from html into tex
-    $result =~ s/\b_+\b/\\makebox\[1 cm\]\[b\]{\\hrulefill}/g;
+    $result =~ s/\b__+\b/\\makebox\[1 cm\]\[b\]{\\hrulefill}/g;
     #conversion of html characters to LaTeX equivalents
     if ($result =~ m/&(\w+|#\d+);/) {
 	$result = &character_chart($result);
     }
+    $result =~ s/(\\end{tabular})\s*\\vskip 0 mm/$1/g;
+    $result =~ s/(\\begin{enumerate})\s*\\noindent/$1/g;
 #-- writing .tex file in prtspool 
     my $temp_file;
     my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout_".time."_".rand(10000000).".tex";
@@ -314,6 +316,7 @@ FINALEND
 
 sub character_chart {
     my $result = shift;	
+    $result =~ s/&#0?0?7;//g;
     $result =~ s/&#0?0?9;//g;
     $result =~ s/&#0?10;//g;
     $result =~ s/&#0?13;//g;
@@ -472,8 +475,8 @@ sub character_chart {
 #    $result =~ s/&reg;//g;
 #    $result =~ s/&#175;//g;
 #    $result =~ s/&macr;//g;
-    $result =~ s/&#176;/\$^\\{\\circ\\}\$/g;
-    $result =~ s/&deg;/\$^\\{\\circ\\}\$/g;
+    $result =~ s/&#176;/\$^{\\circ}\$/g;
+    $result =~ s/&deg;/\$^{\\circ}\$/g;
     $result =~ s/&#177;/\$\\pm\$/g;
     $result =~ s/&plusmn;/\$\\pm\$/g;
     $result =~ s/&#178;/\$^2\$/g;
@@ -635,6 +638,9 @@ sub character_chart {
     return $result;
 }
 
+
+#'"`
+
 sub additional_cleanup {
     my $result = shift;	
     my $first_app = index($result,'\documentclass',0);