16

How do I do this in TikZ:

I want to draw a circular node with a cross in it to resemble a multiplier like in the diagram shown in the link below. I can draw a circle but I don't know how to put the cross inside.

3 Answers 3

34
\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} 

enter image description here

0
6

Below a solution with four parameters for putting labels in the 4 circle sections. It would be nice to place the args relatively to the shape width/height, but I don't know how it can be done.

\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}

enter image description here enter image description here

EDIT: following FHZ's comment, the args can be placed relatively to the shape dimension with (here at 40% of the distance between cardinal direction and center):

\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};
1
  • Thanks for your answer. It was exactly the idea I was looking for. It is possible to automatically center using \node at ($(path picture bounding box.south)!0.4!(path picture bounding box.center)$) {\tiny #1};where !0.4! places the element 4 tenths the way from the edge to center.
    – FHZ
    May 1, 2021 at 21:33
2

I full the previous answer with a solution made ​​with the package 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}

Please note the package requires version 2.1cvs of pgf

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .