Function Repository Resource:

InsertDelimiter

Source Notebook

Add a delimiter cell for separating content

Contributed by: Kunal Khadke, Jayanta Phadikar

ResourceFunction["InsertDelimiter"][]

adds a delimiter cell to the current notebook.

ResourceFunction["InsertDelimiter"][nb]

adds a delimiter cell to the NotebookObject nb.

Details and Options

Delimiter cells are helpful for separating related yet dissimilar textual content while writing a computational essay.
Delimiter cells are often used in the documentation of built-in functions.
ResourceFunction["InsertDelimiter"] accepts the following options:
CellMargins{{66,0},{0,0}}the absolute margins in printer's points to leave around the cell
CellFrameColorGrayLevel[0.6]the color of the delimiter
In resource definition notebooks, ResourceFunction["InsertDelimiter"][] is effectively equivalent to pressing the "Insert Delimiter" button in the toolbar.
Options for ResourceFunction["InsertDelimiter"] have no effect in resource definition notebooks.

Examples

Basic Examples (1) 

Insert a delimiter between two paragraphs:

In[1]:=
nb = CreateDocument[];
In[2]:=
NotebookWrite[nb, Cell[
StringTake[
ExampleData[{"Text", "AliceInWonderland"}], 400], "Text"]];
ResourceFunction["InsertDelimiter"][nb];
NotebookWrite[nb, Cell[
StringTake[
ExampleData[{"Text", "Hamlet"}], 400], "Text"]];
In[3]:=
NotebookClose[nb]

Scope (2) 

Open a notebook and move the current selection:

In[4]:=
nb = NotebookOpen[FindFile["ExampleData/document.nb"]];
In[5]:=
SelectionMove[nb, Next, Cell, 4];
SelectionMove[nb, After, Cell];

The delimiter is inserted at the current selection point:

In[6]:=
ResourceFunction["InsertDelimiter"][nb]
In[7]:=
NotebookClose[nb]

For resource definition notebooks, InsertDelimiter[] is effectively equivalent to using the "Insert Delimiter" button from the toolbar:

In[8]:=
nbFR = CreateNotebook["FunctionResource"];

Move the selection:

In[9]:=
NotebookFind[nbFR, "Scope"];
SelectionMove[nbFR, Next, Cell, 3];
SelectionMove[nbFR, After, Cell];

Insert the delimiter cell:

In[10]:=
ResourceFunction["InsertDelimiter"][nbFR]
In[11]:=
NotebookClose[nbFR]

Options (2) 

CellMargins (1) 

Create a delimiter cell with no horizontal margins:

In[12]:=
nb = CreateDocument[];
In[13]:=
NotebookWrite[nb, Cell[
StringTake[
ExampleData[{"Text", "AliceInWonderland"}], 400], "Text"]];
ResourceFunction["InsertDelimiter"][nb, CellMargins -> {{0, 0}, {0, 0}}]
NotebookWrite[nb, Cell[
StringTake[
ExampleData[{"Text", "Hamlet"}], 400], "Text"]];
In[14]:=
NotebookClose[nb]

CellFrameColor (1) 

Change the delimiter color within a normal notebook with CellFrameColor:

In[15]:=
nb = CreateDocument[];
In[16]:=
NotebookWrite[nb, Cell[
StringTake[
ExampleData[{"Text", "AliceInWonderland"}], 400], "Text"]];
ResourceFunction["InsertDelimiter"][nb, CellFrameColor -> Red]
NotebookWrite[nb, Cell[
StringTake[
ExampleData[{"Text", "Hamlet"}], 400], "Text"]];
In[17]:=
NotebookClose[nb]

Possible Issues (2) 

A delimiter cell is added at the end with CellPrint:

In[18]:=
CreateDocument[];

Evaluate the following code in the new notebook created above:

In[19]:=
CellPrint[
Cell[
StringTake[
ExampleData[{"Text", "AliceInWonderland"}], 400], "Text"]];
ResourceFunction["InsertDelimiter"][]
CellPrint[
Cell[
StringTake[
ExampleData[{"Text", "Hamlet"}], 400], "Text"]];
In[20]:=
NotebookClose[nb]

Use NotebookWrite to add a delimiter cell in the order mentioned:

In[21]:=
nb = CreateDocument[];
In[22]:=
NotebookWrite[nb, Cell[
StringTake[
ExampleData[{"Text", "AliceInWonderland"}], 400], "Text"]];
ResourceFunction["InsertDelimiter"][nb];
NotebookWrite[nb, Cell[
StringTake[
ExampleData[{"Text", "Hamlet"}], 400], "Text"]];
In[23]:=
NotebookClose[nb]

Publisher

Kunal Khadke

Version History

  • 1.0.0 – 23 August 2021

License Information