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.

I would like to draw a tree in tex that is more like a sketch of a tree: It should contain variable node numbers.

enter image description here

Important is, that the dots are contained in the tree drawn. Is that possible with an automated command?

You see, since my painting skills are limitated I don't want to use TikZ and simply add the nodes this tree contains. I would like to say: Here is my structure, draw it for me. All I found is drawing trees with complete defined nodes.

EDIT

Without any style definitions here is a minimal example of what I thought about:

\documentclass{standalone}

\usepackage{tikz}

\begin{document}
\tikzstyle{every node} = [rectangle,
                draw=black,
                fill=gray,
                text=black,
                text centered,
                rounded corners]

    \begin{tikzpicture}         [sibling distance=8cm]

    \node {Document}
        child {
            [sibling distance=2cm]
            node (p1) {Paragraph}
            child {
                node (e11) {Element}
                child {
                    node {AttributeSet}
                }
            }
            child {
                node (e1n) {Element}
                child {
                    node {AttributeSet}
                }
            }
            child {
                node {AttributeSet}
            }
        }
        child {
            [sibling distance=2cm]
            [sibling distance=2cm]
            [sibling distance=2cm]
            node (pn) {Paragraph}
            child {
                node (en1) {Element}
                child {
                    node {AttributeSet}
                }
            }
            child {
                node (enn) {Element}
                child {
                    node {AttributeSet}
                }
            }
            child {
                node {AttributeSet}
            }
        }
    ;

    \path[draw,dashed] (p1)--(pn);
    \path[draw,dashed] (e11)--(e1n);
    \path[draw,dashed] (en1)--(enn);
\end{tikzpicture}

\end{document}

I would prefer the dashed line to be just three/four dots.

enter image description here

share|improve this question

1 Answer 1

Perhaps I don't understand the question...

Without TikZ but with pict2e; you need something to draw nice straight lines, here a code. If you want to automate the drawing, you can create some macros with dimensions for the arguments. It's easy to build a macro to place a circle and the label.

 \documentclass[11pt]{scrartcl}
 \usepackage{pict2e,calc}
 \newdimen\xlab
 \newdimen\ylab
 \newcommand*\Vertex[3]{%
   \put(#1,#2){\circle*{5}}
    \put(\numexpr #1 +5\relax,\numexpr #2 +5\relax){#3}
 }    

 \begin{document}  
 \setlength\unitlength{2pt}% 
 \fbox{\begin{picture}(200,120)
 \Vertex{100}{98}{A}
   \put(90,75){\circle*{5}} 
   \put(90,75){\line(10,23){10}}
    % \put(120,75){\circle*{5}} 
   \Vertex{120}{75}{B-N} 
     \put(120,75){\line(-20,23){20}}
      \put(5,10){\circle*{5}} 
      \put(5,10){\line(85,65){85}}
      \put(50,10){\circle*{5}}
       \put(50,10){\line(40,65){40}}   
      \put(80,10){\circle*{5}}   
      \put(80,10){\line(10,65){10}} 

      \put(120,10){\circle*{5}}
      \put(120,10){\line(0,65){65}}    
      \put(170,10){\circle*{5}}
      \put(170,10){\line(-50,65){50}}    
      \put(190,10){\circle*{5}}
      \put(190,10){\line(-70,65){70}}

      \put(100,75){\dots} 
      \put(65,10){\dots}
      \put(140,10){\dots}
    %  \put(105,105){$A$}   
      \end{picture}}
 \end{document} 

enter image description here

share|improve this answer
    
Hello, my problem isn't TikZ, but that I have to specify the positions of the nodes. I would like to prefer definition as in tex.stackexchange.com/questions/34216/…, without specifying where to draw the nodes. But is it possible with variable node number? –  Bertram Nudelbach Jun 15 '12 at 16:13
    
It would be interesting that you give exactly the arguments necessary. –  Alain Matthes Jun 15 '12 at 16:23
    
I think tex would draw a much more beautiful tree than I would. So I would prefer to give the tree structure and get a perfect looking tree. –  Bertram Nudelbach Jun 15 '12 at 16:30
    
@BertramNudelbach I kind of feel where you are going with the question but if we (as human users) can not understand, I doubt that any automation script would understand what you want. Can you please give the requirements more clearly? I understand that you want to give a few ideas about the tree and you want to obtain exactly what kind of tree? You can provide hand sketches or some tree picture from online sources etc. about the end product. –  percusse Jun 15 '12 at 16:38
    
@percusse okay I see. I'm sorry for being so opaque :-) I'm making a presentation about the structure of a code. Basically it's nearly the same as the structure of the class``Document`` in Java. I would like to show that the document can contain 1..n elements. Each of these elements (lvl 1) contains an AtributeSet and 1..n elements. These elements (lvl 2) contain only a single AtributeSet. The tree shown above is simply all I want to have. Except some captions. –  Bertram Nudelbach Jun 15 '12 at 16:52

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.