4

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.

  • 2
    Does using \begin{minipage}[c] instead \begin{minipage}[b] for both minipages give more like what you want? – David Purton Nov 11 '18 at 6:39
3

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}

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.