I am trying to use NotebookWrite to paste a plot into another notebook. The code looks something like:

ptemp = Show[Plot[x^2,{x,-2,2}],Plot[x^3,{x,-2,2}]]; nb = CreateDocument[]; NotebookWrite[nb,ptemp];

But when I run the code I get an error message: An unknown box name (Graphics) was sent as the BoxForm for the expression.

Is there any way to use NotebookWrite to insert a graphic? Does there exist any sort of wrapper for Graphics that would make it NotebookWrite-able?


1 Answer 1


Use :
NotebookWrite[nb, ToBoxes[ptemp]]

With NotebookWrite[], you must use boxes ("low-level-box-language"), not Graphics (which belongs to normal Mathematica language, like nearly everything). The "box-language" is what you see when you type ctrl-shift-E on a cell. ToBoxes transforms pTemp to a box. NotebookWrite[] inserts automatically the data (the box) in a Cell[] (see doc) and inserts the Cell[..data..] in the notebook.

  • $\begingroup$ +1, and it's good to note explicitly that this applies to everything, not just graphics. Everything needs to be converted to boxes before using them in NotebookWrite. $\endgroup$
    – Szabolcs
    Apr 26, 2013 at 19:22
  • $\begingroup$ @Szabolcs Thanks. I have improved my answer. Hope it's clear. $\endgroup$
    – andre314
    Apr 26, 2013 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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