7

Can somebody help me make this commutative diagram look more aesthetic?

% compile with LaTeX

\documentclass{article}
\usepackage{pictexwd,dcpic}

\begin{document}
\begindc{\commdiag}[500]
\obj(0,0){$F(V)$}
\obj(2,0){$F(W)$} 
\obj(-1,1){$F'(U_1)$} 
\obj(3,1){$F'(U_3)$}
\obj(1,2){$F'(U_2)$}
\mor(-1,1)(1,2){}
\mor(-1,1)(3,1){}
\mor(-1,1)(0,0){}
\mor(-1,1)(2,0){}
\mor(3,1)(2,0){}
\mor(1,2)(0,0){}
\mor(1,2)(2,0){}
\mor(1,2)(3,1){}
\mor(3,1)(0,0){}
\mor(3,1)(2,0){}
\mor(0,0)(2,0){}
\enddc      
\end{document}

enter image description here

LaRiFaRi
  • 43,807
  • 1
    Could you please elaborate more on look more aesthetic? – Claudio Fiandrino May 28 '15 at 06:52
  • @ClaudioFiandrino Create the image in latex, you will see that the arrows crash into the objects. – Nicolas Bourbaki May 28 '15 at 06:55
  • You may want to shorten your arrows like \mor(0,0)(2,0)[200,200]{} or alike. 200 are the number of DC-units which should be shortened. One value stands for 'at beginning' and the second one for 'at start'. – LaRiFaRi Jun 23 '15 at 23:20
  • Is your question answered by one of the posts? If not, please edit your question. If yes, please accept one answer here by clicking the check mark to its left and I will delete my comment here. Thank you. – LaRiFaRi May 03 '16 at 11:46

6 Answers6

15

The following example sets the corners of the pentagram by a node with polygon shape of a regular pentagon:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\begin{document}
  \begin{tikzpicture}
    \node[
      regular polygon,
      regular polygon sides=5,
      minimum width=30mm,
    ] (PG) {}
      (PG.corner 1) node (PG1) {$F'(U_2)$}
      (PG.corner 2) node (PG2) {$F'(U_1)$}
      (PG.corner 3) node (PG3) {$F(V)$}
      (PG.corner 4) node (PG4) {$F(W)$}
      (PG.corner 5) node (PG5) {$F'(U_3)$}
    ;
    \foreach \S/\E in {
      1/3, 1/4, 1/5,
      2/1, 2/3, 2/4, 2/5,
      3/4,
      5/3, 5/4%
    } {
      \draw[->] (PG\S) -- (PG\E);
    }
  \end{tikzpicture}
\end{document}

Result

The height can be reduced by specifying yscale:

\node[..., yscale=.75] (PG) {}

Result yscale=.75


The lines

 (PG.corner 1) node (PG1) {$F'(U_2)$}
 ...
 (PG.corner 5) node (PG5) {$F'(U_3)$}

can also be written as:

  \foreach \t [count=\i] in {F'(U_2), F'(U_1), F(V), F(W), F'(U_3)} {
    (PG.corner \i) node (PG\i) {$\t$}
  }
Heiko Oberdiek
  • 271,626
10

I can just offer two solutions with :

% arara: pdflatex

\documentclass{article}
\usepackage{tikz-cd}

\begin{document}
\newlength{\edgelentgh}
\setlength{\edgelentgh}{3cm}
\[
\begin{tikzcd}[row sep={0cm,between origins},column sep={0cm,between origins}] % setting seperators to zero for easier manipulation
&[.3090169944\edgelentgh]
&[.5\edgelentgh] % above value times golden ratio
F'(U_2)\arrow{ddl}\arrow{ddr}\arrow{drr} 
&[.5\edgelentgh] 
&[.3090169944\edgelentgh] 
\\[.5877852523\edgelentgh]
F'(U_1)\arrow{urr}\arrow{rrrr}\arrow{dr}\arrow{drrr} 
&&&& 
F'(U_3) \arrow{dlll}\arrow{dl} 
\\[.9510565163\edgelentgh] % above value times golden ratio
& 
F(V)\arrow{rr} 
&& 
F(W) 
& 
\end{tikzcd}
\]      

% This example is given in the tikz-cd manual:

\begin{tikzpicture}[commutative diagrams/every diagram]
\node (P0) at (90:.8506508084\edgelentgh) {$F'(U_2)$};
\node (P1) at (90+72:.8506508084\edgelentgh) {$F'(U_1)$} ;
\node (P2) at (90+2*72:.8506508084\edgelentgh) {$F(V)$};
\node (P3) at (90+3*72:.8506508084\edgelentgh) {$F(W)$};
\node (P4) at (90+4*72:.8506508084\edgelentgh) {$F'(U_3)$};
%
\path[commutative diagrams/.cd, every arrow, every label]
(P0) -- (P4) edge (P3)
(P0) edge (P3)
(P0) edge (P2)
(P1) edge (P0)
(P1) edge (P4)
(P1) edge (P3)
(P1) -- (P2) edge (P3)
(P4) edge (P2);
\end{tikzpicture}
\end{document}

enter image description here

LaRiFaRi
  • 43,807
6

A MetaPost solution using the boxes package, included in a LuaLaTeX program to make it easier to typeset.

The differents nodes are linked thanks to this link macro:

  def link(suffix a, b) =
    drawarrow a.c -- b.c cutbefore bpath a cutafter bpath b 
  enddef; 

As its syntax suggests, it deletes the parts of the line before the boundary of the first node and after the boundary of the second, before drawing the actual arrow.

\documentclass[border=2mm]{standalone}
\usepackage{luamplib}
  \mplibtextextlabel{enable}
  \everymplib{input boxes;
    def link(suffix a, b) =
      drawarrow a.c -- b.c cutbefore bpath a cutafter bpath b 
    enddef; 
    beginfig(1);}
  \everyendmplib{endfig;}
\begin{document}
  \begin{mplibcode}
    u := 1.75cm;
    boxit.fv("$F(V)$"); fv.c = origin;
    boxit.fw("$F(W)$"); fw.c = (2u, 0);
    boxit.fpu1("$F'(U_1)$"); fpu1.c = (-u, u);
    boxit.fpu2("$F'(U_2)$"); fpu2.c = (u, 2u);
    boxit.fpu3("$F'(U_3)$"); fpu3.c = (3u, u);
    drawunboxed(fv, fw, fpu1, fpu2, fpu3);
    forsuffixes a = fv, fw, fpu3, fpu2: link(fpu1, a); endfor
    forsuffixes a = fv, fw, fpu3: link(fpu2, a); endfor
    link(fv, fw); link(fpu3, fv); link(fpu3, fw);
  \end{mplibcode}
\end{document}

Output:

enter image description here

Franck Pastor
  • 18,756
4

You can use the xypic package:

\documentclass{standalone}
\usepackage[all]{xy}

\begin{document}
$$
\xymatrix{
 &           & F'(U_2) \ar[dddl] \ar[dddr] \ar[drr]                 \\
    F'(U_1) \ar[urr] \ar[rrrr] \ar[ddr] \ar[ddrrr]  &&          &&
    F'(U_3)  \ar[ddl] \ar[ddlll]                                    \\
 &  F(V) \ar[rr]                                    &&  F(W)
}
$$
\end{document}

Which outputs:

Picture of the pentagram with better arrows but bad spacing

This is slightly better than what you have but the spacing doesn't look really good. But you can add an empty row to make it more tall:

\documentclass{standalone}
\usepackage[all]{xy}

\begin{document}
$$
\xymatrix{
 &           & F'(U_2) \ar[dddl] \ar[dddr] \ar[drr]                 \\
    F'(U_1) \ar[urr] \ar[rrrr] \ar[ddr] \ar[ddrrr]  &&          &&
    F'(U_3)  \ar[ddl] \ar[ddlll]                                    \\
                                                                  \\
 &  F(V) \ar[rr]                                    &&  F(W)
}
$$
\end{document}

Now it outputs:

Picture of the pentagram

Which looks pretty good to me.

The advantage of xypic is that it is extremely simple and you can use a matrix-like syntax to define the diagram.

Bakuriu
  • 2,218
3

And just in plain Metapost, with nice line crossings.

I switched F(V) with F(W) to make the loop simpler.

enter image description here

prologues := 3;
outputtemplate := "%j%c.eps";

beginfig(1);
numeric R; R = 120;
picture t[];
t1=thelabel(btex $F'(U_1)$ etex, (0,R) rotated 72);
t2=thelabel(btex $F'(U_2)$ etex, (0,R));
t3=thelabel(btex $F'(U_3)$ etex, (0,R) rotated -72);
t4=thelabel(btex $F(V)$    etex, (0,R) rotated -144);
t5=thelabel(btex $F(W)$    etex, (0,R) rotated +144);

path arc;
bboxmargin := 5; 
for i=1 upto 5:
  draw t[i];
  for j=i+1 upto 5:
     arc := center t[i] -- center t[j]
            cutbefore bbox t[i] cutafter bbox t[j];
     undraw arc withpen pencircle scaled 4;
     drawarrow arc;
  endfor
endfor
endfig;

end.
Thruston
  • 42,268
0

Chapter 4.4 of the manual of DCpic shows a pentagon shaped diagram. Re-using that code, you get:

% arara: pdflatex

\documentclass{article}
\usepackage{pictexwd,dcpic}

\begin{document}
\begindc{\commdiag}[70]
\obj(6,4)[4]{$F(V)$}
\obj(18,4)[3]{$F(W)$} 
\obj(2,16)[5]{$F'(U_1)$} 
\obj(22,16)[2]{$F'(U_3)$}
\obj(12,22)[1]{$F'(U_2)$}
\mor{1}{2}{}\mor{1}{3}{}\mor{1}{4}{}
\mor{2}{3}{}\mor{2}{4}{}
\mor{4}{3}{}
\mor{5}{1}{}\mor{5}{2}{}\mor{5}{3}{}\mor{5}{4}{}
\enddc
\end{document}

enter image description here

LaRiFaRi
  • 43,807