将图形和两个表格对齐在同一行

将图形和两个表格对齐在同一行

我试图将一个图形和两个表格对齐在同一行,同时每个表格仍带有标题。目前我正在使用类似以下方法:

\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{times,latexsym}
\usepackage[T1]{fontenc}
\usepackage{url}
\usepackage{tabularx}
\usepackage{times}
\usepackage{array}
\usepackage{tikz}
\usepackage{soul}
\usepackage{caption, floatrow}
\renewcommand{\UrlFont}{\ttfamily\small}
\usepackage{times}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage[official]{eurosym}
\usepackage{mathtools}
\usepackage{adjustbox}
\usepackage{subfig}
\usepackage{wrapfig}
\usepackage{lipsum}
\usepackage{subcaption}
\newsavebox{\bigimage}
\usepackage{caption}
\newfloatcommand{capbtabbox}{table}[][0.25\linewidth]


\begin{document}
\begin{figure}
\CenterFloatBoxes
    \begin{floatrow}
    \ffigbox[0.8\textwidth]{
        \includegraphics[width=0.8\textwidth]{Rplot01.png}
    }{
        \caption{ 
 figure 1 of some kind}
    }
    \capbtabbox[0.2\textwidth]{
        \caption{first table}
        \begin{tabular}{l|ccc}
        \toprule
         & AA &  BB & CC \\
        \midrule
        Number & 20.0 & 21.0 & 22.0 \\
        - (first exp) & 23.0 & 24.0 & 25.0  \\
        - (second exp) & 20.0 & 21.0 & 22.0 \\
        \bottomrule
        \end{tabular}
        \adjustbox{width=0.5\textwidth}{\caption{second table}\begin{tabular}{l|ccc}
                \toprule
                  &\\
                \midrule
                invalid experiments & 300 \\\hdashline
                valid experiments with positive top 1 & 10 (25\%) \\ 
                valid experiments with negative top 1 & 50 (75\%) \\ 
                \bottomrule
                \end{tabular}}
    }{}
    \end{floatrow}
\end{figure}

\end{document}

结果如下: 在此处输入图片描述

问题是表 1 的标题消失了,并且表 1 和表 2 的宽度不一致。我仍然希望左侧有图像,右侧有两个垂直堆叠的表格,每个表格的标题位于表格本身下方,如下所示:

在此处输入图片描述

谢谢你的帮助!

答案1

像这样:

在此处输入图片描述

  • 图表minipage
  • 用于表格标题\captionof{table}{...}
  • 用于表格small字体大小
  • 而是使用times字体newtxtext
\documentclass{article}
\usepackage[T1]{fontenc}    % use 8-bit T1 fonts
\usepackage{newtxtext}
\usepackage{microtype}

\usepackage[export]{adjustbox}
\usepackage[skip=1ex, below skip=2ex]{caption}
\usepackage{makecell}
%---------------------------------------------------------------%
\usepackage{lipsum}% For dummy text. Don't use in a real document


\begin{document}
\lipsum[66]
    \begin{figure}[ht]
\begin{minipage}{0.4\textwidth}\centering
    \includegraphics[width=\textwidth]{example-image-duck}
    \caption{figure 1 of some kind}
\end{minipage}\hfill
\begin{minipage}{0.56\textwidth}
    \small
    \captionsetup{singlelinecheck=false}
    \begin{tabular}{@{} l|ccc @{}}
    \Xhline{1pt}
        & AA &  BB & CC \\
    \Xhline{0.5pt}
Number & 20.0 & 21.0 & 22.0 \\
- (first exp) & 23.0 & 24.0 & 25.0  \\
- (second exp) & 20.0 & 21.0 & 22.0 \\
    \Xhline{1pt}
    \end{tabular}
\captionof{table}{first table}
   
   \begin{tabular}{@{} l|c @{}}
    \Xhline{1pt}
invalid experiments & 300 \\
valid experiments with positive top 1 & 10 (25\%) \\
valid experiments with negative top 1 & 50 (75\%) \\
    \Xhline{1pt}
    \end{tabular}
\captionof{table}{second table}
    \end{minipage}
    \end{figure}
\lipsum[66]
\end{document}

笔记:

  • hyperref必须在序言中最后加载
  • hyperref也加载url,所以不需要再次加载
  • subfig并且subcaption不能很好地协同工作,Stik 只与其中一个协同工作,更强大的是subcaption

相关内容