在microtype
手册的第 17 页中,他们使用了多个箭头,当您单击某些关键字时,这些箭头会变得可见。这些箭头链接到一个图形和正文的某些部分。使用哪些软件包来创建它?
经过一番搜索,我意识到它ocgx
能够基于可点击开关隐藏/显示对象。使用它ocgx
可以创建可以隐藏且不重叠的简单对象。下面的 MWE 隐藏并显示两个三角形和箭头。
但我希望它们像microtype
手册中那样重叠。箭头应该在顶层,不会被文本隐藏,并且能够穿过文本。有没有关于如何实现这一点的建议,或者哪些其他软件包可以产生类似的结果?
\documentclass{article}
\usepackage{ocgx}
\usepackage{tikz}
\begin{document}
The Two triangles
\begin{ocg}{OCG 2}{ocg3}{0}
\begin{tikzpicture}
\path[draw,line width=4pt,red] (1,1) -- (2,2)--(3,1)--cycle;
\end{tikzpicture}
\end{ocg}
\begin{ocg}{OCG 2}{ocg2}{0}
\begin{tikzpicture}
\path[draw,line width=4pt] (1,1) -- (2,2)--(3,1)--cycle;
\end{tikzpicture}
\end{ocg}
\begin{ocg}{OCG 2}{ocg4}{0}
\tikz \draw[-latex,red] (0,-1) node {} -- (2,2);
\end{ocg}
\begin{ocg}{OCG 2}{ocg5}{0}
\tikz \draw[-latex] (1,1) node {} -- (2,2);
\end{ocg}
\switchocg{ocg2}{Black Triangle}
\switchocg{ocg3}{Red Triangle}
\switchocg{ocg4}{Red Arrow}
\switchocg{ocg5}{Black Arrow}
\结束{文档}
答案1
您是否恰巧在寻找overlay
钥匙remember picture
和tikzmark
图书馆?
\documentclass{article}
\usepackage[tikz]{ocgx2}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\begin{document}
\tikzmarknode{H}{Hello} \tikzmarknode{w}{world!} \tikzmarknode{A}{And}
\tikzmarknode{f}{fellow} \tikzmarknode{c}{cats}!
\begin{ocg}{OCG 2}{ocg2}{0}
\begin{tikzpicture}[overlay,remember picture]
\draw[red,thick] (H) to[out=45,in=135] (w);
\end{tikzpicture}
\end{ocg}
\begin{ocg}{OCG 2}{ocg3}{0}
\begin{tikzpicture}[overlay,remember picture]
\draw[blue,thick] (H) to[out=-45,in=-135] (w);
\end{tikzpicture}
\end{ocg}
\begin{ocg}{OCG 2}{ocg4}{0}
\begin{tikzpicture}[overlay,remember picture]
\draw[red,thick] (A) to[out=45,in=-135] (c);
\end{tikzpicture}
\end{ocg}
\begin{ocg}{OCG 2}{ocg5}{0}
\begin{tikzpicture}[overlay,remember picture]
\draw[blue,thick] (A) to[out=-45,in=135] (c);
\end{tikzpicture}
\end{ocg}
\switchocg{ocg2}{upper}
\switchocg{ocg3}{lower}
\switchocg{ocg4}{upper 2}
\switchocg{ocg5}{lower 2}
\end{document}
点击upper
获取
点击lower
获取
点击upper 2
获取
等等。
您可以通过多种方式使用它。
\documentclass{article}
\usepackage[tikz]{ocgx2}
\usepackage{tikz}
\usepackage{tikzlings}
\usetikzlibrary{tikzmark,calc}
\begin{document}
Hello \switchocg{ocg1}{\tikzmarknode{c}{cats}},
\switchocg{ocg2}{\tikzmarknode{k}{koalas}} and
\switchocg{ocg3}{\tikzmarknode{m}{marmots}}!
\begin{ocg}{OCG 2}{ocg1}{0}
\begin{tikzpicture}[overlay,remember picture]
\begin{scope}[shift={($(c)+(-1,1)$)},local bounding box=cat]
\cat[eyes=green]
\end{scope}
\draw[thick,-latex] (cat) to[bend right] (c);
\end{tikzpicture}
\end{ocg}
\begin{ocg}{OCG 2}{ocg2}{0}
\begin{tikzpicture}[overlay,remember picture]
\begin{scope}[shift={($(c)+(0,-3)$)},local bounding box=koala]
\koala[blush]
\end{scope}
\draw[thick,-latex] (koala) to[bend right] (k);
\end{tikzpicture}
\end{ocg}
\begin{ocg}{OCG 2}{ocg3}{0}
\begin{tikzpicture}[overlay,remember picture]
\begin{scope}[shift={($(m)+(1,1)$)},local bounding box=marmot]
\marmot[whiskers,teeth]
\end{scope}
\draw[thick,-latex] (marmot) to[bend right] (m);
\end{tikzpicture}
\end{ocg}
\end{document}
试试当你点击这些生物的名字时会发生什么。(当然,你需要 Acrobat Reader。)