在此示例中,我期望文本周围的三角形更加紧密,类似于矩形节点中文本周围的内部间距。我该如何缩小内部间距?
\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
[trusty/.style={regular polygon,regular polygon sides=3,
ultra thick,draw=black},
corp/.style={rectangle,ultra thick,
inner sep=4pt,minimum size=1.3cm, rounded corners=4mm,draw=black}
]
\node (opco) at (0,0) [corp] {entity};
\node (holdco) [corp][below=of opco] {another entity};
\node (trust) [trusty][ right=of holdco] {trust entity};
\end{tikzpicture}
\end{document}
答案1
根据regular polygon
(pgfmanual
v3.1.9a,第 71.3 节“几何形状”或此在线版本),此形状的边框始终使用内切圆,因此可能会造成更大的视觉效果inner sep
。
tikz
有一个isosceles triangle
形状,当设置时isosceles triangle apex angle=60
(也可能设置shape border rotate=90
)将有一个等边三角形边框。但这次节点文本不在节点的中心。
您可以使用regular polygon
较小的负数inner sep
作为解决方法。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\tikzset{
equilateral triangle/.style={
shape=isosceles triangle,
isosceles triangle apex angle=60,
shape border rotate=90,
},
}
\begin{document}
\begin{tikzpicture}
\node[draw, equilateral triangle, label=isosceles triangle] {text};
\node[draw, regular polygon,regular polygon sides=3, label=regular polygon]
at (3,0) {text};
\node[draw, regular polygon,regular polygon sides=3, label={[align=center]regular polygon\\negative inner sep}, inner sep=-.1em]
at (6,0) {text};
\end{tikzpicture}
\end{document}