diff options
author | Karl Berry <karl@freefriends.org> | 2019-05-08 21:16:33 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-05-08 21:16:33 +0000 |
commit | 32ff12b1b57c748dbe6a1d28fa7ebfaa0916390e (patch) | |
tree | 6a1b2b4986c3b423bd156cb9a688df15555bbd98 /Master/texmf-dist/tex/latex/tikzmark | |
parent | 6f272323ab4ef903d4e94df73f8f35be51b1f20d (diff) |
tikzmark (8may19)
git-svn-id: svn://tug.org/texlive/trunk@51050 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/tikzmark')
-rw-r--r-- | Master/texmf-dist/tex/latex/tikzmark/tikzlibrarytikzmark.code.tex | 243 |
1 files changed, 189 insertions, 54 deletions
diff --git a/Master/texmf-dist/tex/latex/tikzmark/tikzlibrarytikzmark.code.tex b/Master/texmf-dist/tex/latex/tikzmark/tikzlibrarytikzmark.code.tex index b97a15682b8..c39d9a82746 100644 --- a/Master/texmf-dist/tex/latex/tikzmark/tikzlibrarytikzmark.code.tex +++ b/Master/texmf-dist/tex/latex/tikzmark/tikzlibrarytikzmark.code.tex @@ -61,6 +61,36 @@ next page/ignore/.style={% next page vector={\pgfqpoint{0pt}{0pt}}% }, + if tikzmark on current page/.code n args={3}{% + \@ifundefined{save@pt@\tikzmark@pp@name{#1}}{% + \pgfkeysalso{#3}% + }{% + \@ifundefined{save@pg@\csname save@pt@\tikzmark@pp@name{#1}\endcsname}{% + \pgfkeysalso{#3}% + }{% + \ifnum\csname save@pg@\csname save@pt@\tikzmark@pp@name{#1}\endcsname\endcsname=\the\value{page}\relax% + \pgfkeysalso{#2}% + \else + \pgfkeysalso{#3}% + \fi + }% + }% + }, + if tikzmark on page/.code n args={4}{% + \@ifundefined{save@pt@\tikzmark@pp@name{#1}}{% + \pgfkeysalso{#4}% + }{% + \@ifundefined{save@pg@\csname save@pt@\tikzmark@pp@name{#1}@label\endcsname}{% + \pgfkeysalso{#4}% + }{% + \ifnum\csname save@pg@\csname save@pt@\tikzmark@pp@name{#1}\endcsname\endcsname=#2\relax% + \pgfkeysalso{#3}% + \else + \pgfkeysalso{#4}% + \fi + }% + }% + }, tikzmark prefix/.initial=,% tikzmark suffix/.initial=,% } @@ -77,6 +107,10 @@ \def\savepicturepage#1#2{% \expandafter\gdef\csname save@pg@#1\endcsname{#2}% } +\def\tikzmarkalias#1#2{% + \pgf@node@gnamelet{save@pt@#1}{save@pt@#2}% + \pgf@node@gnamelet{save@pt@#1@offset}{save@pt@#2@offset}% +} \def\tmk@labeldef#1,#2\@nil{% \edef\tmk@label{\tikzmark@pp@name{#1}}% \def\tmk@def{#2}% @@ -109,22 +143,19 @@ \@ifundefined{save@pg@\csname save@pt@\tmk@label\endcsname}{}{% \@ifundefined{save@pg@\pgfpictureid}{}{% \pgfkeysvalueof{/tikz/next page vector}% + \edef\tmk@pg{\the\numexpr \csname save@pg@\csname save@pt@\tmk@label\endcsname\endcsname - \csname save@pg@\pgfpictureid\endcsname\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 + \tmk@pg\pgf@x\relax \advance \pgf@ya by % - -\csname save@pg@\pgfpictureid\endcsname\pgf@y\relax + \tmk@pg\pgf@y\relax }% }% \pgf@x=\pgf@xa \pgf@y=\pgf@ya \pgftransforminvert \pgf@pos@transform{\pgf@x}{\pgf@y}% - }% - } + }% +} \newcommand\tikzmark@outside[2][]{% \tikz[remember picture with id=#2]{#1}% } @@ -138,8 +169,13 @@ \ifx\pgfpictureid\@undefined \let\tikzmark@next=\tikzmark@outside \else + \relax + \ifx\scope\tikz@origscope\relax + \let\tikzmark@next=\tikzmark@outside + \else \let\tikzmark@next=\tikzmark@inside \fi + \fi \tikzmark@next% } \newcommand\pgfmark[1]{% @@ -171,19 +207,58 @@ tikzmark suffix=-\the\beamer@slideinframe } }{} +\newif\iftikzmark@ \newcommand\iftikzmark[3]{% \@ifundefined{save@pt@\tikzmark@pp@name{#1}}{% #3% }{% #2% }% +}% +\newcommand\iftikzmarkexists[1]{% + \@ifundefined{save@pt@\tikzmark@pp@name{#1}}{% + \tikzmark@false% + }{% + \tikzmark@true% }% -\newcommand\subnode[3][]{% + \iftikzmark@ +}% +\newcommand\iftikzmarkonpage[2]{% + \@ifundefined{save@pt@\tikzmark@pp@name{#1}}{% + \tikzmark@false + }{% + \@ifundefined{save@pg@\csname save@pt@\tikzmark@pp@name{#1}\endcsname}{% + \tikzmark@false + }{% + \ifnum\csname save@pg@\csname save@pt@\tikzmark@pp@name{#1}\endcsname\endcsname=#2\relax% + \tikzmark@true + \else + \tikzmark@false + \fi + }% + }% + \iftikzmark@ +} +\newcommand\iftikzmarkoncurrentpage[1]{% + \@ifundefined{save@pt@\tikzmark@pp@name{#1}}{% + \tikzmark@false + }{% + \@ifundefined{save@pg@\csname save@pt@\tikzmark@pp@name{#1}\endcsname}{% + \tikzmark@false + }{% + \ifnum\csname save@pg@\csname save@pt@\tikzmark@pp@name{#1}\endcsname\endcsname=\the\value{page}\relax% + \tikzmark@true + \else + \tikzmark@false + \fi + }% + }% + \iftikzmark@ +} +\def\subnode@#1#2#3{% \begingroup \pgfmark{#2}% \setbox\pgfnodeparttextbox=\hbox\bgroup #3\egroup - \def\tikz@shape{rectangle}% - \def\tikz@anchor{center}% \def\tikz@fig@name{#2}% \tikzset{every subnode/.try,#1}% \pgfpointorigin @@ -193,46 +268,85 @@ \advance\pgf@y by -.5\dp\pgfnodeparttextbox \pgftransformshift{}% \setbox\@tempboxa=\hbox\bgroup - \pgfutil@ifundefined{pgf@sh@s@\tikz@shape}% - {\PackageError{pgf}{Unknown shape ``\tikz@shape''}{}}% {% - {% - \let\pgf@sh@savedmacros=\pgfutil@empty% MW - \let\pgf@sh@savedpoints=\pgfutil@empty% - \def\pgf@sm@shape@name{\tikz@shape}% CJ % TT added prefix! - \csname pgf@sh@s@\tikz@shape\endcsname% - \pgf@sh@savedpoints% - \pgf@sh@savedmacros% MW - \pgftransformshift{% - \pgf@sh@reanchor{\tikz@shape}{\tikz@anchor}% - \pgf@x=-\pgf@x% - \pgf@y=-\pgf@y% - }% - \expandafter\pgfsavepgf@process\csname pgf@sh@sa@\tikz@fig@name\endcsname{% - \pgf@sh@reanchor{\tikz@shape}{\tikz@anchor}% FIXME : this is double work! - }% - % Save the saved points and the transformation matrix - \edef\pgf@node@name{\tikz@fig@name}% - \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 - \expandafter\pgf@sh@@temp\expandafter{\pgf@sh@savedmacros}% MW - \pgfgettransform\pgf@temp - \expandafter\xdef\csname pgf@sh@nt@\pgf@node@name\endcsname{\pgf@temp}% - \expandafter\xdef\csname pgf@sh@pi@\pgf@node@name\endcsname{\pgfpictureid}% - \fi% + \let\pgf@sh@savedmacros=\pgfutil@empty% MW + \let\pgf@sh@savedpoints=\pgfutil@empty% + \def\pgf@sm@shape@name{rectangle}% CJ % TT added prefix! + \pgf@sh@s@rectangle% + \pgf@sh@savedpoints% + \pgf@sh@savedmacros% MW + \pgftransformshift{% + \pgf@sh@reanchor{rectangle}{center}% + \pgf@x=-\pgf@x% + \pgf@y=-\pgf@y% }% + \expandafter\pgfsavepgf@process\csname pgf@sh@sa@\tikz@fig@name\endcsname{% + \pgf@sh@reanchor{rectangle}{center}% FIXME : this is double work! + }% + % Save the saved points and the transformation matrix + \edef\pgf@node@name{\tikz@fig@name}% + \ifx\pgf@node@name\pgfutil@empty% + \else% + \expandafter\xdef\csname pgf@sh@ns@\pgf@node@name\endcsname{rectangle}% + \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}% + \expandafter\xdef\csname pgf@sh@pi@\pgf@node@name\endcsname{\pgfpictureid}% + \fi% }% \egroup \box\pgfnodeparttextbox \endgroup } + +\newcommand\subnode[3][]{% + \ifmmode + \mathchoice{% + \subnode@{#1}{#2-d}{\(\displaystyle #3\)}% + }{% + \subnode@{#1}{#2-t}{\(\textstyle #3\)}% + }{% + \subnode@{#1}{#2-s}{\(\scriptstyle #3\)}% + }{% + \subnode@{#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 + \else + \pgfnodealias{#2}{#2-d}% + \tikzmarkalias{#2}{#2-d}% + \fi + \else + \pgfnodealias{#2}{#2-t}% + \tikzmarkalias{#2}{#2-t}% + \fi + \else + \pgfnodealias{#2}{#2-s}% + \tikzmarkalias{#2}{#2-s}% + \fi + \else + \pgfnodealias{#2}{#2-ss}% + \tikzmarkalias{#2}{#2-ss}% + \fi + \else + \subnode@{#1}{#2}{#3}% + \fi +} + \def\tikzmarknode@#1#2#3{% \tikz[% remember picture, @@ -243,6 +357,7 @@ \node[ anchor=base, inner sep=0pt, + minimum width=0pt, name={#2}, node contents={#3}, every tikzmarknode/.try, @@ -263,7 +378,7 @@ }% \let\pgf@nodecallback\pgfutil@gobble \def\tzmk@prfx{pgf@sys@pdf@mark@pos@pgfid}% - \edef\tzmk@pic{\tzmk@prfx\the\pgf@picture@serial@count} + \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 @@ -271,18 +386,22 @@ \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 + % No fallback due to potential nested mathchoices \else \pgfnodealias{#2}{#2-d}% + \tikzmarkalias{#2}{#2-d}% \fi \else \pgfnodealias{#2}{#2-t}% + \tikzmarkalias{#2}{#2-t}% \fi \else \pgfnodealias{#2}{#2-s}% + \tikzmarkalias{#2}{#2-s}% \fi \else \pgfnodealias{#2}{#2-ss}% + \tikzmarkalias{#2}{#2-ss}% \fi \else \tikzmarknode@{#1}{#2}{#3}% @@ -324,6 +443,10 @@ \tl_new:N \l__sn_group_tl \clist_new:N \l__sn_nodes_clist \bool_new:N \l__sn_file_bool +\bool_new:N \g__sn_preamble_bool +\bool_set_true:N \g__sn_preamble_bool +\msg_new:nnn {tikzmark} {no file} {File~ "#1"~ doesn't~ exist.} +\msg_new:nnn {tikzmark} {loading nodes} {Loading~ nodes~ from~ "#1".} \dim_new:N \l__sn_x_dim \dim_new:N \l__sn_y_dim \dim_new:N \l__sn_xa_dim @@ -335,7 +458,7 @@ \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} +\tl_gset:Nx \g__sn_filename_tl {\c_sys_jobname_str} \cs_new_nopar:Npn \sn_open_stream: { @@ -445,13 +568,18 @@ } \cs_new_nopar:Npn \restore_nodes_from_file:n #1 { - \file_if_exist:nT {#1.nodes} + \file_if_exist:nTF {#1.nodes} { + \msg_log:nnn {tikzmark} {loading nodes} {#1} \ExplSyntaxOn \file_input:n {#1.nodes} \ExplSyntaxOff } + { + \msg_warning:nnn {tikzmark} {no file} {#1} + } } +\AtBeginDocument{\bool_gset_false:N \g__sn_preamble_bool} \cs_new_nopar:Npn \compose_transformations:Nnn #1#2#3 { @@ -568,16 +696,23 @@ } }, 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 + \bool_if:NTF \g__sn_preamble_bool + { + \restore_nodes_from_file:n {#1} + } + { + \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~ file/.default = \g__sn_filename_tl, restore~ nodes~ from~ list/.code={ \tikz_fig_must_be_named: \pgfkeysalso{append~ after~ command={ |