diff options
-rw-r--r-- | Master/texmf-dist/doc/latex/tikzmark/README.txt | 10 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikzmark/tikzmark.pdf | bin | 454472 -> 461039 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/tikzmark/tikzmark.dtx | 307 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/tikzmark/tikzlibrarytikzmark.code.tex | 243 | ||||
-rwxr-xr-x | Master/tlpkg/libexec/ctan2tds | 1 |
5 files changed, 447 insertions, 114 deletions
diff --git a/Master/texmf-dist/doc/latex/tikzmark/README.txt b/Master/texmf-dist/doc/latex/tikzmark/README.txt new file mode 100644 index 00000000000..ef4d2e566dd --- /dev/null +++ b/Master/texmf-dist/doc/latex/tikzmark/README.txt @@ -0,0 +1,10 @@ +---------------------------------------------------------------- +tikzmark --- remembering absolute positioning with TikZ +E-mail: loopspace@mathforge.org +Released under the LaTeX Project Public License v1.3c or later +See http://www.latex-project.org/lppl.txt +---------------------------------------------------------------- + +The tikzmark package defines a command to "remember" a position +on a page for later (or earlier) use, primarily (but not +exclusively) with TikZ. diff --git a/Master/texmf-dist/doc/latex/tikzmark/tikzmark.pdf b/Master/texmf-dist/doc/latex/tikzmark/tikzmark.pdf Binary files differindex 55386a7232f..c97ed9a71ba 100644 --- a/Master/texmf-dist/doc/latex/tikzmark/tikzmark.pdf +++ b/Master/texmf-dist/doc/latex/tikzmark/tikzmark.pdf diff --git a/Master/texmf-dist/source/latex/tikzmark/tikzmark.dtx b/Master/texmf-dist/source/latex/tikzmark/tikzmark.dtx index 88ae0b2efea..2cdf663e410 100644 --- a/Master/texmf-dist/source/latex/tikzmark/tikzmark.dtx +++ b/Master/texmf-dist/source/latex/tikzmark/tikzmark.dtx @@ -201,7 +201,7 @@ and the derived files tikzmark.ins, %</driver> % \fi % -% \CheckSum{919} +% \CheckSum{1119} % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -226,14 +226,15 @@ and the derived files tikzmark.ins, % \changes{1.3}{2017/06/01}{Tikzmark no longer uses semi-colon (too many issues with catcodes) and fix for beamer-awareness} % \changes{1.4}{2017/10/29}{Bug fixes: spurious characters in aux file, tikzmark prefix/suffix ignored in iftikzmark test} % \changes{1.5}{2018/09/09}{Reintroduced the original command (now as tikzmarknode) with a mathchoice hack for different math modes} -% \changes{1.6}{2019/10/18}{Added the ability to save node information between runs and between TeX documents} +% \changes{1.6}{2018/10/18}{Added the ability to save node information between runs and between TeX documents} +% \changes{1.7}{2019/05/07}{Added conditions to test if a tikzmark is on a particular page} % % \DoNotIndex{\newcommand,\newenvironment} % % \providecommand*{\url}{\texttt} % \title{The \textsf{tikzmark} package} % \author{Andrew Stacey \\ \url{loopspace@mathforge.org}} -% \date{v1.6~from 2018/10/18} +% \date{v1.7~from 2019/05/07} % % % \maketitle @@ -406,9 +407,21 @@ and the derived files tikzmark.ins, % % \item \Verb+\iftikzmark+\marg{name}\marg{true code}\marg{false code} % -% This is a simple conditional to test if a particular mark is available. +% This is a conditional to test if a particular mark is available. % It executes \Verb+true code+ if it is and \Verb+false code+ if not. % +% \item \Verb+\iftikzmarkexists+\marg{name} +% +% This is a conditional to test if a particular mark is available which works with the lower level \TeX\ \Verb+\else+ and \Verb+\fi+. +% +% \item \Verb+\iftikzmarkoncurrentpage+\marg{name} +% +% This is a conditional to test if a particular mark is on the current page; it works with the lower level \TeX\ \Verb+\else+ and \Verb+\fi+. +% +% \item \Verb+\iftikzmarkonpage+\marg{name}\marg{page} +% +% This is a conditional to test if a particular mark is on a given page; it works with the lower level \TeX\ \Verb+\else+ and \Verb+\fi+. +% % \item \Verb+\tikzmarknode+\oarg{options}\marg{name}\marg{contents} % % This is a reincarnation of the original \Verb+\tikzmark+ command which places its contents inside a \Verb+\tikz+ node. It also defines a \Verb+tikzmark+ with the same name. Using a sneaky trick with \Verb+\mathchoice+, it works inside a math environment. The spacing either side might not be quite right as although it detects the math style it doesn't got beyond that. The \Verb+options+ are passed to the node. @@ -437,6 +450,15 @@ and the derived files tikzmark.ins, % % This is a key equivalent of the \Verb+\iftikzmark+ command. % +% \item \Verb+/tikz/if tikzmark on current page=#1#2#3+ +% +% This is a key equivalent of the \Verb+\iftikzmarkoncurrentpage+ command. +% If true, the keys in \Verb+#2+ are executed, otherwise the keys in \Verb+#3+. +% +% \item \Verb+/tikz/if tikzmark on page=#1#2#3#4+ +% +% This is a key equivalent of the \Verb+\iftikzmarkonpage+ command. +% % \item \Verb+/tikz/next page+, \Verb+/tikz/next page vector+ % % It is possible to refer to a mark on a different page to the current page. @@ -477,6 +499,8 @@ and the derived files tikzmark.ins, % The simplest way to turn a pseudo-node into a more normal node is to use the \Verb+fit+ library. % Using the above example, \Verb+\node[fit=(a),draw,inner sep=0pt] {};+ would draw a rectangle around the word \Verb+sub+ of exactly the same size as would appear had a normal node been created. % +% Using a sneaky trick with \Verb+\mathchoice+, \Verb+subnode+ works inside a math environment. The spacing either side might not be quite right as although it detects the math style it doesn't got beyond that. +% % \item \emph{Node saving} % % The node saving system takes the information stored about a node and saves it for later use. @@ -824,6 +848,36 @@ and the derived files tikzmark.ins, 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 + }% + }% + }, % \end{macrocode} % Prefix and suffix for tikzmark names, shamelessly borrowed from the main tikz code % \begin{macrocode} @@ -856,6 +910,16 @@ and the derived files tikzmark.ins, % \end{macrocode} % \end{macro} % +% \begin{macro}{\tikzmarkalias} +% Alias a tikzmark to another name (used in tikzmarknode) +% \begin{macrocode} +\def\tikzmarkalias#1#2{% + \pgf@node@gnamelet{save@pt@#1}{save@pt@#2}% + \pgf@node@gnamelet{save@pt@#1@offset}{save@pt@#2@offset}% +} +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\tmk@labeldef} % Auxiliary command for the coordinate system. % \begin{macrocode} @@ -897,22 +961,19 @@ and the derived files tikzmark.ins, \@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}% - }% - } + }% +} % \end{macrocode} % \end{macro} % @@ -940,8 +1001,13 @@ and the derived files tikzmark.ins, \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% } % \end{macrocode} @@ -1000,25 +1066,79 @@ and the derived files tikzmark.ins, % % \begin{macro}{\iftikzmark} % \begin{macrocode} +\newif\iftikzmark@ \newcommand\iftikzmark[3]{% \@ifundefined{save@pt@\tikzmark@pp@name{#1}}{% #3% }{% #2% }% +}% +% \end{macrocode} +% +% A version suitable for \Verb+\if ... \else ... \fi+. +% \begin{macrocode} +\newcommand\iftikzmarkexists[1]{% + \@ifundefined{save@pt@\tikzmark@pp@name{#1}}{% + \tikzmark@false% + }{% + \tikzmark@true% + }% + \iftikzmark@ +}% +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\iftikzmarkonpage} +% \begin{macrocode} +\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@ +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\iftikzmarkoncurrentpage} +% \begin{macrocode} +\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@ +} % \end{macrocode} % \end{macro} % % \begin{macro}{\subnode} % Note: much of this code was inevitably adapted from the node defining code in the TikZ/PGF sources. % \begin{macrocode} -\newcommand\subnode[3][]{% +\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 @@ -1028,46 +1148,86 @@ and the derived files tikzmark.ins, \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 +% \pgfnodealias{#2}{#2-t}% %% Fallback + \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 +} + % \end{macrocode} % \end{macro} % @@ -1086,6 +1246,7 @@ and the derived files tikzmark.ins, \node[ anchor=base, inner sep=0pt, + minimum width=0pt, name={#2}, node contents={#3}, every tikzmarknode/.try, @@ -1106,7 +1267,7 @@ and the derived files tikzmark.ins, }% \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 @@ -1114,18 +1275,22 @@ and the derived files tikzmark.ins, \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}% @@ -1207,6 +1372,17 @@ and the derived files tikzmark.ins, \bool_new:N \l__sn_file_bool % \end{macrocode} % +% This boolean is for whether we are in the preamble or not. +% \begin{macrocode} +\bool_new:N \g__sn_preamble_bool +\bool_set_true:N \g__sn_preamble_bool +% \end{macrocode} +% +% \begin{macrocode} +\msg_new:nnn {tikzmark} {no file} {File~ "#1"~ doesn't~ exist.} +\msg_new:nnn {tikzmark} {loading nodes} {Loading~ nodes~ from~ "#1".} +% \end{macrocode} +% % Dimensions and token lists for shifting % \begin{macrocode} \dim_new:N \l__sn_x_dim @@ -1224,7 +1400,7 @@ and the derived files tikzmark.ins, \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: { @@ -1378,8 +1554,7 @@ and the derived files tikzmark.ins, { \save_nodes:Nn \l__sn_tmpa_tl {#1} % \end{macrocode} -% Save the token list to the aux file so that on reading the aux -% file, we restore the node definitions +% Save the token list to the nodes file so that on reading it back in, we restore the node definitions % \begin{macrocode} \sn_open_stream: \iow_now:Nx \g__sn_stream @@ -1416,13 +1591,18 @@ and the derived files tikzmark.ins, % \begin{macrocode} \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} % \end{macrocode} % \end{macro} % @@ -1584,16 +1764,23 @@ and the derived files tikzmark.ins, % Restore nodes from file % \begin{macrocode} 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, % \end{macrocode} % Restore nodes from list % \begin{macrocode} 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={ diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds index 48b39d8e00b..d35ecb9c799 100755 --- a/Master/tlpkg/libexec/ctan2tds +++ b/Master/tlpkg/libexec/ctan2tds @@ -2696,6 +2696,7 @@ my $core_latex = "$Master/texmf-dist/tex/latex"; 'thucoursework' => 'pdflatex-preserve-pdf --engine xelatex', 'thumb' => 'latex -translate-file=empty.tcx', # no 8-bit 'tikz-page' => 'tex -8bit', # no doc remake, 8-bit name + 'tikzmark' => 'tex', 'todonotes' => 'latex', # requires interaction 'toptesi' => 'latex', # requires interaction 'tudscr' => 'tex', |