我正在尝试用箭头连接单独的 tikz 图像内的点。叠加选项效果很好,但必须缩放图像才能适合幻灯片(我在 beamer 演示中使用它们)。但是,当我使用 scalebox 绘制图表时,箭头会绘制在原始(未缩放)坐标上。缩放箭头也不起作用。有没有办法解决这个问题(也许不使用 scalebox)?
谢谢您的回答。
梅威瑟:
\documentclass[preview]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{subcaption}
\usepackage{tikz}
\begin{document}
\begin{figure}[htb]
\centering
\begin{subfigure}[b]{0.45\textwidth}
\scalebox{0.65}{%
\begin{tikzpicture}[remember picture]
\tikzset{point/.style = {circle, fill=black, draw=black, inner sep=2pt}} % Points
\draw[thick,->,>=stealth](-0.5,0)--(6,0) node[right]{$x$}; % Axis X
\draw[thick,->,>=stealth](0,-0.5)--(0,4) node[above]{$y$}; % Axis Y
\node[point, label=above:A] (A) at (2.5,2.5) {}; % Point A
\end{tikzpicture}}
\end{subfigure}
\begin{subfigure}[b]{0.45\textwidth}
\scalebox{0.65}{%
\begin{tikzpicture}[remember picture]
\tikzset{point/.style = {circle, fill=black, draw=black, inner sep=2pt}} % Points
\draw[thick,->,>=stealth](-0.5,0)--(6,0) node[right]{$x$}; % Axis X
\draw[thick,->,>=stealth](0,-0.5)--(0,4) node[above]{$y$}; % Axis Y
\node[point, label=above:B] (B) at (2.5,2.5) {}; % Point B
\end{tikzpicture}}
\end{subfigure}
\end{figure}
\begin{tikzpicture}[overlay, remember picture]
\path[->,red,thick] (A) edge [bend right] (B);
\end{tikzpicture}
\end{document}
答案1
唯一不受影响的点\scalebox
是(current bounding box.south west)
。
\documentclass[preview]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{subcaption}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{figure}[htb]
\centering
\begin{subfigure}[b]{0.45\textwidth}
\scalebox{0.65}{%
\begin{tikzpicture}[remember picture]
\tikzset{point/.style = {circle, fill=black, draw=black, inner sep=2pt}} % Points
\draw[thick,->,>=stealth](-0.5,0)--(6,0) node[right]{$x$}; % Axis X
\draw[thick,->,>=stealth](0,-0.5)--(0,4) node[above]{$y$}; % Axis Y
\node[point, label=above:A] (A) at (2.5,2.5) {}; % Point A
\coordinate (C) at (current bounding box.south west);
\end{tikzpicture}}
\end{subfigure}
\begin{subfigure}[b]{0.45\textwidth}
\scalebox{0.65}{%
\begin{tikzpicture}[remember picture]
\tikzset{point/.style = {circle, fill=black, draw=black, inner sep=2pt}} % Points
\draw[thick,->,>=stealth](-0.5,0)--(6,0) node[right]{$x$}; % Axis X
\draw[thick,->,>=stealth](0,-0.5)--(0,4) node[above]{$y$}; % Axis Y
\node[point, label=above:B] (B) at (2.5,2.5) {}; % Point B
\coordinate (D) at (current bounding box.south west);
\end{tikzpicture}}
\end{subfigure}
\end{figure}
\begin{tikzpicture}[overlay, remember picture]
\path[->,red,thick] ($(C)!0.65!(A)$) edge [bend right] ($(D)!0.65!(B)$);
\end{tikzpicture}
\end{document}
答案2
使用scale
和transform shape
缩放节点的标签。
\documentclass[preview]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{subcaption}
\usepackage{tikz}
\begin{document}
\begin{figure}[htb]
\centering
\begin{subfigure}[b]{0.45\textwidth}
%\scalebox{0.65}{%
\begin{tikzpicture}[scale=0.65,transform shape,remember picture]
\tikzset{point/.style = {circle, fill=black, draw=black, inner sep=2pt}} % Points
\draw[thick,->,>=stealth](-0.5,0)--(6,0) node[right]{$x$}; % Axis X
\draw[thick,->,>=stealth](0,-0.5)--(0,4) node[above]{$y$}; % Axis Y
\node[point, label=above:A] (A) at (2.5,2.5) {}; % Point A
\end{tikzpicture}
%}
\end{subfigure}
\begin{subfigure}[b]{0.45\textwidth}
%\scalebox{0.65}{%
\begin{tikzpicture}[scale=0.65,transform shape,remember picture]
\tikzset{point/.style = {circle, fill=black, draw=black, inner sep=2pt}} % Points
\draw[thick,->,>=stealth](-0.5,0)--(6,0) node[right]{$x$}; % Axis X
\draw[thick,->,>=stealth](0,-0.5)--(0,4) node[above]{$y$}; % Axis Y
\node[point, label=above:B] (B) at (2.5,2.5) {}; % Point B
\end{tikzpicture}
%}
\end{subfigure}
\end{figure}
\begin{tikzpicture}[overlay, remember picture]
\path[->,red,thick] (A) edge [bend right] (B);
\end{tikzpicture}
\end{document}