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.

This is my code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{trees}


\tikzstyle{bag} = [text width=8em, text centered]

\begin{document}
\begin{tikzpicture}[-,>=stealth',level/.style={sibling distance = 2.5cm/#1,
  level distance = 1cm}] 
\node [bag] {$||$}
    child{node[bag] {$\&\&$}
      child{node[bag] {$enabled$}}
      child{node[bag] {$\&\&$}
          child{node[bag] {$tcas\_eq$}}
          child{node[bag] {$intent\_not\_known$}}
       }
    }
    child{node[bag] {$!$}
      child{node[bag] {$tcas\_eq$}}
    }
; 
\end{tikzpicture}
\end{document}

This is the output:

enter image description here

How to make last two nodes' content separate?

I want something like this:

enter image description here

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

This may not be the best solution, but here is an answer using anchors to position the nodes relative to their left/right border instead of their center. I also use a modified bag style to ensure tighter spacing :

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{trees}


\tikzstyle{bag} = [text width=8em,
text centered]

\tikzstyle{bag_mod} = [text width=2em,
text centered]


\begin{document}
\begin{tikzpicture}[-,>=stealth',level/.style={sibling distance = 2.5cm/#1,
  level distance = 1cm}] 
\node [bag] {$||$}
    child{node[bag] {$\&\&$}
      child{node[bag] {$enabled$}}
      child{node[bag] {$\&\&$}
          child{node[bag_mod,left] {$tcas\_eq$}}
          child{node[bag_mod,right] {$intent\_not\_known$}}
       }
    }
    child{node[bag] {$!$}
      child{node[bag] {$tcas\_eq$}}
    }
; 
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
add comment

I'd say this is a perfect job for my package forest:

\documentclass{article}
\usepackage{forest}

\begin{document}
\begin{forest}
  for tree=math content
  [||
    [\&\&
      [enabled]
      [\&\&
        [tcas\_eq]
        [intent\_not\_known]
      ]
    ]
    [!
      [tcas\_eq]
    ]
  ]
\end{forest}
\end{document}

(The math content style is available only in the most recent version, 1.03. In older versions, you can either say for tree={content format={\ensuremath{\forestoption{content}}}}, or simply enclose each node's text in $...$.)

share|improve this answer
    
Nice package, Živanović! –  Daniel Feb 9 '13 at 12:50
    
@hpesoj626 No, ctan is down! :-( –  Sašo Živanović Feb 9 '13 at 15:42
add comment

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.