6

I'm new to TikZ, and have drawn the following picture,

\documentclass[12pt,a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{trees,arrows}
\begin{document}

\begin{tikzpicture}[every node/.style={draw,shape=circle,inner sep=2pt,fill=black}]
    \node [label=above:$a$]{}
        child {node[label=above:$b$,label=below:$p\land q$]{}}
        child {node[label=above:$c$,label=below:$p\land \lnot q$]{}}
;
\end{tikzpicture}

\end{document}

enter image description here

But there's too much space above the propositional formula on the right, is there any way I can decrease the amount of whitespace to be closer to the amount of whitespace for the labels a, b, c?

[edit] Jesse linked me to a way of adjusting the position of the label manually, but a way to align both labels without fine tuning would be nice.

5

1 Answer 1

7

This bad aligning comes from every node/.style={draw,shape=circle,inner sep=2pt,fill=black}. Labels are also nodes so shape=circle makes all labels being circles.

\documentclass[tikz,border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{trees,arrows}
\begin{document}

\begin{tikzpicture}[every node/.style={draw,shape=circle,inner sep=2pt,fill=black},
                    every label/.style={draw,fill=none}]
    \node [label=above:$a$]{}
        child {node[label=above:$b$,label=below:$p\land q$]{}}
        child {node[label=above:$c$,label=below:$p\land \lnot q$]{}}
;
\end{tikzpicture}

\end{document}

enter image description here

You can change this behavior with every label/.style={shape=rectangle, draw=none, fill=none} or every label/.append style={shape=rectangle} which produces

enter image description here

If you want to understand why options draw=none and fill=none are included in every label definition, look at Every non-label node in TikZ.

You must log in to answer this question.

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