summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty11
-rw-r--r--Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty132
2 files changed, 92 insertions, 51 deletions
diff --git a/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty b/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty
index 5b1872cd213..956f0fb86d2 100644
--- a/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty
+++ b/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty
@@ -102,6 +102,17 @@
\ProvidesExplPackage{ocgbase}{\g@ocgbase@date@tl}{\g@ocgbase@version@tl}
{support package for ocgx2.sty}
+\msg_set:nnnn{ocgbase}{support~outdated}{
+ Support~package~`#1'~too~old.
+}{
+ Get~an~up~to~date~version~of~`#1'.\\
+ Aborting.
+}
+\@ifpackagelater{pdfbase}{2017/03/23}{}{
+ \msg_error:nnn{ocgbase}{support~outdated}{pdfbase.sty}
+ \tex_endinput:D
+}
+
\tl_new:N\g_ocgbase_ocgs_tl %takes ocg object refs
\seq_new:N\g_ocgbase_ocgorder_seq
\seq_new:N\g_ocgbase_offocgs_seq
diff --git a/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty b/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty
index 2654ce7309c..5654fc279fe 100644
--- a/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty
+++ b/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty
@@ -37,8 +37,8 @@
\RequirePackage{xparse}
\RequirePackage{l3keys2e}
-\def\g@ocgxii@date@tl{2017/03/23}
-\def\g@ocgxii@version@tl{0.21}
+\def\g@ocgxii@date@tl{2017/03/26}
+\def\g@ocgxii@version@tl{0.22}
\ProvidesExplPackage{ocgx2}{\g@ocgxii@date@tl}{\g@ocgxii@version@tl}
{ports `ocgx' functionality to dvips+ps2pdf, xelatex and dvipdfmx}
@@ -50,7 +50,7 @@
\iow_now:Nx\@mainaux{
\token_to_str:N\providecommand\token_to_str:N\ocgxii@newkey[2]{}
\token_to_str:N\providecommand
- \token_to_str:N\ocgxii@stack@on@page[2]{}
+ \token_to_str:N\ocgxii@ocg@stack@on@page[2]{}
}
}
@@ -134,16 +134,6 @@
\sys_if_engine_xetex:T{\bool_gset_true:N\g_ocgxii_dvipdfmx_bool}
\RequirePackage{ocgbase} %also loads pdfbase.sty
-\msg_set:nnnn{ocgx2}{support~outdated}{
- Support~package~`#1'~too~old.
-}{
- Get~an~up~to~date~version~of~`#1'.\\
- Aborting.
-}
-\@ifpackagelater{pdfbase}{2017/03/23}{}{
- \msg_error:nnn{xsavebox}{support~outdated}{pdfbase.sty}
- \tex_endinput:D
-}
%re-implement ocg-p's `ocg' environment
\DeclareDocumentEnvironment{ocg}{O{}mmm}{
@@ -215,7 +205,7 @@
}
\tl_gset:cx{ocgx2.ocg.#3}{\tl_use:c{ocgxii@#3}}
\ocgbase_ocgstack_push:n{\tl_use:c{ocgxii@#3}}
- \ocgxii_ocgstack_shipout:N\g_ocgbase_ocgstack_seq
+ \ocgxii_stack_shipout:NN\ocgxii@ocg@stack@on@page\g_ocgbase_ocgstack_seq
\group_end:
\ocgbase_oc_bdc:n{\tl_use:c{ocgxii@#3}}
\ignorespaces
@@ -236,7 +226,7 @@
\seq_gpop_left:NN\g_ocgxii_nested_seq\l_trash_tl
}
\ocgbase_ocgstack_pop:N\l_trash_tl
- \ocgxii_ocgstack_shipout:N\g_ocgbase_ocgstack_seq
+ \ocgxii_stack_shipout:NN\ocgxii@ocg@stack@on@page\g_ocgbase_ocgstack_seq
\bool_gset_false:N\g_ocgxii_nestedB_bool
\bool_gset_true:N\g_ocgxii_nestedE_bool
}
@@ -245,14 +235,15 @@
\bool_new:N\g_ocgxii_nestedE_bool % nested OCG end
\seq_new:N\g_ocgxii_nested_seq % for keeping track of parent OCGs
-\cs_new_nopar:Nn\ocgxii_ocgstack_shipout:N{
+\cs_new_nopar:Nn\ocgxii_stack_shipout:NN{
\iow_shipout_x:Nx\@mainaux{
- \token_to_str:N\ocgxii@stack@on@page{
+ \token_to_str:N#1{
\exp_not:N\int_use:N\g_ocgxii_page_int
- }{\seq_use:Nn#1{,}}
+ }{\seq_use:Nn#2{,}}
}
}
-\cs_new_nopar:Npn\ocgxii@stack@on@page#1#2{
+
+\cs_new_nopar:Npn\ocgxii@ocg@stack@on@page#1#2{
\seq_gset_from_clist:cn{g_pending_ocgs_on_#1_seq}{#2}
%re-add braces around items for dvips
\bool_if:nT{\sys_if_output_dvi_p: && !\g_ocgxii_dvipdfmx_bool}{
@@ -262,10 +253,44 @@
}
}
}
-\ocgxii@stack@on@page{0}{} %initialize
+\ocgxii@ocg@stack@on@page{0}{} %initialize
+
+\cs_new_nopar:Npn\ocgxii@lnkcol@stack@on@page#1#2{
+ \seq_gset_from_clist:cn{g_pending_lnkcols_on_#1_seq}{#2}
+}
+\ocgxii@lnkcol@stack@on@page{0}{} %initialize
%end-of-page action
\pbs_eop_action:n{
+ \seq_if_exist:cT{g_pending_lnkcols_on_\int_use:c{g_ocgxii_page_int}_seq}{
+ %check whether end-of-page link colour stack has settled
+ \iow_shipout:Nx\@mainaux{
+ \token_to_str:N\ocgxii@newkey{ocgx2.oldlnkcol.\int_use:N\g_ocgxii_page_int}{
+ \seq_use:cn{g_pending_lnkcols_on_\int_use:c{g_ocgxii_page_int}_seq}{,}
+ }
+ }
+ \bool_if:nT{
+ !\cs_if_exist:cTF{ocgx2.oldlnkcol.\int_use:N\g_ocgxii_page_int}{
+ \str_if_eq_x_p:nn{
+ \tl_use:c{ocgx2.oldlnkcol.\int_use:N\g_ocgxii_page_int}
+ }{
+ \seq_use:cn{g_pending_lnkcols_on_\int_use:c{g_ocgxii_page_int}_seq}{,}
+ }
+ }{
+ \c_false_bool
+ }
+ }{
+ \tl_if_exist:NF\g_ocgxii_rerunwarned_tl{
+ \tl_new:N\g_ocgxii_rerunwarned_tl
+ \AtEndDocument{\msg_warning:nn{ocgx2}{rerun}}
+ }
+ }
+ % 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@ocgcolor{{\l_tmpa_tl}}
+ \ocgxii_colorlink_end:
+ }
+ }
%check whether end-of-page ocg stack has settled
\iow_shipout:Nx\@mainaux{
\token_to_str:N\ocgxii@newkey{ocgx2.oldstack.\int_use:N\g_ocgxii_page_int}{
@@ -291,27 +316,25 @@
%now close pending ocgs
\seq_map_variable:cNn{
g_pending_ocgs_on_\int_use:c{g_ocgxii_page_int}_seq
- }\l_ocgxii_arg_tl{
- \str_if_eq_x:nnTF{\l_ocgxii_arg_tl}{(ocglink)}{
- \ocgxii_colorlink_end:
- }{
- \ocgbase_oc_emc:
- }
- }
+ }\l_tmpb_tl{\ocgbase_oc_emc:}
}
%begin-of-page action (to output box background)
\pbs_bop_action:n{
- % re-open pending ocgs
- \seq_set_eq:Nc\l_ocgxii_temp_seq{
+ % re-open all pending ocgs in original order
+ \seq_set_eq:Nc\l_ocgxii_pending_ocgs_seq{
g_pending_ocgs_on_\int_use:c{g_ocgxii_page_int}_seq
}
- \seq_reverse:N\l_ocgxii_temp_seq
- \seq_map_variable:NNn\l_ocgxii_temp_seq\l_ocgxii_arg_tl{
- \str_if_eq_x:nnTF{\l_ocgxii_arg_tl}{(ocglink)}{
+ \seq_reverse:N\l_ocgxii_pending_ocgs_seq
+ \seq_map_variable:NNn\l_ocgxii_pending_ocgs_seq\l_tmpa_tl{
+ \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@ocgcolor{{\l_tmpa_tl}}
\ocgxii_colorlink_begin:
- }{
- \ocgbase_oc_bdc:n{\l_ocgxii_arg_tl}
}
}
\int_gincr:N\g_ocgxii_page_int
@@ -324,6 +347,14 @@
g_pending_ocgs_on_\int_eval:n{\g_ocgxii_page_int-\c_one}_seq
}
}
+ %the same for link colour stack
+ \seq_if_exist:cF{g_pending_lnkcols_on_\int_use:c{g_ocgxii_page_int}_seq}{
+ \seq_gset_eq:cc{
+ g_pending_lnkcols_on_\int_use:c{g_ocgxii_page_int}_seq
+ }{
+ g_pending_lnkcols_on_\int_eval:n{\g_ocgxii_page_int-\c_one}_seq
+ }
+ }
}
\int_new:N\g_ocgxii_page_int %abs. page counter
@@ -651,6 +682,9 @@
}{
% 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@colorlink##1{
\ifx\Hy@setbreaklinks\@gobble
@@ -659,14 +693,14 @@
\Hy@breaklinkstrue
\fi
\ifHy@breaklinks
- \seq_if_in:NnT\g_ocgbase_ocgstack_seq{(ocglink)}{
- \msg_error:nn{ocgx2}{nested~breakable~ocgcolorlinks}
+ \seq_get_left:NNT\g_ocgxii_lnk_color_seq\l_tmpa_tl{
+ \tl_gset_eq:NN\ocgxii@ocgcolor\l_tmpa_tl
+ \ocgxii_colorlink_end:
}
- \ocgbase_ocgstack_push:n{(ocglink)}
- \ocgxii_ocgstack_shipout:N\g_ocgbase_ocgstack_seq
\begingroup
- \gdef\ocgxii@ocgcolor{##1}
\ocgxii_colorlink_begin:
+ \seq_gpush:Nx\g_ocgxii_lnk_color_seq{{##1}}
+ \ocgxii_stack_shipout:NN\ocgxii@lnkcol@stack@on@page\g_ocgxii_lnk_color_seq
\else
\begingroup
\def\ocgxii@ocgcolor{##1}
@@ -675,10 +709,15 @@
}
\def\Hy@endcolorlink{
\ifHy@breaklinks
+ \seq_gpop:NN\g_ocgxii_lnk_color_seq\l_tmpa_tl
+ \tl_gset_eq:NN\ocgxii@ocgcolor\l_tmpa_tl
+ \ocgxii_stack_shipout:NN\ocgxii@lnkcol@stack@on@page\g_ocgxii_lnk_color_seq
\ocgxii_colorlink_end:
- \ocgbase_ocgstack_pop:N\l_trash_tl
- \ocgxii_ocgstack_shipout:N\g_ocgbase_ocgstack_seq
\endgroup
+ \seq_get_left:NNT\g_ocgxii_lnk_color_seq\l_tmpa_tl{
+ \tl_gset_eq:NN\ocgxii@ocgcolor\l_tmpa_tl
+ \ocgxii_colorlink_begin:
+ }
\else
\color@endgroup\egroup
\mbox{
@@ -717,7 +756,7 @@
}
}
-\bool_if:nT\l_ocgxii_ocgcolorlinks_bool{
+\bool_if:NT\l_ocgxii_ocgcolorlinks_bool{
\@ifpackageloaded{hyperref}{
\Hy@colorlinkstrue
\Hy@AtBeginDocument{
@@ -732,15 +771,6 @@
}
}
-\msg_set:nnn{ocgx2}{nested~breakable~ocgcolorlinks}{
- Breakable~OCG~color-links~cannot~be~nested.~Sorry.\\\\
- Put\\\\
- \space\space\string\hypersetup{breaklinks=false}...
- \string\hypersetup{breaklinks=true}\\\\
- around~the~outermost~of~a~group~of~nested~links.
-}
-\def\ocgxii@ocgcolor{{black}}
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% tikz related code follows (to be enabled with package option `tikz')