diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/ocgx2')
-rw-r--r-- | Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty | 4 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty | 173 |
2 files changed, 100 insertions, 77 deletions
diff --git a/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty b/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty index 956f0fb86d2..ec2b8b9393a 100644 --- a/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty +++ b/Master/texmf-dist/tex/latex/ocgx2/ocgbase.sty @@ -96,8 +96,8 @@ \RequirePackage{expl3} \RequirePackage{pdfbase} -\def\g@ocgbase@date@tl{2017/03/16} -\def\g@ocgbase@version@tl{0.8} +\def\g@ocgbase@date@tl{2017/03/30} +\def\g@ocgbase@version@tl{0.10} \ProvidesExplPackage{ocgbase}{\g@ocgbase@date@tl}{\g@ocgbase@version@tl} {support package for ocgx2.sty} diff --git a/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty b/Master/texmf-dist/tex/latex/ocgx2/ocgx2.sty index 5654fc279fe..76e68c39fca 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/26} -\def\g@ocgxii@version@tl{0.22} +\def\g@ocgxii@date@tl{2017/03/30} +\def\g@ocgxii@version@tl{0.24} \ProvidesExplPackage{ocgx2}{\g@ocgxii@date@tl}{\g@ocgxii@version@tl} {ports `ocgx' functionality to dvips+ps2pdf, xelatex and dvipdfmx} @@ -51,6 +51,8 @@ \token_to_str:N\providecommand\token_to_str:N\ocgxii@newkey[2]{} \token_to_str:N\providecommand \token_to_str:N\ocgxii@ocg@stack@on@page[2]{} + \token_to_str:N\providecommand + \token_to_str:N\ocgxii@lnkcol@stack@on@page[2]{} } } @@ -257,6 +259,11 @@ \cs_new_nopar:Npn\ocgxii@lnkcol@stack@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@lnkcol@stack@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@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@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@begingroup\tl_set_eq:NN\color@setgroup\group_begin: +} +\cs_new_nopar:Nn\ocgxii_colourlink_nobreak_end:{ + \color@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@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@colorlink##1{ - \begingroup - \def\Hy@ocgcolor{##1} - \setbox0=\hbox\bgroup\color@begingroup\let\color@setgroup\begingroup + \group_begin: + \tl_set:Nn\l_ocgxii_lnkcol_tl{##1} + \ocgxii_colourlink_nobreak_begin: } \def\Hy@endcolorlink{ - \color@endgroup\egroup - \mbox{ - \ocgbase@oc@bdc{\OBJ@OCG@print} - \rlap{\copy0} - \ocgbase@oc@emc\ocgbase@oc@bdc{\OBJ@OCG@view} - \begingroup - \expandafter\HyColor@UseColor\Hy@ocgcolor - \box0 - \endgroup - \ocgbase@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@colorlink##1{ - \ifx\Hy@setbreaklinks\@gobble - \ifHy@breaklinks\Hy@breaklinkstrue\fi - \else + \ifx\Hy@setbreaklinks\@gobble\else \Hy@breaklinkstrue \fi \ifHy@breaklinks \seq_get_left:NNT\g_ocgxii_lnk_color_seq\l_tmpa_tl{ - \tl_gset_eq:NN\ocgxii@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@lnkcol@stack@on@page\g_ocgxii_lnk_color_seq \else - \begingroup - \def\ocgxii@ocgcolor{##1} - \setbox0=\hbox\bgroup\color@begingroup\let\color@setgroup\begingroup + \group_begin: + \tl_set:Nn\l_ocgxii_lnkcol_tl{##1} + \ocgxii_colourlink_nobreak_begin: \fi } \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 + \tl_gset_eq:NN\g_ocgxii_lnkcol_tl\l_tmpa_tl \ocgxii_stack_shipout:NN\ocgxii@lnkcol@stack@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@ocgcolor\l_tmpa_tl - \ocgxii_colorlink_begin: + \tl_gset_eq:NN\g_ocgxii_lnkcol_tl\l_tmpa_tl + \ocgxii_colourlink_begin: } \else - \color@endgroup\egroup - \mbox{ - \ocgbase@oc@bdc{\OBJ@OCG@print} - \rlap{\copy0} - \ocgbase@oc@emc\ocgbase@oc@bdc{\OBJ@OCG@view} - \begingroup - \expandafter\HyColor@UseColor\ocgxii@ocgcolor - \box0 - \endgroup - \ocgbase@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@oc@bdc{\OBJ@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@UseColor\g_ocgxii_lnkcol_tl \ocgxii_literal_page:n{-88888~-88888~99999~99999~re~f} - \ocgbase@oc@emc - \ocgbase@oc@bdc{\OBJ@OCG@view} - \begingroup - \expandafter\HyColor@UseColor\ocgxii@ocgcolor - \ocgxii_literal_page:n{-88888~-88888~99999~99999~re~f} - \endgroup - \ocgbase@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@colorlinkstrue \Hy@AtBeginDocument{ \ocgbase_new_ocg:nnn{OCView}{/Print<</PrintState/OFF>>}{on} - \tl_gset:Nx\OBJ@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@OCG@print{\ocgbase_last_ocg:} + \tl_gset:Nx\g_ocgxii_ocgprint_tl{\ocgbase_last_ocg:} \ocgxii_enable_ocglinks: } }{ |