2

Inserting a table at the beginning of an itemize environment creates an unwanted spacing. How do i prevent this?

\begin{frame}
\footnotesize
\textbf{Aufgabe:\hspace{3mm}Zweidimensionale diskrete    
 Zufallsvariablen}\\[3mm]
  \begin{itemize}
\item[a)] \begin{table}[H]
\centering
\renewcommand{\arraystretch}{1.3}
    \begin{tabular}{|C{1.5cm}||C{1cm}|C{1cm}|C{1cm}||C{1.5cm}|} \hline
         $X \ \textbackslash \ Y$  & $y_1=0$  & $y_2=1$ & $y_3=2$ & $f_X(x_i)$      \\ \hline\hline 
         $x_1=2$               & (1)      & $0,08$  & $0,04$  & $0,4$      \\ \hline    
         $x_2=4$               & $0,14$   & (7)     & (3)     & $0,2$   \\  \hline  
         $x_3=6$               & (2)      & (5)     & $0,04$  & (4)   \\    \hline\hline    
         $f_Y(y_j)$            & $0,7$    & (6)     & $0,1$   & $1$   \\    \hline  
    \end{tabular}
  \end{table}
  \end{itemize}
  \end{frame} 

enter image description here

  • Welcome to TeX SX! What spacing? – Bernard Jul 12 '16 at 19:32
2

There is no need to use a table environment when you want to set a tabular. So, set it as-is, without the use of \centering:

enter image description here

\documentclass{beamer}

\usepackage{array,booktabs}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}

\begin{document}

\begin{frame}
  \footnotesize
  \textbf{Aufgabe:\hspace{3mm}Zweidimensionale diskrete    
  Zufallsvariablen}

  \begin{itemize}
    \item[a)]
      \begin{tabular}{|C{1.5cm}||C{1cm}|C{1cm}|C{1cm}||C{1.5cm}|} \hline
        $X \setminus Y$  & $y_1=0$  & $y_2=1$ & $y_3=2$ & $f_X(x_i)$ \\ \hline\hline
        $x_1=2$          & (1)      & $0,08$  & $0,04$  & $0,4$      \\ \hline
        $x_2=4$          & $0,14$   & (7)     & (3)     & $0,2$      \\ \hline
        $x_3=6$          & (2)      & (5)     & $0,04$  & (4)        \\ \hline\hline
        $f_Y(y_j)$       & $0,7$    & (6)     & $0,1$   & $1$        \\ \hline
      \end{tabular}

    \item[b)]
      \begin{tabular}{ C{1.5cm} *{3}{C{1cm}} C{1.5cm} }
        \toprule
        $X \setminus Y$  & $y_1=0$  & $y_2=1$ & $y_3=2$ & $f_X(x_i)$ \\
        \midrule
        $x_1=2$          & (1)      & $0.08$  & $0.04$  & $0.4$      \\
        $x_2=4$          & $0.14$   & (7)     & (3)     & $0.2$      \\
        $x_3=6$          & (2)      & (5)     & $0.04$  & (4)        \\
        \bottomrule
        $f_Y(y_j)$       & $0.7\phantom{0}$    & (6)     & $0.1\phantom{0}$   & $1$        \\
      \end{tabular}

  \end{itemize}

\end{frame}

\end{document}

I've suggested some alternatives to your tabular in my \item[b)] using booktabs, for example.


Vertical alignment of the \item with the tabulars could be achieved using some raising:

enter image description here

\documentclass{beamer}

\usepackage{array,booktabs}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}

\begin{document}

\begin{frame}
  \footnotesize
  \textbf{Aufgabe:\hspace{3mm}Zweidimensionale diskrete    
  Zufallsvariablen}

  \begin{itemize}
    \item[a)]
      \raisebox{\dimexpr.7\baselineskip+.4pt}{\begin{tabular}[t]{|C{1.5cm}||C{1cm}|C{1cm}|C{1cm}||C{1.5cm}|} \hline
        $X \setminus Y$  & $y_1=0$  & $y_2=1$ & $y_3=2$ & $f_X(x_i)$ \\ \hline\hline
        $x_1=2$          & (1)      & $0,08$  & $0,04$  & $0,4$      \\ \hline
        $x_2=4$          & $0,14$   & (7)     & (3)     & $0,2$      \\ \hline
        $x_3=6$          & (2)      & (5)     & $0,04$  & (4)        \\ \hline\hline
        $f_Y(y_j)$       & $0,7$    & (6)     & $0,1$   & $1$        \\ \hline
      \end{tabular}}

    \item[b)]
      \raisebox{\dimexpr\aboverulesep+\heavyrulewidth+\belowrulesep+.5\baselineskip}{\begin{tabular}[t]{ C{1.5cm} *{3}{C{1cm}} C{1.5cm} }
        \toprule
        $X \setminus Y$  & $y_1=0$  & $y_2=1$ & $y_3=2$ & $f_X(x_i)$ \\
        \midrule
        $x_1=2$          & (1)      & $0.08$  & $0.04$  & $0.4$      \\
        $x_2=4$          & $0.14$   & (7)     & (3)     & $0.2$      \\
        $x_3=6$          & (2)      & (5)     & $0.04$  & (4)        \\
        \bottomrule
        $f_Y(y_j)$       & $0.7\phantom{0}$    & (6)     & $0.1\phantom{0}$   & $1$        \\
      \end{tabular}}

  \end{itemize}

\end{frame}

\end{document}
1

Is this what you want? I raised the table by \arraystretch × 0.7\baselineskip (the height of a row in the table above the baseline). I slightly improved the look of tthe table using hhline:

\documentclass{beamer}
\usepackage{array, hhline}

\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}

\begin{document}

\begin{frame}
\footnotesize
\textbf{Aufgabe:\hspace{3mm}Zweidimensionale diskrete
 Zufallsvariablen}\\[3mm]
  \begin{itemize}
\item[a)]\raisebox{0.91\baselineskip}
{\renewcommand{\arraystretch}{1.3}
    \begin{tabular}[t]{|C{1.5cm}||C{1cm}|C{1cm}|C{1cm}||C{1.5cm}|}
         \hhline{-||---||-} 
         $X \ \textbackslash \ Y$ & $y_1=0$ & $y_2=1$ & $y_3=2$ & $f_X(x_i)$ \\ 
         \hhline{:=::===::=:}
         $x_1=2$ & (1) & $0,08$ & $0,04$ & $0,4$ \\ 
         \hhline{-||---||-}
         $x_2=4$ & $0,14$ & (7) & (3) & $0,2$ \\
         \hhline{-||---||-}
         $x_3=6$ & (2) & (5) & $0,04$ & (4) \\
         \hhline{:=::===::=:}
         $f_Y(y_j)$ & $0,7$ & (6) & $0,1$ & $1$ \\
         \hhline{-||---||-} 
    \end{tabular}}
  \end{itemize}
  \end{frame}

  \end{document} 

enter image description here

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.