0

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}
4
  • 1
    Please post the code you used to generate the screenshot.
    – Mico
    Jan 18, 2016 at 13:35
  • I've now added a MWE that produces exactly the error I posted a screen shot of.
    – ndrizza
    Jan 18, 2016 at 13:51
  • Your example produces errors: ! Undefined control sequence. <argument> i\in \N l.77 $\inf\dset{i\in\N}{A_i\text{ tritt ein}} $\\ ? ! Undefined control sequence. <argument> n\in \N l.78 $=\inf\dset{n\in\N}{Y_i=1} $ ? ! Extra alignment tab has been changed to \cr. <recently read> \endtemplate l.84 $\displaystyle \frac{1-p}{p^2}$ & Jan 18, 2016 at 13:54
  • Thanks. I've fixed it. Now there shouldn't be any errors anymore.
    – ndrizza
    Jan 18, 2016 at 13:59

1 Answer 1

2

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}
5
  • Thank you. That fixed it. Now the text is upper aligned - just by adding [t].
    – ndrizza
    Jan 18, 2016 at 14:02
  • However, now the other cells aren't centered vertically anymore - apparently that happened just because the tabulars were vertically centered. Do you know how i can vertically center everything in a row and just vertially align to top one cell?
    – ndrizza
    Jan 18, 2016 at 14:03
  • Alternatively, how would you create multi-row cells (instead of tabulars)?
    – ndrizza
    Jan 18, 2016 at 14:04
  • @ndrizza I added a second version to the answer, take your pick:-) Jan 18, 2016 at 14:13
  • Thank you very much! The m-property on the tabular makes the table look nice!
    – ndrizza
    Jan 18, 2016 at 14:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .