# TikZ/PGF - how to draw a node as a line (rectangle with zero height)?

I want to a sequence of nodes, finished by a line. I tried this:

\documentclass{article}
\usepackage{tikz}
\tikzstyle{st1}=[circle, inner sep=1.5pt, draw]
\tikzstyle{st2}=[rectangle, inner xsep=2pt, inner ysep=0pt, draw]
\begin{document}
\begin{tikzpicture}[grow=down, level distance=10pt, every node/.style={st1}]
\path node{} child {node{} child {node[st2]{}}};
\end{tikzpicture}
\end{document}


but this gives , i.e. the node has some height. Is there some (simple) way to make the last node into a line? If possible using definition of st2, so it it simple to use.

The closest thing I managed is:

\documentclass{article}
\usepackage{tikz}
\tikzstyle{st1}=[circle, inner sep=1.5pt, draw]
\tikzset{st2/.style={rectangle, inner sep=-2pt, draw=none}}
\begin{document}
\begin{tikzpicture}[grow=down, level distance=10pt, every node/.style={st1}]
\path node{} child {node{} child {node[st2]{\textbf{--}}}};
\end{tikzpicture}
\end{document}


but this is more a dirty hack. In addition, it needs needs having \textbf{--} in every such node .. and it won't work if I ever need the sequence to be horizontal.

Thanks.

-
I just realized that I probably should have used \tikzset instead of \tikzstyle, as explained in Should \tikzset or \tikzstyle be used to define TikZ styles?. However, I leave it as it is, since it works and the accepted answer uses this as well.. – Michal Kaut Dec 6 '12 at 11:44

The key is to give a minimum height to that node. Here you can see the result with 0pt and .4pt respectively:

UPDATE: Also, in order to get a better control of the width of the node, use minimum width instead of inner xsep. Analogously, you better use minimum width for the circular nodes too, instead of inner sep=1.5pt. This way you can play with the size of the nodes, as for example:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\tikzstyle{st1}=[circle, inner sep=0pt, minimum width=4pt, draw]
\tikzstyle{st2}=[rectangle, inner sep=0pt, minimum height=0pt, minimum width=4pt, draw]

\tikzstyle{st1b}=[circle, inner sep=0pt, minimum width=6pt, draw]
\tikzstyle{st2b}=[rectangle, minimum height=.4pt, minimum width=6pt, inner sep=0pt, draw]

\begin{tikzpicture}[grow=down, level distance=10pt, every node/.style={st1}]
\path node{} child {node{} child {node[st2]{}}};
\end{tikzpicture}
\begin{tikzpicture}[grow=down, level distance=10pt, every node/.style={st1b}]
\path node{} child {node{} child {node[st2b]{}}};
\end{tikzpicture}
\end{document}


Which produces:

-
Exactly what I needed, thanks a lot! – Michal Kaut Dec 6 '12 at 11:10
And once more thanks for the update, that was a good point. – Michal Kaut Dec 6 '12 at 11:41