I have the code below... it does everything I want except that the "*" inside the bottom node isn't centered. I thought to use a symbol like \ast but fell short. Similarly, the text "Input x" and "Input y" on the top left and right nodes respectively isn't in the middle of the "signal" blocks.

Is there any way to make it so that the text is forced into the exact middle of the nodes?


\tikzstyle{decision} = [diamond, draw, fill=blue!20,
    text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt]

\tikzstyle{block} = [signal, draw, signal to=south,
    text width=4.5em, rounded corners]

\tikzstyle{line} = [draw, -latex]

\tikzstyle{cloud} = [draw, ellipse, node distance=3cm, minimum height=3em, minimum width=3em]

%\tikzstyle{signal} = [signal, draw, signal to=south]

    single arrow,
    single arrow head extend=0,
    shape border uses incircle,
    shape border rotate=-90,

\begin{tikzpicture}[node distance = 2cm, auto]
    block/.style={signal, draw, signal to=south}]
    % Place nodes
    \node [cloud, line width=2pt] (init) {\huge +};
    \node [line width=2pt, text depth=0.25ex, text width=5em, block, above left of=init, node distance=10em] (inputx) {Input x};
    \node [line width=2pt, block, above right of=init, node distance=10em] (inputy) {Input y};
    \node [line width=2pt, cloud, below of=init, node distance=10em] (*) {\huge *};
    % Draw arrows
    \path[->, line width=2pt]
     (inputx) edge (init)
     (inputy) edge (init);
    \path[->, line width=2pt] ([xshift=1ex]init.south) edge ([xshift=1ex]*.north);
    \path[->, line width=2pt] ([xshift=-1ex]init.south) edge ([xshift=-1ex]*.north);

  • The character itself is not centered. Use $\ast$ instead. – Symbol 1 Apr 27 '17 at 14:37
  • @Symbol Many thanks, that worked. I'm still not sure on the other points, though (making "Input x" and "Input y" forced into the centre of their respective nodes). – Ben A Apr 27 '17 at 14:42
  • You probably need align=center. But why did you use text width=5em? – Symbol 1 Apr 27 '17 at 14:43
  • align=center works in that it places the text in the middle of the top part of the "signal" node, but not exactly in the middle of the shape itself. I used text width=5em because I read somewhere that text width and text depth had to explicitly defined. I think I may need to change how my node(s) are defined altogether. – Ben A Apr 27 '17 at 14:46
  • That is not true AFAIK. You need to set text width if and only if your node contains more than one lines (especially when you need \\ in node). You can simply discard both text width and align, and TikZ will do the rest. If the text is not vertically centered, then it is the design of the shape that makes it difficult. In that case, you need to bring align=center back and write something like {\\[3ex] Input x}. – Symbol 1 Apr 27 '17 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.