I'm applying a background color to code blocks in org-mode, as shown in this line from my colortheme:

'(org-block ((t (:background "#F5F5F5" :family "Source Code Pro" :height 140))))

expanded item with code block

When I collapse an item that contains a code block, the code block's background color extends from the end of the item's heading to the edge of the window, which I did not expect -- I expected collapsing the item would hide any evidence of the contained code-block.

collapsed item with code block

Is there any way to prevent the code block background from "bleeding through" like this?


I found that adding a blank line past the source block prevents the bleeding.

  • Confirmed. But is this a bug or by design? It seems header formatting should be independent of its collapse/expand state (except for the presence of ellipses to indicate collapsed content.) – Snelephant Feb 2 '18 at 21:19
  • Correction: This issue appears be unique to specific themes. For example, leuven theme does not exhibit the above behavior. – Snelephant Feb 2 '18 at 21:45

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.