하위 그림이 나란히 표시되지 않습니다.

하위 그림이 나란히 표시되지 않습니다.

두 개의 tikzpicture를 나란히 정렬하는 데 문제가 있습니다. 내가 시도하는 모든 것이 그들이 서로 쌓이는 것을 막지는 못할 것 같습니다.

여기 MWE가 있습니다. 두 번째 tikz사진은 문제를 보여주기 위한 원입니다.

\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}

도와주셔서 정말 감사드립니다. 문제가 어디에 있는지 정말 모르겠습니다. 나란히 문제

답변1

내 의견을 자세히 설명하겠습니다. subcaptionboxes 사이의 빈 줄을 제거해야 합니다. 새로운 라인이 시작됩니다.

주제에서 벗어난 일부 설명:

  • 나는 사용하지 않을 것이다 \resizebox.
  • 왼쪽 이미지의 코드는 다음과 같은 (간결한) 방법으로도 작성할 수 있습니다.
\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}

여기에 이미지 설명을 입력하세요

답변2

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}

여기에 이미지 설명을 입력하세요

관련 정보