Search code examples
imagelatextabularbeamer

Too much space after first line in table in beamer class


I'm working in Latex beamer class and have a table environment in there. For some reason the space between the 1st and the 2nd line is huge and I have no idea where that comes from. Here's my code:

\documentclass{beamer}
\usepackage{beamerthemeshadow}
\usepackage{longtable}
\usepackage[ngerman, english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\setbeamertemplate{caption}{\insertcaption} \setbeamertemplate{caption label separator}{}
\begin{document}
\frame{
\begin{table}
\begin{tabular}{|p{1,5cm}||p{1,5cm}|p{1,5cm}|p{1,5cm}|p{1,5cm}|p{1,5cm}|}\\
& \begin{figure}
\includegraphics[width=0.7\linewidth]{CDUCSU.png}
\caption{}
\label{fig:CDUCSU.png}
\end{figure} &

\begin{figure}
\includegraphics[width=0.7\linewidth]{SPD_logo_svg.png}
\caption{}
\label{fig:SPD.png}
\end{figure} & 


\begin{figure}
\includegraphics[width=0.7\linewidth]{Gruene.png}
\caption{}
\label{fig:Gruene.png}
\end{figure}&

\begin{figure}
\includegraphics[width=0.7\linewidth]{Linke.png}
\caption{}
\label{fig:Linke.png}
\end{figure}


&
\begin{figure}
\includegraphics[width=0.5\linewidth]{Piraten.png}\caption{}\label{fig:Piraten.png}\end{figure} \\\hline
Definition &&&&& \\\hline
political standpoint&&&&& no priorization of data. No  \\
\end{tabular}
\end{table}
}
\end{document}

What I get is this. Output of Latex Table with too much space between logos and next row

Any idea how I can reduce the space between the logos and the next row?

Help is very much appreciated!


Solution

  • There is no need to use a figure environment in order to insert a figure into your document. The figure environment is merely a floating box that has a caption set to Figure and that's that. You can even place a tabular inside a figure environment, or just text, or just a caption...

    In that sense, since you're not using the \caption, you should just use

    enter image description here

    \documentclass{beamer}
    \usepackage{beamerthemeshadow}
    \usepackage{tabularx}
    \begin{document}
    
    \begin{frame}
      \begin{tabularx}{\textwidth}{|p{1.5cm}|| *{5}{X|} }
        & \includegraphics[width=0.7\linewidth]{example-image-a}
          & \includegraphics[width=0.7\linewidth]{example-image-b}
          & \includegraphics[width=0.7\linewidth]{example-image-c}
          & \includegraphics[width=0.7\linewidth]{example-image-a}
          & \includegraphics[width=0.5\linewidth]{example-image-b} \\
        \hline
        Definition & & & & & \\
        \hline
        Political standpoint & & & & & no priorization of data. No
      \end{tabularx}
    \end{frame}
    
    \end{document}
    

    Note that I've used tabularx in order to have a tabular that has a fixed width (\textwidth) without having to specify the column widths for columns 2-6. The X-column figures out exactly how wide they should be in order to fit the entire tabularx into \textwidth. You don't have to do this, but it makes for a consistently nice view.

    Also, length specifications require a period for decimals. That is, 1.5cm, not 1,5cm.


    Of course, the same discussion above holds for the table environment. There's no need to use a table environment if you want to place a tabular (my code shows this).