0

I am trying to create an image and 2 tables one below the other next to it using the below code with floatrow package

\begin{figure}
\begin{floatrow}
\ffigbox{%
  \rule{3cm}{3cm}%
}{%
  \caption{A figure}%
}
\capbtabbox{%
  \begin{tabular}{cc} \hline
  Author & Title \\ \hline
  Knuth & The \TeX book \\
  Lamport & \LaTeX \\ \hline
  \end{tabular}
  \begin{tabular}{cc} \hline
  Author & Title \\ \hline
  Knuth & The \TeX book \\
  Lamport & \LaTeX \\ \hline
  \end{tabular}
}{}
\end{floatrow}
\end{figure}

but I could only get this layout

enter image description here

Could you please let me know if there is an easy fix to place the tables one below the other instead of side by side. Thanks.

3
  • 2
    Please extend your code fragment to complete small document! If you like to have image and table above each other, insert empty lines between them ...
    – Zarko
    Nov 2, 2021 at 20:44
  • Try adding some vertical spacing in between the tables. You may use \vspace{}, \smallskip, etc.
    – Imran
    Nov 2, 2021 at 21:14
  • 1
    Yes, but the first step is to stop using floatrow. Nov 3, 2021 at 4:07

2 Answers 2

1

The better I can do: enter image description here

with this (no professional)code:

\documentclass[10pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx,lipsum}
\usepackage{caption}[2007/04/11]

\begin{document}
    \lipsum[1]\\
    
    \begin{figure}[h!]
    %   \vspace{1cm}
    \rule{3cm}{4cm}%
    \end{figure}
    \vspace{-5.3cm} % <<<< TRIALS AND ERRORS
\qquad \qquad
    \begin{table}[htp]
        \centering
        \caption{First table}
        \begin{tabular}{lll}
            \hline
            1 & 2 & $\sin x$\\
            3 & 4 & $\cos x$\\
            5 & 6 & $\tan x$\\
            \hline
        \end{tabular}
        \caption{First table}
        
        \begin{tabular}{lll}
            \hline
            1 & 2 & $\sin x$\\
            3 & 4 & $\cos x$\\
            5 & 6 & $\tan x$\\
            \hline
        \end{tabular}
    \end{table}\\
    \noindent\lipsum[1-2]
\end{document}
0

I made this more complicated than it has to be, but it can handle a variety of widths this way.

\documentclass{article}
\usepackage{caption}
\begin{document}

\begin{figure}
\hrule% MWE only
\centering
\sbox0{\rule{3cm}{3cm}}% measure width
\begin{minipage}[c]{\wd0}
  \usebox0
  \caption{A figure}%
\end{minipage}\hfil
\sbox1{\begin{tabular}{cc} \hline
  Author & Title \\ \hline
  Knuth & The \TeX book \\
  Lamport & \LaTeX \\ \hline
  \end{tabular}}%
\sbox2{\begin{tabular}{cc} \hline
  Author & Title \\ \hline
  Knuth & The \TeX book \\
  Lamport & \LaTeX \\ \hline
  \end{tabular}}%
\ifdim\wd1>\wd2 \dimen0=wd1 \else \dimen0=\wd2 \fi
\begin{minipage}[c]{\dimen0}
\captionof{table}{A table}
\centering
\usebox1

\usebox2
\end{minipage}
\hrule% MWE only
\end{figure}

\end{document}

You must log in to answer this question.

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