% Copyright (C) 2012 by Paul Gaborit % % This file may be distributed and/or modified % % 1. under the LaTeX Project Public License and/or % 2. under the GNU Public License. \RequirePackage{ocgx} \usetikzlibrary{calc} \makeatletter \tikzset{ ocg/.style={ocg/.cd,#1,/tikz/.cd}, ocg={ % parameters name/.store in=\ocgx@name, visibity/.store in=\ocgx@visibility, status/.is choice, status/visible/.style={visibity=1}, status/invisible/.style={visibity=0}, % default values name=, status=visible, % ref ref/.style={ /tikz/execute at begin scope={\ocg{\ocgx@name}{#1}{\ocgx@visibility}}, /tikz/execute at end scope={\endocg}, }, }, switch ocg/.style={ postaction={ path picture={ \path let \p1 = (path picture bounding box.south west), \p2 = (path picture bounding box.north east), \p3 = (\x2-\x1,\y2-\y1) in (path picture bounding box.center) node[inner sep=0pt,anchor=center,outer sep=0pt] {\switchocg{#1}{\phantom{\rule{\x3}{\y3}}}}; } }, }, switch ocg with mark on/.style 2 args={ postaction={ path picture={ \begin{ocg}{#1}{#1}{1} \draw (path picture bounding box.south west) -- (path picture bounding box.north east) (path picture bounding box.south east) -- (path picture bounding box.north west) ; \end{ocg} }, switch ocg={#1 #2}, } }, switch ocg with mark off/.style 2 args={ postaction={ path picture={ \begin{ocg}{#1}{#1}{0} \draw (path picture bounding box.south west) -- (path picture bounding box.north east) (path picture bounding box.south east) -- (path picture bounding box.north west) ; \end{ocg} }, switch ocg={#1 #2}, } }, show ocg/.style={ postaction={ path picture={ \path let \p1 = (path picture bounding box.south west), \p2 = (path picture bounding box.north east), \p3 = (\x2-\x1,\y2-\y1) in (path picture bounding box.center) node[inner sep=0pt,anchor=center] {\showocg{#1}{\phantom{\rule{\x3}{\y3}}}}; }, }, }, hide ocg/.style={ postaction={ path picture={ \path let \p1 = (path picture bounding box.south west), \p2 = (path picture bounding box.north east), \p3 = (\x2-\x1,\y2-\y1) in (path picture bounding box.center) node[inner sep=0pt,anchor=center] {\hideocg{#1}{\phantom{\rule{\x3}{\y3}}}}; }, }, }, actions ocg/.style n args={3}{ postaction={ path picture={ \path let \p1 = (path picture bounding box.south west), \p2 = (path picture bounding box.north east), \p3 = (\x2-\x1,\y2-\y1) in (path picture bounding box.center) node[inner sep=0pt,anchor=center] {\actionsocg{#1}{#2}{#3}{\phantom{\rule{\x3}{\y3}}}}; }, }, }, } \makeatother