2
$\begingroup$

In my day-to-day work with Mathematica I use a stylesheet I have derived from Mathematica's default stylesheet. One modification I would like to make to my stylesheet is to reduce the spacing between a section title and the first cell inside the section. This is not controlled by the CellMargins option. Is there another notebook option that can be set to reduce this gap?

$\endgroup$
7
  • 2
    $\begingroup$ The spacing is controlled by the cell margin --Try this: CellMargins->{{27, Inherited}, {0, 34}}. What makes you say that it isn't? $\endgroup$ Commented Oct 12, 2012 at 2:09
  • 3
    $\begingroup$ bear in mind that the total spacing between a section cell and the next cell is the sum of the bottom margin for the section cell and the top margin for the subsequent cell. $\endgroup$ Commented Oct 12, 2012 at 2:12
  • $\begingroup$ @MikeHoneychurch -- it's a bit embarrassing, but I reached my conclusion that it was not controlled by CellMargins because I thought the margins list went {{left,right},{top,bottom}} and not {{left,right},{bottom, top}}. I was changing the wrong list element and thus not seeing the result I expected. $\endgroup$
    – m_goldberg
    Commented Oct 12, 2012 at 6:54
  • 1
    $\begingroup$ we've all made mistakes like that. I've made worse. Just bear in mind though that for a consistent spacing you will need to have the same cell type (e.g. subsection) following your section cell because most cells types are configured by default to have different top margins. (and therefore the spacing between section->input will be different from section->text etc.) $\endgroup$ Commented Oct 12, 2012 at 8:32
  • $\begingroup$ This is a good question though, with a useful answer. Do you want to add it as an answer rather than a comment Mike? $\endgroup$ Commented Oct 13, 2012 at 3:22

1 Answer 1

4
$\begingroup$

As commented by Mike Honeychurch:

The spacing is controlled by the cell margin.Try this:

CellMargins->{{27, Inherited}, {0, 34}}

Bear in mind that the total spacing between a section cell and the next cell is the sum of the bottom margin for the section cell and the top margin for the subsequent cell.

For a consistent spacing you will need to have the same cell type (e.g. subsection) following your section cell because most cells types are configured by default to have different top margins. (and therefore the spacing between section->input will be different from section->text etc.)

$\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.