summaryrefslogtreecommitdiff
path: root/example.org
blob: 6f90e509de3c6dfd2daf02955008f094423f3adf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
* Document top-level heading

This is an example of a complex document.  To see the Org syntax, view the [[https://raw.githubusercontent.com/alphapapa/org-make-toc/master/example.org][raw version]] of this file.

** Main ToC: Itself excluded
:PROPERTIES:
:TOC:      :include all :ignore this
:END:

This heading itself is excluded from its TOC.

:CONTENTS:
- [[#document-top-level-heading][Document top-level heading]]
  - [[#chapter-1-inline-toc][Chapter 1: Inline TOC]]
    - [[#section-1a][Section 1a]]
      - [[#subsection-1a1][Subsection 1a1]]
      - [[#subsection-1b1-included-despite-its-excluded-parent][Subsection 1b1: Included, despite its excluded parent]]
  - [[#chapter-2-toc-as-sibling][Chapter 2: TOC as sibling]]
    - [[#chapter-2-toc][Chapter 2 TOC]]
    - [[#section-2a][Section 2a]]
      - [[#subsection-2a1][Subsection 2a1]]
    - [[#section-2b-child-is-excluded][Section 2b: Child is excluded]]
  - [[#chapter-3-toc-as-parent][Chapter 3: TOC as parent]]
    - [[#chapter-3-toc][Chapter 3 TOC]]
      - [[#section-3a][Section 3a]]
        - [[#subsection-3a1][Subsection 3a1]]
      - [[#section-3b][Section 3b]]
        - [[#subsection-3b1][Subsection 3b1]]
  - [[#chapter-4-limited-depth][Chapter 4: Limited depth]]
    - [[#section-4a][Section 4a]]
    - [[#section-4b][Section 4b]]
  - [[#appendices][Appendices]]
    - [[#appendix-a-comprehensive-toc][Appendix A: Comprehensive TOC]]
    - [[#appendix-b][Appendix B]]
    - [[#appendix-c][Appendix C]]
:END:

** Chapter 1: Inline TOC
:PROPERTIES:
:TOC:       :include descendants
:END:

This chapter includes its TOC inline, with text before...

:CONTENTS:
- [[#section-1a][Section 1a]]
  - [[#subsection-1a1][Subsection 1a1]]
  - [[#subsection-1b1-included-despite-its-excluded-parent][Subsection 1b1: Included, despite its excluded parent]]
:END:

...and after it.

*** Section 1a

This section is included in the chapter's TOC.

**** Subsection 1a1

This subsection is also included.

*** Section 1b: Excluded, but child included
:PROPERTIES:
:TOC:      :ignore this
:END:

This section is not included in the chapter's TOC, but its subsection is (you probably wouldn't want to do this, but you could).

**** Subsection 1b1: Included, despite its excluded parent

This subsection is included in the chapter's TOC even though its parent is excluded.

** Chapter 2: TOC as sibling

This chapter has its TOC as a sibling of its sections.

*** Chapter 2 TOC
:PROPERTIES:
:TOC:    :include siblings
:END:
:CONTENTS:
- [[#section-2a][Section 2a]]
  - [[#subsection-2a1][Subsection 2a1]]
- [[#section-2b-child-is-excluded][Section 2b: Child is excluded]]
:END:

*** Section 2a

This section is included.

**** Subsection 2a1

This subsection is included.

*** Section 2b: Child is excluded
:PROPERTIES:
:TOC:      :depth 0
:END:

This section is included in the TOC.

**** Subsection 2b1: The excluded child

But its subsection is not.

** Chapter 3: TOC as parent

This chapter has its TOC as a parent of the chapter sections.

*** Chapter 3 TOC
:PROPERTIES:
:TOC:      :include descendants
:END:
:CONTENTS:
- [[#section-3a][Section 3a]]
  - [[#subsection-3a1][Subsection 3a1]]
- [[#section-3b][Section 3b]]
  - [[#subsection-3b1][Subsection 3b1]]
:END:

**** Section 3a

This section is included.

***** Subsection 3a1

This subsection is included.

**** Section 3b

This section is included.

***** Subsection 3b1

This subsection is included.

** Chapter 4: Limited depth
:PROPERTIES:
:TOC:       :include descendants :depth 1
:END:

This chapter's TOC uses =:depth 1= to exclude subsections.

:CONTENTS:
- [[#section-4a][Section 4a]]
- [[#section-4b][Section 4b]]
:END:

*** Section 4a

This section is included in the chapter's TOC.

**** Subsection 4a1

This subsection is excluded.

*** Section 4b

This section is included in the chapter's TOC.

**** Subsection 4b1

This subsection is excluded.

** Appendices
:PROPERTIES:
:TOC:      :include descendants :depth 1
:END:

The appendices have a local TOC, and one of them is a comprehensive TOC of the entire document (unlike the main TOC at the top of the document, which is abridged).

:CONTENTS:
- [[#appendix-a-comprehensive-toc][Appendix A: Comprehensive TOC]]
- [[#appendix-b][Appendix B]]
- [[#appendix-c][Appendix C]]
:END:

*** Appendix A: Comprehensive TOC
:PROPERTIES:
:TOC:      :include all :force (depth ignore)
:END:

This comprehensive TOC uses =:include all :force (depth ignore)= to force all headings to be included, regardless of their local settings.

:CONTENTS:
- [[#document-top-level-heading][Document top-level heading]]
  - [[#main-toc-itself-excluded][Main ToC: Itself excluded]]
  - [[#chapter-1-inline-toc][Chapter 1: Inline TOC]]
    - [[#section-1a][Section 1a]]
      - [[#subsection-1a1][Subsection 1a1]]
    - [[#section-1b-excluded-but-child-included][Section 1b: Excluded, but child included]]
      - [[#subsection-1b1-included-despite-its-excluded-parent][Subsection 1b1: Included, despite its excluded parent]]
  - [[#chapter-2-toc-as-sibling][Chapter 2: TOC as sibling]]
    - [[#chapter-2-toc][Chapter 2 TOC]]
    - [[#section-2a][Section 2a]]
      - [[#subsection-2a1][Subsection 2a1]]
    - [[#section-2b-child-is-excluded][Section 2b: Child is excluded]]
      - [[#subsection-2b1-the-excluded-child][Subsection 2b1: The excluded child]]
  - [[#chapter-3-toc-as-parent][Chapter 3: TOC as parent]]
    - [[#chapter-3-toc][Chapter 3 TOC]]
      - [[#section-3a][Section 3a]]
        - [[#subsection-3a1][Subsection 3a1]]
      - [[#section-3b][Section 3b]]
        - [[#subsection-3b1][Subsection 3b1]]
  - [[#chapter-4-limited-depth][Chapter 4: Limited depth]]
    - [[#section-4a][Section 4a]]
      - [[#subsection-4a1][Subsection 4a1]]
    - [[#section-4b][Section 4b]]
      - [[#subsection-4b1][Subsection 4b1]]
  - [[#appendices][Appendices]]
    - [[#appendix-a-comprehensive-toc][Appendix A: Comprehensive TOC]]
    - [[#appendix-b][Appendix B]]
    - [[#appendix-c][Appendix C]]
  - [[#footer-excluded][Footer: Excluded]]
:END:

*** Appendix B

Possibly vestigial.

*** Appendix C

Definitely vestigial.

** Footer: Excluded
:PROPERTIES:
:TOC:      :ignore this
:END:

# Local Variables:
# before-save-hook: org-make-toc
# End: