11
$\begingroup$

I would like to Export a Summary Box in its expanded Form. How do i do this? I can Export a collapsed Summary Box by doing:

result = ConvolutionLayer[4,8] (*which is a summary Box*)
Export["testFile.pdf", result]
$\endgroup$
  • $\begingroup$ Interactively you can expand the summary box and then right-click on the cell bracket and select "Save selection as", but it would be nice to be able to do that programmatically $\endgroup$ – Jason B. Feb 5 at 18:00
11
$\begingroup$

edit: simplified code and an explanation

I could bet I already answered that in the past but can't find. The solution works as follows:

What you see is a box expression (MakeBoxes[result of evaluation]) rendered by the FrontEnd. You can inspect it via Ctrl+Shift+E or by applying ToBoxes on your expression. The latter allows you to work with boxes and modify them.

After inspection we see that it is roughly DynamicModule[{open = False}, PaneSelector[...].... So we want to replace False with True in order to make the initial pane open. You can later use RawBoxes or DisplayForm to preview results or to make Export export its rendered form instead of raw box expression.

result = ConvolutionLayer[4,8];

result // 
  ToBoxes // 
  ReplaceAll[ HoldPattern[Typeset`open = _] :> (Typeset`open = True)] // 
  RawBoxes //  
  Export["test.pdf", #] &

enter image description here

$\endgroup$
  • $\begingroup$ Unevaluated also works for this, ReplaceAll[ HoldPattern[Typeset`open = False] :> Unevaluated[Typeset`open = True]] $\endgroup$ – Jason B. Feb 5 at 18:13
  • $\begingroup$ @JasonB. Good for you :p I find it hard to use Unevaluated for more than simple things so I don't use it ;) $\endgroup$ – Kuba Feb 5 at 18:17
  • 1
    $\begingroup$ This is in a Hold... structure so you don't even need to Hold. You can just do something like HoldPattern[Typeset`open = _] :> (Typeset`open = True) $\endgroup$ – b3m2a1 Feb 5 at 21:10
  • $\begingroup$ @b3m2a1 you are right, guess I shouldn't have skipped my 3rd coffee. Will correct it tomorrow. $\endgroup$ – Kuba Feb 5 at 21:14
  • $\begingroup$ @Kuba Thanks for giving me this insight. Do you also know how i can ommit the ConvolutionLayer[]? $\endgroup$ – Gladaed Feb 28 at 17:24

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.