将图形与位于图形上方的表格并排放置

将图形与位于图形上方的表格并排放置

我正在尝试在左侧插入一个图形,并在右侧的图形上插入一个表格。我有以下 MWE:

\documentclass{article}
\usepackage{subfig,graphicx}
\begin{document}
\begin{figure}[h]
    \caption{A figure and a table atop a figure, side-by-side}
    \centering
    \subfloat[A figure left of a table+figure]{
        \rule{4.4cm}{6.6cm}
      }
      \subfloat[A table and figure right of a figure]{
        \begin{minipage}[b]{\textwidth} %
          \mbox{
        \subfloat{\begin{tabular}{cc}\hline
            Table head & Table head \\ \hline
            Some values & Some values \\
            Some values & Some values \\
            Some values & Some values \\
            Some values & Some values \\
            Some values & Some values \\
            Some values & Some values \\ \hline
        \end{tabular}
      }}
    \mbox{
      \subfloat[A figure below the table]{
        \rule{4.4cm}{2.6cm}
      }
      }
    \end{minipage}}
\end{figure}
\end{document}

这给了我以下信息:在此处输入图片描述

这几乎就是我想要的,只是我希望右边的图形位于表格下方,而右边的表格和图形都位于最左边图形的右侧。因此,就像:

图 a 表 a 图 a 表 a 图 a 图 a 图 b 图 a 图 b

我该怎么做?我上面做错了什么?

答案1

\subfloat请注意, (来自)的基线subfig位于标题处。

\documentclass{article}
\usepackage{subfig,graphicx}
\begin{document}
\begin{figure}[ht]
    \caption{A figure and a table atop a figure, side-by-side}
    \begin{minipage}[t]{0.5\textwidth}
    \centering
    \subfloat[A figure left of a table+figure]{
        \rule{4.4cm}{6.6cm}
      }%\llap{\rule{\linewidth}{0.5pt}}% to show baseline
    \end{minipage}%
    \begin{minipage}[t]{0.5\textwidth}% align caption of first subfloat
    \centering
        \subfloat[A table above a figure]{\begin{tabular}{cc}\hline
            Table head & Table head \\ \hline
            Some values & Some values \\
            Some values & Some values \\
            Some values & Some values \\
            Some values & Some values \\
            Some values & Some values \\
            Some values & Some values \\ \hline
        \end{tabular}}\par
      \subfloat[A figure below the table]{
        \rule{4.4cm}{2.6cm}
      }
    \end{minipage}
\end{figure}
\end{document}

一个稍微优雅的解决方案。底部顶部对齐。

\documentclass{article}
\usepackage{subfig,graphicx}
\begin{document}
\begin{figure}[ht]
  \caption{A figure and a table atop a figure, side-by-side}
    \sbox0{\subfloat[A figure left of a table+figure]{
        \rule{4.4cm}{6.6cm}
      }}% measure height
    \sbox1{\subfloat[A table above a figure]{\begin{tabular}{cc}\hline
            Table head & Table head \\ \hline
            Some values & Some values \\
            Some values & Some values \\
            Some values & Some values \\
            Some values & Some values \\
            Some values & Some values \\
            Some values & Some values \\ \hline
        \end{tabular}}}% measure width
    \sbox2{\subfloat[A figure below the table]{
        \rule{4.4cm}{2.6cm}
      }}% subcaptions are in the above order
    \dimen0=\dimexpr \ht0+\dp0\relax% get total height
    \dimen1=\dimexpr \ht1+\dp1+\ht2+\dp2\relax
    \ifdim\dimen0>\dimen1\relax \dimen1=\dimen0 \fi
    \ifdim\wd1>\wd2\relax \dimen0=\wd1 \else \dimen0=\wd2 \fi

    \centering
    \usebox0\hfil
    \begin{minipage}[t][\dimen1][t]{\dimen0}% align caption of first subfloat
    \centering
      \usebox1\par\vfill
      \usebox2
    \end{minipage}
\end{figure}
\end{document}

相关内容