1

I was trying to align one figure and two tables in the same row while still have a caption to each table. Currently I am using something like:

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

and the result is as follows: enter image description here

The issue is that table 1's caption disappears and table 1 and table 2 are not having the same width. I still want the image at the left and two vertically stacked tables on the right with each table's caption below the table itself, something like:

enter image description here

Thanks for any help!

3
  • Welcome to TeX.SE. Which document class do you use, which font size do you employ, and how wide is the textblock?
    – Mico
    May 27, 2021 at 3:29
  • @Mico I use article document class, the font size should be the default and I don't remember changing the textblock...I edit the question and put the whole setup there! Thanks a lot! May 27, 2021 at 3:33
  • Floatrow tends to put captions where it wants to, not where you want them. I advise against using it. See also tex.stackexchange.com/questions/403661/… May 27, 2021 at 4:36

1 Answer 1

2

Like this:

enter image description here

  • figure and tables are in minipages
  • for table caption is used \captionof{table}{...}
  • for table small font size is used
  • instead times the newtxtext font is used
\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}

Note:

  • hyperref had to be load last in preamble
  • hyperref also load url, so it not need to be loaded again
  • subfig and subcaption doesn't work well together, Stik with just one of them, the more powerful is subcaption
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .