[Tex/LaTex] Figure with subfigures containing text and a drawing

floatssubfloats

I am trying to do something similar to this What I am trying to achieve but I have no idea on how to do it. Usually when I add figures i use the \begin{figure}, the problem is that I have no idea on how to achieve this result. Any idea?

Thanks

Best Answer

A solution using subcaption, tikz-cd for the diagram and makecell for easy multi-line cells in a tabular environment:

        \documentclass[12pt, a4paper]{article}

        \usepackage[utf8]{inputenc}
        \usepackage[T1]{fontenc}
        \usepackage{lmodern}
        \usepackage{sansmathfonts} 

        \usepackage{caption, subcaption} 
        \usepackage{makecell}
        \usepackage{tikz-cd}
        \usetikzlibrary{arrows}
        \tikzset{%
        commutative diagrams/.cd,
        arrow style=tikz,
        diagrams={>= triangle 45, line width=2*tikzcdrule}
        }%

        \begin{document}

        \begin{figure}[!h]
          \centering\sffamily\bfseries\boldmath
          \captionsetup[subfigure]{labelfont = sf}
          \begin{subfigure}[b]{0.3\textwidth}
               \renewcommand{\cellalign}{rt}\renewcommand{\cellgape}{\Gape[4pt]}
                \begin{tabular}{ccc}
                      A & \makecell{eff : \\ dur :} & \makecell[l]{P \\ 1} \\
                      B & \makecell{eff : \\ dur :} & \makecell[l]{Q \\ 2}  \\
                      C & \makecell{pref :  \\ eff : \\dur : } & \makecell[l]{P,  Q \\ R \\ 2}
                    \end{tabular}
                    \caption{}\label{fig: 1a}
          \end{subfigure}
          \begin{subfigure}[b]{0.3\textwidth}
                    $ \begin{tikzcd}[row sep = scriptsize]
                        A_{[0} \rar & P_{\mkern 2mu [1}\arrow{ddl} \\
                          B_{[0} \rar & Q_{[2} \dlar \\
                          C_{[2} \rar & R_{[5}
                        \end{tikzcd} $\vspace{-4.3pt}
                    \caption{}\label{fig: 1b}
          \end{subfigure}
          \caption{A figure}\label{fig1}
        \end{figure}

        \end{document}

enter image description here

Related Question