summaryrefslogtreecommitdiff
path: root/macros/luatex/optex/outlines.opm
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2020-02-13 03:00:51 +0000
committerNorbert Preining <norbert@preining.info>2020-02-13 03:00:51 +0000
commit8379012d545fd6a59fae8842d97d14ec0c2b27d7 (patch)
tree740889c25a2f4eb83c4433954ec856b568728575 /macros/luatex/optex/outlines.opm
parent2dbfa6c67f1c50ff228326c6ec6cccfdecb61735 (diff)
CTAN sync 202002130300
Diffstat (limited to 'macros/luatex/optex/outlines.opm')
-rw-r--r--macros/luatex/optex/outlines.opm62
1 files changed, 62 insertions, 0 deletions
diff --git a/macros/luatex/optex/outlines.opm b/macros/luatex/optex/outlines.opm
new file mode 100644
index 0000000000..e95f4ec9c5
--- /dev/null
+++ b/macros/luatex/optex/outlines.opm
@@ -0,0 +1,62 @@
+%% This is part of OpTeX project, see http://petr.olsak.net/optex
+
+\_codedecl \pdfunidef {PDFunicode strings for outlines <2019-05-21>}
+
+\_def\_outlines#1{\_pdfcatalog{/PageMode/UseOutlines}\openref
+ \_ifx\_toclist\_empty
+ \_opwarning{\noexpand\outlines -- data unavailable. TeX me again}%
+ \_else
+ \_ifx\_urlcolor\_empty
+ \opwarning{\_noexpand\outlines doesn't work when \_noexpand\hyperlinks isn't declared}\_fi
+ {\_let\_tocline=\_outlinesA
+ \_count0=0 \_count1=0 \_toclist % calculate numbers o childs
+ \_def\_outlinelevel{#1}\_let\_tocline=\_outlinesB
+ \_count0=0 \_count1=0 \_toclist}% create outlines
+ \_fi
+}
+\_def\_outlinesA#1#2#3#4#5{%
+ \_advance\_count#1 by1
+ \_ifcase#1\_or
+ \_addoneol{_ol:\_the\_count0}\_or
+ \_addoneol{_ol:\_the\_count0:\_the\_count1}\_fi
+}
+\_def\_addoneol#1{%
+ \_ifcsname #1\_endcsname
+ \_tmpnum=\_csname#1\_endcsname\_relax
+ \_advance\_tmpnum by1 \_sxdef{#1}{\_the\_tmpnum}%
+ \_else \_sxdef{#1}{1}%
+ \_fi
+}
+\_def\_outlinesB#1#2#3#4#5{%
+ \_advance\_count#1 by1
+ \_ifcase#1\_tmpnum=\_csifdefined{_ol:\_the\_count0}{0}\_relax\_or
+ \_tmpnum=\_csifdefined{_ol:\_the\_count0:\_the\_count1}{0}\_relax\_or
+ \_tmpnum = 0\_relax\_fi
+ \_pdfunidef\_tmp{#4}%
+ \_outlinesC{#1}{toc:\tocilabel.#3}{\_ifnum#1<\_outlinelevel\_space\_else-\_fi}{\_tmpnum}{\_tmp}%
+}
+\_def\_csifdefined#1#2{\_ifcsname #1\_endcsname \_csname#1\_endcsname \_else #2\_fi}
+\_def\_outlinesC#1#2#3#4#5{\_pdfoutline goto name{#2} count #3#4{#5}\_relax}
+
+\_newcount\_oulnum
+\_def\_insertoutline#1{\_global\_advance\_oulnum by1
+ \_pdfdest name{oul:\_the\_oulnum} xyz\_relax
+ \_pdfoutline goto name{oul:\_the\_oulnum} count0 {#1}\_relax
+}
+
+\_public
+ \outlines \insertoutline ;
+
+\_endcode % ----------------------------
+
+The PDF format provides ``outlines'' which are notes placed in the special frame of
+the PDF viewer. These notes can be managed as structured and hyperlinked
+table of contents of the document. The command "\outlines{<level>}" creates
+such outlines from data used for table of contents in the document. The
+"<level>" parameter gives the level of opened sub-outlines
+in the default view. The deeper levels can be open by mouse click on the
+triangle symbol after that.
+
+The command "\insertoutline{<text>}" inserts next entry into PDF outlines at
+the main level~0. This entry can be placed before table of contents (created
+by "\outlines") or after it.