我有两个这样的 tikz 节点:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning}
\usepackage{amsmath,bm,times}
\newcommand{\mx}[1]{\mathbf{\bm{#1}}} % Matrix command
\newcommand{\vc}[1]{\mathbf{\bm{#1}}} % Vector command
\begin{document}
\newcommand{\titleheight}{0.25in}
\newcommand{\titlewidth}{2.0in}
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
\tikzstyle{category}=[draw, fill=yellow!20]
\tikzstyle{title}=[minimum height=\titleheight,minimum width=\titlewidth, text width=\titlewidth, fill=blue!20, text centered,draw=black,line width=0.1mm]
\tikzstyle{summary}=[minimum width=\titlewidth, text width=\titlewidth, text centered,draw=black,line width=0.1mm ]
\begin{tikzpicture}
\node (1t) [title] {Zomerfeld v. Noto (2012) [1]};
\node (1s) [summary,below of=1t,node distance=0.5in] {Inadmissible evidence can be used to evaluate the admissibility of evidence but that doesn’t make the inadmissible evidence admissible.};
\end{tikzpicture}
\end{document}
如何使底部节点 (1s) 直接位于顶部节点 (1t) 下方?我不想对这个距离进行硬编码,因为底部节点的大小是可变的。
答案1
正如我所说的我的评论,您没有使用该positioning
库。Zarko 的答案是使用该语法。无论如何,如果您想要接触节点,我建议使用该shapes.multipart
库或上面的代码。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}
\newcommand{\titleheight}{0.25in}
\newcommand{\titlewidth}{2.0in}
\begin{document}
\begin{tikzpicture}
\node [rectangle split, rectangle split parts=2, draw,
minimum height=\titleheight,minimum width=\titlewidth,
text width=\titlewidth, text centered,draw=black,line width=0.1mm,
rectangle split part fill={blue!20,white}]
{\nodepart{one}Zomerfeld v. Noto (2012) [1]
\nodepart{two}Inadmissible evidence can be used to evaluate the admissibility of
evidence but that doesn't make the inadmissible evidence admissible.};
\end{tikzpicture}
\end{document}