diff options
author | Karl Berry <karl@freefriends.org> | 2015-11-24 23:47:48 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-11-24 23:47:48 +0000 |
commit | f93faaa13d53d6bb5b69098ba27a1a1252bfb81b (patch) | |
tree | 359d351e246c2e77139c2cf3bc8a1a55abc9f9ad /Master/texmf-dist | |
parent | 9bb767d4587999135ff5a93b1337f477e3c662c5 (diff) |
ocgx2 (24nov15)
git-svn-id: svn://tug.org/texlive/trunk@38940 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/ocgx2/ChangeLog | 5 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/ocgx2/README | 15 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty | 34 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty | 138 |
4 files changed, 162 insertions, 30 deletions
diff --git a/Master/texmf-dist/doc/latex/ocgx2/ChangeLog b/Master/texmf-dist/doc/latex/ocgx2/ChangeLog index 14a35b7a08a..30e962c8596 100644 --- a/Master/texmf-dist/doc/latex/ocgx2/ChangeLog +++ b/Master/texmf-dist/doc/latex/ocgx2/ChangeLog @@ -1,3 +1,8 @@ +2015-11-23 + * v0.11 (ocgx2.sty) + * v0.3 (ocgbase.sty) + * new: PDF layers spanning multiple pages + 2015-11-02 * v0.10 (ocgx2.sty) * v0.2 (ocgbase.sty) diff --git a/Master/texmf-dist/doc/latex/ocgx2/README b/Master/texmf-dist/doc/latex/ocgx2/README index a8671fbcb59..ed5d3b512fc 100644 --- a/Master/texmf-dist/doc/latex/ocgx2/README +++ b/Master/texmf-dist/doc/latex/ocgx2/README @@ -1,7 +1,7 @@ ================================== The `ocgx2' LaTeX Package - Version 0.10 [2015/11/02] + Version 0.11 [2015/11/23] (C) 2015--\today Alexander Grahn ================================== @@ -23,7 +23,10 @@ and adds support for all known engines and back-ends including: To enable dvipdfmx support, pass `dvipdfmx' globally as a class option. - * New feature: grouping layers into Radio Button Groups + * New features: + + + layers across page breaks + + grouping layers into Radio Button Groups Also, it adds some minor improvements, such as package options, remembering option settings of re-opened ocgs, correct behaviour of ocg @@ -71,6 +74,9 @@ and <options> : viewocg = always | never | ifvisible tikz (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 @@ -78,10 +84,7 @@ 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. -Package options have global scope. Environment options override package -options locally. - -`ocg' environments can be nested. +`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: diff --git a/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty b/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty index df92035991e..445d42a2752 100644 --- a/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty +++ b/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty @@ -94,8 +94,8 @@ \RequirePackage{l3keys2e} \RequirePackage{atenddvi} -\def\g@ocgbase@date@tl{2015/11/02} -\def\g@ocgbase@version@tl{0.2} +\def\g@ocgbase@date@tl{2015/11/23} +\def\g@ocgbase@version@tl{0.3} \ProvidesExplPackage{ocgbase}{\g@ocgbase@date@tl}{\g@ocgbase@version@tl} {support package for ocgx2.sty} @@ -115,7 +115,6 @@ %process package options \ProcessKeysOptions{ocgbase} -%\AtBeginDocument{ \AtBeginDvi{ \@ifpackageloaded{pdfbase}{}{\RequirePackage{pdfbase}} } @@ -135,7 +134,7 @@ \pbs_pdfobj:nnn{}{array}{\g_ocgbase_offocgs_tl} \tl_set:Nx\l_ocgbase_offocgentry_tl{/OFF~\pbs_pdflastobj:} } - %build Order list + %global Order list \tl_new:N\l_ocgbase_ocgorderentry_tl \seq_if_empty:NF\g_ocgbase_ocgorder_seq{ %process radio button groups in the Order array @@ -156,7 +155,11 @@ } %second sweep on Order array to generate the final Order entry \tl_new:N\l_ocgbase_ocgorder_tl + \tl_set:Nn\l_ocgbase_order_item_count_tl{\c_zero} \seq_map_inline:Nn\g_ocgbase_ocgorder_seq{ + \tl_set:Nx\l_ocgbase_order_item_count_tl{ + \int_eval:n{\l_ocgbase_order_item_count_tl+\c_one} + } \cs_if_exist:cTF{g_ocgbase_#1_rbtn_order_seq}{ \int_compare:nT{\seq_count:c{g_ocgbase_#1_rbtn_order_seq}>\c_zero}{ \tl_put_right:Nx\l_ocgbase_ocgorder_tl{ @@ -164,8 +167,25 @@ } } }{ - %ordinary (non-radiobutton group) item (ocg obj ref, `[', `]') - \tl_put_right:Nn\l_ocgbase_ocgorder_tl{~#1} + %ordinary (non-radiobutton group) item (ocg obj ref, `[' or `]'), + \tl_set:Nx\l_ocgbase_current_order_item_tl{#1} + \tl_set:Nx\l_ocgbase_next_order_item_tl{ + \seq_item:Nn\g_ocgbase_ocgorder_seq{ + \l_ocgbase_order_item_count_tl+\c_one + } + } + \tl_set:Nx\l_ocgbase_prev_order_item_tl{ + \seq_item:Nn\g_ocgbase_ocgorder_seq{ + \l_ocgbase_order_item_count_tl-\c_one + } + } + \bool_if:nF{ %avoid empty nesting groups + \str_if_eq_p:Vn\l_ocgbase_current_order_item_tl{[} && + \str_if_eq_p:Vn\l_ocgbase_next_order_item_tl{]} + || + \str_if_eq_p:Vn\l_ocgbase_current_order_item_tl{]} && + \str_if_eq_p:Vn\l_ocgbase_prev_order_item_tl{[} + }{\tl_put_right:Nn\l_ocgbase_ocgorder_tl{~#1}} } } \tl_if_empty:NF\l_ocgbase_ocgorder_tl{ @@ -229,7 +249,7 @@ \cs_new:Nn\ocgbase_last_ocg:{\g_ocgbase_last_ocg_tl} %macro for appending OCG object to global `Order' list -% in Layers Tab of the GUI) +% in Layers Tab of the GUI \cs_new:Nn\ocgbase_add_to_order_list:n{ \seq_gput_right:Nx\g_ocgbase_ocgorder_seq{#1} } diff --git a/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty b/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty index 6872f2e9322..946682d0332 100644 --- a/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty +++ b/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty @@ -13,6 +13,8 @@ % and adds support for all known engines and backends including % latex+dvips+ps2pdf, xelatex, latex+dvipdfmx, lualatex. % +% With ocgx2, PDF layers may extend across page breaks. +% % Adds some minor improvements, such as package options, remembering option % settings of reopened ocgs, correct behaviour of ocg switching links that were % themselves placed on layers, compatibility with the animate and media9 @@ -34,10 +36,14 @@ \RequirePackage{xparse} \RequirePackage{l3keys2e} +\RequirePackage{afterpage} -\ProvidesExplPackage{ocgx2}{2015/11/02}{0.10} +\ProvidesExplPackage{ocgx2}{2015/11/23}{0.11} {ports `ocgx' functionality to dvips+ps2pdf, xelatex and dvipdfmx} +%creating global definitions +\cs_new:Npn\ocgxii@newkey#1#2{\tl_gset:cx{#1}{#2}} + %package opts %unknown package option error message \msg_set:nnnn{ocgx2}{unknown~package~option}{Unknown~package~option~`#1'.}{ @@ -109,17 +115,25 @@ %re-implement ocg-p's `ocg' environment \DeclareDocumentEnvironment{ocg}{O{}mmm}{ + \ocgxii_beginocg:nnnn{#1}{#2}{#3}{#4} +}{ + \ocgxii_endocg: +} + +\cs_new_nopar:Nn\ocgxii_beginocg:nnnn{ + \bool_gset_false:N\g_ocgxii_nestedE_bool \bool_if:NT\g_ocgxii_nestedB_bool{\ocgbase_add_to_order_list:n{[}} \bool_gset_true:N\g_ocgxii_nestedB_bool - \bool_gset_false:N\g_ocgxii_nestedE_bool \group_begin: \ocgxii_reset_cmd_opts: % ... to the user-set package options \tl_if_exist:cTF{ocgxii@#3}{ %re-open existing layer \tl_set:Nx\l_tempa_tl{\tl_use:c{ocgxii@#3.opts},#1} \tl_gset:cx{ocgxii@#3.opts}{\l_tempa_tl} %new options appended \keys_set:nV{ocgx2/user}\l_tempa_tl - \int_compare:nT{\l_ocgxii_listno_tl=\c_zero}{ + \int_compare:nTF{\l_ocgxii_listno_tl=\c_zero}{ \ocgbase_add_to_order_list:n{\tl_use:c{ocgxii@#3}} + }{ + \bool_gset_false:N\g_ocgxii_nestedB_bool } }{ \tl_gset:cn{ocgxii@#3.opts}{#1} @@ -128,12 +142,14 @@ \l_ocgxii_view_tl\l_ocgxii_print_tl\l_ocgxii_export_tl }{#4} \tl_gset:cx{ocgxii@#3}{\ocgbase_last_ocg:} - \int_compare:nF{\l_ocgxii_listno_tl=\c_one}{ + \tl_gset:cn{ocgxii_#3_is_listed}{0} + \int_compare:nTF{\l_ocgxii_listno_tl=\c_one}{ + \bool_gset_false:N\g_ocgxii_nestedB_bool + }{ \ocgbase_add_to_order_list:n{\ocgbase_last_ocg:} } - \iow_now:Nx\@auxout{ - \token_to_str:N\expandafter\xdef\token_to_str:N\csname - \space OCGpdfobj#3\endcsname{\ocgbase_last_ocg:} + \iow_now:Nx\@mainaux{ + \token_to_str:N\ocgxii@newkey{ocgx2.ocg.#3}{\ocgbase_last_ocg:} } } \seq_map_inline:Nn\l_ocgxii_rbgrps_seq{% process list of radio btn groups @@ -142,10 +158,8 @@ } } \bool_if:nT{ -% !\cs_if_exist_p:c{OCGpdfobj#3} || %lazy evaluation may cease to work -% !\str_if_eq_x_p:nn{\use:c{OCGpdfobj#3}}{\tl_use:c{ocgxii@#3}} - !\cs_if_exist:cTF{OCGpdfobj#3}{ - \str_if_eq_x_p:nn{\tl_use:c{OCGpdfobj#3}}{\tl_use:c{ocgxii@#3}} + !\cs_if_exist:cTF{ocgx2.ocg.#3}{ + \str_if_eq_x_p:nn{\tl_use:c{ocgx2.ocg.#3}}{\tl_use:c{ocgxii@#3}} }{ \c_false_bool } @@ -155,22 +169,112 @@ \AtEndDocument{\msg_warning:nn{ocgx2}{rerun}} } } - \tl_gset:cx{OCGpdfobj#3}{\tl_use:c{ocgxii@#3}} + \tl_gset:cx{ocgx2.ocg.#3}{\tl_use:c{ocgxii@#3}} \seq_gput_left:Nx\g_ocgxii_ocgstack_seq{\tl_use:c{ocgxii@#3}} + \ocgxii_ocgstack_shipout:N\g_ocgxii_ocgstack_seq \group_end: \ocgbase_oc_bdc:n{\tl_use:c{ocgxii@#3}} \ignorespaces -}{ +} + +\cs_new_nopar:Nn\ocgxii_endocg:{ \unskip \ocgbase_oc_emc: - \seq_gpop_left:NN\g_ocgxii_ocgstack_seq\l_tempa_tl + \seq_gpop_left:NN\g_ocgxii_ocgstack_seq\l_trash_tl + \ocgxii_ocgstack_shipout:N\g_ocgxii_ocgstack_seq + \bool_gset_false:N\g_ocgxii_nestedB_bool \bool_if:NT\g_ocgxii_nestedE_bool{\ocgbase_add_to_order_list:n{]}} \bool_gset_true:N\g_ocgxii_nestedE_bool - \bool_gset_false:N\g_ocgxii_nestedB_bool } + \bool_new:N\g_ocgxii_nestedB_bool % nested OCG begin \bool_new:N\g_ocgxii_nestedE_bool % nested OCG end +\cs_gset:Nn\ocgxii_ocgstack_shipout:N{ + \iow_shipout_x:Nx\@mainaux{ + \token_to_str:N\ocgxii@stack@on@page{ + \exp_not:N\int_use:N\g_ocgxii_page_int + }{\seq_use:Nn#1{,}} + } +} +\cs_new_nopar:Npn\ocgxii@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}{ + \seq_map_inline:cn{g_pending_ocgs_on_#1_seq}{ + \seq_gpop_left:cN{g_pending_ocgs_on_#1_seq}\l_trash_tl + \seq_gput_right:cn{g_pending_ocgs_on_#1_seq}{{##1}} + } + } +} +\ocgxii@stack@on@page{0}{} %initialize + +%end of page action in output routine +\cs_new_nopar:Nn\ocgxii_at_end_page:{ + %check whether end-of-page ocg stack has settled + \iow_now:Nx\@mainaux{ + \token_to_str:N\ocgxii@newkey{ocgx2.oldstack.\int_use:N\g_ocgxii_page_int}{ + \seq_use:cn{g_pending_ocgs_on_\int_use:c{g_ocgxii_page_int}_seq}{,} + } + } + \bool_if:nT{ + !\cs_if_exist:cTF{ocgx2.oldstack.\int_use:N\g_ocgxii_page_int}{ + \str_if_eq_x_p:nn{ + \tl_use:c{ocgx2.oldstack.\int_use:N\g_ocgxii_page_int} + }{ + \seq_use:cn{g_pending_ocgs_on_\int_use:c{g_ocgxii_page_int}_seq}{,} + } + }{ + \c_false_bool + } + }{ + \cs_if_exist:NF\g_ocgxii_rerunwarned_tl{ + \tl_new:N\g_ocgxii_rerunwarned_tl + \AtEndDocument{\msg_warning:nn{ocgx2}{rerun}} + } + } + %now close pending ocgs + \seq_map_variable:cNn{ + g_pending_ocgs_on_\int_use:c{g_ocgxii_page_int}_seq + }\l_ocgxii_arg_tl{ + \ocgbase_oc_emc: + } +} + +%begin of page action in output routine +\cs_new_nopar:Nn\ocgxii_at_begin_page:{ + % re-open pending ocgs + \seq_set_eq:Nc\l_ocgxii_temp_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{ + \ocgbase_oc_bdc:n{\l_ocgxii_arg_tl} + } + % copy pending ocg stack to next page, if it has not been initialized yet + % from aux file + \int_gincr:N\g_ocgxii_page_int + \seq_if_exist:cF{g_pending_ocgs_on_\int_use:c{g_ocgxii_page_int}_seq}{ + \seq_gset_eq:cc{ + g_pending_ocgs_on_\int_use:c{g_ocgxii_page_int}_seq + }{ + g_pending_ocgs_on_\int_eval:n{\g_ocgxii_page_int-\c_one}_seq + } + } +} +\int_new:N\g_ocgxii_page_int %abs. page counter + +%modify output routine to manage ocgs spanning multiple pages +\cs_set_eq:NN\ocgxii_outputpage_orig:\@outputpage +\cs_set_nopar:Npn\@outputpage{ + \vbox_set:Nn\@outputbox{ + \ocgxii_at_begin_page: + \box_use_clear:N\@outputbox + \ocgxii_at_end_page: + } + \ocgxii_outputpage_orig: +} + %stack of PDF obj references of currently open OCGs \seq_new:N\g_ocgxii_ocgstack_seq @@ -452,7 +556,7 @@ \cs_new:Nn\ocgxii_process_ocgref:NN{ \str_if_eq_x:nnF{#2}{}{ - \tl_if_exist:cTF{OCGpdfobj#2}{\tl_put_right:Nx#1{~\tl_use:c{OCGpdfobj#2}}}{ + \tl_if_exist:cTF{ocgx2.ocg.#2}{\tl_put_right:Nx#1{~\tl_use:c{ocgx2.ocg.#2}}}{ \msg_warning:nnx{ocgx2}{undefined~OCG}{#2} \cs_if_exist:NF\g_ocgxii_refundefwarned_tl{ \tl_new:N\g_ocgxii_refundefwarned_tl @@ -539,7 +643,7 @@ } } -% tikz related code follows (enabled with package option `tikz') +% tikz related code follows (to be enabled with package option `tikz') \bool_if:NF\l_ocgxii_tikz_bool{\endinput} \ExplSyntaxOff |