2

I'm trying to align a table and a figure in Latex, but I`m not getting the results I want. I followed this answer : Table and figure side-by-side with independent captions

This is the code I used

\documentclass{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{standalone}

\usepackage{pgf}

\usepackage[font=small,labelfont=bf]{caption}
% Table float box with bottom caption, box width adjusted to content
\newfloatcommand{capbtabbox}{table}[][\FBwidth]

\begin{document}
\begin{minipage}{\textwidth}
  \begin{minipage}[b]{0.49\textwidth}
    \vspace{0pt}
    \centering
    \rule{6.4cm}{3.6cm}
  \end{minipage}
  \hfill
  \begin{minipage}[b]{0.49\textwidth}
    \vspace{0pt}
    \centering
    \begin{tabular}{cc}\hline
      Table head & Table head \\ \hline
        Some values & Some values \\
        Some values & Some values \\
        Some values & Some values \\
        Some values & Some values \\
        Some values & Some values \\
        Some values & Some values \\ \hline
      \end{tabular}
    \end{minipage}
  \end{minipage}
\end{document}

But this is what I get : enter image description here

David Carlisle
  • 757,742

1 Answers1

2

Your code features several unneeded minipage environments. Remove the "wrappers", and use the [t] positioning specifier for both the remaining minipage environment and the tabular environment.

enter image description here

\documentclass{article}
\usepackage[english]{babel}
\usepackage[font=small,labelfont=bf]{caption}

\begin{document}
\noindent
\begin{minipage}[t]{6.4cm}
    \vspace{0sp}
    \rule{\textwidth}{3.6cm}
\end{minipage}
\hfill
\begin{tabular}[t]{@{}cc@{}} 
        \hline
        Table head & Table head   \\ 
        \hline
        Some values & Some values \\
        Some values & Some values \\
        Some values & Some values \\
        Some values & Some values \\
        Some values & Some values \\
        Some values & Some values \\ 
        \hline
\end{tabular}
\end{document}
Mico
  • 506,678