Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

The Outline stylesheet only seems to cover 6 levels of depth. Is there any way to increase that?

Here's an example. Hitting tab on the last level just indents its content, but doesn't add another level of depth.

enter image description here

share|improve this question
1  
This limit is hard-coded in the stylesheet file $InstallationDirectory\SystemFiles\FrontEnd\StyleSheets\Utility\Outline.nb (you can view the plain text content if you open it with, say, Notepad). You can probably make your own stylesheet with any number of levels using Outline.nb as the starting point, but ... this involves more than adding a few lines to this file. –  kguler Oct 11 '12 at 17:24
1  
I would copy-paste the Outline6 style in the stylesheet as a reference and then just change the name to Outline7, increasing the left CellMargins by 40 or whatever, changing the style according to taste, adding Outline7 to Outline6's StyleKeyMapping so that Tabbing the Outline6 brings you to Outline7, changing Outline7's StyleKeyMapping so that backspace brings you to Outline6. Also, add Outline7 to the DockedCells list in the Working style cell –  Rojo Oct 21 '12 at 16:13
add comment

1 Answer

up vote 8 down vote accepted
+100

In the following, I take Outline.nb file and insert a cell-group to add a 7th level and modify the remaining cells (1) to add the new level to the toolbar, (2) to modify the current level 6 behavior in response to Tab and Shift+Tab key events, (3) for all levels, reset the counter values to zero for all child levels including level 7.

(* get Outline.nb file *)
ol = ToFileName[{$InstallationDirectory, "SystemFiles", "FrontEnd", 
"StyleSheets", "Utility"}, "Outline.nb"];
stylnbk = Import[ol];  

The code piece to be inserted into the toolbar:

insertToToolbar = {" | ", TooltipBox[ButtonBox["7", ButtonFunction :>
  (SelectionMove[ButtonNotebook[], After, Cell];
   NotebookWrite[ButtonNotebook[], Cell["XXXX", "Outline7"], All];
   SelectionMove[ButtonNotebook[], All, CellContents]),
 BaseStyle -> "ToolbarButton",
 Appearance -> None, ButtonFrame -> None,
 Evaluator -> Automatic,
 ImageSize -> Automatic, Method -> "Queued"], 
"Insert outline level 7.", ActionDelay -> 0.35`]};

and the piece to add the new level:

level7CellGroup = Cell[CellGroupData[{Cell[StyleData["Outline7"],
  CellMargins -> {{320, 10}, {7, 7}},
  ReturnCreatesNewCell -> True,
  StyleKeyMapping -> {"Backspace" -> "Outline6", 
    KeyEvent["Tab", Modifiers -> {Shift}] -> "Outline6"},
  CellGroupingRules -> {"SectionGrouping", 110},
  DefaultNewCellStyle -> "Outline7",
  DefaultReturnCreatedCellStyle -> "Outline7",
  ParagraphIndent -> 0, CounterIncrements -> "Outline7",
  MenuSortingValue -> 1500,
  MenuCommandKey -> "7",
  FontFamily -> "Verdana",
  FontSize -> 10,
  CounterBoxOptions -> {CounterFunction :> (CharacterRange[
         "\[GothicA]", "\[GothicZ]"][[#1]] &)}],
 Cell[StyleData["Outline7", "Numbered"],
  CellDingbat -> StyleBox[RowBox[{CounterBox["Outline7"], "."}],
    FontFamily -> "Verdana", TextAlignment -> Right]],
 Cell[
  StyleData["Outline7", "PreviewNumbered", 
   StyleDefinitions -> StyleData["Outline7", "Numbered"]]],
 Cell[StyleData["Outline7", "Bulleted"], 
  CellDingbat -> "\[FilledVerySmallSquare]"],
 Cell[
  StyleData["Outline7", "PreviewBulleted", 
   StyleDefinitions -> StyleData["Outline7", "Bulleted"]]], 
 Cell[StyleData["Outline7", "Presentation"], 
  CellMargins -> {{350, 10}, {10, 10}}, FontSize -> 20]}, 
Closed]];

Next, create a new notebook from Outline.nb using a series of replacements

newStylSht = (stylnbk /. 
    HoldPattern[DockedCells -> {Cell[BoxData[StyleBox[
        GridBox[{lst : {StyleBox["Outline Level: ", FontWeight -> "Bold"],
               PatternSequence[TooltipBox[__], " | "] .., 
               TooltipBox[__]}}, gbopts__], sbopts__]], cellopts__]}] :> 
     DockedCells -> 
      {Cell[BoxData[StyleBox[GridBox[{Join[lst, insertToToolbar]}, gbopts], 
          sbopts]], cellopts]} /. 
   HoldPattern[CounterAssignments -> cas : {{_, 0} ..}] :> 
    CounterAssignments -> Insert[cas, {"Outline7", 0}, -1] /.
  HoldPattern[DefaultReturnCreatedCellStyle-> "Outline6"] :>
   Sequence[DefaultNewCellStyle -> "Outline7", 
    DefaultReturnCreatedCellStyle-> "Outline6",
    CounterAssignments -> {{"Outline7", 0}}] /. 
 HoldPattern[StyleKeyMapping -> skm:{"Backspace" -> "Outline5", 
      KeyEvent["Tab", Modifiers -> {Shift}] -> "Outline5"}] :> 
  StyleKeyMapping -> Insert[skm, "Tab" -> "Outline7", 1] /.
HoldPattern[Cell[CellGroupData[
    cgd:{Cell["Styles for Outline Documents", "Section"], ___}, opt___]]] :>
 Cell[CellGroupData[Insert[cgd, level7CellGroup, -1], opt]]);

Save the new notebook in the same directory:

flNm = ToFileName[{$InstallationDirectory, "SystemFiles", "FrontEnd", 
   "StyleSheets", "Utility"},  "Outline7Levels.nb"]; 
NotebookSave[newStylSht, flNm]

To install the new stylesheet:

Select Install from the File menu:

enter image description here

.. or open a new notebook and from the Format menu select Edit StyleSheet, and click the button Install Stylesheet:

enter image description here

to invoke the Install Mathematica Item dialog window. In the dialog window, select From File as Source:

enter image description here

Navigate to the directory where the new stylesheet notebook is saved; select the file Outline7Levels.nb and give it a name, click OK:

enter image description here

The new stylesheet is now available in the Format menu:

enter image description here

and the Format>>Style and Format>>Screen Environment sub-menus show the new styles:

enter image description here

enter image description here

enter image description here

share|improve this answer
    
Sorry for the wait. Very detailed answer. Everything went great. Thank you! –  Mirov Oct 26 '12 at 12:46
    
@user745434, thank you. Glad it worked for what you needed. –  kguler Oct 26 '12 at 13:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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