1

I'm trying to decently put a figure right next to a table. I tried all the approaches suggested here and here. None of them worked.

The closest was the first one, but I get an error Package floatrow Error: Caption(s) lost at the \captionof{figure} line.

Code:

\documentclass{article}

\usepackage[demo]{graphicx}
\usepackage{floatrow}
\usepackage{caption}


\begin{document}
\begin{table*}
   \begin{minipage}{0.45\textwidth}
      % \setlength{\tabcolsep}{4pt}
      % \scriptsize
      \caption{Wind turbulence characteristic values.}
      \begin{tabular}{| c | c | c | c | c |}
         \hline
         {}          & $\overline{U}$ & $u(t)$ & $v(t)$ & $w(t)$ \\
         \hline
         $\mu$ [m/s] & 49.7 & 0 & 0 & 0 \\
         \hline
         $\sigma$ [m/s] & - &  6.34  &  4.76  &   3.17 \\
         \hline
         L$_{x}$ [m]    & - &  120   &  30    &   10 \\
         \hline
         L$_{y}$ [m]    & - &  40    &  30    &   7.5 \\
         \hline
         L$_{z}$ [m]    & - &  30    &  7.5   &   7.5 \\
         \hline
         C$_{x}$     & - &  12   &   12  &  12 \\
         \hline
         C$_{y}$     & - &   6   &   6   &   6 \\
         \hline
         C$_{z}$     & - &   9   &   9   &   9 \\
         \hline
      \end{tabular}
   \end{minipage}
   \hfill
   \begin{minipage}{0.45\textwidth}
      \includegraphics{graphs/dataset17b.pdf}
      \captionof{figure}{Caption figure}
      \label{fig:ravine_coeffs}
   \end{minipage}
\end{table*}
\end{document}

Current result:

enter image description here

EDIT: I'd also need to make references to both, so I'd need to put \labels.

11
  • Have you tested the examples from the linked questions unchanged? Do they work? Can you please extend your code snippet to a minimal working example, that can be copied to reproduce your problem without guessing how to extend it to compile? You should also replace the image file, which we do not have (see the link above), e.g., using an example image from package mwe.
    – cabohah
    Commented Mar 22 at 8:40
  • @cabohah I will provide a MWE soon. Yes, I did try a standalone version of the first link. It does not even compile for me.
    – mEm
    Commented Mar 22 at 8:45
  • Why a table cannot be inside a minipage is already explained in the first sentence of the answer to the question in your first link: table is a float. The specification of floats is to float outside the environments. Floats cannot be used inside boxes. A minipage is a special kind of box.
    – cabohah
    Commented Mar 22 at 8:46
  • 1
    BTW: If you are using package floatrow, you should read the manual. The package provides it own environment floatrow and commands \ttabbox and \ffigbox to place tables and figures side by side
    – cabohah
    Commented Mar 22 at 8:50
  • 1
    Needless to say, this is much simpler without floatrow, but may still have prolems WRT hyperref (see tex.stackexchange.com/questions/643473/…) Commented Mar 22 at 14:55

1 Answer 1

1

As already told in a comment: If you use package floatrow, you should use the package's feature to place floating contents side by side. So you should use the floatrow environment and commands like \ttabbox, \ffigbox, \floatbox etc.

For example you could use something like:

\documentclass{article}

\usepackage[demo]{graphicx}
\usepackage{floatrow}
\usepackage{caption}


\begin{document}
\begin{table}% table* does only make sense with option twocolumn or command \twocolumn
  \begin{floatrow}
    \TopFloatBoxes\ttabbox{\caption{Wind turbulence characteristic values.}}
      {\begin{tabular}{| c | c | c | c | c |}
         \hline
         {}          & $\overline{U}$ & $u(t)$ & $v(t)$ & $w(t)$ \\
         \hline
         $\mu$ [m/s] & 49.7 & 0 & 0 & 0 \\
         \hline
         $\sigma$ [m/s] & - &  6.34  &  4.76  &   3.17 \\
         \hline
         L$_{x}$ [m]    & - &  120   &  30    &   10 \\
         \hline
         L$_{y}$ [m]    & - &  40    &  30    &   7.5 \\
         \hline
         L$_{z}$ [m]    & - &  30    &  7.5   &   7.5 \\
         \hline
         C$_{x}$     & - &  12   &   12  &  12 \\
         \hline
         C$_{y}$     & - &   6   &   6   &   6 \\
         \hline
         C$_{z}$     & - &   9   &   9   &   9 \\
         \hline
      \end{tabular}}
%  \killfloatstyle
    \ffigbox{\caption{Caption figure}\label{fig:ravine_coeffs}}
      {\includegraphics{graphs/dataset17b.pdf}}
  \end{floatrow}
\end{table}
\end{document}

to get

table and figure side by side top aligned.

See the floatrow manual for more information, e.g., about vertical alignment using \TopFloatBoxes, \CenterFloatBoxes, \BottomFloatBoxes, nested boxes, \killfloatstyle and all the options and features the package provides.

5
  • Thanks @cabohah ! How to control boxes dimensions ? The figure goes out of the document. I tried forcing the width with \ffigbox[0.4\textwidth] but does nothing.
    – mEm
    Commented Mar 22 at 9:25
  • 1
    BTW: I've never used floatrow before. I've just spend some minutes to read parts of the manual. So maybe my code could be improved. And yes, the tabular code can be improved: Don't use vertical lines in tables unless you really, really need them. Reduce horizontal lines in tables to a minimum. Tables with line matrices are difficult to read and ugly.
    – cabohah
    Commented Mar 22 at 9:25
  • Read the manual. The \floatbox command (and therefore also \ffigbox and \ttabbox) has optional arguments for width, height etc.
    – cabohah
    Commented Mar 22 at 9:27
  • That's why I asked.. I read, tried, but nothing changed.. Thanks anyway fo rthe help. I see if I figure that out.
    – mEm
    Commented Mar 22 at 9:30
  • 1
    Without knowing, what you've tried, I can only guess: The optional width argument of \ffixbog does not change the height or width values of options the width and height of \includegraphics. It only changes the width and height of the box. And if you have more problems, please ask more questions (with corresponding MWE).
    – cabohah
    Commented Mar 22 at 9:32

You must log in to answer this question.

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