MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Programmed PageBreaks

  • To: mathgroup at smc.vnet.net
  • Subject: [mg16735] RE: [mg16431] Programmed PageBreaks
  • From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
  • Date: Wed, 24 Mar 1999 02:23:49 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

Earlier I sent in a palette with a few buttons.

The "Delete All Graphics" button had a serious bug.
If your notebook had no graphics, but did have graphics output cells the
button would delete ALL CELLS in your notebook.  I have since corrected this
bug using the code below.

Be patient with the button to "Delete All Graphics".  For large notebboks it
takes a while.  Watch the top of the window for the palette to see if it's
still running.

--------------------------

Rolf Mertig posted a nice palette to do what you want some time ago.  Since
then I enhanced the "Insert PageBreak" button, and added two unrelated
buttons.  The palette below has five buttons.


1-  CleanSlate[]
This button evaluates CleanSlate[] without feedback except "Running name.nb"
is displayed in the window frame of the palette while CleanSlate is
evaluating.  I made this button because I got tired of deleting cells from
CleanSlate[]; in my notebooks.  Note, CleanSlate isn't a built-in feature.
But it's a nice tool and you can find it in the distribution CD for version
3.0. 

2- Delete All Graphics
This button will delete all Graphic cells and any corresponding output
cells.

3- Insert PageBreak
This button inserts a cell that does little more than force a page break.
The cell has a red cell bracket as a visual indication.  If the selection
pointer is between cells the "Page Break Cell" is inserted at the selection
pointer.  I modified the button from Rolf Mertig so that if the selection
pointer is in the middle of a cell when the button is used you get a "Page
Break Cell" after the cell where the selection pointer was.

4-  Next PageBreak
Selects the first "Page Break Cell" after the selection pointer.  Once the
cell is selected the cell bracket turns cyan.

5- Previous PageBreak
Selects the nearest "Page Break Cell" that comes before the selection
pointer.    Once the cell is selected the Cell Bracket turns cyan.

-------------------------

Copy the code below into the Front End.
Select Yes to interpret the text.
Select the Window containing the palette, and save the notebook.

I saved the notebook in the folder:
  WolframResearch/Mathematica/30/SystemFiles/FrontEnd/Palettes
That way I can access the palette from the menu selection:
    --> File
      --> Palettes

------------------
Regards,
Ted Ersek


(******* Code Begins Here *********)
Notebook[{
Cell[BoxData[
    TagBox[GridBox[{
          {
            ButtonBox[\(CleanSlate[]\ \ \ \ \ \ \ \ \ \ \ \ \ \ \),
              ButtonFunction:>Block[ {Print}, 
                  CompoundExpression[ 
                    CleanSlate[ ], Null]],
              ButtonEvaluator->Automatic,
              Active->True]},
          {
            
            ButtonBox[\(\ \ \ \ \ \ \ \ Delete\ All\ Graphics\ \ \ \ \ \ \ \

              \),
              ButtonFunction:>Module[ {
                  Set[ nb1, 
                    InputNotebook[ ]], nb2, posn}, 
                  CompoundExpression[ 
                    Print[ boo], 
                    Set[ nb2, 
                      NotebookGet[ nb1]], 
                    Set[ posn, 
                      Position[ nb2, 
                        Alternatives[ 
                          Cell[ 
                            BoxData[ 
                              TagBox[ 
                                RowBox[ {"\[SkeletonIndicator]", 
                                  Alternatives[ 
                                  "Graphics", "Graphics3D", 
                                    "ContourGraphics", "DensityGraphics", 
                                    "SurfaceGraphics", "GraphicsArray", 
                                    "Sound"], "\[SkeletonIndicator]"}], 
                                False, Editable -> False]], "Output", 
                            BlankNullSequence[ ]], 
                          Cell[ 
                            GraphicsData[ 
                              BlankSequence[ ]], "Graphics", 
                            BlankNullSequence[ ]]], Infinity]], 
                    If[ 
                      UnsameQ[ posn, {}], 
                      NotebookPut[ 
                        Delete[ nb2, posn], nb1]]]],
              ButtonEvaluator->Automatic,
              Active->True]},
          {
            ButtonBox[\(Insert\ a\ PageBreak\ \ \ \ \),
              ButtonFunction:>Module[ {
                  Set[ nb, 
                    InputNotebook[ ]]}, 
                  CompoundExpression[ 
                    SelectionMove[ nb, All, Cell], 
                    If[ 
                      SameQ[ 
                        NotebookRead[ 
                          NotebookSelection[ nb]], {}], 
                      SelectionMove[ nb, Previous, Cell]], 
                    SelectionMove[ nb, After, Cell], 
                    NotebookWrite[ 
                      InputNotebook[ ], 
                      Cell[ 
                        TextData[ " "], "Text", CellMargins -> {{0, 
                        0}, {-10, -4}}, CellBracketOptions -> {"Thickness"
-> 
                        2, "Color" -> RGBColor[ 1, 0, 0]}, 
                        CellElementSpacings -> {"CellMinHeight" -> 1}, 
                        PageBreakBelow -> True, GeneratedCell -> True, 
                        Magnification -> .5, Editable -> False, CellTags -> 
                        "PageBreakCell"]]]],
              ButtonEvaluator->Automatic]},
          {
            ButtonBox[\(Next\ PageBreak\ \ \ \ \ \ \ \ \ \ \ \),
              ButtonFunction:>CompoundExpression[ 
                  NotebookFind[ 
                    InputNotebook[ ], "PageBreakCell", Next, CellTags]],
              ButtonEvaluator->Automatic]},
          {
            ButtonBox[\(Previous\ PageBreak\ \ \),
              ButtonFunction:>CompoundExpression[ 
                  NotebookFind[ 
                    InputNotebook[ ], "PageBreakCell", Previous, CellTags]],
              ButtonEvaluator->Automatic]}
          },
        RowSpacings->0.3],
      DisplayForm]], NotebookDefault,
  CellMargins->{{Inherited, Inherited}, {7, Inherited}},
  CellEditDuplicate->True,
  CellGroupingRules->"OutputGrouping",
  CellHorizontalScrolling->True,
  PageBreakAbove->True,
  PageBreakWithin->False,
  GroupPageBreakWithin->False,
  GeneratedCell->True,
  CellAutoOverwrite->True,
  CellLabelMargins->{{11, Inherited}, {Inherited, Inherited}},
  DefaultFormatType->DefaultOutputFormatType,
  LineSpacing->{1.25, 0},
  AutoItalicWords->{},
  FormatType->InputForm,
  ScriptMinSize->9,
  CounterIncrements->"Output",
  StyleMenuListing->None,
  FontFamily->"Courier"]
},
FrontEndVersion->"Microsoft Windows 3.0",
ScreenRectangle->{{0, 800}, {0, 544}},
Editable->False,
WindowToolbars->{},
PageWidth->433,
WindowSize->{Fit, Fit},
WindowMargins->{{Automatic,5}, {Automatic,5}},
WindowFrame->"Palette",
WindowElements->{},
WindowFrameElements->"CloseBox",
WindowClickSelect->False,
ScrollingOptions->{"PagewiseScrolling"->True},
ShowCellBracket->False,
CellMargins->{{0, 0}, {Inherited, 0}},
Active->True,
CellOpen->True,
ShowCellLabel->False,
ShowCellTags->False,
ImageMargins->{{0, Inherited}, {Inherited, 0}},
Magnification->1
]



  • Prev by Date: Re: Help me! - SphericaPlot
  • Next by Date: Re: ReadList Problems
  • Previous by thread: RE: Programmed PageBreaks
  • Next by thread: ImplicitPlot3D problem