0
\usepackage{graphicx}
\usepackage{multicol}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{siunitx}
\usepackage[export]{adjustbox}
\usepackage{wrapfig}

\begin{document}
\begin{table}[!htb]
    \begin{minipage}{.5\linewidth}
    \caption{Distribution Along Boundaries}
        \begin{tabular}{c|c}
        \toprule{}
            Title1 & Title2\\
            \hline \hline
            D1 & 10\\
            D2 & 6\\
            D3 & 4\\
            D4 & 2\\
            \bottomrule
        \label{table:distribution}
        \end{tabular}
        \linebreak
    \caption{Mesh Across Domains}
        \begin{tabular}{c|l|cc|c}
        \toprule{}
            {Title} & {Title} &\multicolumn{2}{c|}{Title} & {Title}\\
            {} & {} & {X} & {Y} & {}\\
            \hline \hline
            1 & Free & 0. & 0 & 1\\
            2 & Free & 0. & 0 & 4\\
            3 & Free & 0. & 0 & 1\\
            \bottomrule
        \label{table:mesh}
        \end{tabular}
    \end{minipage} 
    \begin{minipage}{0.4\linewidth}
        \begin{figure}[H]
            \begin{flushright}
                \includegraphics[width=1\columnwidth, right]{Figures/somefigure.png}
        \caption{Caption}
        \label{fig:somefig}
        \end{flushright}
        \end{figure}   
    \end{minipage}
\end{table}
\end{document}
1
  • 2
    Please provide a complete (but still minimal) document starting with \documentclass so we don't have to guess what packages you're using; also change the \includegraphics command to use something like example-image-a from the graphicx package (see here) so we can actually compile your code. Also, please explain further what you are trying to do. I don't understand why you have a figure float inside a table float or what the end product is supposed to look like.
    – frabjous
    Commented May 31, 2022 at 20:38

2 Answers 2

1

Tables and image in table. For tables are used tabularray package, for vertical center image is used adjustbox package (which load graphcx package too):

  • a case with tables left aligned in table column:
\documentclass[12pt]{article}
\usepackage[export]{adjustbox}
\usepackage[skip=0.33\baselineskip,
            font=footnotesize, labelfont=bf]{caption} 

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\usepackage{tabularray}
\UseTblrLibrary{booktabs, counter, varwidth}

\begin{document}
    \begin{table}[htb]
\begin{tblr}{colspec = {@{} X[c] X[r] @{} },
             measure = vbox
             }
\begin{minipage}{\linewidth}%\centering
\captionsetup{singlelinecheck=off}
    \caption{Distribution Along Boundaries} 
    \label{table:distribution}
    \begin{tblr}{c|c}
        \toprule 
    Title 1 & Title 2   \\
        \midrule
    D1      & 10        \\
    D2      & 6         \\
    D3      & 4         \\
    D4      & 2         \\
        \bottomrule
    \end{tblr}
    
    \bigskip
    \caption{Mesh Across Domains}
    \label{table:mesh}
    \begin{tblr}{c|l|cc|c}
        \toprule 
    Title   & Title &\SetCell[c=2]{c}   Title
                                            & Title \\
            &       &       X   &      Y    &       \\
        \midrule
    1       & Free  & 0.        & 0         & 1     \\
    2       & Free  & 0.        & 0         & 4     \\
    3       & Free  & 0.        & 0         & 1     \\
        \bottomrule
    \end{tblr}
\end{minipage}
        &   \includegraphics[width=0.8\linewidth,
                             valign=m]{example-image}
           \captionof{figure}{Figure caption} 
                    \label{fig:somefig}
\end{tblr}
    \end{table}
\end{document}

enter image description here

  • a case with tables centered in table column. For such design you need:
    • remove \captionsetup{singlelinecheck=off}
    • add \centering \command after \begin{minipage} Wit these changes in above MWE, the result of its compilation is:

enter image description here

(red lines show text borders)

0

If this layout is what you are looking for

a

(1) Add \hfill between the two minipages to push the figure to the right margin.

(2) Use \captionof{figure}{...} to add the caption for the figure inside a table environment. (Need the package caption).

(3) Put the labels after the captions.

\documentclass[12pt]{article}

\usepackage{graphicx}
\usepackage{caption} % for captionof <<<<

\usepackage{showframe}% ONLY to show the margins

\usepackage{booktabs}
\begin{document}
    \begin{table}[!htb]
        \begin{minipage}{.4\linewidth}
            \caption{Distribution Along Boundaries} \label{table:distribution}
            \begin{tabular}{c|c}
                \toprule{}
                Title1 & Title2\\
                \hline \hline
                D1 & 10\\
                D2 & 6\\
                D3 & 4\\
                D4 & 2\\
                \bottomrule         
            \end{tabular}
            \bigskip
            \caption{Mesh Across Domains}\label{table:mesh}     
            \begin{tabular}{c|l|cc|c}
                \toprule{}
                {Title} & {Title} &\multicolumn{2}{c|}{Title} & {Title}\\
                {} & {} & {X} & {Y} & {}\\
                \hline \hline
                1 & Free & 0. & 0 & 1\\
                2 & Free & 0. & 0 & 4\\
                3 & Free & 0. & 0 & 1\\
                \bottomrule         
            \end{tabular}
        \end{minipage}
     \hfill % added <<<<<<<<<<
        \begin{minipage}{0.4\linewidth}
                    \includegraphics[width=1\columnwidth]{example-image}
                    \captionof{figure}{Figure caption} % changed <<<<<<<<<<<
                    \label{fig:somefig}
        \end{minipage}
    \end{table}
\end{document}

Using

\begin{table}[!htb]             
            \begin{minipage}{.59\linewidth}
                \centering % added <<<<<<<<
                \caption{Distribution Along Boundaries} \label{table:distribution}

produces a better looking arrangement

b

You must log in to answer this question.

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