Echo
Echo

Reputation: 600

Can I connect and collapse multiple cells together in a ipython notebook?

So, I have a ipython notebook consisting of several 100 cells. A couple of consecutive cells logically belong to one particular functionality or milestone of the notebook. These logical divisions are separated by a cell containing a heading (in markdown). I can collapse individual cells. Is it possible to collapse multiple cells together , such that only the header cell is visible and when I uncollapse it, I see all the cells under that header?

For visualization

Cell 1 : Heading 1 

Cell 2 : functionality x

Cell 3 : functionality y

Cell 4 : Heading 2

Cell 5 : functionality A 

Cell 6 : functionality B

I want to connect cell 2, cell 3 to cell 1 and cell 5, cell 6 to cell 4.

So that when I collapse it. It looks like this :

Cell 1 : Heading 1

...

Cell 4 : Heading 2

Currently, I am achieving this by collapsing each and every individual cell under a heading which is soon becoming tiresome. I am looking for any plug in , script , anything that can help me achieve this.

Upvotes: 0

Views: 2014

Answers (1)

krassowski
krassowski

Reputation: 15449

Yes, JupyterLab 3.1 supports collapsing multiple cells at once. There is a small arrow that shows up when hovering over markdown cells with headings:

collapse multiple cells demonstration

Alternatively, you could turn on syncCollapseState (Advanced Settings Editor -> Table of Contents) and use the Table of Contents to collapse multiple cells at once, as demonstrated in the documentation, here.

Though I need to warn you that this functionality is brand new and there are some rough edges (for example, moving cells may behave strange for now), though improvements are being worked on!

Upvotes: 2

Related Questions