2

I'm trying to align an image and a table whithin the same figure, however, some alignment issues arise.

My code is:

\documentclass{article}
\usepackage{multirow}
\usepackage{amsbsy}
\usepackage{subfig}
\usepackage{multicol}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{amsbsy}
\usepackage{subfig}
\usepackage{booktabs}
\begin{document}
\begin{figure}[!htb] 
  \centering 
  \begin{tabular}{l}
  \subfloat[]{
   \includegraphics[height=4.5cm]{Figures/goldmine} \label{fig:goldmineGraphic}}  
    \subfloat[]{
      %\input{Figures/Tikz/goldMineState.tex}\label{fig:goldMineState}}  
      \begin{tabular}{ll}
    \toprule
    Object & Attributes \\
    \midrule
    $miner1$ & $x=0,y=1$ \\
    $miner2$ & $x=1,y=3$ \\
    $miner3$ & $x=4,y=3$ \\
    $gold1$ & $x=1,y=0$ \\
    \multicolumn{2}{c}{$\vdots$} \\
    $gold6$ & $x=4,y=2$ \\
    $wall1$ & $x=1,y=1,pos=S$ \\
    \multicolumn{2}{c}{$\vdots$}\\
    $wall24$ & $x=4,y=4,pos=E$ \\
    \bottomrule
  \end{tabular}}
  \end{tabular}
 \caption{AA}
 \label{fig:goldmine}
\end{figure}
\end{document}

which results in:

code result

What I actually wanted is something like this, with the two subfloats (the graphic and the table) aligned horizontally (not overstepping each other):

enter image description here

Any idea of how to solve this?

2

You could choose adjustbox package as one of the options. The package provides \adjustbox command with lot of options. Here is the amended code for your requirement.

Note: I have added \usepackage{adjustbox} and \adjustbox{raise=-5pc} in this code.

\documentclass{article}
\usepackage{multirow}
\usepackage{adjustbox}
\usepackage{amsbsy}
\usepackage{subfig}
\usepackage{multicol}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{amsbsy}
\usepackage{subfig}
\usepackage{booktabs}
\begin{document}
\begin{figure}[!htb] 
  \centering 
  \begin{tabular}{l}
  \subfloat[]{\adjustbox{raise=-5pc}{\includegraphics[height=4.5cm]{Figures/goldmine} \label{fig:goldmineGraphic}}}
    \subfloat[]{
      %\input{Figures/Tikz/goldMineState.tex}\label{fig:goldMineState}}  
      \begin{tabular}{ll}
    \toprule
    Object & Attributes \\
    \midrule
    $miner1$ & $x=0,y=1$ \\
    $miner2$ & $x=1,y=3$ \\
    $miner3$ & $x=4,y=3$ \\
    $gold1$ & $x=1,y=0$ \\
    \multicolumn{2}{c}{$\vdots$} \\
    $gold6$ & $x=4,y=2$ \\
    $wall1$ & $x=1,y=1,pos=S$ \\
    \multicolumn{2}{c}{$\vdots$}\\
    $wall24$ & $x=4,y=4,pos=E$ \\
    \bottomrule
  \end{tabular}}
  \end{tabular}
 \caption{AA}
 \label{fig:goldmine}
\end{figure}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.