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 need to create a diagram for a book, indicating the order in which chapters may be read. For example:

enter image description here

(Taken from http://www.proba.jussieu.fr/pageperso/giacomin/pub/RPM/Site/Contents_files/dep.jpg -- not mine.)

Further (due to publisher requirements) it needs to be done in TeX, rather than imported as a diagram. (I imagine TikZ might work well, but positioning all the nodes by hand would be tortuous.) What's the best way of producing an attractive diagram?

share|improve this question
    
Do publishers often require the making of all diagrams in TeX? Sounds like a PITA, why wouldn't they allow EPS/PDF diagrams imported? –  levesque Oct 3 '12 at 15:13

1 Answer 1

up vote 16 down vote accepted

Here's something to get you started in tikz

screenshot

It's not identical to your picture, but I have to leave some of the work for you :) I've used the positioning library to specify each of the nodes in terms of relative positions to one another.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}[>=stealth,every node/.style={shape=rectangle,draw,rounded corners},]
    % create the nodes
    \node (c1) {Chapter 1};
    \node (c4) [below right=of c1]{Chapter 4};
    \node (c5) [below left=of c4]{Chapter 5};
    \node (c6) [right =of c5]{Chapter 6};
    \node (c7) [right =of c6]{Chapter 7};
    \node (c8) [right =of c7]{Chapter 8};
    \node (c9) [right =of c8]{Chapter 9};
    \node (c2) [below =of c5]{Chapter 2};
    \node (c3) [below right =of c2]{Chapter 3};
    % connect the nodes
    \draw[->] (c1) to[out=0,in=135] (c4);
    \draw[->] (c1.west) to[out=180,in=180] (c2.west);
    \draw[->] (c4) to[out=180,in=75] (c5);
    \draw[->] (c4) -- (c6);
    \draw[->] (c4.south east) -- (c7);
    \draw[->] (c4.east) to[out=0,in=110] (c8);
    \draw[->] (c4.east) to[out=0,in=110] (c9);
    \draw[->,dashed] (c2) -- (c5);
    \draw[->,dashed] (c2) -- (c6);
    \draw[->,dashed] (c2) -- (c7.south);
    \draw[->,dashed] (c2) -- (c8.south);
    \draw[->] (c2) -- (c3);
\end{tikzpicture}

\end{document}

Here's something that is a little better

enter image description here

As detailed in Caramdir's answer to Add more anchors to standard TikZ nodes the standard nodes have anchors node.〈angle〉 where angle is between 0 (=east) and 360, which I have used as follows

\draw[->] (c1) to[out=0,in=135] (c4);
\draw[->] (c1.west) to[out=180,in=180] (c2.west);
\draw[->] (c4) to[out=180,in=75] (c5);
\draw[->] (c4) -- (c6);
\draw[->] (c4.south east) -- (c7);
\draw[->] (c4.-5) to[out=0,in=110] (c8);
\draw[->] (c4.5) to[out=0,in=110] (c9);
\draw[->,dashed] (c2) -- (c5);
\draw[->,dashed] (c2) -- (c6);
\draw[->,dashed] (c2.5) to[out=0,in=225] (c7.south);
\draw[->,dashed] (c2.east) to[out=0,in=225] (c8.south);
\draw[->] (c2.-5) to[out=0,in=135] (c3.west);

Of course, all of this could probably be tidied up into a \foreach loop, but I find the code a little easier to read without.

share|improve this answer
    
That's nearly perfect -- thank you. The only thing I need is the facility to `nudge' one node slightly in one direction... is that possible? –  Mohan Oct 3 '12 at 19:39
1  
@Mohan you can nudge these nodes by using, for example, below=1cm of... –  cmhughes Oct 3 '12 at 19:50
    
Perfect. Thank you very much. –  Mohan Oct 3 '12 at 19: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.