I'm thinking I could do this by redefining one of the cell styles to be
a "Page Break" style with no content, vanishing height and
PageBreakBelow->True, so I could just insert or delete a "page break
cell" in this style anywhere I wanted to force a break..
Other better ways to do this?
Thanks -- sie...@ee.stanford.edu
Here is a little palette to do this (but without inventing a new cell
style).
Clicking on "PageBreakCell" inserts a cell with an empty string and
(nearly)
vanishing height.
The buttons "NextPBC" and "PreviousPBC" can be used to jump from one
"PageBreakCell" to another.
---
Rolf Mertig
Mertig Research & Consulting
Mathematica training and programming Development and distribution of
FeynCalc Amsterdam, The Netherlands
http://www.mertig.com
-------------------------------------------
(***********************************************************************
Mathematica-Compatible Notebook
This notebook can be used on any computer system with Mathematica 3.0,
MathReader 3.0, or any compatible application. The data for the
notebook starts with the line of stars above.
To get the notebook into a Mathematica-compatible application, do one of
the following:
* Save the data starting with the line of stars above into a file
with a name ending in .nb, then open the file inside the application;
* Copy the data starting with the line of stars above to the
clipboard, then use the Paste menu command inside the application.
Data for notebooks contains only printable 7-bit ASCII and can be sent
directly in email or through ftp in text mode. Newlines can be CR, LF
or CRLF (Unix, Macintosh or MS-DOS style).
NOTE: If you modify the data for this notebook not in a Mathematica-
compatible application, you must delete the line below containing the
word CacheID, otherwise Mathematica-compatible applications may try to
use invalid cache data.
For more information on notebooks and Mathematica-compatible
applications, contact Wolfram Research:
web: http://www.wolfram.com
email: in...@wolfram.com
phone: +1-217-398-0700 (U.S.)
Notebook reader applications are available free of charge from Wolfram
Research.
***********************************************************************)
(*CacheID: 232*)
(*NotebookFileLineBreakTest
NotebookFileLineBreakTest*)
(*NotebookOptionsPosition[ 3246, 89]*)
(*NotebookOutlinePosition[ 4286, 128]*) (*
CellTagsIndexPosition[ 4242, 124]*)
(*WindowFrame->Palette*)
Notebook[{
Cell[BoxData[GridBox[{
{
ButtonBox[
StyleBox["PageBreakCell",
"Subsubsection",
ShowStringCharacters->True],
ButtonFunction:>CompoundExpression[
NotebookWrite[
InputNotebook[ ],
Cell[
TextData[ " "], "Text", CellMargins -> {{0,
0}, {-10, -4}}, CellBracketOptions -> {"Thickness"
-> 4,
"Color" -> RGBColor[ 1, 0, 0]}, CellElementSpacings
-> {
"CellMinHeight" -> 1}, PageBreakBelow -> True,
GeneratedCell -> True, Magnification -> 0.5,
CellTags ->
"PageBreakCell"]]],
ButtonEvaluator->Automatic]},
{
ButtonBox[
StyleBox[\(Next\ PBC\),
"Subsubsection",
ShowStringCharacters->True],
ButtonFunction:>CompoundExpression[
NotebookFind[
InputNotebook[ ], "PageBreakCell", Next, CellTags]],
ButtonEvaluator->Automatic]},
{
ButtonBox[
StyleBox[\(Previous\ PBC\),
"Subsubsection",
ShowStringCharacters->True],
ButtonFunction:>CompoundExpression[
NotebookFind[
InputNotebook[ ], "PageBreakCell", Previous,
CellTags]],
ButtonEvaluator->Automatic]}
},
RowSpacings->0,
ColumnSpacings->0]], NotebookDefault,
PageBreakAbove->True]
},
FrontEndVersion->"X 3.0",
ScreenRectangle->{{0, 1152}, {0, 864}}, Editable->False,
WindowToolbars->{},
PageWidth->312,
WindowSize->{105, 68},
WindowMargins->{{106, Automatic}, {Automatic, 56}},
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
]
(***********************************************************************
Cached data follows. If you edit this Notebook file directly, not
using Mathematica, you must remove the line containing CacheID at the
top of the file. The cache data will then be recreated when you save
this file from within Mathematica.
***********************************************************************)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[1710, 49, 1532, 38, 72, NotebookDefault,
PageBreakAbove->True]
}
]
*)
(***********************************************************************
End of Mathematica Notebook file.
***********************************************************************)
> I'd like a fast, simple way to insert or remove forced page breaks in
> Mathematica notebooks (such as used to be available as a menu command
> in v 2.0), without opening the Option Investigator or digging into cell
> options.
>
> I'm thinking I could do this by redefining one of the cell styles to be
> a "Page Break" style with no content, vanishing height and
> PageBreakBelow->True, so I could just insert or delete a "page break
> cell" in this style anywhere I wanted to force a break..
>
> Other better ways to do this?
>
> Thanks -- sie...@ee.stanford.edu
You could create a palette of buttons that turn the option on and off:
(* Here is a button that adds a page break *)
(addpb =ButtonBox[StyleBox["Add page break below",FontFamily ->
"Helvetica"],
ButtonFunction :>
Module[{expr =NotebookRead[SelectedNotebook[]]},
If[Head[expr]===Cell,
SetOptions[NotebookSelection[SelectedNotebook[]],
PageBreakBelow -> True]]] , ButtonEvaluator ->
Automatic,
Active -> True]) // DisplayForm
(* Here is a button that removes a page break *)
(removepb =
ButtonBox[
StyleBox["Remove page break below",FontFamily -> "Helvetica"],
ButtonFunction :>
Module[{expr =NotebookRead[SelectedNotebook[]]},
If[Head[expr]===Cell,
SetOptions[NotebookSelection[SelectedNotebook[]],
PageBreakBelow -> False]]] , ButtonEvaluator ->
Automatic,
Active -> True]) // DisplayForm
(* This arranges the buttons in a column *)
(palgrid = GridBox[{{addpb},{removepb}},RowSpacings -> 0])//DisplayForm
Drag select the resulting column of buttons and then click on the front
end menu command sequence
File -> Generate Palette from Selection
To use the buttons, select a cell where you want a page break below and
then click on the button. To remove, select the cell and click on the
other button.
You could take a more sophisticated approach and combine two buttons
into a toggle by adding code to check the current value of the cell
option and then replacing it with its opposite.
Hope that helps.
--
P.J. Hinton
Mathematica Programming Group pa...@wolfram.com Wolfram
Research, Inc. http://www.wolfram.com/~paulh/
Disclaimer: Opinions expressed herein are those of the author alone.
Item["Page Break Above Cell", PageBreakAbove->True,
Scope->SelectionCell],
Item["Page Break Below Cell", PageBreakBelow->True,
Scope->SelectionCell],
Item["No Break Above Cell", PageBreakAbove->False,
Scope->SelectionCell],
Item["No Break Below Cell", PageBreakBelow->False,
Scope->SelectionCell]
}],
Make a backup copy before any modification! Insertion point can be where
you want, as a special menu item, or in the format menu.
Mind the fact that there is an incoherence in the Mathematica file
management: if your machine is a PC, $MachineType returns "PC", but the
files are stored in a "Windows" directory!
Hope this helps,
****************************************
Jean-Marie THOMAS
jmth...@agat.net
Conseil et Audit en Ingnierie de Calcul Strasbourg, France
http://www.agat.net
****************************************