I have a number of lecture notebooks that I publish to Dropbox in PDF format. It's been working great for years, but something seems to have gone wrong in the latest version of Mathematica. My code for printing my notebooks to PDFs is something similar to the following.

 NotebookOpen[NotebookDirectory[] <> ToString[i] <> ".nb"]; 
  "/Users/michaelmccain/Desktop/" <> ToString[i] <> ".pdf"];
 , {i, 1, 10}]

Note: I have ten notebooks named 1.nb, 2.nb, ...10.nb in the current directly when I execute this function.

This function works as it is suppose to so long as my notebooks contain no or little graphics. If more than a couple graphics are in one of the notebooks then the loop stops at that notebook and no more PDFs are printed. Interestingly, Mathematica does not freeze and I do not get a spinning wheel. Mathematica continue to work.

This problem is easily solved by removing the graphics from the notebook. Then the loop finishes and all files are published in PDF format. But I would like the graphics to stay in my PDF lectures. If I NotebookPrint[] each notebook individually... it also works, but this highly inefficient. Especially with 100 lecture notebooks that need to be published at once.

Is anyone else having this issue in Mathematica 11.1? I'd like to report it as a bug. But would like confirmation.

I am using MacOS 10.12

  • $\begingroup$ I think the loop is timing out because it has to wait to long for it to print to PDF. Is there a way to give each increment of the loop the time it needs to complete the task? $\endgroup$
    – B flat
    Jul 29, 2017 at 8:14
  • 1
    $\begingroup$ Have you tried Export instead of NotebookPrint? $\endgroup$ Jul 30, 2017 at 1:49
  • 1
    $\begingroup$ @AlexeyPopkov - Yes. It does not help. However, I just figured out what's going on and a solution. It appears that loops like Table[] will abort if the computation time in any iteration exceeds a certain amount. Wrapping AbortProtect[] fixes the problem. $\endgroup$
    – B flat
    Jul 30, 2017 at 2:04
  • $\begingroup$ That's very strange: Table never generate aborts! Probably abort is generated outside of Table. I suggest you to report this as possible bug. $\endgroup$ Jul 30, 2017 at 2:18
  • $\begingroup$ Yes. I think it may be. I had no problems using the same code in previous versions of Mathematica. $\endgroup$
    – B flat
    Jul 30, 2017 at 2:21

1 Answer 1


Using AbortProtect[] solves the problem.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.