--- loncom/interface/lonprintout.pm	2005/01/05 12:07:27	1.350
+++ loncom/interface/lonprintout.pm	2005/01/10 11:46:03	1.351
@@ -1,7 +1,7 @@
 #  The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.350 2005/01/05 12:07:27 foxr Exp $
+# $Id: lonprintout.pm,v 1.351 2005/01/10 11:46:03 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1014,8 +1014,10 @@ ENDPART
 	my $flag_latex_header_remove = 'NO';
 	my $flag_page_in_sequence = 'NO';
 	my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'};
-	my @page_breaks = split /\|\|\|/, $helper->{'VARS'}->{'FINISHPAGE'};
-	my $page_index = 0;
+	my %page_breaks;
+	foreach my $break (split /\|\|\|/, $helper->{'VARS'}->{'FINISHPAGE'}) {
+	    $page_breaks{$break} = 1;
+	}
 	my $prevassignment='';
 	&Apache::lonnet::delenv('form.counter');
 	&Apache::lonxml::init_counter();
@@ -1024,8 +1026,7 @@ ENDPART
 	    # Note due to document structure, not allowed to put \newpage
 	    # prior to the first resource
 
-	    if (($master_seq[$i] eq $page_breaks[$page_index])) {
-		$page_index++;
+	    if (defined $page_breaks{$master_seq[$i]}) {
 		if($i != 0) {
 		    $result.="\\newpage\n";
 		}
@@ -1425,23 +1426,20 @@ sub print_resources {
 	$namepostfix="\\\\Name: ";
 	$fullname = "CODE - ".$moreenv->{'CODE'};
     }
-    my @page_breaks = split /\|\|\|/,$helper->{'VARS'}->{'FINISHPAGE'};
-    my $page_index  = 0;
+    my %page_breaks;
+    foreach my $break (split /\|\|\|/,$helper->{'VARS'}->{'FINISHPAGE'}) {
+	$page_breaks{$break} = 1;
+    }
     my $i           = 0;
     #goes through all resources, checks if they are available for 
     #current student, and produces output   
     &Apache::lonnet::delenv('form.counter');
     &Apache::lonxml::init_counter();
     foreach my $curresline (@{$master_seq})  {
-	if ($curresline eq $page_breaks[$page_index]) {
-	    #
-	    #  Due to document structure, we cannot put a 
-	    #  page break prior to the first document
-	    #
+	if (defined $page_breaks{$curresline}) {
 	    if($i != 0) {
 		$current_output.= "\\newpage\n";
 	    }
-	    $page_index++;
 	}
 	$i++;
 	if ( !($type eq 'problems' &&