summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/optex/base/maketoc.opm
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/luatex/optex/base/maketoc.opm')
-rw-r--r--Master/texmf-dist/tex/luatex/optex/base/maketoc.opm49
1 files changed, 37 insertions, 12 deletions
diff --git a/Master/texmf-dist/tex/luatex/optex/base/maketoc.opm b/Master/texmf-dist/tex/luatex/optex/base/maketoc.opm
index 84e699d67df..8dfd821640a 100644
--- a/Master/texmf-dist/tex/luatex/optex/base/maketoc.opm
+++ b/Master/texmf-dist/tex/luatex/optex/base/maketoc.opm
@@ -1,16 +1,17 @@
% This is part of the OpTeX project, see http://petr.olsak.net/optex
-\_codedecl \maketoc {Macros for maketoc <2020-03-12>} % preloaded in format
+\_codedecl \maketoc {Macros for maketoc <2020-02-09>} % preloaded in format
\_doc ------------------------------------
- \`\_Xtoc` `{<level>}{<type>}{<number>}<title>` (in `.ref` file) reads the
- specified data and appends them to the \`\_toclist` as
- \^`\_tocline``{<level>}{<type>}{<number>}{<title>}{<gpageno>}{<pageno>}`
+ \`\_Xtoc` `{<level>}{<type>}{<number>}{<o-title>}<title>` (in `.ref` file) reads
+ given data and appends them to the \`\_toclist` as
+ \^`\_tocline``{<level>}{<type>}{<number>}{<o-title>}{<title>}{<gpageno>}{<pageno>}`
where:
\begitems
* `<level>`: 0 reserved, 1: chapter, 2: section, 3: subsection
* `<type>`: the type of the level, i.e. chap, sec, secc
* `<number>`: the number of the chapter/section/subsection in the format 1.2.3
+ * `<o-title>`: outlines title, if differs from `<title>`.
* `<title>`: the title text
* `<gpageno>`: the page number numbered from 1 independently of pagination
* `<pageno>`: the page number used in the pagination
@@ -25,13 +26,13 @@
\_def\_toclist{}
\_newifi \_ifischap \_ischapfalse
-\_def\_Xtoc#1#2#3{\_ifnum#1=0 \_ischaptrue\_fi
- \_addto\_toclist{\_tocline{#1}{#2}{#3}}\_scantoeol\_XtocA}
+\_def\_Xtoc#1#2#3#4{\_ifnum#1=0 \_ischaptrue\_fi
+ \_addto\_toclist{\_tocline{#1}{#2}{#3}{#4}}\_scantoeol\_XtocA}
\_def\_XtocA#1{\_addto\_toclist{{#1}}\_ea\_addto\_ea\_toclist\_ea{\_currpage}}
\_doc ------------------------------------
- \`\_tocline``{<level>}{<type>}{<number>}{<title>}{<gpageno>}{<pageno>}` prints
- the record to the table of contents. It opens group, reduces `\_leftskip`,
+ \`\_tocline``{<level>}{<type>}{<number>}{<o-title>}{<title>}{<gpageno>}{<pageno>}`
+ prints the record to the table of contents. It opens group, reduces `\_leftskip`,
`\_rightskip`, runs the \^`\everytocline` (user can customise the design of TOC
here) and runs `\_tocl:<level> {<number>}{<title>}{<pageno>}` macro.
This macro starts with vertical mode,
@@ -53,15 +54,15 @@
\_cod ------------------------------------
\_newcount \_tocrefnum
-\_def\_tocline#1#2#3#4#5#6{%
+\_def\_tocline#1#2#3#4#5#6#7{%
\_advance\_tocrefnum by1
\_bgroup
\_leftskip=\_iindent \_rightskip=2\_iindent
\_ifischap \_advance\_leftskip by \_iindent \_fi
- \_def\_pgn{\_ilink[pg:#5]}%
+ \_def\_pgn{\_ilink[pg:#6]}%
\_the\_everytocline
\_ifcsname _tocl:#1\_endcsname
- \_cs{_tocl:#1}{#3}{\_scantextokens{#4}}{#6}\_par
+ \_cs{_tocl:#1}{#3}{\_scantextokens{#5}}{#7}\_par
\_fi
\_egroup
}
@@ -96,6 +97,29 @@
\_def\_tocpar{\_nobreak \_hskip-2\_iindent\_null \_par}
\_doc -----------------------------------
+ If you want a special formating of TOC with adding more
+ special lines (no generated as titles from `\chap`, `\sec`, `\secc`), you
+ can define `\addtotoc{<level>}{<type>}{<number>}{<o-title>}{<title>}` macro:
+ \begtt
+ \def\addtotoc#1#2#3#4#5{%
+ \incr\_tocrefnum
+ \_dest[toc:\_the\_tocrefnum]%
+ \_ewref\_Xtoc{{#1}{#2}{#3}{#4}#5}%
+ }
+ \endtt
+ and you can declare special lines (or something else)
+ as an unused level (10 in the following example):
+ \begtt
+ \sdef{_tocl:10}#1#2#3{\medskip\hbox{\Blue #2}\medskip}
+ \endtt
+ Now, users can add a blue line into TOC by
+ \begtt \catcode`\<=13
+ \addtotoc{10}{blue-line}{}{\relax}{<blue text to be added in the TOC>}
+ \endtt
+ anywhere in the document. Note that `\relax` in the fourth parameter
+ means that outline will be not generated. And second parameter
+ `blue-line` is only a comment (unused in macros).
+
\`\maketoc` prints warning if TOC data is empty, else it creates TOC by
running \^`\_toclist`
\_cod ----------------------------------
@@ -124,6 +148,7 @@
\_endcode
+2021-02-09 \thisoutline implemented
2020-04-23 \_tocpar introduced (incompatible change)
2020-04-22 \_pg -> \_pgn (incompatible change)
-2020-03-12 introduced \ No newline at end of file
+2020-03-12 introduced