1
$\begingroup$

I'm very much a beginner in Mathematica, so first of all sorry to waste you time with my problem.

To learn the cell-structuring of a project I'm working on using the different format types available. This would mean that I first would have a global title, then a chapter title and then sections with each several subsections. In the end it should look like a sort of tree structure (see the image below for example) after which I can open each hierarchical level subsequently.

However, I don't know if I keep clicking at a wrong position or if I make another simple error, but I can only direct my files to a two-level hierarchy, rather than that they self-structure based on their format type. I searched for what can be the problem, but it might be too simple since I have been looking and struggling for a while now without any progression. I would very much appreciate if anyone can guide me to what I did wrong all the time.

Notebook[{Cell[
   CellGroupData[{Cell[TextData[StyleBox["Project", "Title"]], 
      "Chapter", CellChangeTimes -> {{3.76979*10^9, 3.76979*10^9}}], 
     Cell[BoxData[
       StyleBox[RowBox[{"My", " ", "Project"}], "Chapter"]], "Input", 
      CellChangeTimes -> {{3.76979*10^9, 3.76979*10^9}}, 
      CellLabel -> "In[135]:="], 
     Cell[BoxData[StyleBox[RowBox[{"Subject", " ", "1"}], "Section"]],
       "Input", CellChangeTimes -> {{3.76979*10^9, 3.76979*10^9}}, 
      CellLabel -> "In[136]:="], 
     Cell[BoxData[
       StyleBox[RowBox[{"Description", " ", "1"}], "Subsection"]], 
      "Input", CellChangeTimes -> {{3.76979*10^9, 3.76979*10^9}}], 
     Cell[BoxData[StyleBox[RowBox[{"Text", " ", "1"}], "Text"]], 
      "Input", CellChangeTimes -> {{3.76979*10^9, 3.76979*10^9}}], 
     Cell[BoxData[
       StyleBox[RowBox[{"Description", " ", "2"}], "Subsection"]], 
      "Input", CellChangeTimes -> {{3.76979*10^9, 3.76979*10^9}}, 
      CellLabel -> "In[138]:="], 
     Cell[BoxData[StyleBox[RowBox[{"Text", " ", "2"}], "Text"]], 
      "Input", CellChangeTimes -> {{3.76979*10^9, 3.76979*10^9}}], 
     Cell[BoxData[StyleBox[RowBox[{"Subject", " ", "2"}], "Section"]],
       "Input", CellChangeTimes -> {{3.76979*10^9, 3.76979*10^9}}], 
     Cell[BoxData[
       StyleBox[RowBox[{"Description", " ", "3"}], "Subsection"]], 
      "Input", 
      CellChangeTimes -> {{3.76979*10^9, 3.76979*10^9}, {3.76979*10^9,
          3.76979*10^9}}], 
     Cell[BoxData[StyleBox[RowBox[{"Text", " ", "3"}], "Text"]], 
      "Input", CellChangeTimes -> {{3.76979*10^9, 3.76979*10^9}}], 
     Cell[BoxData[
       StyleBox[RowBox[{"Description", " ", "4"}], "Subsection"]], 
      "Input", 
      CellChangeTimes -> {{3.76979*10^9, 3.76979*10^9}, {3.76979*10^9,
          3.76979*10^9}}], 
     Cell[BoxData[StyleBox[RowBox[{"Text", " ", "4"}], "Text"]], 
      "Input", CellChangeTimes -> {{3.76979*10^9, 3.76979*10^9}}], 
     Cell[BoxData[
       RowBox[{"NotebookGet", "[", 
         RowBox[{"EvaluationNotebook", "[", "]"}], "]"}]], "Input", 
      CellChangeTimes -> {{3.76979*10^9, 3.76979*10^9}}, 
      CellLabel -> "In[139]:="]}, Open]]}, WindowSize -> {766, 772}, 
 WindowMargins -> {{0, Automatic}, {Automatic, 0}}, 
 FrontEndVersion -> 
  "12.0 for Microsoft Windows (64-bit) (April 8, 2019)", 
 StyleDefinitions -> "Default.nb"]

enter image description here

$\endgroup$
2
  • $\begingroup$ What stylesheet are you using? Also, perhaps you can evaluate NotebookGet[EvaluationNotebook[]] in your notebook and copy the output here. $\endgroup$ – Carl Woll Jun 17 '19 at 20:08
  • $\begingroup$ I use the default stylesheet, I inserted the code in the question $\endgroup$ – Jeroen Jun 17 '19 at 20:21
2
$\begingroup$

If you look at your cells, other than the first cell ("Project"), they are all "Input" cells. For example, take the second cell in your notebook expression:

Cell[
    BoxData[
        StyleBox[RowBox[{"My", " ", "Project"}], "Chapter"]
    ],
    "Input",
    CellChangeTimes -> {{3.76979*10^9, 3.76979*10^9}},
    CellLabel -> "In[135]:="
]

where I adjusted the white space to clarify the structure of the cell. Note how the second argument of the Cell expression is "Input". You want this to be "Chapter". That is, you want the cell structure to be:

Cell[
    "My Project",
    "Chapter"
]

My guess is that you created an input cell by typing "My Project", and then you highlighted "My Project" and used Format | Style | Chapter from the format menu. If you instead avoid highlighting the text "My Project" and use the same menu item, the cell style will change instead of the style of the highlighted text.

For older versions of Mathematica, you may have to select the cell bracket to change the style of the cell.

$\endgroup$
2
  • $\begingroup$ I tried your suggestion and it works now, thanks a lot! $\endgroup$ – Jeroen Jun 17 '19 at 20:54
  • $\begingroup$ Huh, that's subtle. Nice one! $\endgroup$ – Chris K Jun 17 '19 at 21:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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