-5

How can I draw this figure using LaTeX code?

e

2
  • 5
    With use of the tikz-cd package should be easy. What you try so far? At list you should rotate image, that we can more easy read text on image ...
    – Zarko
    Feb 3, 2020 at 9:04
  • I looked at many question here but I could not find a question that contain a combination of a rectangle and triangle in one figure@Zarko
    – Intuition
    Feb 3, 2020 at 9:06

2 Answers 2

6

As starting point based on one of my old answer. In diagram you need to insert correct variables:

\documentclass[margin=3.1415692mm,varwidth]{standalone}
\usepackage{tikz-cd}
\usetikzlibrary{arrows.meta, bending}
\usepackage{amssymb}

    \begin{document}
    \[
\begin{tikzcd}[sep=large,
               every arrow/.append style = {-{Straight Barb[bend]}},
%               every label/.append style = {font=\normalsize}
               ]
                &   W \ar[d,"f"]
                      \ar[dl,bend right]
                      \ar[dr,bend  left]    &                   \\
B 
\ar[d,"xxx" ']  &   (A\times B)
                    \ar[l,"xxx" ']
                    \ar[r,"xxx"]
                    \ar[d,"xxx"]            &   A
                                                \ar[d,"xxx"]    \\
Y               &   X\times X       
                    \ar[l,"xxx" ']
                    \ar[r,"xxx"]            &   X               \\
\end{tikzcd}
    \]
\end{document}

enter image description here

6
  • 1
    +1: 3.1415692mm :) Feb 3, 2020 at 9:59
  • 2
    @Dr.ManuelKuehner, huh, answer is based on one my old answer, where I also joked about the standalone border size ... I overlooked this here. Hopefully is not to disturbing :-)
    – Zarko
    Feb 3, 2020 at 10:10
  • it is not compiling.
    – Intuition
    Feb 3, 2020 at 11:53
  • 1
    @Intuition, than your installation of LaTeX is ill. Showed images is generated on my PC with use of the recent MIkTeX and also tested on Overleaf. The MWE certainly works. Please be more specific, what error you get?
    – Zarko
    Feb 3, 2020 at 12:57
  • It compiled thanks! :) and how can I put maps on the bended arrows?
    – Intuition
    Feb 19, 2020 at 13:19
1

I've found this online editor, Matcha, to be a very convenient tool for quickly typesetting images for Latex. It has an intuitive graphical interface that is quite pleasant to work with, and can be exported either as Tikz code or as an image.

For inspiration, here's a quick version of your image that I quickly whipped up.

Mathcha example

And the automatically-generated Tikz code:

\tikzset{every picture/.style={line width=0.75pt}} %set default line width to 0.75pt        

\begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1]
%uncomment if require: \path (0,211.1999969482422); %set diagram left start at 0, and has height of 211.1999969482422

%Curve Lines [id:da9024082468764771] 
\draw    (346.5,26.52) .. controls (380.29,28.17) and (406.02,55.37) .. (425.9,85.81) ;
\draw [shift={(426.8,87.2)}, rotate = 237.17000000000002] [color={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;

%Straight Lines [id:da7724897046680852] 
\draw    (322.8,42.2) -- (323.75,82.2) ;
\draw [shift={(323.8,84.2)}, rotate = 268.64] [color={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;

%Curve Lines [id:da11287460295056873] 
\draw    (297.8,24.2) .. controls (270.65,24.87) and (238.13,56.88) .. (217.07,78.87) ;
\draw [shift={(215.8,80.2)}, rotate = 313.66999999999996] [color={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;

%Straight Lines [id:da7338437223633045] 
\draw    (432.8,112.2) -- (433.75,152.2) ;
\draw [shift={(433.8,154.2)}, rotate = 268.64] [color={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;

%Straight Lines [id:da025882083777394982] 
\draw    (324.8,111.2) -- (325.75,151.2) ;
\draw [shift={(325.8,153.2)}, rotate = 268.64] [color={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;

%Straight Lines [id:da07040880715340103] 
\draw    (207.8,112.2) -- (208.75,152.2) ;
\draw [shift={(208.8,154.2)}, rotate = 268.64] [color={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;

%Straight Lines [id:da1706718911066456] 
\draw    (287.8,97.2) -- (223.8,98.17) ;
\draw [shift={(221.8,98.2)}, rotate = 359.13] [color={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;

%Straight Lines [id:da14767706108481948] 
\draw    (293.8,169.2) -- (226.8,169.2) ;
\draw [shift={(224.8,169.2)}, rotate = 360] [color={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;

%Straight Lines [id:da6043606661934966] 
\draw    (363.8,99.2) -- (415.8,99.2) ;
\draw [shift={(417.8,99.2)}, rotate = 180] [color={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;

%Straight Lines [id:da07792819458867695] 
\draw    (356.8,169.2) -- (416.8,169.2) ;
\draw [shift={(418.8,169.2)}, rotate = 180] [color={rgb, 255:red, 0; green, 0; blue, 0 }  ][line width=0.75]    (10.93,-3.29) .. controls (6.95,-1.4) and (3.31,-0.3) .. (0,0) .. controls (3.31,0.3) and (6.95,1.4) .. (10.93,3.29)   ;


% Text Node
\draw (324,24) node    {$W$};
% Text Node
\draw (432,97) node    {$A$};
% Text Node
\draw (434,168) node    {$X$};
% Text Node
\draw (327,97) node    {$( A\times B)_{P}$};
% Text Node
\draw (208,98) node    {$B$};
% Text Node
\draw (209,168) node    {$Y$};
% Text Node
\draw (326,169) node    {$X\times Y$};
% Text Node
\draw (388,88) node    {$Pr_{A}$};
% Text Node
\draw (260,86) node    {$Pr_{B}$};
% Text Node
\draw (389,180) node    {$Pr_{X}$};
% Text Node
\draw (261,179) node    {$Pr_{Y}$};
% Text Node
\draw (453,128.4) node    {$in_{A}$};
% Text Node
\draw (189,129.4) node    {$in_{B}$};
% Text Node
\draw (351,130) node    {$in_{A\times B}$};

\end{tikzpicture}
3
  • 1
    Very nice. The lines in the horizontal arrows are not quite straight, and the two arcs are not symmetrical. For me, this image is not quite ready for publication. I find the code complicated, and hard to edit. Feb 3, 2020 at 14:07
  • The point is not to edit the code but to use the graphical interface. Lines can be made straight by holding the shift key. You can find out more by heading over to Mathcha.
    – Patrick
    Feb 3, 2020 at 22:58
  • Thank you very much Patrick
    – Intuition
    Jun 25, 2022 at 22:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .