File: example.org

package info (click to toggle)
org-make-toc 0.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 208 kB
  • sloc: sh: 918; lisp: 342; makefile: 32
file content (334 lines) | stat: -rw-r--r-- 9,635 bytes parent folder | download
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334


* 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]]
  - [[#chapter-5-local-settings][Chapter 5: Local settings]]
    - [[#section-5a][Section 5a]]
      - [[#section-5a1][Section 5a1]]
      - [[#section-5a2][Section 5a2]]
    - [[#section-5b][Section 5b]]
      - [[#section-5b1][Section 5b1]]
    - [[#section-5c][Section 5c]]
      - [[#section-5c1][Section 5c1]]
        - [[#section-5c1a][Section 5c1a]]
        - [[#section-5c1b][Section 5c1b]]
  - [[#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.

** Chapter 5: Local settings
:PROPERTIES:
:TOC:      :include descendants :depth 2
:END:

This chapter's TOC includes descendants only two levels deep by default.  However, Section 5b sets =:depth 3= (relative to itself) in order to include deeper descendants in its own section TOC.  Normally this depth setting would propagate up to the Chapter 5 TOC and cause, e.g. Section 5b1a to be included in the Chapter 5 TOC.  However, Section 5b also sets =:local depth=, which prevents its depth setting from propagating up the tree, so the sections 5b1a and 5b1b are excluded from the Chapter 5 TOC.

One could also set =:force depth= in the chapter 5 TOC to accomplish the same thing.  However, doing so would force the depth setting for /all/ subtrees in its TOC.  Instead, by using =:local depth= on Section 5b, we allow Section 5c to set =:depth 3=, which /is/ allowed to propagate up to the chapter 5 TOC.  So notice that, although Sections 5b and 5c are structurally identical, the way they are shown in the Chapter 5 TOC differs, because Section 5b sets =:local depth= while Section 5c does not.

If this seems complicated, perhaps it is, but it's optional power that's available when needed.

:CONTENTS:
- [[#section-5a][Section 5a]]
  - [[#section-5a1][Section 5a1]]
  - [[#section-5a2][Section 5a2]]
- [[#section-5b][Section 5b]]
  - [[#section-5b1][Section 5b1]]
- [[#section-5c][Section 5c]]
  - [[#section-5c1][Section 5c1]]
    - [[#section-5c1a][Section 5c1a]]
    - [[#section-5c1b][Section 5c1b]]
:END:

*** Section 5a

This section is included in the Chapter 5 TOC.

**** Section 5a1

This section is included in the Chapter 5 TOC.

**** Section 5a2

This section is included in the Chapter 5 TOC.

*** Section 5b
:PROPERTIES:
:TOC:      :include descendants :depth 3 :local depth
:END:
:CONTENTS:
- [[#section-5b1][Section 5b1]]
  - [[#section-5b1a][Section 5b1a]]
  - [[#section-5b1b][Section 5b1b]]
:END:

**** Section 5b1

This section is included in the Chapter 5 TOC.

***** Section 5b1a

This section is *not* included in the Chapter 5 TOC.

***** Section 5b1b

This section is *not* included in the Chapter 5 TOC.

*** Section 5c
:PROPERTIES:
:TOC:      :include descendants :depth 3
:END:
:CONTENTS:
- [[#section-5c1][Section 5c1]]
  - [[#section-5c1a][Section 5c1a]]
  - [[#section-5c1b][Section 5c1b]]
:END:

**** Section 5c1

This section is included in the Chapter 5 TOC.

***** Section 5c1a

This section is included in the Chapter 5 TOC.

***** Section 5c1b

This section is included in the Chapter 5 TOC.

** 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]]
  - [[#chapter-5-local-settings][Chapter 5: Local settings]]
    - [[#section-5a][Section 5a]]
      - [[#section-5a1][Section 5a1]]
      - [[#section-5a2][Section 5a2]]
    - [[#section-5b][Section 5b]]
      - [[#section-5b1][Section 5b1]]
        - [[#section-5b1a][Section 5b1a]]
        - [[#section-5b1b][Section 5b1b]]
    - [[#section-5c][Section 5c]]
      - [[#section-5c1][Section 5c1]]
        - [[#section-5c1a][Section 5c1a]]
        - [[#section-5c1b][Section 5c1b]]
  - [[#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: