Select Git revision
tikzlibrarytikzmark.code.tex
-
Denis Rochau authoredDenis Rochau authored
tikzlibrarytikzmark.code.tex 7.60 KiB
%%
%% This is file `tikzlibrarytikzmark.code.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% tikzmark.dtx (with options: `tikzlibrary')
%% ----------------------------------------------------------------
%% tikzmark --- remembering absolute positioning with TikZ.
%% E-mail: stacey@math.ntnu.no
%% Released under the LaTeX Project Public License v1.3c or later
%% See http://www.latex-project.org/lppl.txt
%% ----------------------------------------------------------------
%%
\tikzset{%
remember picture with id/.style={%
remember picture,
overlay,
save picture id=#1,
},
every picture/.append style={%
execute at end picture={%
\ifpgfrememberpicturepositiononpage%
\edef\pgf@temp{%
\noexpand\write\noexpand\pgfutil@auxout{%
\string\savepicturepage{\pgfpictureid}{\noexpand\thepage}}}%
\pgf@temp
\fi%
},
},
save picture id/.code={%
\immediate\write\pgfutil@auxout{%
\string\savepointas{#1}{\pgfpictureid}}%
},
if picture id/.code args={#1#2#3}{%
\@ifundefined{save@pt@#1}{%
\pgfkeysalso{#3}%
}{
\pgfkeysalso{#2}%
}
},
next page/.is choice,
next page vector/.initial={\pgfqpoint{0pt}{0pt}},
next page/below/.style={%
next page vector={\pgfqpoint{0pt}{-\the\paperheight}}%
},
next page/above/.style={%
next page vector={\pgfqpoint{0pt}{\the\paperheight}}%
},
next page/left/.style={%
next page vector={\pgfqpoint{-\the\paperwidth}{0pt}}%
},
next page/right/.style={%
next page vector={\pgfqpoint{\the\paperwidth}{0pt}}%
},
next page/ignore/.style={%
next page vector={\pgfqpoint{0pt}{0pt}}%
},
}
\def\savepointas#1#2{%
\expandafter\gdef\csname save@pt@#1\endcsname{#2}%
}
\def\savepicturepage#1#2{%
\expandafter\gdef\csname save@pg@#1\endcsname{#2}%
}
\def\tmk@labeldef#1,#2\@nil{%
\def\tmk@label{#1}%
\def\tmk@def{#2}%
}
\tikzdeclarecoordinatesystem{pic}{%
\pgfutil@in@,{#1}%
\ifpgfutil@in@%
\tmk@labeldef#1\@nil
\else
\tmk@labeldef#1,(0pt,0pt)\@nil
\fi
\@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
\@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
}%
}%
\pgf@x=\pgf@xa
\pgf@y=\pgf@ya
}%
}
\newcommand\tikzmark[2][]{%
\tikz[remember picture with id=#2] #1;}
\newcommand\pgfmark[1]{%
\bgroup
\global\advance\pgf@picture@serial@count by1\relax%
\edef\pgfpictureid{pgfid\the\pgf@picture@serial@count}%
\pgfsys@markposition{\pgfpictureid}%
\edef\pgf@temp{%
\noexpand\write\noexpand\pgfutil@auxout{%
\string\savepicturepage{\pgfpictureid}{\noexpand\thepage}}}%
\pgf@temp
\immediate\write\pgfutil@auxout{%
\string\savepointas{#1}{\pgfpictureid}}%
\egroup
}
\newcommand\iftikzmark[3]{%
\@ifundefined{save@pt@#1}{%
#3%
}{%
#2%
}%
}%
\newcommand\subnode[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
\tikz@scan@one@point\pgfutil@firstofone(pic cs:#2)\relax
\advance\pgf@x by .5\wd\pgfnodeparttextbox
\advance\pgf@y by .5\ht\pgfnodeparttextbox
\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%
}%
}%
\egroup
\box\pgfnodeparttextbox
\endgroup
}
\def\usetikzmarklibrary{\pgfutil@ifnextchar[{\use@tikzmarklibrary}{\use@@tikzmarklibrary}}%}
\def\use@tikzmarklibrary[#1]{\use@@tikzmarklibrary{#1}}
\def\use@@tikzmarklibrary#1{%
\edef\pgf@list{#1}%
\pgfutil@for\pgf@temp:=\pgf@list\do{%
\expandafter\pgfkeys@spdef\expandafter\pgf@temp\expandafter{\pgf@temp}%
\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\edef\csname tikzmark@library@#1@atcode\endcsname{\the\catcode`\@}
\expandafter\edef\csname tikzmark@library@#1@barcode\endcsname{\the\catcode`\|}
\catcode`\@=11
\catcode`\|=12
\pgfutil@InputIfFileExists{tikzmarklibrary\pgf@temp.code.tex}{}{
\PackageError{tikzmark}{I did not find the tikzmark extras library '\pgf@temp'.}{}
}%
\catcode`\@=\csname tikzmark@library@#1@atcode\endcsname
\catcode`\|=\csname tikzmark@library@#1@barcode\endcsname
\fi%
\fi
}%
}
%%
%% Copyright (C) 2011 by Andrew Stacey <stacey@math.ntnu.no>
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License (LPPL), either
%% version 1.3c of this license or (at your option) any later
%% version. The latest version of this license is in the file:
%%
%% http://www.latex-project.org/lppl.txt
%%
%% This work is "maintained" (as per LPPL maintenance status) by
%% Andrew Stacey.
%%
%% This work consists of the file tikzmark.dtx
%% and the derived files tikzmark.ins,
%% tikzmark.pdf,
%% tikzlibrarytikzmark.code.tex, and
%% tikzmarklibrarylistings.code.tex
%% tikzmarklibraryhighlight.code.tex
%%
%%
%% End of file `tikzlibrarytikzmark.code.tex'.