南北定义的节点之间的距离

南北定义的节点之间的距离

我想定义节点距离,使该距离位于节点的南北之间,而不是相对于中心。更准确地说

在此处输入图片描述

图像生成自

\documentclass{standalone}
\usepackage{tikz}
\begin{document}    
\begin{tikzpicture}

    \node[text width=16cm] (A) at (0,0) {some text, some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text};     

\node[below of=A, node distance=8cm, text width=16cm] (B) {some text, some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text};

\node[below of=B, node distance=8cm, text width=16cm] (C) {some text, some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text, some text, some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text,some text};

\draw[red, very thick] (0,0)--(0,-8);
\draw[blue, very thick] (1,-1)--(1,-7);
\node [anchor=east, text width=6cm, red] at (-1.5,-4) {Distance between nodes is defined by the center, in this example it is 8cm\\ \verb|\node (A) at (0,0) {some text ...};|\\\verb|\node[below of=A,|\\ \verb|node distace=8cm,...] (B) {some text ...};|};
\draw[red, very thick] (-1,-8)--(-1,-16);
\node [anchor=west, text width=6cm, blue] at (1.5,-4) {I would like to set the node distance value as the value between the distance from the south of node A to the north of node B};
\draw[blue, very thick] (1,-9)--(1,-14);
\node [anchor=west, text width=6cm, blue] at (1.5,-11) {So that it is possible to make the next nodes have the same distance between the south and north pole, even if the text increases or decreases in size. In this example, the distance has decreased};
\end{tikzpicture}
\end{document}    

答案1

\usetikzlibrary{positioning}如果您添加并使用 ,则这是默认行为below=of A。请of注意=,另请参阅PGF/TikZ 中“right of=”和“right=of”之间的区别

node distance还要注意,你需要在键之前设置below,即,而不是below=of A,node distance=8cm,你需要

node distance=8cm,below=of A

或者你可以使用较短的版本,

below=8cm of A

如果在所有情况下都应应用相同的距离,则将其node distance作为选项添加到tikzpicture环境中,如下面的代码所示。

\documentclass{standalone}
\usepackage{tikz,lipsum} % the latter for dummy text
\usetikzlibrary{positioning}
\begin{document}    
\begin{tikzpicture}[node distance=8cm]

\node[text width=16cm] (A) at (0,0) {\lipsum*[1]};     

\node[below=of A, text width=16cm] (B) {\lipsum*[2]};

\node[below=of B, text width=16cm] (C) {\lipsum*[3]};

\draw[red, very thick] (A.south)--(B.north) 
node [pos=0.5,anchor=east, text width=6cm, red] at (-1.5,-4) {This line goes from A.south to B.north};

\draw[red, very thick] (B.south)--++(0,-8)
node [pos=0.5,anchor=west, text width=6cm, blue] at (1.5,-11) {This line starts at B.south and goes 8cm down};

\draw[blue, very thick] ([xshift=1cm]A.south)--++(0,-8)
node [midway,anchor=west, text width=6cm, blue] at (1.5,-4) {This line starts 1cm right of A.south and goes 8cm down};
\end{tikzpicture}
\end{document}  

在此处输入图片描述

相关内容