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

  • 2
    you want [t] aligned minipages not [b] so they both align on the vspace{0pt} (which otherwise is doing nothing) – David Carlisle Mar 12 '19 at 21:23
  • Welcome to TeX SX! Try replacing [b]with [t]. – Bernard Mar 12 '19 at 21:24
  • Thank you @Bernard , it works – Liam F-A Mar 12 '19 at 21:37
  • It should also be noted that [t] and [b] select the baseline of the first and last lines in a minipage or tabular. Hence the \vspace in Mico's solution aligns with the \hline in the tabular. \raisebox has more control. – John Kormylo Mar 13 '19 at 5:11
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}

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.