2

I am trying to center a table containing 4 images and a foot note in beamer (the lines are only for debug). This is the code I am using:

\documentclass[]{beamer}

\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc} % acentos
\usepackage{listings} % incluir código
\usepackage{caption}  % titulos para los listings
\usepackage{color}
\begin{document}
\begin{frame}
    \begin{centering}
        \begin{tabular}{ | r | l | }
            \includegraphics[width=0.325\textwidth]{img/g2} &
            \includegraphics[width=0.325\textwidth]{img/g2Isodata} \\
            \includegraphics[width=0.325\textwidth]{img/g2Huang} &
            \includegraphics[width=0.325\textwidth]{img/g2Default} \\
            \multicolumn{2}{p{\dimexpr\textwidth-\tabcolsep\relax}}{\tiny \center Imagen binarizada mediante el algoritmo Isodata (arriba a la derecha), el algoritmo de Huang (abajo a la izquierda) y el algoritmo por defecto (abajo a la derecha)} \\

        \end{tabular}
    \end{centering}
\end{frame}
\end{document}

This is however the result I am getting:

enter image description here

I dont understand why it behaves that way. How can I properly center that table?

5
  • Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – user31729
    Sep 7 '14 at 22:34
  • Your images seem to be too large, as the caption overlaps the navigation bar!
    – user31729
    Sep 7 '14 at 22:34
  • @ChristianHupfer all the images are the same size, and they dont have any white margins. What I don't understand is why the table is not horizantaly centered
    – José D.
    Sep 7 '14 at 22:38
  • \centering is a command, not an environment. Remove \end{centering} (This does not solve the problem, however)
    – user31729
    Sep 7 '14 at 22:41
  • Why does the second column behaves like if it had to extend to the full size of the page? (this is what happens with smaller images, btw i.imgur.com/0dENSzi.png)
    – José D.
    Sep 7 '14 at 22:43
2

It's the \multicolumn command, i.e. the parbox in it -- the OP used basically the whole \textwidth for the width of that \multicolumn.

Since both images have 0.325\textwidth, it's basically sufficient to use 0.65\textwidth for the \parbox. (Not taking into account any other \tabcolsep)

I added some 'improvements' -- remove demo from the options to the beamer class for production run!

\documentclass[demo]{beamer}

\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc} % acentos
\usepackage{calc}%
\usepackage{listings} % incluir código
\usepackage{caption}  % titulos para los listings
\usepackage{color}
\begin{document}
\begin{frame}
  \begin{center}
    \begin{tabular}{| c | c |}
      \includegraphics[width=0.325\textwidth]{img/g2} &
      \includegraphics[width=0.325\textwidth]{img/g2Isodata} \tabularnewline
      \includegraphics[width=0.325\textwidth]{img/g2Huang} &
      \includegraphics[width=0.325\textwidth]{img/g2Default} \tabularnewline
      \multicolumn{2}{p{0.65\textwidth-\tabcolsep}}{\tiny \centering Imagen binarizada mediante el algoritmo Isodata (arriba a la derecha), el algoritmo de Huang (abajo a la izquierda) y el algoritmo por defecto (abajo a la derecha)}
    \end{tabular}
\end{center}
\end{frame}
\end{document}

enter image description here

0

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.