0

I have a combined figure and table side by side which I'd like to be centered and go beyond text margin on each side by 3 cm. I can only make it pass the margin on the right side, the left side just follows along. Here's is my current take. Any suggestions?

\blindtext
\usepackage{floatrow}
% Table float box with bottom caption, box width adjusted to content
\newfloatcommand{capbtabbox}{table}

\begin{figure}[h]
\hspace*{-3in}
\begin{floatrow}
\ffigbox[][]{\caption{subcaption1}}
    {\includegraphics[scale=0.4]{Files/attention.png}
}{%
  \caption{A figure}%
  \label{sometjing}
}
\capbtabbox{%
  \begin{tabular}{lcc} \hline
  \textbf{Topic} & \textbf{Mean} & \textbf{CI LL 2.5\%} & \textbf{CI UL 97.5\%} \\ \hline
        1 & 0.0012 & -0.0433 & 0.0448 \\ 
        2 & -0.0357 & -0.0607 & -0.0112 \\ 
        3 & -0.0171 & -0.0607 & 0.0279 \\
        4 & -0.0245 & -0.0626 & 0.0187 \\ 
        5 & 0.0629 & 0.0047 & 0.1227 \\ 
        6 & 0.0499 & -0.044 & 0.1429 \\ 
        7 & 0.0595 & -0.0108 & 0.1261 \\
        8 & -0.1114 & -0.1784 & -0.042 \\ 
        9 & 0.0316 & -0.0693 & 0.1304 \\ 
        10 & 0.0348 & -0.0883 & 0.1515 \\
        11 & 0.0601 & 0.0066 & 0.1123 \\ 
        12 & -0.0014 & -0.101 & 0.0942 \\
  \end{tabular}
}{%
  \caption{A table}%
}
\end{floatrow}
\end{figure}

This is what it looks like https://imgur.com/a/3JDvWsX

3
  • Welcome to TSE. Please post a Minimal Working Example, instead of a code snippet. Dec 18, 2022 at 11:37
  • 1
    you declare only three columns, but table has four ...
    – Zarko
    Dec 18, 2022 at 12:17
  • Floatrow uses a picture environment, so normal rules don't apply. OTOH, there is nothing floatrow provides which cannot be done with subcaption. Dec 18, 2022 at 17:33

1 Answer 1

1

Like this:

enter image description here

With use of the tabularray, booktabs, siunitx packages (latter two loaded as tabularray libraries) and caption package for use of captof{table}{...} directive:

\documentclass{article}
\usepackage{geometry}
\usepackage{blindtext}

\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx, 
                counter, varwidth}
\usepackage[demo]{graphicx}
\usepackage[skip=1ex,
            font=small, labelfont=bf]{caption}


\begin{document}
\blindtext
    \begin{figure}[ht]
\begin{tblr}{colspec={@{} X[f]X[h] @{}},
             measure = vbox}
\includegraphics[width=\linewidth]{Files/attention.png} % <---
\caption{A figure}
\label{fig:something}   
    &   \begin{tblr}{colspec = {@{} Q[c, si={table-format=2.0}]
                                       *{3}{X[c, m,  si={table-format=-1.4}]}
                                        @{}},
                              rowsep = 1pt,
                              row{1} = {guard, font=\small\bfseries}
                             }
                \toprule
            Topic   & Mean      & CI LL \qty{2.5}{\%}
                                            & CI UL \qty{97.5}{\%} \\
                \midrule
            1       & 0.0012    & -0.0433   &  0.0448 \\
            2       & -0.0357   & -0.0607   & -0.0112 \\
            3       & -0.0171   & -0.0607   &  0.0279 \\
            4       & -0.0245   & -0.0626   &  0.0187 \\
            5       & 0.0629    &  0.0047   &  0.1227 \\
            6       & 0.0499    & -0.044    &  0.1429 \\
            7       & 0.0595    & -0.0108   &  0.1261 \\
            8       & -0.1114   & -0.1784   & -0.042  \\
            9       & 0.0316    & -0.0693   &  0.1304 \\
            10      & 0.0348    & -0.0883   &  0.1515 \\
            11      & 0.0601    &  0.0066   &  0.1123 \\
            12      & -0.0014   & -0.101    &  0.0942 \\
                \bottomrule
                \end{tblr}
            \captionof{table}{A table}
            \label{tab:something}
\end{tblr}
    \end{figure}
\end{document}

As you can see, image size is determined by width instead by scale.

2
  • Sorry, I can't make it work. I've fiddled around with the code, but I still end up with this in the output. But thanks! imgur.com/a/83yUfsQ
    – Quantizer
    Dec 19, 2022 at 15:18
  • @Quantizer, my suggestion, as it is in answer, works and gives showed result. Tested with pdfLaTeX and LuaLatex in recent MIKTeX as well in Overleaf. If you not get the same result as are showed in answer, than you change something in provided code or your sistem may be very outdated.
    – Zarko
    Dec 19, 2022 at 18:18

You must log in to answer this question.

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