9

I'm trying to remove the white space that appears between two lines as a result of going to an empty node. Specifically, I have a node drawing to the left of the empty node and then the empty node drawing to the a new full node.

I've already used inner sep=0 and outer sep=0 on the node to reduce the empty gap. However,a small sliver still remains.

I need to have the empty node there for space reasons.

Image: empty location

MWE:

\documentclass{article}
\usepackage{tikz}%pictures
\usetikzlibrary{shapes,arrows}
\begin{document}
\begin{tikzpicture}[auto,>=latex'] 
    \tikzstyle{block} = [draw, shape=rectangle, minimum height=3em, minimum width=3em, node distance=2cm, line width=1pt]
    \tikzstyle{sum} = [draw, shape=circle, node distance=1.5cm, line width=1pt, minimum width=1.25em]
    \tikzstyle{connection}=[inner sep=0,outer sep=0]
 %Creating Blocks and Connection Nodes
\node [block, right of=input] (h1) {$0.99$};
 \node [right of=h1] (hsum) {};
    \node [connection, right of=hsum] (cont) {};
    \path (h1) -- coordinate (hmed) (h1);
    %Connecting Blocks
    \begin{scope}[line width=1pt]
         \draw (input) -- (h1);\draw (h1) -- (cont);
    \end{scope}
 %Creating Blocks and Connection Nodes
\node [block, right of=cont] (m1) {$0.18$};\node [block, right of=m1] (m2) {$0.16$};
 \node [right of=m2] (msum) {};
    \node [connection, right of=msum] (output) {};
    \path (m1) -- coordinate (mmed) (m2);
    %Connecting Blocks
    \begin{scope}[line width=1pt]
         \draw (cont) -- (m1);\draw (m1) -- (m2);\draw (m2) -- (output);
    \end{scope}
 \end{tikzpicture}
\end{document}
11

You can use a coordinate like

\coordinate[right of=hsum] (cont);

Code:

\documentclass{article}
\usepackage{tikz}%pictures
\usetikzlibrary{shapes,arrows}
\begin{document}
\begin{tikzpicture}[auto,>=latex']
    \tikzstyle{block} = [draw, shape=rectangle, minimum height=3em, minimum width=3em, node distance=2cm, line width=1pt]
    \tikzstyle{sum} = [draw, shape=circle, node distance=1.5cm, line width=1pt, minimum width=1.25em]
    \tikzstyle{connection}=[inner sep=0,outer sep=0]
 %Creating Blocks and Connection Nodes
 \coordinate (input);
\node [block, right of=input] (h1) {$0.99$};
 \node [right of=h1] (hsum) {};
    \coordinate[right of=hsum] (cont);
    \path (h1) -- coordinate (hmed) (h1);
    %Connecting Blocks
    \begin{scope}[line width=1pt]
         \draw (input) -- (h1);\draw (h1) -- (cont);
    \end{scope}
 %Creating Blocks and Connection Nodes
\node [block, right of=cont] (m1) {$0.18$};\node [block, right of=m1] (m2) {$0.16$};
 \node [right of=m2] (msum) {};
    \node [connection, right of=msum] (output) {};
    \path (m1) -- coordinate (mmed) (m2);
    %Connecting Blocks
    \begin{scope}[line width=1pt]
         \draw (cont) -- (m1);\draw (m1) -- (m2);\draw (m2) -- (output);
    \end{scope}
 \end{tikzpicture}
\end{document}

enter image description here

If you want to stick to the node, use cont.center for the connections instead of cont like:

\draw (input) -- (h1);\draw (h1) -- (cont.center);

Code again:

\documentclass{article}
\usepackage{tikz}%pictures
\usetikzlibrary{shapes,arrows}
\begin{document}
\begin{tikzpicture}[auto,>=latex']
    \tikzset{block/.style = {draw, shape=rectangle, minimum height=3em, minimum width=3em, node
                              distance=2cm, line width=1pt},
              sum/.style = {draw, shape=circle, node distance=1.5cm, line width=1pt, minimum 
                            width=1.25em},
              connection/.style={inner sep=0,outer sep=0}
    }
 %Creating Blocks and Connection Nodes
 \coordinate (input);
\node [block, right of=input] (h1) {$0.99$};
 \node [right of=h1] (hsum) {};
    \node [connection, right of=hsum] (cont) {};
    \path (h1) -- coordinate (hmed) (h1);
    %Connecting Blocks
    \begin{scope}[line width=1pt]
         \draw (input) -- (h1);\draw (h1) -- (cont.center);
    \end{scope}
 %Creating Blocks and Connection Nodes
\node [block, right of=cont] (m1) {$0.18$};\node [block, right of=m1] (m2) {$0.16$};
 \node [right of=m2] (msum) {};
    \node [connection, right of=msum] (output) {};
    \path (m1) -- coordinate (mmed) (m2);
    %Connecting Blocks
    \begin{scope}[line width=1pt]
         \draw (cont.center) -- (m1);\draw (m1) -- (m2);\draw (m2) -- (output);
    \end{scope}
 \end{tikzpicture}
\end{document}

Also, use tikzset instead of tikzstyle (deprecated) as I did in the second code.

| improve this answer | |
-1

You can do this by adding some property to tikzpicture as follows:

\begin{tikzpicture}[every node/.style={inner sep=0,outer sep=0}]
| improve this answer | |
  • This applies to all nodes inside the picture and needs to be overwritten for nodes, where the space is needed as for the three rectangular nodes with the numbers. Using coordinate instead of node is the better choice for denoting a point without node contents. – Heiko Oberdiek Jul 2 '17 at 7:25

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.