2

I would like to make the following figure: enter image description here

Thus have an arrow with a few vertical dashes and a text underneath the edges. I tried to use mathcha.io, but if you know how to do so with the commands like \draw, \node, \edge, \paths that would be preferred.

The main issue I am having is how to embed the different arrows each as a subfigure with a caption in one figure.

See here my code:

\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}


\begin{figure}[h]
    \centering
    \begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1]
        %uncomment if require: \path (0,235); %set diagram left start at 0, and has height of 235
        
        %Straight Lines [id:da7385431531953355] 
        \draw    (100,16) -- (597.2,16.7) ;
        \draw [shift={(599.2,16.7)}, rotate = 180.08] [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:da703699466676206] 
        \draw    (247,4) -- (247.2,29.7) ;
        %Straight Lines [id:da2030449187410226] 
        \draw    (430,4) -- (430.2,29.7) ;
        
        
        % Text Node
        \draw (146,23) node [anchor=north west][inner sep=0.75pt]   [align=left] {X};
        % Text Node
        \draw (311,24) node [anchor=north west][inner sep=0.75pt]   [align=left] {Y};
        % Text Node
        \draw (492,22) node [anchor=north west][inner sep=0.75pt]   [align=left] {Z};
    \end{tikzpicture}
    \caption{Subfigure a} 
    \label{Subfigure_a}
\end{figure}

4
  • Does this answer your question? link link
    – codeR
    Apr 24 at 12:01
  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.
    – cabohah
    Apr 24 at 12:52
  • 1
    BTW: It is not enough to load package subcaption, you also have to use it, e.g. using \subcaptionbox or \begin{subcaptionblock}…\end{subcaptioblock} or \begin{subfigure}…\end{subfigure}. See the manual for more information.
    – cabohah
    Apr 24 at 12:55
  • 1
    @duplicatevoters IMHO a question with answers, that all use obsolete package subfigure is not really a good duplicate source.
    – cabohah
    Apr 24 at 13:02

1 Answer 1

4

I would suggest using \subcaptionbox for this:

\documentclass{article}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{tikz}

\begin{document}
\begin{figure}
    \centering
    \subcaptionbox{subfigure a}[\textwidth]{
    \begin{tikzpicture}
        \def\length{6}   % Length of your arrow
        \def\height{0.5} % Height of your intersections
        \draw[->] (-\length,0) -- (\length,0);
        \node at (-2*\length/3,0) [yshift=-4,anchor=north]{X};
        \node at ( 0,0)           [yshift=-4,anchor=north]{Y};
        \node at ( 2*\length/3,0) [yshift=-4,anchor=north]{Z};
        \draw[-] (-\length/3,-\height/2) -- (-\length/3,\height/2);
        \draw[-] ( \length/3,-\height/2) -- ( \length/3,\height/2);
    \end{tikzpicture}
    }
    \subcaptionbox{subfigure b}[\textwidth]{
    \begin{tikzpicture}
        \def\length{6}   % Length of your arrow
        \def\height{0.5} % Height of your intersections
        \draw[->] (-\length,0) -- (\length,0);
        \node at (-2*\length/3,0) [yshift=-4,anchor=north]{X};
        \node at ( 0,0)           [yshift=-4,anchor=north]{Y};
        \node at ( 2*\length/3,0) [yshift=-4,anchor=north]{Z};
        \draw[-] (-\length/3,-\height/2) -- (-\length/3,\height/2);
        \draw[-] ( \length/3,-\height/2) -- ( \length/3,\height/2);
    \end{tikzpicture}
    }
\end{figure}
\end{document}

For me, this creates a nicely centered figure: pdf output

1
  • Thanks a lot @Marmorexx! This is perfect. Could you also do the same for this figure:
    – Drawer
    Apr 29 at 10:18

You must log in to answer this question.

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