0
$\begingroup$

I have a notebook with several groups of cells grouped with their respective headlines (Title ... down to Subsubsection). I grouped them all manually.

It often becomes necessary, to add something to the end of these chapters headed by their respective headlines.

But if I split the last cell by Shift+Ctl+D, a new cell is generated, but this happens below the current group of cells and not as part of the group. This also holds true, if I split somewhere in the middle of the text in the cell (i.e. not at the very end of the content: with something to the right of my division point).

This is very awkward and I am looking for something to let Shift+Ctl+D split off the remaining part (if any) and keep it grouped with the group "from above".

If this can not be achieved by manipulating one of the zillion settings of OptionsInspector (which one, if there is one), what about some proper procedure for KeyEvent.tr?

BTW: Would it be possible to add the right option to all headline styles (the ones mentioned above) such that they are never divided from the next cell on printing (like it is possible in LibreOffice or MS Word to link each headline to the next paragraph due to a feature set for the headline: If they would be split by a page break, both are kept together and an automatic pagebreak is added before them and of course it vanishes again, if due to modifications above the point, such additional pagebreaking becomes superfluous later).

$\endgroup$

1 Answer 1

0
$\begingroup$

I'm not sure how the options will help you if your cell grouping is manual. The available CellGroupingRules are pretty rich and you may could probably tweak the styling so that it worked with automatic grouping, but that is neither here nor there.

On the other hand, there are FrontEndTokens that will do exactly what you want.

Try this:

SetOptions[
 EvaluationNotebook[],
 NotebookEventActions -> {
   {"MenuCommand", "CellSplit"} :>
    With[{ev = EvaluationNotebook[]},
     RunScheduledTask[
      FrontEndTokenExecute[ev, "SelectNextCell"];
      FrontEndTokenExecute[ev, "SelectPreviousCell"];
      FrontEndTokenExecute[ev, "CellGroup"],
      {.01, 1}
      ]
     ],
   PassEventsDown -> True
   }
 ]

We need a scheduled task so that the grouping is done after the split.

As for page breaking, take a look at GroupPageBreakWithin. I think it will do what you want.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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