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 am working on a project, and need to add a diagram that displays a commutative diagram illustrating basic function composition similar to what is on page 17 in the image attached. I would like to make it look a bit "nicer" for lack of a better term though. I really do not know where to even begin however. Any help is appreciated.

enter image description here

Here is a beginning. While I realize it is only a beginning, it is all I have been able to put together thus far. Thanks:

\documentclass[a4paper,12pt]{article}

\usepackage{tikz}
\usetikzlibrary{matrix,arrows}

\begin{document}
\begin{tikzpicture}[description/.style={fill=white,inner sep=2pt}]
\matrix (m) [matrix of math nodes, row sep=3em,
column sep=2.5em, text height=1.5ex, text depth=0.25ex]
{ X & & Y \\
& V & \\ };
%\draw[double,double distance=5pt] (m-1-1) – (m-1-3);
\path[-,font=\scriptsize]
(m-1-1) edge node[auto] {$ f $} (m-1-3)
edge node[description] {$ g \circ f $} (m-2-2)
(m-1-3) edge node[auto] {$ g $} (m-2-2);
\end{tikzpicture}

\end{document}

It does not have the arrows nor the ellipses I would like, but it is a start. Thanks again for the help!

share|improve this question
5  
What have you tried so far? We need to see some code. –  Jubobs Dec 3 '13 at 14:29
2  
What would look nicer? It would be much easier to use regular shapes (circles or ellipses) or no shapes really. The diagram you show is less a commutative diagram and more a visualization in my eyes. –  Qrrbrbirlbel Dec 3 '13 at 14:47
    
@Qrrbrbirlbel I think the OP really wants a visualization (for teaching purposes) rather than the commutative diagram he asks for. Drawing the sets as blobs is then a better convention. –  Ethan Bolker Dec 3 '13 at 15:07
    
@EthanBolker Sorry I really did just want a visualization rather than a commutative diagram. I apologize for the misnomer. Is there any way to achieve that in LaTeX? –  Michael Dykes Dec 3 '13 at 15:12
2  
–1: Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document. Let me know when you added an MWE and I’d be happy to redeem my downvote ;-) –  Tobi Dec 3 '13 at 15:32

1 Answer 1

up vote 3 down vote accepted

You can add the option -> to draw the arrows. To add the ellipses, load the shapes.geometric library, and add

nodes={ellipse,draw,minimum width=<length>}

to the list of options for the \matrix command. Here, ellipse causes the node to have an elliptical shape, draw draws the elliptical border of the node, and minimum width=<length> specifies the minimal width of the node.

Code

\documentclass[border=2pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{matrix,arrows,shapes.geometric}

\begin{document}

\begin{tikzpicture}[description/.style={fill=white,inner sep=2pt}]
  \matrix (m)[matrix of math nodes,
    row sep=3em,column sep=2.5em,
    text height=1.5ex, text depth=0.25ex,
    nodes={ellipse,draw,minimum width=2cm},
  ]{
    X && Y \\
    & V & \\
  };
  \path[->,font=\scriptsize]
  (m-1-1) edge node[auto] {$ f $} (m-1-3)
  edge node[description] {$ g \circ f $} (m-2-2)
  (m-1-3) edge node[auto] {$ g $} (m-2-2);
\end{tikzpicture}

\end{document}

Output

enter image description here


Upadate

An example that more closely resemble your picture:

Code

\documentclass[border=2pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{calc,positioning,shapes.geometric}

\begin{document}

\begin{tikzpicture}
  \tikzset{
    elps/.style 2 args={draw,ellipse,minimum width=#1,minimum height=#2},
    node distance=3cm,
    font=\footnotesize,
    >=latex,
  }
  \node(x)[elps={1.3cm}{1cm},label={below left:$X$}]{};
  \node(y)[elps={2cm}{1.2cm},right=of x,label={below left:$Y$}]{};
  \node(v)[elps={1.5cm}{.9cm},below right=2cm of x,label={below left:$V$}]{};
  \fill[gray!50]($(y.center)-(5pt,5pt)$)circle[x radius=.7cm,y radius=.3cm]coordinate(im);
  \node at (im){$\mathrm{im}(f)$};
  \draw[->](x)to[bend right]node[above right]{$g\circ f$}(v);
  \draw[->](y)to[bend left]node[right]{$g$}(v);
  \draw[->](x)to[bend left=20]node[above]{$f$}(y);
\end{tikzpicture}

\end{document}

Output

enter image description here

share|improve this answer
    
I think that is what I am looking for. Thanks! –  Michael Dykes Dec 4 '13 at 16:45

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.