16

Say I'm writing a text:

* Animals

There are many of them in the wild.

** Examples of animals :noexport:
- Dogs
- Fish
- Triceratops

# I'd like the subheading to end here!! Following sentence should belong to outer scope. 

Animals are not the same as plants.

* Plants

There are also many of them in the wild.

I'd like my subheading Examples of animals in the example above, to end after - Triceratops, and all further text to continue on the parent heading Animals. Currently, if I cycle visibility and hide Examples of animals, then all text below it will be hidden up entil the next heading.

How can I force to prematurely end a headline?!

If this functionality is not implemented in org-mode, how can I insert structured text in the middle of a heading and selectively hide (org-cycle) it?

4
  • 2
    Pretty sure you can't.
    – Dan
    Commented May 29, 2017 at 14:09
  • Any alternatives to insert structured text in the middle of a heading and selectively hide it? The solution need not consist of a subheading
    – Daniel
    Commented May 29, 2017 at 14:16
  • 1
    An example block #+BEGIN_EXAMPLE...#+END_EXAMPLE would seem more appropriate here. Commented May 29, 2017 at 17:11
  • Plain lists may also work (prefixed with dash). They're foldable, but are treated as plain text, so you can do whatever you want.
    – Chrisuu
    Commented Feb 28, 2022 at 23:02

3 Answers 3

8

As others have mentioned, org-mode is strictly hierarchical. Once you begin a headline at a certain level, nothing ends it except a new headline. You can't return to the previous one. If you want a certain chunk of text in the middle of a section to be set off and foldable you want a block; use either an example block or a source block (with org as the source language):

#+NAME: examples-of-animals
#+BEGIN_EXAMPLE
- test 1
- test 2
#+END_EXAMPLE

EXAMPLE blocks are exported literally. If you want formatted export (and to control whether it exports at all) use a source block:

#+BEGIN_SRC org-mode :exports none
** Examples of animals
  - test 1
  - test 2
#+END_SRC

http://orgmode.org/manual/Working-with-source-code.html#Working-with-source-code In this case the :exports none option causes the block to not be exported, but it will be editable as normal org-mode text.

3

That cannot be done: org-mode imposes a strictly hierarchical structure on the document. As a possible answer to your last question, you may be able to use inline tasks - see the Org-mode FAQ for more info.

2
  • Thanks, but inline tasks do not selectively hide, i.e., they still glob the contents until the next heading comes around.
    – Daniel
    Commented May 29, 2017 at 23:51
  • I think these are two different questions. OP wants to insert some text belonging to the parent node; the example described in the linked page is to insert text belonging to the previous sibling node instead of the current one.
    – shynur
    Commented Nov 27, 2023 at 14:00
3

You may be able to use an inline task for this. It is like a headline but usually 15stars deep. It is not part of the outline hierarchy.

2
  • I didn't know about inline tasks. They are cool but they still obey the org-mode structure, i.e., they'll still glob all content until the next heading comes around.
    – Daniel
    Commented May 29, 2017 at 23:53
  • You need to add an END at end of a 15 star headline to make it like a drawer. See orgmode.org/w/?p=org-mode.git;a=blob_plain;f=lisp/… Commented May 30, 2017 at 11:15

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.