diff options
author | Karl Berry <karl@freefriends.org> | 2018-10-18 20:26:16 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-10-18 20:26:16 +0000 |
commit | e733c4ce552976cdecb3df9524a6f88ed0fd8e1f (patch) | |
tree | 382ec73a79383c1e67dd5fe63e8ce6db026060fc /Master/texmf-dist/tex | |
parent | 894d9f174f933eb6ab4ec662cb6f8945c6129182 (diff) |
tikzmark (18oct18)
git-svn-id: svn://tug.org/texlive/trunk@48929 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/tikzmark/tikzlibrarytikzmark.code.tex | 449 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/tikzmark/tikzmarklibrarylistings.code.tex | 2 |
2 files changed, 421 insertions, 30 deletions
diff --git a/Master/texmf-dist/tex/latex/tikzmark/tikzlibrarytikzmark.code.tex b/Master/texmf-dist/tex/latex/tikzmark/tikzlibrarytikzmark.code.tex index c7be8a5bc48..b97a15682b8 100644 --- a/Master/texmf-dist/tex/latex/tikzmark/tikzlibrarytikzmark.code.tex +++ b/Master/texmf-dist/tex/latex/tikzmark/tikzlibrarytikzmark.code.tex @@ -12,6 +12,7 @@ %% See http://www.latex-project.org/lppl.txt %% ---------------------------------------------------------------- %% +\RequirePackage{expl3, l3keys2e, xparse} \tikzset{% remember picture with id/.style={% remember picture, @@ -23,14 +24,18 @@ \ifpgfrememberpicturepositiononpage% \edef\pgf@temp{% \noexpand\write\noexpand\pgfutil@auxout{% - \string\savepicturepage{\pgfpictureid}{\noexpand\arabic{page}}}}% + \string\savepicturepage% + {\pgfpictureid}{\noexpand\arabic{page}}% + }% + }% \pgf@temp \fi% }, }, save picture id/.code={% \protected@write\pgfutil@auxout{}{% - \string\savepointas{\tikzmark@pp@name{#1}}{\pgfpictureid}{0pt}{0pt}}% + \string\savepointas% + {\tikzmark@pp@name{#1}}{\pgfpictureid}{0pt}{0pt}}% }, if picture id/.code args={#1#2#3}{% \@ifundefined{save@pt@\tikzmark@pp@name{#1}}{% @@ -59,10 +64,15 @@ tikzmark prefix/.initial=,% tikzmark suffix/.initial=,% } -\def\tikzmark@pp@name#1{\csname pgfk@/tikz/tikzmark prefix\endcsname#1\csname pgfk@/tikz/tikzmark suffix\endcsname}% +\def\tikzmark@pp@name#1{% + \csname pgfk@/tikz/tikzmark prefix\endcsname% + #1% + \csname pgfk@/tikz/tikzmark suffix\endcsname% +}% \def\savepointas#1#2#3#4{% \expandafter\gdef\csname save@pt@#1\endcsname{#2}% - \expandafter\gdef\csname save@pt@#1@offset\endcsname{\pgfqpoint{#3}{#4}}% + \expandafter\gdef\csname save@pt@#1@offset\endcsname% + {\pgfqpoint{#3}{#4}}% } \def\savepicturepage#1#2{% \expandafter\gdef\csname save@pg@#1\endcsname{#2}% @@ -81,26 +91,32 @@ \@ifundefined{save@pt@\tmk@label}{% \tikz@scan@one@point\pgfutil@firstofone\tmk@def }{% - \pgfsys@getposition{\csname save@pt@\tmk@label\endcsname}\save@orig@pic% - \pgfsys@getposition{\pgfpictureid}\save@this@pic% - \pgf@process{\pgfpointorigin\save@this@pic}% - \pgf@xa=\pgf@x - \pgf@ya=\pgf@y - \pgf@process{\pgfpointorigin\save@orig@pic}% - \advance\pgf@x by -\pgf@xa - \advance\pgf@y by -\pgf@ya - \pgf@xa=\pgf@x - \pgf@ya=\pgf@y - \pgf@process{\pgfpointorigin\csname save@pt@\tmk@label @offset\endcsname}% + \pgfsys@getposition{\csname save@pt@\tmk@label\endcsname}% + \save@orig@pic% + \pgfsys@getposition{\pgfpictureid}\save@this@pic% + \pgf@process{\pgfpointorigin\save@this@pic}% + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \pgf@process{\pgfpointorigin\save@orig@pic}% + \advance\pgf@x by -\pgf@xa + \advance\pgf@y by -\pgf@ya + \pgf@xa=\pgf@x + \pgf@ya=\pgf@y + \pgf@process% + {\pgfpointorigin\csname save@pt@\tmk@label @offset\endcsname}% \advance\pgf@xa by \pgf@x \advance\pgf@ya by \pgf@y \@ifundefined{save@pg@\csname save@pt@\tmk@label\endcsname}{}{% \@ifundefined{save@pg@\pgfpictureid}{}{% \pgfkeysvalueof{/tikz/next page vector}% - \advance \pgf@xa by \csname save@pg@\csname save@pt@\tmk@label\endcsname\endcsname\pgf@x\relax -\advance \pgf@ya by \csname save@pg@\csname save@pt@\tmk@label\endcsname\endcsname\pgf@y\relax - \advance \pgf@xa by -\csname save@pg@\pgfpictureid\endcsname\pgf@x\relax -\advance \pgf@ya by -\csname save@pg@\pgfpictureid\endcsname\pgf@y\relax + \advance \pgf@xa by % + \csname save@pg@\csname save@pt@\tmk@label\endcsname\endcsname\pgf@x\relax + \advance \pgf@ya by % + \csname save@pg@\csname save@pt@\tmk@label\endcsname\endcsname\pgf@y\relax + \advance \pgf@xa by % + -\csname save@pg@\pgfpictureid\endcsname\pgf@x\relax + \advance \pgf@ya by % + -\csname save@pg@\pgfpictureid\endcsname\pgf@y\relax }% }% \pgf@x=\pgf@xa @@ -116,7 +132,7 @@ \tikzset{remember picture}% \tikz@scan@one@point\pgfutil@firstofone#2\relax \protected@write\pgfutil@auxout{}{% - \string\savepointas{\tikzmark@pp@name{#1}}{\pgfpictureid}{\the\pgf@x pt}{\the\pgf@y pt}}% + \string\savepointas{\tikzmark@pp@name{#1}}{\pgfpictureid}{\the\pgf@x}{\the\pgf@y}}% } \def\tikzmark{% \ifx\pgfpictureid\@undefined @@ -140,8 +156,12 @@ \egroup } \@ifclassloaded{beamer}{ - \renewcommand<>{\tikzmark@outside}[2][]{\only#3{\beameroriginal{\tikzmark@outside}[{#1}]{#2}}} - \renewcommand<>{\tikzmark@inside}[2]{\only#3{\beameroriginal{\tikzmark@inside}{#1}{#2}}} + \renewcommand<>{\tikzmark@outside}[2][]{% + \only#3{\beameroriginal{\tikzmark@outside}[{#1}]{#2}}% + } + \renewcommand<>{\tikzmark@inside}[2]{% + \only#3{\beameroriginal{\tikzmark@inside}{#1}{#2}}% + } }{} \@ifclassloaded{beamer}{ \renewcommand<>{\pgfmark}[1]{\only#2{\beameroriginal{\pgfmark}{#1}}} @@ -152,7 +172,7 @@ } }{} \newcommand\iftikzmark[3]{% - \@ifundefined{save@pt@#1}{% + \@ifundefined{save@pt@\tikzmark@pp@name{#1}}{% #3% }{% #2% @@ -196,9 +216,12 @@ \ifx\pgf@node@name\pgfutil@empty% \else% \expandafter\xdef\csname pgf@sh@ns@\pgf@node@name\endcsname{\tikz@shape}% - \edef\pgf@sh@@temp{\noexpand\gdef\expandafter\noexpand\csname pgf@sh@np@\pgf@node@name\endcsname}% - \expandafter\pgf@sh@@temp\expandafter{\pgf@sh@savedpoints}% - \edef\pgf@sh@@temp{\noexpand\gdef\expandafter\noexpand\csname pgf@sh@ma@\pgf@node@name\endcsname}% MW + \edef\pgf@sh@@temp{% + \noexpand\gdef\expandafter\noexpand\csname pgf@sh@np@\pgf@node@name\endcsname}% + \expandafter\pgf@sh@@temp\expandafter{% + \pgf@sh@savedpoints}% + \edef\pgf@sh@@temp{% + \noexpand\gdef\expandafter\noexpand\csname pgf@sh@ma@\pgf@node@name\endcsname}% MW \expandafter\pgf@sh@@temp\expandafter{\pgf@sh@savedmacros}% MW \pgfgettransform\pgf@temp \expandafter\xdef\csname pgf@sh@nt@\pgf@node@name\endcsname{\pgf@temp}% @@ -210,7 +233,64 @@ \box\pgfnodeparttextbox \endgroup } -\def\usetikzmarklibrary{\pgfutil@ifnextchar[{\use@tikzmarklibrary}{\use@@tikzmarklibrary}}%} +\def\tikzmarknode@#1#2#3{% + \tikz[% + remember picture, + baseline=(#2.base), + save picture id={#2}, + every tikzmarknode picture/.try + ] { + \node[ + anchor=base, + inner sep=0pt, + name={#2}, + node contents={#3}, + every tikzmarknode/.try, + #1 + ]}% +} + +\newcommand\tikzmarknode[3][]{% + \ifmmode + \mathchoice{% + \tikzmarknode@{#1}{#2-d}{\(\displaystyle #3\)}% + }{% + \tikzmarknode@{#1}{#2-t}{\(\textstyle #3\)}% + }{% + \tikzmarknode@{#1}{#2-s}{\(\scriptstyle #3\)}% + }{% + \tikzmarknode@{#1}{#2-ss}{\(\scriptscriptstyle #3\)}% + }% + \let\pgf@nodecallback\pgfutil@gobble + \def\tzmk@prfx{pgf@sys@pdf@mark@pos@pgfid}% + \edef\tzmk@pic{\tzmk@prfx\the\pgf@picture@serial@count} + \expandafter\ifx\csname\tzmk@pic\endcsname\relax + \edef\tzmk@pic{\tzmk@prfx\the\numexpr\the\pgf@picture@serial@count-1\relax}% + \expandafter\ifx\csname\tzmk@pic\endcsname\relax +\edef\tzmk@pic{\tzmk@prfx\the\numexpr\the\pgf@picture@serial@count-2\relax}% + \expandafter\ifx\csname\tzmk@pic\endcsname\relax +\edef\tzmk@pic{\tzmk@prfx\the\numexpr\the\pgf@picture@serial@count-3\relax}% + \expandafter\ifx\csname\tzmk@pic\endcsname\relax + \pgfnodealias{#2}{#2-t}% %% Fallback + \else + \pgfnodealias{#2}{#2-d}% + \fi + \else + \pgfnodealias{#2}{#2-t}% + \fi + \else + \pgfnodealias{#2}{#2-s}% + \fi + \else + \pgfnodealias{#2}{#2-ss}% + \fi + \else + \tikzmarknode@{#1}{#2}{#3}% + \fi +} +\def\usetikzmarklibrary{% + \pgfutil@ifnextchar[{\use@tikzmarklibrary}{\use@@tikzmarklibrary}% + }%} \def\use@tikzmarklibrary[#1]{\use@@tikzmarklibrary{#1}} \def\use@@tikzmarklibrary#1{% \edef\pgf@list{#1}% @@ -219,7 +299,8 @@ \ifx\pgf@temp\pgfutil@empty \else \expandafter\ifx\csname tikzmark@library@\pgf@temp @loaded\endcsname\relax% - \expandafter\global\expandafter\let\csname tikzmark@library@\pgf@temp @loaded\endcsname=\pgfutil@empty% + \expandafter\global\expandafter\let% + \csname tikzmark@library@\pgf@temp @loaded\endcsname=\pgfutil@empty% \expandafter\edef\csname tikzmark@library@#1@atcode\endcsname{\the\catcode`\@} \expandafter\edef\csname tikzmark@library@#1@barcode\endcsname{\the\catcode`\|} \catcode`\@=11 @@ -234,8 +315,318 @@ }% } +\ExplSyntaxOn +\prop_new:N \g__sn_prop +\tl_new:N \l__sn_tmpa_tl +\tl_new:N \l__sn_tmpb_tl +\tl_new:N \l__open_bracket_tl +\tl_set:Nn \l__open_bracket_tl {[} %] +\tl_new:N \l__sn_group_tl +\clist_new:N \l__sn_nodes_clist +\bool_new:N \l__sn_file_bool +\dim_new:N \l__sn_x_dim +\dim_new:N \l__sn_y_dim +\dim_new:N \l__sn_xa_dim +\dim_new:N \l__sn_ya_dim +\tl_new:N \l__sn_centre_tl + +\tl_new:N \l__sn_transformation_tl +\tl_set:Nn \l__sn_transformation_tl {{1}{0}{0}{1}{0pt}{0pt}} +\iow_new:N \g__sn_stream +\bool_new:N \g__sn_stream_bool +\tl_new:N \g__sn_filename_tl +\tl_set:Nx \g__sn_filename_tl {\c_sys_jobname_str} + +\cs_new_nopar:Npn \sn_open_stream: +{ + \bool_if:NF \g__sn_stream_bool + { + \iow_open:Nn \g__sn_stream {\tl_use:N \g__sn_filename_tl .nodes} + \bool_gset_true:N \g__sn_stream_bool + } +} + +\AtEndDocument +{ + \ExplSyntaxOn + \bool_if:NT \g__sn_stream_bool + { + \iow_close:N \g__sn_stream + } + \ExplSyntaxOff +} +\makeatletter +\cs_set_eq:NN \tikz_set_node_name:n \tikz@pp@name +\cs_set_eq:NN \tikz_fig_must_be_named: \tikz@fig@mustbenamed + +\cs_new_nopar:Npn \tikz_scan_point:n #1 +{ + \tikz@scan@one@point\pgfutil@firstofone#1\relax +} + +\cs_new_nopar:Npn \tikz_scan_point:NNn #1#2#3 +{ + \tikz@scan@one@point\pgfutil@firstofone#3\relax + \dim_set_eq:NN #1 \pgf@x + \dim_set_eq:NN #2 \pgf@y +} + +\makeatother +\cs_generate_variant:Nn \tikz_scan_point:n {V} +\cs_generate_variant:Nn \tikz_scan_point:NNn {NNV} +\cs_new_nopar:Npn \save_nodes:Nn #1#2 +{ + \tl_clear:N \l__sn_tmpa_tl + \tikz_scan_point:NNn \l__sn_x_dim \l__sn_y_dim {(current~ bounding~ box.center)} + \dim_set:Nn \l__sn_x_dim {-\l__sn_x_dim} + \dim_set:Nn \l__sn_y_dim {-\l__sn_y_dim} + \tl_set:Nx \l__sn_centre_tl { + {1}{0}{0}{1}{\dim_use:N \l__sn_x_dim}{\dim_use:N \l__sn_y_dim} + } + \clist_map_inline:nn {#2} + { + \tl_if_exist:cT {pgf@sh@ns@##1} + { + \clist_map_inline:nn {ns,np,ma,pi} + { + \tl_put_right:Nn \l__sn_tmpa_tl + { + \tl_gset:cn {pgf@sh@####1@ \tikz_set_node_name:n{##1} } + } + \tl_if_exist:cTF {pgf@sh@####1@##1} + { + \tl_put_right:Nx \l__sn_tmpa_tl { + {\exp_not:v {pgf@sh@####1@ \tikz_set_node_name:n {##1}}} + } + } + { + \tl_put_right:Nx \l__sn_tmpa_tl {{}} + } + } + \tl_put_right:Nn \l__sn_tmpa_tl + { + \tl_gset:cn {pgf@sh@nt@ \tikz_set_node_name:n{##1} } + } + \compose_transformations:NVv \l__sn_tmpb_tl \l__sn_centre_tl {pgf@sh@nt@##1} + \tl_put_right:Nx \l__sn_tmpa_tl {{\exp_not:V \l__sn_tmpb_tl}} + \tl_put_right:Nn \l__sn_tmpa_tl { + \transform_node:Nn \l__sn_transformation_tl { + \tikz_set_node_name:n{##1} + } + } + } + } + \tl_set_eq:NN #1 \l__sn_tmpa_tl +} +\cs_new_nopar:Npn \save_nodes_to_list:nn #1#2 +{ + \save_nodes:Nn \l__sn_tmpa_tl {#2} + \prop_gput:NnV \g__sn_prop {#1} \l__sn_tmpa_tl +} +\cs_new_nopar:Npn \save_nodes_to_file:n #1 +{ + \save_nodes:Nn \l__sn_tmpa_tl {#1} + \sn_open_stream: + \iow_now:Nx \g__sn_stream + { + \iow_newline: + \exp_not:V \l__sn_tmpa_tl + \iow_newline: + } +} +\cs_generate_variant:Nn \save_nodes_to_list:nn {VV} +\cs_generate_variant:Nn \save_nodes_to_file:n {V} +\cs_new_nopar:Npn \restore_nodes_from_list:n #1 +{ + \prop_get:NnNT \g__sn_prop {#1} \l__sn_tmpa_tl + { + \tl_use:N \l__sn_tmpa_tl + } +} +\cs_new_nopar:Npn \restore_nodes_from_file:n #1 +{ + \file_if_exist:nT {#1.nodes} + { + \ExplSyntaxOn + \file_input:n {#1.nodes} + \ExplSyntaxOff + } +} + +\cs_new_nopar:Npn \compose_transformations:Nnn #1#2#3 +{ + \tl_gset:Nx #1 + { + {\fp_eval:n { + \tl_item:nn {#2} {1} + * \tl_item:nn {#3} {1} + + + \tl_item:nn {#2} {3} + * \tl_item:nn {#3} {2} + } + } + {\fp_eval:n { + \tl_item:nn {#2} {2} + * \tl_item:nn {#3} {1} + + + \tl_item:nn {#2} {4} + * \tl_item:nn {#3} {2} + } + } + {\fp_eval:n { + \tl_item:nn {#2} {1} + * \tl_item:nn {#3} {3} + + + \tl_item:nn {#2} {3} + * \tl_item:nn {#3} {4} + } + } + {\fp_eval:n { + \tl_item:nn {#2} {2} + * \tl_item:nn {#3} {3} + + + \tl_item:nn {#2} {4} + * \tl_item:nn {#3} {4} + } + } + {\fp_to_dim:n { + \tl_item:nn {#2} {1} + * \tl_item:nn {#3} {5} + + + \tl_item:nn {#2} {3} + * \tl_item:nn {#3} {6} + + + \tl_item:nn {#2} {5} + } + } + {\fp_to_dim:n { + \tl_item:nn {#2} {2} + * \tl_item:nn {#3} {5} + + + \tl_item:nn {#2} {4} + * \tl_item:nn {#3} {6} + + + \tl_item:nn {#2} {6} + } + } + } +} +\cs_generate_variant:Nn \compose_transformations:Nnn {cVv,NVv,NVn,NvV,NnV} +\cs_new_nopar:Npn \transform_node:Nn #1#2 +{ + \compose_transformations:cVv {pgf@sh@nt@#2} #1 {pgf@sh@nt@#2} +} +\cs_new_nopar:Npn \set_transform_from_node:n #1 +{ + \tl_set_eq:Nc \l__sn_transformation_tl {pgf@sh@nt@#1} + \tikz_scan_point:NNn \l__sn_x_dim \l__sn_y_dim {(#1.center)} + + \dim_set:Nn \l__sn_x_dim {\l__sn_x_dim - \tl_item:cn {pgf@sh@nt@#1}{5}} + \dim_set:Nn \l__sn_y_dim {\l__sn_y_dim - \tl_item:cn {pgf@sh@nt@#1}{6}} + + \compose_transformations:NnV \l__sn_transformation_tl { + {1}{0}{0}{1}{\dim_use:N \l__sn_x_dim}{\dim_use:N \l__sn_y_dim} + } \l__sn_transformation_tl +} +\cs_generate_variant:Nn \set_transform_from_node:n {v} +\tikzset{ + set~ saved~ nodes~ file~ name/.code={ + \tl_gset:Nx \g__sn_filename_tl {#1} + }, + transform~ saved~ nodes/.code={ + \set_transform_from_node:v {tikz@last@fig@name} + }, + set~ node~ group/.code={ + \tl_set:Nn \l__sn_group_tl {#1} + \pgfkeysalso{ + execute~ at~ end~ scope={ + \maybe_save_nodes: + } + } + }, + save~ nodes~ to~ file/.code={ + \tl_if_eq:nnTF {#1}{false} + { + \bool_set_false:N \l__sn_file_bool + } + { + \bool_set_true:N \l__sn_file_bool + } + \pgfkeysalso{ + execute~ at~ end~ scope={ + \maybe_save_nodes: + } + } + }, + save~ node/.code={ + \tikz_fig_must_be_named: + \pgfkeysalso{append~ after~ command={ + \pgfextra{ + \clist_gput_right:Nv \l__sn_nodes_clist {tikz@last@fig@name} + } + } + } + }, + restore~ nodes~ from~ file/.code={ + \tikz_fig_must_be_named: + \pgfkeysalso{append~ after~ command={ + \pgfextra{ + \scope + \split_argument:NNn \tikzset \restore_nodes_from_file:n {#1} + \endscope + } + } + } + }, + restore~ nodes~ from~ list/.code={ + \tikz_fig_must_be_named: + \pgfkeysalso{append~ after~ command={ + \pgfextra{ + \scope + \split_argument:NNn \tikzset \restore_nodes_from_list:n {#1} + \endscope + } + } + } + } +} +\cs_generate_variant:Nn \clist_gput_right:Nn {Nv} +\cs_new_nopar:Npn \split_argument:NNn #1#2#3 +{ + \tl_set:Nx \l__sn_tmpa_tl {\tl_head:n {#3}} + \tl_if_eq:NNTF \l__sn_tmpa_tl \l__open_bracket_tl + { + \split_argument_aux:NNp #1#2#3 + } + { + #2 {#3} + } +} +\cs_new_nopar:Npn \split_argument_aux:NNp #1#2[#3]#4 +{ + #1 {#3} + #2 {#4} +} +\cs_new_nopar:Npn \maybe_save_nodes: +{ + \clist_if_empty:NF \l__sn_nodes_clist + { + \bool_if:NTF \l__sn_file_bool + { + \save_nodes_to_file:V \l__sn_nodes_clist + } + { + \tl_if_empty:NF \l__sn_group_tl + { + \save_nodes_to_list:VV \l__sn_group_tl \l__sn_nodes_clist + } + } + \clist_gclear:N \l__sn_nodes_clist + } +} +\ExplSyntaxOff %% -%% Copyright (C) 2011-2016 by Andrew Stacey <loopspace@mathforge.org> +%% Copyright (C) 2011-2018 by Andrew Stacey <loopspace@mathforge.org> %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License (LPPL), either diff --git a/Master/texmf-dist/tex/latex/tikzmark/tikzmarklibrarylistings.code.tex b/Master/texmf-dist/tex/latex/tikzmark/tikzmarklibrarylistings.code.tex index 940e6dd925e..085323e146d 100644 --- a/Master/texmf-dist/tex/latex/tikzmark/tikzmarklibrarylistings.code.tex +++ b/Master/texmf-dist/tex/latex/tikzmark/tikzmarklibrarylistings.code.tex @@ -47,7 +47,7 @@ \PackageError{tikzmark listings}{The listings package has not been loaded.}{} } %% -%% Copyright (C) 2011-2016 by Andrew Stacey <loopspace@mathforge.org> +%% Copyright (C) 2011-2018 by Andrew Stacey <loopspace@mathforge.org> %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License (LPPL), either |