我希望能够在节点的 z 和 w 之间添加更多空间。我尝试了 bigskip 和其他方法(包括重新定义 baselineskip),这两个词(在原始文档中)似乎仍然很紧。似乎 medskip/bigskip 命令在节点内被忽略了?
梅威瑟:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[cc/.style={minimum height=1.21cm,align=center,fill=green!20,rounded corners=2pt,thick,inner sep=4,outer sep=0,minimum width=18mm},cred/.style={minimum height=1.21cm,align=center,fill=green!20,rounded corners=2pt,thick,inner sep=4,outer sep=0,minimum width=18mm},cgreen/.style={minimum height=1.21cm,align=center,fill=green!20,rounded corners=2pt,thick,inner sep=4,outer sep=0,minimum width=18mm},corange/.style={minimum height=1.21cm,align=center,fill=green!20,rounded corners=2pt,thick,inner sep=4,outer sep=0,minimum width=18mm}]
\path (0,0) node[cc] (A) {x} (2.3,0) node[cc] (B) {z \bigskip \\ w} (4.6,0) node[cc] (C) {t\\v} (6.8,0) node[cc] (D) {CC \\ CC};
\end{tikzpicture}
\end{document}
答案1
像这样?
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{chains,
positioning}
\begin{document}
\begin{tikzpicture}[
node distance = 0mm and 4mm,
start chain = going right,
cc/.style = {fill=#1, rounded corners=2pt,
minimum height=1.21cm, minimum width=18mm, align=center,
inner sep=4, outer sep=0,
on chain},
cc/.default = green!20
]
\node[cc] (A) {x};
\node[cc] (B) {z\\[2ex] w}; % <---
\node[cc] (C) {t\\v};
\node[cc] (D) {CC\\ CC};
\end{tikzpicture}
\end{document}