Las subfiguras no se mostrarán una al lado de la otra

Las subfiguras no se mostrarán una al lado de la otra

Tengo problemas para alinear dos imágenes tikz una al lado de la otra. Parece que todo lo que intento no evitará que se apilen uno debajo del otro.

Aquí hay un MWE, la segunda imagen de tikz es un círculo solo para mostrar el problema.

\documentclass[a4paper]{article}
\usepackage{geometry}
\geometry{left=20mm,right=20mm,top=20mm,bottom=20mm}

\usepackage[font=small, labelfont=bf, labelsep=space, justification=centering]{caption}
\usepackage[list=true]{subcaption}

\usepackage{tikz}
\usetikzlibrary{angles}
\usetikzlibrary{arrows}
\usetikzlibrary{quotes}
\usepackage{tkz-euclide}

\begin{document}

\begin{figure}[h]
    \centering
    \subcaptionbox{Sezione del cilindro, $h>d$.\label{fig:h>d}}{
        \centering
        \resizebox{0.45\textwidth}{!}{
            \begin{tikzpicture}%[scale=]
                \begin{scope}[rotate = 30]
                    \draw[black, thick] (0,0) rectangle (6,4);
                    \draw[black, thick, loosely dotted] (-0.5,2) -- (6.35,2);
                    \draw[black, thick, loosely dotted] (3,-0.5) -- (3,4.5);
                    \draw[black, loosely dashed] (3,2) -- (1.85,0);
                    \filldraw[black] (0,2) circle (2pt) node[anchor=east] {M \quad};
                    \filldraw[black] (1.85,0) circle (2pt) node[anchor=north] {\quad T};
                    \filldraw[black] (3,2) circle (2pt) node[anchor=west] {CDM};
                    \filldraw[black] (0,0) circle (2pt) coordinate(P) node[anchor=north] {P$=(0,0)$};
                    \filldraw[black] (0,4) circle (2pt) node[anchor=east] {A};
                    \filldraw[black] (6,0) circle (2pt) coordinate(B) node[anchor=north west] {B};
                    \filldraw[black] (6,4) circle (2pt) node[anchor=south] {C};
                    
                    \draw[|-|] (6.4, 0) -- (6.4,2) node[anchor=south west] {$d$} -- (6.4,4);
                    \draw[|-|] (0,4.7) -- (3,4.7) node[anchor = south east] {$h$} -- (6,4.7);
                \end{scope}
                \draw[black, loosely dashed, ->] (0,0) -- (0,5.3) node[anchor = north west] {$y$};
                \filldraw[black] (0,4.625) circle (2pt) node[anchor=south east] {Q};
                \draw[black, loosely dashed, ->] (-1.5,0) -- (2,0) coordinate(G) node[anchor = west] {$x$};
                \pic["$\alpha$",draw=black,thick,<->,angle eccentricity=1.2,angle radius=1.2cm] {angle=G--P--B};
            \end{tikzpicture}
        }
    }
    
    \hfill
    
    \subcaptionbox{Sezione del cilindro, $h<d$.\label{fig:h<d}}{
        \centering
        \resizebox{0.45\textwidth}{!}{
            \begin{tikzpicture}[scale=0.2]
                \filldraw[black] (0,0) circle (2pt);
            \end{tikzpicture}
        }
    }
\end{figure}

\end{document}

Gracias por tu ayuda, es realmente apreciada. Realmente no sé dónde podría estar el problema. problema lado a lado

Respuesta1

Permítanme explicar mi comentario: es necesario eliminar las líneas vacías entre subcaptionboxes. Comienza nuevas líneas.

Algunas observaciones fuera de tema:

  • Yo no usaría \resizebox.
  • El código para la imagen de la izquierda también se puede escribir de la siguiente forma (concisa):
\documentclass[a4paper]{article}
\usepackage[margin=20mm]{geometry}

\usepackage[font=small, labelfont=bf, labelsep=space, justification=centering]{caption}
\usepackage[list=true]{subcaption}

\usepackage{tikz}
\usetikzlibrary{angles, arrows,
                quotes}
\usepackage{tkz-euclide} % not used in this image

\begin{document}
    \begin{figure}[h]
\centering
    \subcaptionbox{Sezione del cilindro, $h>d$.\label{fig:h>d}}{
            \begin{tikzpicture}[
            dot/.style = {circle, fill=red, minimum size=5pt, inner sep=0pt}
                                ]
                \begin{scope}[rotate = 30]
                    \draw[thick] (0,0) rectangle (6,4);
                    \draw[thick, loosely dotted] (-0.5,2) -- (6.35,2);
                    \draw[thick, loosely dotted] (3,-0.5) -- (3,4.5);
                    \draw[loosely dashed] (3,2) -- (1.85,0);
                    \node[dot,label= left:N] at (0,2) {}; 
                    \node[dot,label=below:T] at (1.85,0) {};
                    \node[dot,label=right:CDM] at (3,2) {};
                    \node (P) [dot,label=below:{P$=(0,0)$}] at (0,0) {};
                    \node[dot,label= left:A] at (0,4) {};
                    \node (B) [dot,label=right:B] at (6,0) {};
                    \node[dot,label=above:C] at (6,4) {};

                    \draw[|-|] (6.4, 0) to ["$d$" '] (6.4,4);
                    \draw[|-|] (0,4.7)  to ["$h$"] (6,4.7);
                \end{scope}
                \draw[loosely dashed, ->] (0,0)  -- (0,5.3) node[anchor = north west] {$y$};
                \draw[loosely dashed, ->] (-1.5,0) -- (2,0) node (G)[anchor = west]  {$x$};               \node[dot,label=above left:Q] at (0,4.625) {};
                
                \pic["$\alpha$",draw,thick,<->,angle eccentricity=1.2,angle radius=1.2cm] {angle=G--P--B};
            \end{tikzpicture}
    }
    \hfil
    \subcaptionbox{Sezione del cilindro, $h<d$.\label{fig:h<d}}{
        %\resizebox{0.45\textwidth}{!}{
            \begin{tikzpicture}%[scale=10]
                \filldraw[black] (0,0) circle (20pt);
            \end{tikzpicture}
        %}
    }
    \end{figure}
\end{document}

ingrese la descripción de la imagen aquí

Respuesta2

Como dice Zarko.

\documentclass[a4paper]{article}
\usepackage{geometry}
\geometry{left=20mm,right=20mm,top=20mm,bottom=20mm}

\usepackage[font=small, labelfont=bf, labelsep=space, justification=centering]{caption}
\usepackage[list=true]{subcaption}

\usepackage{tikz}
\usetikzlibrary{angles}
\usetikzlibrary{arrows}
\usetikzlibrary{quotes}
\usepackage{tkz-euclide}

\begin{document}

\begin{figure}[h]
    \centering
    \subcaptionbox{Sezione del cilindro, $h>d$.\label{fig:h>d}}{
        \centering
        \resizebox{0.45\textwidth}{!}{
            \begin{tikzpicture}%[scale=]
                \begin{scope}[rotate = 30]
                    \draw[black, thick] (0,0) rectangle (6,4);
                    \draw[black, thick, loosely dotted] (-0.5,2) -- (6.35,2);
                    \draw[black, thick, loosely dotted] (3,-0.5) -- (3,4.5);
                    \draw[black, loosely dashed] (3,2) -- (1.85,0);
                    \filldraw[black] (0,2) circle (2pt) node[anchor=east] {M \quad};
                    \filldraw[black] (1.85,0) circle (2pt) node[anchor=north] {\quad T};
                    \filldraw[black] (3,2) circle (2pt) node[anchor=west] {CDM};
                    \filldraw[black] (0,0) circle (2pt) coordinate(P) node[anchor=north] {P$=(0,0)$};
                    \filldraw[black] (0,4) circle (2pt) node[anchor=east] {A};
                    \filldraw[black] (6,0) circle (2pt) coordinate(B) node[anchor=north west] {B};
                    \filldraw[black] (6,4) circle (2pt) node[anchor=south] {C};
                    
                    \draw[|-|] (6.4, 0) -- (6.4,2) node[anchor=south west] {$d$} -- (6.4,4);
                    \draw[|-|] (0,4.7) -- (3,4.7) node[anchor = south east] {$h$} -- (6,4.7);
                \end{scope}
                \draw[black, loosely dashed, ->] (0,0) -- (0,5.3) node[anchor = north west] {$y$};
                \filldraw[black] (0,4.625) circle (2pt) node[anchor=south east] {Q};
                \draw[black, loosely dashed, ->] (-1.5,0) -- (2,0) coordinate(G) node[anchor = west] {$x$};
                \pic["$\alpha$",draw=black,thick,<->,angle eccentricity=1.2,angle radius=1.2cm] {angle=G--P--B};
            \end{tikzpicture}
        }%
    }%  
    \subcaptionbox{Sezione del cilindro, $h<d$.\label{fig:h<d}}{
        \centering
        \resizebox{0.45\textwidth}{!}{
            \begin{tikzpicture}[scale=0.2]
                \filldraw[black] (0,0) circle (2pt);
            \end{tikzpicture}
        }
    }
\end{figure}

\end{document}

ingrese la descripción de la imagen aquí

información relacionada