From ab891e8f26824be68885db17418c16b85bc48e2f Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Mon, 22 Feb 2021 21:52:28 +0000
Subject: tikzmark (22feb21)

git-svn-id: svn://tug.org/texlive/trunk@57843 c570f23f-e606-0410-a88d-b1316a301751
---
 .../latex/tikzmark/tikzlibrarytikzmark.code.tex    | 90 +++++++++++++++++-----
 1 file changed, 69 insertions(+), 21 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/tikzmark/tikzlibrarytikzmark.code.tex')

diff --git a/Master/texmf-dist/tex/latex/tikzmark/tikzlibrarytikzmark.code.tex b/Master/texmf-dist/tex/latex/tikzmark/tikzlibrarytikzmark.code.tex
index 725b58f571b..8db5f2e37b3 100644
--- a/Master/texmf-dist/tex/latex/tikzmark/tikzlibrarytikzmark.code.tex
+++ b/Master/texmf-dist/tex/latex/tikzmark/tikzlibrarytikzmark.code.tex
@@ -12,6 +12,10 @@
 %% See http://www.latex-project.org/lppl.txt
 %% ----------------------------------------------------------------
 %% 
+\ProvidesFile{tikzlibrarytikzmark.code.tex}[%
+  2021/02/16
+  v1.10
+  TikZ library for marking positions in a document]
 \RequirePackage{expl3, l3keys2e, xparse}
 \tikzset{%
   remember picture with id/.style={%
@@ -32,6 +36,28 @@
       \fi%
     },
   },
+  check picture id/.code={
+    \ifpgfrememberpicturepositiononpage
+    \@ifundefined{pgf@sys@pdf@mark@pos@\pgfpictureid}{%
+      \tikzset{%
+        name prefix/.get=\tzmk@name@prefix,
+        name prefix/.prefix=discard-,
+        execute at end picture={%
+          \tikzset{name prefix/.expand once=\tzmk@name@prefix}%
+        },
+      }%
+    }{}%
+    \fi
+  },
+  maybe define node/.style={%
+    execute at end picture={%
+      \ifpgfrememberpicturepositiononpage
+      \@ifundefined{pgf@sh@pi@\tikz@pp@name{#1}}{%
+        \pgfnodealias{\tikz@pp@name{#1}}{discard-\tikz@pp@name{#1}}%
+      }{}%
+      \fi
+    }%
+  },
   save picture id/.code={%
       \protected@write\pgfutil@auxout{}{%
       \string\savepointas%
@@ -65,10 +91,14 @@
     \@ifundefined{save@pt@\tikzmark@pp@name{#1}}{%
       \pgfkeysalso{#3}%
     }{%
-      \@ifundefined{save@pg@\csname save@pt@\tikzmark@pp@name{#1}\endcsname}{%
+      \@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%
+        \ifnum\csname save@pg@%
+        \csname save@pt@\tikzmark@pp@name{#1}\endcsname%
+        \endcsname=\the\value{page}\relax%
         \pgfkeysalso{#2}%
         \else
         \pgfkeysalso{#3}%
@@ -80,10 +110,14 @@
     \@ifundefined{save@pt@\tikzmark@pp@name{#1}}{%
       \pgfkeysalso{#4}%
     }{%
-      \@ifundefined{save@pg@\csname save@pt@\tikzmark@pp@name{#1}@label\endcsname}{%
+      \@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%
+        \ifnum\csname save@pg@%
+        \csname save@pt@\tikzmark@pp@name{#1}\endcsname%
+        \endcsname=#2\relax%
         \pgfkeysalso{#3}%
         \else
         \pgfkeysalso{#4}%
@@ -143,7 +177,12 @@
       \@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}%
+        \edef\tmk@pg{%
+          \the\numexpr \csname save@pg@%
+          \csname save@pt@\tmk@label\endcsname\endcsname%
+          -
+          \csname save@pg@\pgfpictureid\endcsname\relax%
+        }%
         \ifnum \tmk@pg > 0 \relax
         \advance \pgf@xa by \pgf@x\relax
         \advance \pgf@ya by \pgf@y\relax
@@ -161,13 +200,15 @@
   }%
 }
 \newcommand\tikzmark@outside[2][]{%
+\tikzset{external/export next/.try=false}%
 \tikz[remember picture with id=#2]{#1}%
 }
 \def\tikzmark@inside#1#2{%
   \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}{\the\pgf@y}}%
+    \string\savepointas%
+    {\tikzmark@pp@name{#1}}{\pgfpictureid}{\the\pgf@x}{\the\pgf@y}}%
 }
 \def\tikzmark{%
   \ifx\pgfpictureid\@undefined
@@ -234,7 +275,9 @@
     \@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%
+      \ifnum\csname save@pg@%
+      \csname save@pt@\tikzmark@pp@name{#1}\endcsname%
+      \endcsname=#2\relax%
       \tikzmark@true
       \else
       \tikzmark@false
@@ -250,7 +293,9 @@
     \@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%
+      \ifnum\csname save@pg@%
+      \csname save@pt@\tikzmark@pp@name{#1}\endcsname%
+      \endcsname=\the\value{page}\relax%
       \tikzmark@true
       \else
       \tikzmark@false
@@ -356,10 +401,13 @@
 }
 
 \def\tikzmarknode@#1#2#3{%
+\tikzset{external/export next/.try=false}%
   \tikz[%
     remember picture,
-    baseline=(#2.base),
     save picture id={#2},
+    check picture id,
+    maybe define node={#2},
+    baseline=(#2.base),
     every tikzmarknode picture/.try
   ] {
     \node[
@@ -394,25 +442,25 @@
   \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
-  \pgfutil@ifundefined{pgf@sh@ns@#2}{%
-    \pgfnodealias{#2}{#2-t}%
-    \tikzmarkalias{#2}{#2-t}%
+  \pgfutil@ifundefined{pgf@sh@ns@\tikz@pp@name{#2}}{%
+    \pgfnodealias{\tikz@pp@name{#2}}{\tikz@pp@name{#2-t}}%
+    \tikzmarkalias{\tikzmark@pp@name{#2}}{\tikzmark@pp@name{#2-t}}%
   }{}%
   \else
-    \pgfnodealias{#2}{#2-d}%
-    \tikzmarkalias{#2}{#2-d}%
+    \pgfnodealias{\tikz@pp@name{#2}}{\tikz@pp@name{#2-d}}%
+    \tikzmarkalias{\tikzmark@pp@name{#2}}{\tikzmark@pp@name{#2-d}}%
   \fi
   \else
-    \pgfnodealias{#2}{#2-t}%
-    \tikzmarkalias{#2}{#2-t}%
+    \pgfnodealias{\tikz@pp@name{#2}}{\tikz@pp@name{#2-t}}%
+    \tikzmarkalias{\tikzmark@pp@name{#2}}{\tikzmark@pp@name{#2-t}}%
   \fi
   \else
-    \pgfnodealias{#2}{#2-s}%
-    \tikzmarkalias{#2}{#2-s}%
+    \pgfnodealias{\tikz@pp@name{#2}}{\tikz@pp@name{#2-s}}%
+    \tikzmarkalias{\tikzmark@pp@name{#2}}{\tikzmark@pp@name{#2-s}}%
   \fi
   \else
-    \pgfnodealias{#2}{#2-ss}%
-    \tikzmarkalias{#2}{#2-ss}%
+    \pgfnodealias{\tikz@pp@name{#2}}{\tikz@pp@name{#2-ss}}%
+    \tikzmarkalias{\tikzmark@pp@name{#2}}{\tikzmark@pp@name{#2-ss}}%
   \fi
   \else
     \tikzmarknode@{#1}{#2}{#3}%
@@ -772,7 +820,7 @@
 }
 \ExplSyntaxOff
 %% 
-%% Copyright (C) 2011-2018 by Andrew Stacey <loopspace@mathforge.org>
+%% Copyright (C) 2011-2021 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
-- 
cgit v1.2.3

