并排图片未对齐 - 如何解决?

并排图片未对齐 - 如何解决?

我试图输入 4 个数字,但它们错位了。我该如何解决这个问题?

\documentclass{article}
\usepackage[utf8]{inputenc} % allow utf-8 input
\usepackage[T1]{fontenc}    % use 8-bit T1 fonts
\usepackage{hyperref}       % hyperlinks
\usepackage{url}            % simple URL typesetting
\usepackage{booktabs}       % professional-quality tables
\usepackage{amsfonts}       % blackboard math symbols
\usepackage{nicefrac}       % compact symbols for 1/2, etc.
\usepackage{microtype}      % microtypography
\usepackage{xcolor}         % colors
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\begin{figure*}[ht]
\begin{subfigure}[t]{0.5\textwidth}
    \includegraphics[width=\linewidth]{RLSVI-optimistic-sampling/Figures/Mountaincar/mountaincar.pdf}
    \caption{Episode returns for best runs} \label{fig:comp_best}
  \end{subfigure}%
  \begin{subfigure}[t]{0.5\textwidth}
    \includegraphics[width=\linewidth]{RLSVI-optimistic-sampling/Figures/RiverSwim/Riverswim12.pdf}
    \caption{Episode returns for all runs} \label{fig:comp_all2}
  \end{subfigure}
  \begin{subfigure}[t]{0.5\textwidth}
    \includegraphics[width=\linewidth]{RLSVI-optimistic-sampling/Figures/DeepSea/DeepSea10.pdf}
    \caption{POMD episode for different $\beta$} \label{fig:comp_all}
  \end{subfigure}
 \label{fig:comp1}
 \begin{subfigure}[t]{0.5\textwidth}
    \includegraphics[width=\linewidth]{RLSVI-optimistic-sampling/Figures/DeepSea/deepsea-Msensitivity.pdf}
    \caption{POMD episode for different $\beta$} \label{fig:comp_all1}
  \end{subfigure}
\end{figure*}
\end{document}

这给了我这个 在此处输入图片描述

答案1

我认为您想对齐图像的顶部并单独对齐标题。这使用表格。

我发现前面的例子将顶部对齐并使用了表格,但不是同时对齐。

\documentclass{article}
\usepackage[utf8]{inputenc} % allow utf-8 input
\usepackage[T1]{fontenc}    % use 8-bit T1 fonts
\usepackage{hyperref}       % hyperlinks
\usepackage{url}            % simple URL typesetting
\usepackage{booktabs}       % professional-quality tables
\usepackage{amsfonts}       % blackboard math symbols
\usepackage{nicefrac}       % compact symbols for 1/2, etc.
\usepackage{microtype}      % microtypography
\usepackage{xcolor}         % colors
\usepackage{caption}
\usepackage{subcaption}

\usepackage[export]{adjustbox}% adds [valign=...]
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{duckuments}% novelty only

\begin{document}
\begin{figure*}[tp]% h not supported
\begin{tabularx}{\textwidth}{@{}XX@{}}
    \includegraphics[width=\hsize,valign=top]{example-image-duck}%{RLSVI-optimistic-sampling/Figures/Mountaincar/mountaincar.pdf}
    &
    \includegraphics[width=\hsize,valign=top]{example-image-duck}%{RLSVI-optimistic-sampling/Figures/RiverSwim/Riverswim12.pdf}
    \\
    \subcaption{Episode returns for best runs}\label{fig:comp_best}
    &
    \subcaption{Episode returns for all runs}\label{fig:comp_all2}
    \\
    \includegraphics[width=\hsize,valign=top]{example-image-duck}%{RLSVI-optimistic-sampling/Figures/DeepSea/DeepSea10.pdf}
    &
    \includegraphics[width=\hsize,valign=top]{example-image-duck}%{RLSVI-optimistic-sampling/Figures/DeepSea/deepsea-Msensitivity.pdf}
    \\    
    \subcaption{POMD episode for different $\beta$}\label{fig:comp_all}
    &
    \subcaption{POMD episode for different $\beta$}\label{fig:comp_all1}
\end{tabularx}
\caption{One typically also gives a caption to the figure as a whole}
\end{figure*}
\end{document}

答案2

不错的@joh答案的一个小变化(+1):

  • 用于插入图像\adjincludegraphics
  • 图像的大小由以下因素\adjustboxset决定:
  • 考虑图像的默认基线(在其底部)
\documentclass{article}
\usepackage{microtype}      % microtypography
\usepackage{xcolor}         % colors
\usepackage[aboveskip=0.33\baselineskip]{caption}
\usepackage[aboveskip=0pt, belowskip=1ex]{subcaption}

\usepackage[export]{adjustbox}% adds [valign=...]
\usepackage{tabularx}
\usepackage{duckuments}% novelty only

\begin{document}
    \begin{figure*}[tp]
    \captionsetup{skip=-1ex}
    \adjustboxset{width=\linewidth,valign=bottom}

\begin{tabularx}{\textwidth}{@{}XX@{}}
\adjincludegraphics{example-image-duck}%{RLSVI-optimistic-sampling/Figures/Mountaincar/mountaincar.pdf}
    &\adjincludegraphics[height=33mm]{example-image-duck}%{RLSVI-optimistic-sampling/Figures/RiverSwim/Riverswim12.pdf}
    \\
\subcaption{Episode returns for best runs}\label{fig:comp_best}
    &   \subcaption{Episode returns for all runs}\label{fig:comp_all2}  \\
\adjincludegraphics[height=33mm]{example-image-duck}%{RLSVI-optimistic-sampling/Figures/DeepSea/DeepSea10.pdf}
    &\adjincludegraphics{example-image-duck}%{RLSVI-optimistic-sampling/Figures/DeepSea/deepsea-Msensitivity.pdf}
    \\
\subcaption{POMD episode for different $\beta$}\label{fig:comp_all}
    &   \subcaption{POMD episode for different $\beta$}\label{fig:comp_all1}
\end{figure*}
See \ref{fig:comp_best} ...
\end{document}

在此处输入图片描述

相关内容