我正在使用绘制箭头-|
,但它绘制的是 90 度的急转弯。相反,我想使用以下弯曲箭头格式样式来放松 90 度。
我的代码:
\documentclass[10pt,journal,compsoc]{IEEEtran}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}[
arr/.style = {-stealth},
N/.style = {draw,
font=\scriptsize,
align=left,
inner sep=3pt
},
]
\node (n1) [N, text width=0.5cm] at (1.2, 4) {\vspace*{-0.8mm}{hello}};
\node (n2) [N, text width=0.6cm] at (3, 4) {\vspace*{-0.8mm}{world}};
\draw[arr] (n1.north) -- ([yshift=2mm] n1.north) -| (n2.north) ;
\end{tikzpicture}
\end{document}
输出:
在这里我无法将锋利的箭射掉。
答案1
您也可以使用rounded corners=<inset>
。<inset>
描述角的大小。请参阅第 14.5 节 圆角TikZ 手册。
对于节点的高度,您可以使用text height
(并且,如果需要,text depth
)。
\documentclass[10pt,journal,compsoc]{IEEEtran}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}[
arr/.style = {-stealth,
rounded corners=7,},
N/.style = {draw,
font=\scriptsize,
align=left,
inner sep=3pt
},
]
\node (n1) [N, text height=1.8mm] at (1.2, 4) {hello};
\node (n2) [N, text height=1.8mm] at (3, 4) {world};
\draw[arr] (n1.north) -- ([yshift=4mm] n1.north) -| (n2.north) ;
\end{tikzpicture}
\end{document}
正如 Zarko 所评论的,您也可以使用minimum height
。
如果所有节点都具有相同的最小高度,则可以将此选项放在样式中N
。
\documentclass[10pt,journal,compsoc]{IEEEtran}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}[
arr/.style = {-stealth,
rounded corners=7,
},
N/.style = {draw,
font=\scriptsize,
align=left,
inner sep=3pt,
minimum height=1.8mm
},
]
\node (n1) [N] at (1.2, 4) {hello};
\node (n2) [N] at (3, 4) {world};
\draw[arr] (n1.north) -- ([yshift=4mm] n1.north) -| (n2.north) ;
\end{tikzpicture}
\end{document}
答案2
rounded corners
只需在\draw
命令中添加选项:
\documentclass[10pt,journal,compsoc]{IEEEtran}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}[
arr/.style = {-stealth},
N/.style = {draw,
font=\scriptsize,
align=left,
inner sep=3pt
},
]
\node (n1) [N, text width=0.5cm] at (1.2, 4) {\vspace*{-0.8mm}{hello}};
\node (n2) [N, text width=0.6cm] at (3, 4) {\vspace*{-0.8mm}{world}};
\draw[arr,rounded corners] (n1.north) -- ([yshift=2mm] n1.north) -| (n2.north) ;
\end{tikzpicture}
\end{document}