[LON-CAPA-cvs] cvs: loncom(version_2_9_X) /interface lonprintout.pm

raeburn raeburn@source.lon-capa.org
Tue, 11 May 2010 12:22:10 -0000


raeburn		Tue May 11 12:22:10 2010 EDT

  Modified files:              (Branch: version_2_9_X)
    /loncom/interface	lonprintout.pm 
  Log:
  - Backport 1.574, 1.575.
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.568.2.4 loncom/interface/lonprintout.pm:1.568.2.5
--- loncom/interface/lonprintout.pm:1.568.2.4	Thu Apr  1 23:38:26 2010
+++ loncom/interface/lonprintout.pm	Tue May 11 12:22:10 2010
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.568.2.4 2010/04/01 23:38:26 raeburn Exp $
+# $Id: lonprintout.pm,v 1.568.2.5 2010/05/11 12:22:10 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -306,11 +306,16 @@
 
     my ($text) = @_;
 
-    $text =~ s/\\begin{document}/\\begin{document}{\\$font_size/;
-    $text =~ s/\\end{document}/}\\end{document}/;
-    return $text;
+    # There appear to be cases where the font directive is empty.. in which
+    # case the first substituion would  insert a spurious \ oh happy day.
+    # as this has been the cause of much mystery and hair pulling _sigh_
 
+    if ($font_size ne '') {
 
+        $text =~ s/\\begin{document}/\\begin{document}{\\$font_size/;
+    }
+    $text =~ s/\\end{document}/}\\end{document}/;
+    return $text;
 }
 
 # include_pdf - PDF files are included into the 
@@ -1283,7 +1288,13 @@
 	    $text =~ s/\\pagestyle{fancy}\\rhead{}\\chead{}\s*\\begin{document}/\\textheight = $textheight\\oddsidemargin = $evenoffset\n\\evensidemargin = $evenoffset $topmargintoinsert\\textwidth= $textwidth\\newlength{\\minipagewidth}\n\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\pagestyle{fancy}\\rhead{}\\chead{}\\usepackage{booktabs}\\begin{document}\\voffset=-0\.8cm\n\\setcounter{page}{1}  \\vskip 5 mm\n /;
 	}
 	if ($papersize eq 'a4') {
-	    $text =~ s/(\\begin{document})/$1\\\\special\{papersize=210mm,297mm\}/;
+            my $papersize_text;
+            if ($perm{'pav'}) {
+                $papersize_text = '\\special{papersize=210mm,297mm}';
+            } else {
+                $papersize_text = '\special{papersize=210mm,297mm}';
+            }
+            $text =~ s/(\\begin{document})/$1$papersize_text/;
 	}
     }
     if ($tableofcontents eq 'yes') {$text=~s/(\\setcounter\{page\}\{1\})/$1 \\tableofcontents\\newpage /;}