--- loncom/interface/lonprintout.pm 2009/11/16 11:13:24 1.564 +++ loncom/interface/lonprintout.pm 2009/11/17 11:32:23 1.565 @@ -2,7 +2,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.564 2009/11/16 11:13:24 foxr Exp $ +# $Id: lonprintout.pm,v 1.565 2009/11/17 11:32:23 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -499,8 +499,11 @@ sub printf_style_subst { sub format_page_header { my ($width, $format, $assignment, $course, $student, $section) = @_; - + + $width = &recalcto_mm($width); # Get width in mm. + my $chars_per_line = int($width/1.6); # Character/textline. + # Default format? if ($format eq '') { @@ -514,9 +517,8 @@ sub format_page_header { # but only truncate the course. # - Allow the assignment to be 2 lines (wrapped). # - my $chars_per_line = $width/2; # Character/textline. - + my $name_length = int($chars_per_line *3 /4); my $sec_length = int($chars_per_line / 5); @@ -552,7 +554,19 @@ sub format_page_header { my $testPrintout = '\\\\'.&mt('Construction Space').' \\\\'.&mt('Test-Printout '); $format =~ s/\\\\\s\\\\\s/$testPrintout/; } - + # + # We're going to trust LaTeX to break lines appropriately, but + # we'll truncate anything that's more than 3 lines worth of + # text. This is also assuming (which will probably end badly) + # nobody's going to embed LaTeX control sequences in the title + # header or rather that those control sequences won't get broken + # by the stuff below. + # + my $total_length = 3*$chars_per_line; + if (length($format) > $total_length) { + $format = substr($format, 0, $total_length); + } + return $format;