TikZ`定位`:箭头和节点之间的额外空白

TikZ`定位`:箭头和节点之间的额外空白

使用positioning TikZ库时,我在箭头和 tikz 节点之间出现了虚假的空白,如下图所示。它对简单的矩形很有效。

梅威瑟:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
  \begin{tikzpicture}
    \node[rectangle,draw](node1){Node 1}; 
    \node[rectangle,draw,below=of node1](node2){Node 2}; 
    \node[below=of node2](tikzpic){%
      \begin{tikzpicture}[scale=0.5]
          \draw [step=0.25cm,lightgray,very thin] (0,0) grid (2.5,1.5);
          \draw [->,ultra thick] (0,0.0) -- (0,1.5);
          \draw [->,ultra thick] (0,0.0) -- (2.5,0);
          \draw [fill=blue!7,ultra thick] (0.2,0) ..controls
          (0.5,2.2) and (1.5,0.3) .. (2,0);
        \end{tikzpicture}
    };  
    \draw[->,ultra thick] (node1) -- (node2);
    \draw[->,ultra thick] (node2) -- (tikzpic);
  \end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

这是因为控制点正在扩大边界框。

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
  \begin{tikzpicture}
    \node[rectangle,draw](node1){Node 1}; 
    \node[rectangle,draw,below=of node1](node2){Node 2}; 
    \node[below=of node2,inner sep=0,outer sep=0](tikzpic){%
      \begin{tikzpicture}[scale=0.5]
          \draw [step=0.25cm,lightgray,very thin] (0,0) grid (2.5,1.5);
          \draw [->,ultra thick] (0,0.0) -- (0,1.5);
          \draw [->,ultra thick] (0,0.0) -- (2.5,0);
          \draw [fill=blue!7,ultra thick,overlay] (0.2,0) ..controls
          (0.5,2.2) and (1.5,0.3) .. (2,0);
        \end{tikzpicture}
    };  
    \draw[->,ultra thick] (node1) -- (node2);
    \draw[->,ultra thick] (node2) -- (tikzpic);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容