我如何在 TikZ 中执行此操作:
我想画一个圆形节点,里面有一个十字,像下面链接中显示的乘数一样。我可以画一个圆圈,但我不知道如何在里面放十字。
答案1
\documentclass{scrartcl}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[cross/.style={path picture={
\draw[black]
(path picture bounding box.south east) -- (path picture bounding box.north west) (path picture bounding box.south west) -- (path picture bounding box.north east);
}}]
\node [draw](A){start};
\node [draw,circle,cross,minimum width=1 cm](B) at (3,0){};
\node [draw](C) at( 5,0){end};
\draw[->] (A) -- (B) -- (C);
\end{tikzpicture}
\end{document}
答案2
下面是一个解决方案,其中包含四个参数,用于将标签放在 4 个圆形部分中。最好将参数相对于形状宽度/高度放置,但我不知道该怎么做。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}
\tikzset{add/.style n args={4}{
minimum width=6mm,
path picture={
\draw[black]
(path picture bounding box.south east) -- (path picture bounding box.north west)
(path picture bounding box.south west) -- (path picture bounding box.north east);
\node at ($(path picture bounding box.south)+(0,0.13)$) {\tiny #1};
\node at ($(path picture bounding box.west)+(0.13,0)$) {\tiny #2};
\node at ($(path picture bounding box.north)+(0,-0.13)$) {\tiny #3};
\node at ($(path picture bounding box.east)+(-0.13,0)$) {\tiny #4};
}
}
}
\begin{document}
\begin{tikzpicture}
\node[draw,circle,add={1}{2}{3}{4}] {};
\end{tikzpicture}
\end{document}
编辑:根据 FHZ 的评论,参数可以相对于形状维度放置(这里是基本方向和中心之间距离的 40%):
\node[anchor=center] at ($(path picture bounding box.south)!0.4!(path picture bounding box.center)$) {\tiny #1};
\node[anchor=center] at ($(path picture bounding box.west)!0.4!(path picture bounding box.center)$) {\tiny #2};
\node[anchor=center] at ($(path picture bounding box.north)!0.4!(path picture bounding box.center)$) {\tiny #3};
\node[anchor=center] at ($(path picture bounding box.east)!0.4!(path picture bounding box.center)$) {\tiny #4};
答案3
我使用 schemabloc 包制作的解决方案完成了前面的答案
\documentclass{article}
\usepackage{tikz}
\usepackage{schemabloc}
\begin{document}
{\centering
\begin{tikzpicture}
\sbEntree{dspk}
\sbBloc[5]{band}{Bandpass filter}{dspk}
\sbRelier[\parbox{5em}{DSPK \\ signal}]{dspk}{band}
\sbBlocL{logic}{Logic circuit}{band}
\sbSumb[3]{sum}{logic}
\sbRelier{logic}{sum}
\sbDecaleNoeudy[5]{band}{delay}
\sbBloc[8]{delay}{Delay}{delay}
\sbRelieryx{band-logic}{delay}
\sbRelierxy{delay}{sum}
\sbBlocL{int}{\parbox{5em}{Integrate \& Dump} }{sum}
\sbBlocL{thres}{\parbox{5em}{Treshold \ Device} }{int}
\sbSortie[4]{S}{thres}
\sbRelier[OP]{thres}{S}
\end{tikzpicture}
}
\end{document}
请注意,该软件包需要 pgf 2.1cvs 版本