[Tex/LaTex] Booktabs: Vertically align to top for p{…}-formatted columns

booktabstables

I have a table that looks like this.

enter image description here

The latex code for the column definitions is the following:

\begin{tabular}{lp{4cm}cccccc}

How can I align the text in the second column with property p{4cm} vertically to the top in order to make the rows smaller?

The code below shows a MWE that produces exactly the error i mean:

\documentclass[a4paper, 8pt]{extarticle}

\usepackage{booktabs}

\usepackage[margin=0.5cm,landscape]{geometry}

\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{amssymb}

\newcommand{\cW}{\mathcal{W}}
\newcommand{\N}{\mathbb{N}}

\newcommand{\Prob}[1]{P\left[#1\right]}
\newcommand{\Exp}[1]{Exp\left[#1\right]}
\newcommand{\Var}[1]{Var\left[#1\right]}
\newcommand{\riid}{\stackrel{\text{i.i.d}}{\sim}}
\newcommand{\set}[1]{\left\{ #1 \right\}}
\newcommand{\dset}[2]{\left\{ #1 \ \middle| \ #2 \right\}}

\begin{document}


\begin{tabular}{lp{4cm}cccccc}
\toprule
\textbf{Verteilung $\mu_X$}&
\textbf{Beschrieb von $X$} &
\textbf{$X=$} & 
\textbf{$\cW(X)=$} & 
\begin{tabular}{c}
\textbf{Gewichtsfunktion}\\
\textbf{$p_X(k)=\Prob{X=k}=$}
\end{tabular} &
\begin{tabular}{c}
\textbf{Verteilungsfunktion}\\
\textbf{$F_X(t)=\Prob{X\leq t}=$}
\end{tabular} &
\textbf{$\Exp{X}=$} & 
\textbf{$\Var{X}=$}
\\
\midrule
\vdots
\\
\hline
\begin{tabular}{c}
Binomial\\
$\displaystyle X\sim Bin(n,p)$
\end{tabular} 
& 
Anzahl der Erfolge $X$ bei $n$ unabhängigen 0-1-Experimenten mit
Erfolgsparameter $p$.
&
\begin{tabular}{c}
$\displaystyle \sum_{i=1}^{n} I_{A_i} =\sum_{i=1}^{n}Y_i$ \\
Sind die ZV $Y_1,\ldots,Y_n\riid Be(p)$, \\
so ist $X:=Y_1+\cdots+Y_n\sim Bin(n,p)$.
\end{tabular}
&
$\displaystyle \set{0,1,\ldots,n}$ 
&
$\displaystyle \binom{n}{k}p^k(1-p)^{n-k}$ 
&
$\displaystyle \sum_{k=0}^t \binom{n}{k}p^k(1-p)^{n-k}$ 
&
$np$ 
&
$np(1-p)$ 
\\
\hline
\begin{tabular}{c}
Geometrisch\\
$\displaystyle X\sim Geom(p)$ \\
\\
``gedächtnislos''
\end{tabular} &
Wartezeit $X$ auf den ersten Erfolg bei einer unendlichen Folge von
0-1-Experimenten mit Erfolgsparameter $p$. Spezialfall von $NB(1,p)$ 
&
\begin{tabular}{c}
$\inf\dset{i\in\N}{A_i\text{ tritt ein}}$\\
$=\inf\dset{n\in\N}{Y_i=1}$
\end{tabular} &
$\set{1,2,3,\ldots}$ &
$(1-p)^{k-1}p$ &
$1-(1-p)^t$ &
$\displaystyle \frac{1}{p}$ &
$\displaystyle \frac{1-p}{p^2}$
\\\hline
\vdots
\\\bottomrule
\end{tabular}


\end{document}

Best Answer

The problem is all the nested \begin{tabular}{c} inside your outer table, tabular are by default vertically centred which is what you show in your image, You could use \begin{tabular}[t]{c} so the inner tabular are top aligned (or better, \begin{tabular}[t]{@{}c@{}} so they don't add horizontal padding, but just removing all the inner tabular would be preferable.

enter image description here

I fixed several other errors in the example, undefined commands and using math italic for operators such as Exp.

\documentclass[a4paper, 8pt]{extarticle}

\usepackage{booktabs}

\usepackage[margin=0.5cm,landscape]{geometry}

\usepackage{mathtools}
\usepackage{amsmath,amsfonts}

\newcommand{\cW}{\mathcal{W}}

\newcommand{\Prob}[1]{P\left[#1\right]}
\newcommand{\Exp}[1]{\operatorname{Exp}\left[#1\right]}
\newcommand{\Var}[1]{\operatorname{Var}\left[#1\right]}
\newcommand{\riid}{\stackrel{\text{i.i.d}}{\sim}}
\newcommand{\set}[1]{\left\{ #1 \right\}}
\newcommand{\dset}[2]{\left\{ #1 \ \middle| \ #2 \right\}}
\DeclareMathOperator\Bin{\mathrm{Bin}}
\newcommand\N{\mathbb{N}}
\begin{document}


\begin{tabular}{lp{4cm}cccccc}
\toprule
\textbf{Verteilung $\mu_X$}&
\textbf{Beschrieb von $X$} &
\textbf{$X=$} & 
\textbf{$\cW(X)=$} & 
\begin{tabular}[t]{@{}c@{}}
\textbf{Gewichtsfunktion}\\
\textbf{$p_X(k)=\Prob{X=k}=$}
\end{tabular} &
\begin{tabular}[t]{@{}c@{}}
\textbf{Verteilungsfunktion}\\
\textbf{$F_X(t)=\Prob{X\leq t}=$}
\end{tabular} &
\textbf{$\Exp{X}=$} & 
\textbf{$\Var{X}=$}
\\
\midrule
\vdots
\\
\hline
\begin{tabular}[t]{c}
Binomial\\
$\displaystyle X\sim \Bin(n,p)$
\end{tabular} 
& 
Anzahl der Erfolge $X$ bei $n$ unabhängigen 0-1-Experimenten mit
Erfolgsparameter $p$.
&
\begin{tabular}[t]{@{}c@{}}
$\displaystyle \sum_{i=1}^{n} I_{A_i} =\sum_{i=1}^{n}Y_i$ \\
Sind die ZV $Y_1,\ldots,Y_n\riid Be(p)$, \\
so ist $X:=Y_1+\cdots+Y_n\sim Bin(n,p)$.
\end{tabular}
&
$\displaystyle \set{0,1,\ldots,n}$ 
&
$\displaystyle \binom{n}{k}p^k(1-p)^{n-k}$ 
&
$\displaystyle \sum_{k=0}^t \binom{n}{k}p^k(1-p)^{n-k}$ 
&
$\displaystyle np$ 
&
$np(1-p)$ 
\\
\hline
\begin{tabular}[t]{c}
Geometrisch\\
$\displaystyle X\sim Geom(p)$ \\
\\
``gedächtnislos''
\end{tabular} &
Wartezeit $X$ auf den ersten Erfolg bei einer unendlichen Folge von
0-1-Experimenten mit Erfolgsparameter $p$. Spezialfall von $NB(1,p)$ &
\begin{tabular}[t]{@{}c@{}}
$\displaystyle\inf\dset{i\in\N}{A_i\text{ tritt ein}}$\\
$\displaystyle{}=\inf\dset{n\in\N}{Y_i=1}$
\end{tabular} &
$\displaystyle\set{1,2,3,\ldots}$ &
$\displaystyle(1-p)^{k-1}p$ &
$\displaystyle1-(1-p)^t$ &
$\displaystyle \frac{1}{p}$ &
%???$\displaystyle \frac{1-p}{p^2}$ &
\\\hline
\vdots
\\\bottomrule
\end{tabular}


\end{document}

Or perhaps, despite the question title, you suggest in comments you really wanted centre alignment:

enter image description here

\documentclass[a4paper, 8pt]{extarticle}

\usepackage{booktabs,array}

\usepackage[margin=0.5cm,landscape]{geometry}

\usepackage{mathtools}
\usepackage{amsmath,amsfonts}

\newcommand{\cW}{\mathcal{W}}

\newcommand{\Prob}[1]{P\left[#1\right]}
\newcommand{\Exp}[1]{\operatorname{Exp}\left[#1\right]}
\newcommand{\Var}[1]{\operatorname{Var}\left[#1\right]}
\newcommand{\riid}{\stackrel{\text{i.i.d}}{\sim}}
\newcommand{\set}[1]{\left\{ #1 \right\}}
\newcommand{\dset}[2]{\left\{ #1 \ \middle| \ #2 \right\}}
\DeclareMathOperator\Bin{\mathrm{Bin}}
\newcommand\N{\mathbb{N}}
\begin{document}


\begin{tabular}{lm{4cm}cccccc}
\toprule
\textbf{Verteilung $\mu_X$}&
\textbf{Beschrieb von $X$} &
\textbf{$X=$} & 
\textbf{$\cW(X)=$} & 
\begin{tabular}[c]{@{}c@{}}
\textbf{Gewichtsfunktion}\\
\textbf{$p_X(k)=\Prob{X=k}=$}
\end{tabular} &
\begin{tabular}[c]{@{}c@{}}
\textbf{Verteilungsfunktion}\\
\textbf{$F_X(t)=\Prob{X\leq t}=$}
\end{tabular} &
\textbf{$\Exp{X}=$} & 
\textbf{$\Var{X}=$}
\\
\midrule
\vdots
\\
\hline
\begin{tabular}[c]{c}
Binomial\\
$\displaystyle X\sim \Bin(n,p)$
\end{tabular} 
& 
Anzahl der Erfolge $X$ bei $n$ unabhängigen 0-1-Experimenten mit
Erfolgsparameter $p$.
&
\begin{tabular}[c]{@{}c@{}}
$\displaystyle \sum_{i=1}^{n} I_{A_i} =\sum_{i=1}^{n}Y_i$ \\
Sind die ZV $Y_1,\ldots,Y_n\riid Be(p)$, \\
so ist $X:=Y_1+\cdots+Y_n\sim Bin(n,p)$.
\end{tabular}
&
$\displaystyle \set{0,1,\ldots,n}$ 
&
$\displaystyle \binom{n}{k}p^k(1-p)^{n-k}$ 
&
$\displaystyle \sum_{k=0}^t \binom{n}{k}p^k(1-p)^{n-k}$ 
&
$\displaystyle np$ 
&
$np(1-p)$ 
\\
\hline
\begin{tabular}[c]{c}
Geometrisch\\
$\displaystyle X\sim Geom(p)$ \\
\\
``gedächtnislos''
\end{tabular} &
Wartezeit $X$ auf den ersten Erfolg bei einer unendlichen Folge von
0-1-Experimenten mit Erfolgsparameter $p$. Spezialfall von $NB(1,p)$ &
\begin{tabular}[c]{@{}c@{}}
$\displaystyle\inf\dset{i\in\N}{A_i\text{ tritt ein}}$\\
$\displaystyle{}=\inf\dset{n\in\N}{Y_i=1}$
\end{tabular} &
$\displaystyle\set{1,2,3,\ldots}$ &
$\displaystyle(1-p)^{k-1}p$ &
$\displaystyle1-(1-p)^t$ &
$\displaystyle \frac{1}{p}$ &
%???$\displaystyle \frac{1-p}{p^2}$ &
\\\hline
\vdots
\\\bottomrule
\end{tabular}


\end{document}
Related Question