5

I use the following code, which I modified from the code I found here (second example), to place a table next to a figure.

However, in comparison to the example linked above, I would like to have the figure caption be placed on the bottom of the figure and the table caption on the top of the table, while both should be aligned correctly at the bottom. So the figure caption should be aligned with the bottom of the table.

Unfortunatly, the following code shifts the table and the figure vertically, such that they are not aligned.

How can I fix that?

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}

\begin{document}
  \begin{minipage}{\textwidth}
  \begin{minipage}[b]{0.49\textwidth}
    \centering
    \rule{6.4cm}{2.6cm} % Height changed from 3.6cm to 2.6cm
    \captionof{figure}{A table beside a figure}
  \end{minipage}
  \hfill
  \begin{minipage}[b]{0.49\textwidth}
    \centering
    \captionof{table}{A table beside a figure}
    \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}

Edit: Changed height of figure.

1
  • 2
    Does using \begin{minipage}[c] instead \begin{minipage}[b] for both minipages give more like what you want? Nov 11, 2018 at 6:39

2 Answers 2

6

Set the tabular to be aligned at the [b]aseline as well:

enter image description here

\documentclass{article}

\usepackage[
  font = small,
  labelfont = bf,
  tableposition = top
]{caption}

\begin{document}

\noindent
\begin{minipage}{\textwidth}
  \begin{minipage}[b]{0.49\textwidth}
    \centering
    \rule{5.5cm}{2.6cm} % Height changed from 3.6cm to 2.6cm
    \captionof{figure}{A table beside a figure}
  \end{minipage}
  \hfill
  \begin{minipage}[b]{0.49\textwidth}
    \centering
    \captionof{table}{A table beside a figure}
    \begin{tabular}[b]{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}
0
1

I was able to crack this in one of my own documents and wanted to post it here. The part that took me a long time to figure out was the H tag on the figure.

\begin{table*}
    \begin{minipage}{0.65\linewidth}
        \caption{Table Caption.}
        \label{table:mytable}
        \centering

\begin{tabular}{|l|l|l|l|l|}
\hline
(TABLE GOES HERE)
\end{tabular}


    \end{minipage}
    \begin{minipage}{0.4\linewidth}
    \begin{figure}[H]
        \centering
            \includegraphics[width=.9\textwidth]{figs/myfig.png}
            
    \caption{Figure caption goes here.}
    }
    \label{fig:label}
    \end{figure}
    \end{minipage}
    
\end{table*}

You must log in to answer this question.

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