9

The following code

\documentclass[10pt]{amsart}
\usepackage{tikz}
    \usetikzlibrary{shadows,matrix,arrows}

\begin{document}
\begin{tikzpicture}\small\begin{scope}[->,shorten >=3pt,shorten <=3pt]
\matrix (m) [matrix of math nodes,row sep=0.5cm, column sep=1cm,outer sep=0pt,inner sep=0pt]
{                       &                   \\
                        &e_{12}e_{14}e_{25}e_{25}e_{25} \\
e_{14}e_{15}e_{24}e_{25}&e_{12}e_{15}e_{24}e_{25}e_{25} \\
                        &e_{13}e_{14}e_{35}e_{25}e_{25} \\
                        &e_{13}e_{15}e_{34}e_{25}e_{25} \\
                        &e_{13}e_{25}e_{34}e_{25}e_{25} \\};
\path[-] (m-3-1) edge (m-2-2) edge (m-3-2) edge (m-4-2) edge (m-5-2) edge (m-6-2); 
\path[-,red] (m-3-1) edge (m-5-2);
\end{scope}\end{tikzpicture}
\end{document} 

produces enter image description here.

How can I achieve that all edges from/to a node have a common beginning/ending? enter image description here

3
  • 4
    Use (m-3-1.east) instead of (m-3-1) which is equivalent to (m-3-1.center). And (m-x-x.west) for right column nodes.
    – Ignasi
    Jan 29 '15 at 17:46
  • @Ignasi: Umm, that places the endpoints of edges at the third $e$ (the middle of $e_{14}e_{15}e_{24}e_{25}$) so there is overlapping.
    – Leo
    Jan 29 '15 at 18:05
  • 1
    I tried to say that (m-3-1) is equivalent to (m-3-1.center). So you must use (m-3-1.east) instead of (m-3-1).
    – Ignasi
    Jan 29 '15 at 18:57
11

You are inserting more edges than the necessary. You need 4 black and 1 red. As cited by @Ignasi, you can change the node anchor to west and to east.

If necessary, just use another \path command with a different anchor, if you think that some position is not good. For example, you can use south or south west and so on.

\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{shadows,matrix,arrows}

\begin{document}
    \begin{tikzpicture}\small
    \begin{scope}[->,shorten >=3pt,shorten <=3pt]
    \matrix (m) [matrix of math nodes,row sep=0.5cm, column sep=1cm,outer sep=0pt,inner sep=0pt]
    {   &                                                         \\
        & e_{12}e_{14}e_{25}e_{25}e_{25}                          \\
          e_{14}e_{15}e_{24}e_{25}&e_{12}e_{15}e_{24}e_{25}e_{25} \\
        & e_{13}e_{14}e_{35}e_{25}e_{25}                          \\
        & e_{13}e_{15}e_{34}e_{25}e_{25}                          \\
        & e_{13}e_{25}e_{34}e_{25}e_{25}                          \\
    };
    \path[-] (m-3-1.east) edge (m-2-2.west) edge (m-3-2.west) edge (m-4-2.west) edge (m-6-2.west); 
    \path[-,red] (m-3-1.east) edge (m-5-2.west);
    \end{scope}
    \end{tikzpicture}
\end{document}

enter image description here

0
10

With tikz-cd:

\documentclass[10pt]{amsart}
\usepackage{tikz-cd}

\begin{document}
\begin{tikzcd}[row sep=2ex]
  &e_{12}e_{14}e_{25}e_{25}e_{25} \\
e_{14}e_{15}e_{24}e_{25}
  \ar[ur,dash,start anchor=real east,end anchor=real west]
  \ar[r,dash,start anchor=real east,end anchor=real west]
  \ar[dr,dash,start anchor=real east,end anchor=real west]
  \ar[ddr,dash,start anchor=real east,end anchor=real west,red]
  \ar[dddr,dash,start anchor=real east,end anchor=real west]
  &e_{12}e_{15}e_{24}e_{25}e_{25} \\
  &e_{13}e_{14}e_{35}e_{25}e_{25} \\
  &e_{13}e_{15}e_{34}e_{25}e_{25} \\
  &e_{13}e_{25}e_{34}e_{25}e_{25}
\end{tikzcd}
\end{document} 

enter image description here

Since all arrows share the same attributes, one can set them in the options to \begin{tikzcd} (thanks to Gonzalo Medina for suggesting it):

\begin{tikzcd}[
  row sep=2ex,
  arrows=dash,
  start anchor=real east,
  end anchor=real west,
]
  &e_{12}e_{14}e_{25}e_{25}e_{25} \\
e_{14}e_{15}e_{24}e_{25}
    \ar[ur]
    \ar[r]
    \ar[dr]
    \ar[ddr,red]
    \ar[dddr]
  &e_{12}e_{15}e_{24}e_{25}e_{25} \\
  &e_{13}e_{14}e_{35}e_{25}e_{25} \\
  &e_{13}e_{15}e_{34}e_{25}e_{25} \\
  &e_{13}e_{25}e_{34}e_{25}e_{25}
\end{tikzcd}
1
  • 1
    +1. Nice. Yoor code can be further simplified: \documentclass[10pt]{amsart} \usepackage{tikz-cd} \begin{document} \begin{tikzcd}[row sep=2ex,start anchor=real east,end anchor=real west,arrows=dash] &e_{12}e_{14}e_{25}e_{25}e_{25} \\ e_{14}e_{15}e_{24}e_{25} \ar[ur] \ar[r] \ar[dr] \ar[ddr,red] \ar[dddr] &e_{12}e_{15}e_{24}e_{25}e_{25} \\ &e_{13}e_{14}e_{35}e_{25}e_{25} \\ &e_{13}e_{15}e_{34}e_{25}e_{25} \\ &e_{13}e_{25}e_{34}e_{25}e_{25} \end{tikzcd} \end{document} Jan 29 '15 at 20:21
4

Just for fun and practicing, a solution with forest

\documentclass[10pt]{amsart}
\usepackage{forest}

\begin{document}

\begin{forest}
[$e_{14}e_{15}e_{24}e_{25}$, grow'=east, 
        for tree={parent anchor=east,child anchor=west}, l sep=.75cm 
    [$e_{12}e_{14}e_{25}e_{25}e_{25}$] 
    [$e_{12}e_{15}e_{24}e_{25}e_{25}$, calign with current]
    [$e_{13}e_{14}e_{35}e_{25}e_{25}$]
    [$e_{13}e_{15}e_{34}e_{25}e_{25}$, edge={red}]
    [$e_{13}e_{25}e_{34}e_{25}e_{25}$]]
\end{forest}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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