Subfloat:폭이 다른 두 이미지를 같은 높이로 정렬하는 방법은 무엇입니까?

Subfloat:폭이 다른 두 이미지를 같은 높이로 정렬하는 방법은 무엇입니까?

너비가 다른 두 개의 이미지가 있다고 가정합니다. 이제 우리는 그것들을 나란히 정렬하고 싶지만 높이는 동일합니다.


최소 작업 예(MWE):

\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}

\begin{document}

    \begin{figure}[h]
        \centering
        \subfloat[Picture A]{\includegraphics[width=0.45\linewidth]{example-image-a}}\quad
        \subfloat[Picture B]{\includegraphics[width=0.45\linewidth]{example-image-b}}\\
        \captionsetup{justification=justified,margin=1cm}
        \caption{Comparison of steady state results (a)~x method (b)~y method}
    \end{figure}

\end{document}

결과 스크린샷:

결과 스크린샷


문제 설명:

두 이미지의 너비와 높이가 동일하다면 상단 MWE는 완벽하게 작동합니다.

그러나 제 경우에는 높이가 같지만 너비가 다른 두 개의 이미지가 있습니다. 필요한 너비를 스스로 조정하면서 두 이미지가 동일한 높이를 채택해야 한다고 선언하려면 어떻게 해야 합니까?

[width=0.457585\linewidth]과거에는 비슷한 높이로 크기를 조정할 때까지 이런저런 작업을 하면서 놀았는데 이는 성가신 접근 방식이었습니다.

그렇게 할 수 있는 더 나은 옵션이 있을 것 같은데요?

답변1

패키지 graphicx를 사용하면 이미지의 높이(다른 많은 매개변수 중에서)를 설정할 수도 있습니다. 다음은 가능한 매개변수 중 일부 목록입니다(패키지 문서 참조).

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

귀하의 경우:

\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}

\begin{document}

    \begin{figure}[h]
        \centering
        \subfloat[Picture A]{\includegraphics[height=4cm]{example-image-a}}\quad
        \subfloat[Picture B]{\includegraphics[height=4cm]{example-image-b}}\\
        \captionsetup{justification=justified,margin=1cm}
        \caption{Comparison of steady state results (a)~x method (b)~y method}
    \end{figure}

\end{document}

관련 정보