1

How to place Figure 1 and Figure 2 side by side ? The code below. Thank you very much! enter image description here

    \usepackage{tikz}
    \usetikzlibrary{shapes,arrows}
    \usetikzlibrary{positioning}
\begin{figure}[H]
    \centering
    \caption{Figure 1}
    \label{fig_1}
    \vspace{0.3cm}




    \tikzset{ 
    bBlock/.style={rectangle, draw, fill=red!20, 
    text width=6em, text centered, rounded corners, minimum height=4em},
    rBlock/.style={rectangle, draw, fill= white, 
    text width=6em, text centered, rounded corners, minimum height=4em}, 
    arr/.style={line width=.5pt , draw, -latex'}        
    }

    \begin{tikzpicture}[node distance = 1cm, auto]


    \begin{scope}[xshift=8cm]
     \node [bBlock] (1) {Paper B};
     \node [rBlock, below left = of 1] (2) {Paper C};      
     \node [bBlock, above left =  of 2] (3) {Paper A};
\end{scope}  


    \draw [arr] (1) -- node[anchor=west] {TEXT} (2);
     \draw [arr] (3) -- node[anchor=east] {TEXT} (2);



    \end{tikzpicture}
\end{figure} 


\begin{figure}[H] \centering \caption{Figure 2} \label{fig_2} \vspace{0.3cm}

   \tikzset{ 
    bBlock/.style={rectangle, draw, fill=red!20, 
    text width=6em, text centered, rounded corners, minimum height=4em},
    rBlock/.style={rectangle, draw, fill= white, 
    text width=6em, text centered, rounded corners, minimum height=4em}, 
    arr/.style={line width=.5pt , draw, -latex'}        
    }



    \begin{tikzpicture}[node distance = 1cm, auto]



  \begin{scope}[xshift=8cm]
     \node [bBlock] (1) {Paper Y};
     \node [rBlock, below left = of 1] (2) {Paper X};      
     \node [bBlock, above left =  of 2] (3) {Paper Z};
         \end{scope}  


    \draw [arr] (2) -- node[anchor=west]{TEXT} (1);
     \draw [arr] (2) -- node[anchor=east]{TEXT}  (3);



    \end{tikzpicture}
\end{figure} 

JAO
  • 13
  • 2
    One figure, two minipages (<0.5\textwidth) with no blank lines between them. One caption in each minipage. – John Kormylo Nov 27 '23 at 14:59
  • Welcome to TeX.SX! You'd do this the same way as with any other two figures. – Jasper Habicht Nov 27 '23 at 15:16
  • You have two fundamental problems. Problem one is that your pictures are very wide. Problem two is that (outside of a tizkpicture environment), blank lines cause a paragraph break, so that you have three paragraph breaks between your figures. Problem three is that you have two separate figure environments. – Teepeemm Nov 27 '23 at 19:29

1 Answers1

1

Here on site you can find many examples how to set two figures in parallel, so regarding just this problem, your question is duplicate ...

Beside this problem your figure has some other issues: images are to wide that can be fit in one line. That this be possible, you need enlarge \textwidth and reduce nodes shape sizes and reduce distances between nodes. For example as is done in the following MWE:

\documentclass{article}
\usepackage{geometry}
%--------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage[skip=1ex]{caption}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                positioning,
                quotes}

\begin{document} \begin{figure}[ht] \tikzset{ box/.style = {draw, rounded corners, fill=#1, text width=5em, align=center, minimum height=3em}, box/.default = red!30, every edge/.style = {draw, thick, -Latex}, every edge quotes/.append style = {auto, font=\footnotesize\scshape} } \begin{minipage}{0.5\linewidth}\centering \caption{Figure 1} \label{fig_1} \begin{tikzpicture}[ node distance = 8mm and 4mm ] \node [box] (1) {Paper A}; \node [box=white, below right = of 1] (2) {Paper C}; \node [box, above right = of 2] (3) {Paper B}; % \draw (1) edge["TEXT" '] (2) (3) edge["TEXT"] (2); \end{tikzpicture} \end{minipage}% \begin{minipage}{0.5\linewidth}\centering \caption{Figure 2} \label{fig_2} \begin{tikzpicture}[ node distance = 9mm and 3mm ] \node [box] (1) {Paper A}; \node [box=white, below right = of 1] (2) {Paper C}; \node [box, above right = of 2] (3) {Paper B}; % \draw (2) edge["TEXT"] (1) (2) edge["TEXT" '] (3); \end{tikzpicture} \end{minipage} \end{figure} \end{document}

enter image description here

(red lines indicate page layout)

Zarko
  • 296,517