texlive[43648] Master/texmf-dist: ocgx2 (30mar17)

commits+karl at tug.org commits+karl at tug.org
Thu Mar 30 23:32:38 CEST 2017


Revision: 43648
          http://tug.org/svn/texlive?view=revision&revision=43648
Author:   karl
Date:     2017-03-30 23:32:38 +0200 (Thu, 30 Mar 2017)
Log Message:
-----------
ocgx2 (30mar17)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/ocgx2/ChangeLog
    trunk/Master/texmf-dist/doc/latex/ocgx2/README
    trunk/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty
    trunk/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/latex/ocgx2/README.md

Modified: trunk/Master/texmf-dist/doc/latex/ocgx2/ChangeLog
===================================================================
--- trunk/Master/texmf-dist/doc/latex/ocgx2/ChangeLog	2017-03-30 21:32:20 UTC (rev 43647)
+++ trunk/Master/texmf-dist/doc/latex/ocgx2/ChangeLog	2017-03-30 21:32:38 UTC (rev 43648)
@@ -1,3 +1,16 @@
+2017-03-30
+	* v0.24 : ocgx2.sty
+	* fix: \ocglinkprotect{...} messing up the graphics state (CTM)
+
+2017-03-30
+	* v0.23 : ocgx2.sty
+	* v0.10  : ocgbase.sty
+	* fix: nested ocgcolorlinks over multiple pages
+
+2017-03-26
+	* v0.22 : ocgx2.sty
+	* fix: nested ocgcolorlinks
+
 2017-03-23
 	* v0.21 : ocgx2.sty
 	* v0.9  : ocgbase.sty

Modified: trunk/Master/texmf-dist/doc/latex/ocgx2/README
===================================================================
(Binary files differ)

Added: trunk/Master/texmf-dist/doc/latex/ocgx2/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/ocgx2/README.md	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/ocgx2/README.md	2017-03-30 21:32:38 UTC (rev 43648)
@@ -0,0 +1,168 @@
+# The `ocgx2` LaTeX Package
+
+© 2015--`\today`, Alexander Grahn
+
+https://github.com/agrahn/ocgx2
+
+## Introduction
+
+This package serves as a drop-in replacement for the already existing packages
+`ocgx` by Paul Gaborit and `ocg-p` by Werner Moshammer for the creation of PDF
+Layers.
+
+It re-implements the functionality of the `ocg`, `ocgx` and `ocg-p` packages and
+adds support for all known engines and back-ends including:
+
+- LaTeX ⇒ dvips ⇒ ps2pdf/Distiller
+- (Xe)LaTeX ⇒ (x)dvipdfmx
+- pdfLaTeX, LuaLaTeX
+
+Also, it adds some features, improvements and bug fixes, such as package
+options, remembering option settings of re-opened OCGs, correct behaviour of
+layer switching links that were themselves placed on layers, correct listing
+of (nested) OCGs in the layers tab of PDF viewers, compatibility with the
+`animate` and `media9` packages, a re-implementation of **`hyperref`**'s
+**`ocgcolorlink`** option.
+
+To enable dvipdfmx support, pass `dvipdfmx` globally as a class option.
+
+----
+
+*New features:*
+
++ layers extending across **page breaks**
++ grouping layers into **Radio Button Groups**
++ re-implementing `hyperref`'s `ocgcolorlinks` option
+
+for creating OCG coloured links, which are printed on paper in the default
+text colour and which can, unlike the original `hyperref` implementation,
+extend over **line** and **page breaks**. Moreover, with pdfLaTeX/LuaLaTeX, OCG
+coloured links can be **nested**.
+
+Coloured OCG links are enabled with
+
+````latex
+\usepackage{hyperref} % do NOT set [ocgcolorlinks] here!
+\usepackage[ocgcolorlinks]{ocgx2}
+````
+
+----
+
+`ocgx2` uses code from file `tikzlibraryocgx.code.tex` by P. Gaborit to enable
+TikZ styles for creating PDF Layers and clickable layer switching links in the
+`tikzpicture` context.
+
+Just say:
+````latex
+\usepackage[tikz]{ocgx2}
+````
+instead of
+````latex
+\usepackage{tikz}
+\usetikzlibrary{ocgx}
+````
+to enable these TikZ styles and read the `ocgx` documentation about their usage:
+````
+texdoc ocgx
+````
+The `/tikz/ocg/opts=<ocg options>` parameter adds to the list in section "How to
+add TikZ scopes into OCGs" in the `ocgx` manual. It allows passing `ocg`
+environment options (see below) to the TikZ scope.
+
+## Usage
+
+````latex
+\usepackage[<options>]{ocgx2}
+
+\begin{ocg}[<options>]{<layer name>}{<layer id>}{<initial visibility>}
+  ... material to be put on a PDF layer ...
+\end{ocg}
+````
+With `<initial visibility>` = `( on | true | 1 )  |  ( off | false | 0 )`
+
+and `<options>`:
+````
+viewocg = always | never | ifvisible
+printocg =  always | never | ifvisible
+exportocg =  always | never | ifvisible
+listintoolbar= always | never | iffirstuse
+
+showingui
+radiobtngrp = <group name>
+tikz
+ocgcolorlinks
+````
+**not in** `ocgx`, `ocg-p`:
+
+* `showingui` (same as `listintoolbar`)
+* `radiobtngrp = <group name>` (string; environment-only option)
+* `tikz`  (package-only option, see above)
+* `ocgcolorlinks`  (package-only option, see above)
+
+Package options have global scope. Environment options override package options
+locally.
+
+Layers can be added to one or several Radio Button Groups using the new option
+`radiobtngrp`. From all layers within a Radio Button Group only one can be
+enabled at a time. Enabling a layer, e. g. in the Layers tab of the PDF viewer,
+automatically hides the previously visible layer.  Option `radiobtngrp` can
+be used repeatedly for the same OCG in order to add the layer to more than one
+Radio Button Group.
+
+`ocg` environments can be nested and span multiple pages.
+
+See the `ocg-p` manual about the environment usage and the meaning of the
+remaining options:
+````
+texdoc ocg-p
+````
+
+----
+
+Clickable links for switching PDF layer visibility are created with:
+````latex
+\switchocg{<layer IDs to toggle, space separated>}{<link text>}
+\showocg{<layer IDs to switch ON, space separated>}{<link text>}
+\hideocg{<layer IDs to switch OFF, space separated>}{<link text>}
+\actionsocg{<IDs to toggle>}{<IDs to switch ON>}{<IDs to switch OFF>}{<link text>}
+````
+For details about their usage, read the `ocgx` package manual:
+````
+texdoc ocgx
+````
+For compatibility with the `ocg-p` package, the following commands have
+been provided:
+````latex
+\toggleocgs[triggerocg=...]{<layer IDs to toggle, space separated>}{<link text>}
+\showocgs[triggerocg=...]{<layer IDs to switch ON, space separated>}{<link text>}
+\hideocgs[triggerocg=...]{<layer IDs to switch OFF, space separated>}{<link text>}
+\setocgs[triggerocg=...]{<IDs to toggle>}{<IDs to switch ON>}{<IDs to switch OFF>}{<link text>}
+````
+See the `ocg-p` package manual for the meaning of `triggerocg=...`.
+
+----
+
+Breakable OCG coloured links work best with normal text as link text. If the
+link text is mixed with graphical content, such as from external files or
+inline graphics (e. g. TikZ) and even `\fbox`-ed text, these graphical parts
+must be enclosed in
+````latex
+\ocglinkprotect{...}
+````
+
+For example:
+````latex
+\href{http://ctan.org}{Visit me on \ocglinkprotect{\includegraphics{ctan-lion}}!}
+````
+
+Alternatively, the whole link can be placed inside
+````latex
+\hypersetup{breaklinks=false}...\hypersetup{breaklinks=true}
+````
+to temporarily disable breakable links.
+
+## License
+
+This material is subject to the [LaTeX Project Public License](http://mirrors.ctan.org/help/Catalogue/licenses.lppl.html
+).
+


Property changes on: trunk/Master/texmf-dist/doc/latex/ocgx2/README.md
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty	2017-03-30 21:32:20 UTC (rev 43647)
+++ trunk/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty	2017-03-30 21:32:38 UTC (rev 43648)
@@ -96,8 +96,8 @@
 \RequirePackage{expl3}
 \RequirePackage{pdfbase}
 
-\def\g at ocgbase@date at tl{2017/03/16}
-\def\g at ocgbase@version at tl{0.8}
+\def\g at ocgbase@date at tl{2017/03/30}
+\def\g at ocgbase@version at tl{0.10}
 
 \ProvidesExplPackage{ocgbase}{\g at ocgbase@date at tl}{\g at ocgbase@version at tl}
 {support package for ocgx2.sty}

Modified: trunk/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty	2017-03-30 21:32:20 UTC (rev 43647)
+++ trunk/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty	2017-03-30 21:32:38 UTC (rev 43648)
@@ -37,8 +37,8 @@
 \RequirePackage{xparse}
 \RequirePackage{l3keys2e}
 
-\def\g at ocgxii@date at tl{2017/03/26}
-\def\g at ocgxii@version at tl{0.22}
+\def\g at ocgxii@date at tl{2017/03/30}
+\def\g at ocgxii@version at tl{0.24}
 
 \ProvidesExplPackage{ocgx2}{\g at ocgxii@date at tl}{\g at ocgxii@version at tl}
 {ports `ocgx' functionality to dvips+ps2pdf, xelatex and dvipdfmx}
@@ -51,6 +51,8 @@
     \token_to_str:N\providecommand\token_to_str:N\ocgxii at newkey[2]{}
     \token_to_str:N\providecommand
       \token_to_str:N\ocgxii at ocg@stack at on@page[2]{}
+    \token_to_str:N\providecommand
+      \token_to_str:N\ocgxii at lnkcol@stack at on@page[2]{}
   }
 }
 
@@ -257,6 +259,11 @@
 
 \cs_new_nopar:Npn\ocgxii at lnkcol@stack at on@page#1#2{
   \seq_gset_from_clist:cn{g_pending_lnkcols_on_#1_seq}{#2}
+  %re-add braces around items
+  \seq_map_inline:cn{g_pending_lnkcols_on_#1_seq}{
+    \seq_gpop_left:cN{g_pending_lnkcols_on_#1_seq}\l_trash_tl
+    \seq_gput_right:cn{g_pending_lnkcols_on_#1_seq}{{##1}}
+  }
 }
 \ocgxii at lnkcol@stack at on@page{0}{} %initialize
 
@@ -287,8 +294,8 @@
     }
     % now close the colourlink opened last
     \seq_get:cNT{g_pending_lnkcols_on_\int_use:c{g_ocgxii_page_int}_seq}\l_tmpa_tl{
-      \tl_gset:Nx\ocgxii at ocgcolor{{\l_tmpa_tl}}
-      \ocgxii_colorlink_end:
+      \tl_gset:Nx\g_ocgxii_lnkcol_tl{{\l_tmpa_tl}}
+      \ocgxii_colourlink_end:
     }
   }
   %check whether end-of-page ocg stack has settled
@@ -319,7 +326,7 @@
   }\l_tmpb_tl{\ocgbase_oc_emc:}
 }
 
-%begin-of-page action (to output box background)
+%begin-of-page action
 \pbs_bop_action:n{
   % re-open all pending ocgs in original order
   \seq_set_eq:Nc\l_ocgxii_pending_ocgs_seq{
@@ -330,12 +337,9 @@
     \ocgbase_oc_bdc:n{\l_tmpa_tl}
   }
   % re-open the colourlink opened last
-  \seq_if_exist:cT{g_pending_lnkcols_on_\int_use:c{g_ocgxii_page_int}_seq}{
-    \seq_gset_eq:Nc\g_ocgxii_lnk_color_seq{g_pending_lnkcols_on_\int_use:c{g_ocgxii_page_int}_seq}
-    \seq_get:NNT\g_ocgxii_lnk_color_seq\l_tmpa_tl{
-      \tl_gset:Nx\ocgxii at ocgcolor{{\l_tmpa_tl}}
-      \ocgxii_colorlink_begin:
-    }
+  \seq_get:cNT{g_pending_lnkcols_on_\int_use:c{g_ocgxii_page_int}_seq}\l_tmpa_tl{
+    \tl_gset:Nx\g_ocgxii_lnkcol_tl{{\l_tmpa_tl}}
+    \ocgxii_colourlink_begin:
   }
   \int_gincr:N\g_ocgxii_page_int
   % copy pending ocg stack from previous page, if it has not been initialized
@@ -656,103 +660,122 @@
   }
 }
 
+\cs_new_nopar:Nn\ocgxii_colourlink_begin:{}
+\cs_new_nopar:Nn\ocgxii_colourlink_end:{}
+\cs_new_nopar:Nn\ocgxii_colourlink_nobreak_begin:{
+  \hbox_set:Nn0\bgroup\color at begingroup\tl_set_eq:NN\color at setgroup\group_begin:
+}
+\cs_new_nopar:Nn\ocgxii_colourlink_nobreak_end:{
+  \color at endgroup\egroup
+  \mbox{
+    \ocgbase_oc_bdc:n{\g_ocgxii_ocgprint_tl}
+    \hbox_to_zero:n{\box_use:N0\hss}
+    \ocgbase_oc_emc:\ocgbase_oc_bdc:n{\g_ocgxii_ocgview_tl}
+    \group_begin:
+      \exp_after:wN\HyColor at UseColor\l_ocgxii_lnkcol_tl
+      \box_use_clear:N0
+    \group_end:
+    \ocgbase_oc_emc:
+  }
+}
+
+\seq_new:N\g_ocgxii_lnk_color_seq %stack of colours of currently open links
+
 \bool_if:nTF{\sys_if_output_dvi_p: && !\g_ocgxii_dvipdfmx_bool}{
   % non-breakable links in dvips
   \cs_new_nopar:Nn\ocgxii_enable_ocglinks:{
     \def\Hy at colorlink##1{
-      \begingroup
-      \def\Hy at ocgcolor{##1}
-      \setbox0=\hbox\bgroup\color at begingroup\let\color at setgroup\begingroup
+      \group_begin:
+      \tl_set:Nn\l_ocgxii_lnkcol_tl{##1}
+      \ocgxii_colourlink_nobreak_begin:
     }
     \def\Hy at endcolorlink{
-      \color at endgroup\egroup
-      \mbox{
-        \ocgbase at oc@bdc{\OBJ at OCG@print}
-        \rlap{\copy0}
-        \ocgbase at oc@emc\ocgbase at oc@bdc{\OBJ at OCG@view}
-        \begingroup
-          \expandafter\HyColor at UseColor\Hy at ocgcolor
-          \box0
-        \endgroup
-        \ocgbase at oc@emc
-      }
-      \endgroup
+      \ocgxii_colourlink_nobreak_end:
+      \group_end:
     }
   }
 }{
   % pdftex,luatex,xetex,dvipdfmx:
   % ocgcolorlinks that extend over line and page breaks
-
-  \seq_new:N\g_ocgxii_lnk_color_seq %stack of colours of currently open links
-
   \cs_new_nopar:Nn\ocgxii_enable_ocglinks:{
     \def\Hy at colorlink##1{
-      \ifx\Hy at setbreaklinks\@gobble
-        \ifHy at breaklinks\Hy at breaklinkstrue\fi
-      \else
+      \ifx\Hy at setbreaklinks\@gobble\else
         \Hy at breaklinkstrue
       \fi
       \ifHy at breaklinks
         \seq_get_left:NNT\g_ocgxii_lnk_color_seq\l_tmpa_tl{
-          \tl_gset_eq:NN\ocgxii at ocgcolor\l_tmpa_tl
-          \ocgxii_colorlink_end:
+          \tl_gset_eq:NN\g_ocgxii_lnkcol_tl\l_tmpa_tl
+          \ocgxii_colourlink_end:
         }
-        \begingroup
-        \ocgxii_colorlink_begin:
+        \group_begin:
+        \ocgxii_colourlink_begin:
         \seq_gpush:Nx\g_ocgxii_lnk_color_seq{{##1}}
         \ocgxii_stack_shipout:NN\ocgxii at lnkcol@stack at on@page\g_ocgxii_lnk_color_seq
       \else
-        \begingroup
-        \def\ocgxii at ocgcolor{##1}
-        \setbox0=\hbox\bgroup\color at begingroup\let\color at setgroup\begingroup
+        \group_begin:
+        \tl_set:Nn\l_ocgxii_lnkcol_tl{##1}
+        \ocgxii_colourlink_nobreak_begin:
       \fi
     }
     \def\Hy at endcolorlink{
       \ifHy at breaklinks
         \seq_gpop:NN\g_ocgxii_lnk_color_seq\l_tmpa_tl
-        \tl_gset_eq:NN\ocgxii at ocgcolor\l_tmpa_tl
+        \tl_gset_eq:NN\g_ocgxii_lnkcol_tl\l_tmpa_tl
         \ocgxii_stack_shipout:NN\ocgxii at lnkcol@stack at on@page\g_ocgxii_lnk_color_seq
-        \ocgxii_colorlink_end:
-        \endgroup
+        \ocgxii_colourlink_end:
+        \group_end:
         \seq_get_left:NNT\g_ocgxii_lnk_color_seq\l_tmpa_tl{
-          \tl_gset_eq:NN\ocgxii at ocgcolor\l_tmpa_tl
-          \ocgxii_colorlink_begin:
+          \tl_gset_eq:NN\g_ocgxii_lnkcol_tl\l_tmpa_tl
+          \ocgxii_colourlink_begin:
         }
       \else
-        \color at endgroup\egroup
-        \mbox{
-          \ocgbase at oc@bdc{\OBJ at OCG@print}
-          \rlap{\copy0}
-          \ocgbase at oc@emc\ocgbase at oc@bdc{\OBJ at OCG@view}
-          \begingroup
-            \expandafter\HyColor at UseColor\ocgxii at ocgcolor
-            \box0
-          \endgroup
-          \ocgbase at oc@emc
-        }
-        \endgroup
+        \ocgxii_colourlink_nobreak_end:
+        \group_end:
       \fi
     }
-    \cs_new_nopar:Nn\ocgxii_colorlink_begin:{
-      \ocgxii_literal_page:n{q~7~Tr}
-      \vbox_to_zero:n{
-        \vss
-        \hbox_to_zero:n{\skip_horizontal:n{2\paperwidth}.\hss}
-        \skip_vertical:n{2\paperheight}
-      }
+  }
+  \cs_gset_nopar:Nn\ocgxii_colourlink_begin:{
+    \ocgxii_literal_page:n{q~7~Tr}
+  }
+  \cs_gset_nopar:Nn\ocgxii_colourlink_end:{
+    \vbox_to_zero:n{
+      \vss
+      \hbox_to_zero:n{\skip_horizontal:n{2\paperwidth}.\hss}
+      \skip_vertical:n{2\paperheight}
     }
-    \cs_new_nopar:Nn\ocgxii_colorlink_end:{
-      \ocgbase at oc@bdc{\OBJ at OCG@print}
+    \ocgbase_oc_bdc:n{\g_ocgxii_ocgprint_tl}
+      \ocgxii_literal_page:n{-88888~-88888~99999~99999~re~f}
+    \ocgbase_oc_emc:
+    \ocgbase_oc_bdc:n{\g_ocgxii_ocgview_tl}
+      \group_begin:
+        \exp_after:wN\HyColor at UseColor\g_ocgxii_lnkcol_tl
         \ocgxii_literal_page:n{-88888~-88888~99999~99999~re~f}
-      \ocgbase at oc@emc
-      \ocgbase at oc@bdc{\OBJ at OCG@view}
-        \begingroup
-          \expandafter\HyColor at UseColor\ocgxii at ocgcolor
-          \ocgxii_literal_page:n{-88888~-88888~99999~99999~re~f}
-        \endgroup
-      \ocgbase at oc@emc
-      \ocgxii_literal_page:n{0~Tr~Q}
+      \group_end:
+    \ocgbase_oc_emc:
+    \ocgxii_literal_page:n{0~Tr~Q}
+  }
+}
+
+% user command for protecting graphical content (external file, inline
+% [e. g. TikZ], \fbox{...}) inside breakable ocgcolorlink
+\DeclareDocumentCommand\ocglinkprotect{m}{
+  \seq_get_left:NNT\g_ocgxii_lnk_color_seq\l_tmpa_tl{
+    \tl_gset_eq:NN\g_ocgxii_lnkcol_tl\l_tmpa_tl
+    \ocgxii_colourlink_end:
+    \group_begin:
+      \tl_set_eq:NN\l_ocgxii_lnkcol_tl\l_tmpa_tl
+      \ocgxii_colourlink_nobreak_begin:
+  }
+  #1
+  \seq_get_left:NNT\g_ocgxii_lnk_color_seq\l_tmpa_tl{
+      \ocgxii_colourlink_nobreak_end:
+    \group_end:
+    \vbox_to_zero:n{ % avoid mixing up CTM
+      \vss
+      \hbox_to_zero:n{\skip_horizontal:n{2\paperwidth}.\hss}
+      \skip_vertical:n{2\paperheight}
     }
+    \ocgxii_colourlink_begin:
   }
 }
 
@@ -761,9 +784,9 @@
     \Hy at colorlinkstrue
     \Hy at AtBeginDocument{
       \ocgbase_new_ocg:nnn{OCView}{/Print<</PrintState/OFF>>}{on}
-      \tl_gset:Nx\OBJ at OCG@view{\ocgbase_last_ocg:}
+      \tl_gset:Nx\g_ocgxii_ocgview_tl{\ocgbase_last_ocg:}
       \ocgbase_new_ocg:nnn{OCPrint}{/Print<</PrintState/ON>>}{off}
-      \tl_gset:Nx\OBJ at OCG@print{\ocgbase_last_ocg:}
+      \tl_gset:Nx\g_ocgxii_ocgprint_tl{\ocgbase_last_ocg:}
       \ocgxii_enable_ocglinks:
     }
   }{



More information about the tex-live-commits mailing list