2

Draw lines to form triangle in latex

Please, I want to draw the below diagram in latex and don't know how to go about it.

2
  • 1
    Welcome to TeX.SE xymatrix is one of a good option, but post atleast the text, as no one wants to keyin ...
    – MadyYuvi
    Feb 27 at 9:19
  • 1
    @MadyYuvi Hi :-) I am totally agree with you...For the user there is a documentation here jmilne.org/not/Mxymatrix.pdf or you can use tikz-cd package.
    – Sebastiano
    Feb 27 at 9:29
5

I think a solution with tikz-cd has a more 'natural' feel. And once you have a diagram it can often easily be adapted to similar new ones.

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

\begin{document}

\begin{tikzcd}
A  \arrow[rr,hook] \arrow[dr, "\varphi"'] & & M^+ \arrow[dl, "\varnothing"] \\
        & S  
\end{tikzcd}

\end{document}

enter image description here

1
  • 1
    Quite likely it's \phi and not \varnothing (although I'm not sure one should use both \varphi and \phi). I removed the \LARGE instruction that might confuse the reader and, I guess, was just to make a bigger picture.
    – egreg
    Feb 27 at 11:36
2

You can do it with tikz-cd of course, but if you don't mean to learn this package and use it on a regular basis, I recommand to do it in plain TikZ, like this:

\documentclass{article}

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

\usepackage{amssymb}

\begin{document}

    \begin{tikzpicture}
        \node (A) {$A$};
        \node[below right =of A] (S) {$S$};
        \node[above right =of S] (M) {$M^+$};
        
        \draw[right hook-latex] (A) -- (M);
        \draw[-latex] (A) -- (S) node [midway,left] {$\varphi$};
        \draw[-latex] (M) -- (S) node [midway,right] {$\varnothing$};
    \end{tikzpicture}
    
\end{document}

diagram with hooked arrow

2
  • 2
    I disagree: the quality is definitely lower than the not-so-difficult tikz-cd form.
    – egreg
    Feb 27 at 11:38
  • 1
    I agree that it can (and probably should) be drawn with tikz-cd. The only flaw I can see in my picture is the difference in length for both the diagonal arrows. But the diagram in tiz-cd has the same flaw (due to the math type of the node S).
    – SebGlav
    Feb 27 at 11:58
1

Just for comparison using xy package with the same tips of tikz-cd but with a not very good curved arrow.

\documentclass[a4paper,12pt]{article}
\usepackage[all,cmtip]{xy}
\usepackage{amssymb}
\begin{document}
\xymatrix@R=2.2pc@C=1.5pc{
 A \,\ar[dr]_{\varphi} \ar@{^{(}->}[rr] & & M^{+}\ar[dl]^{\varnothing}\\
 & S &
 }
\end{document}

The code it is not very simple than tikz-cd but if I am able to do it, I think that one week you will be a very nice user to make commutative-diagrams.

PS: I will put \emptyset instead of \varnothing.

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.