Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How can I draw a horizontal line inside a TikZ node? I want the name of the state to be seperated from the rest of the node. How can i achieve this?

\documentclass[tikz,border=2pt]{standalone}

\usetikzlibrary{automata}

\begin{document}
\begin{tikzpicture}[%
    every node/.style={%
        align=center,
        state
    }    
]

    \node (T0)  {
        \textbf{State$_1$} \\  
        \hline \\ % <--- This is not working!
        $\overline{A}$      \\ 
        $B$
    };

\end{tikzpicture}
\end{document}
share|improve this question
    
Either put them inside a tabular or use TikZ for drawing things inside a TikZ picture. –  percusse Apr 1 at 22:16
    
You could just use \underline{\textbf{State$_1$}}. What is the \hline supposed to do? Draw a line from one end of the circle to the other? In that case use multi part nodes. –  Peter Grill Apr 1 at 22:17
2  
You could use \node[circle split] and divide both parts with \nodepart{lower}. This will generate a split-circle node with everything in the upper half, except for the stuff after the \nodepart{lower} command. — Nicolás was a few seconds quicker than me … :D –  Otaka-san Apr 1 at 22:20
1  
Only a couple of seconds quicker. –  Nicolás Apr 1 at 22:30
    
You are all awesome. :) –  David Kristiansen Apr 1 at 22:37

2 Answers 2

up vote 4 down vote accepted

You could try circle split:

\documentclass[tikz,border=2pt]{standalone}

\usetikzlibrary{automata,shapes.multipart}

\begin{document}
\begin{tikzpicture}[%
    every node/.style={%
        align=center,
        state,
        circle split
    }    
]

\node (T0)  {
    \textbf{State$_1$} \\
    \nodepart{lower}
    $\overline{A}$      \\ 
    $B$
};

\end{tikzpicture}
\end{document}

enter image description here

The keys are:

  1. adding to the style circle split
  2. drawing the separator as \nodepart{lower} instead of \hline

One drawback of this method is that the split line is drawn exactly at the middle of the circle. I don't know if that bothers you.

share|improve this answer
1  
Yes. Excatly what I was looking for. Thank you! –  David Kristiansen Apr 1 at 22:24

In TikZ the hline is not defined (as far as i know). If i correctly understood, what you like to achieve, then for node use shape for multiple text parts, like in the following example:

\documentclass[tikz,border=2pt]{standalone}
    \usetikzlibrary{automata,shapes.multipart}
\begin{document}
    \begin{tikzpicture}[%
    every node/.style = {%
        align=center,
        state
    }
                        ]
\node[circle split] (T0)  { \textbf{State$_1$} \\
                    \nodepart{lower}
                            $\overline{A}$     \\
                            $B$
                          };
    \end{tikzpicture}
\end{document}
share|improve this answer
    
Yes thanks. That's excatly what I was looking for! –  David Kristiansen Apr 1 at 22:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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