1

Context : I am using the table environment to make a table. I'm using adjustbox to control the width of my table. Here is what my code looks like :

   \begin{table}[htbp!]
    \begin{adjustbox}{width=\textwidth}
        \renewcommand{\arraystretch}{2.5}
        \begin{tabular}{|M{3.5cm}|M{3cm}|M{5cm}|M{4.5cm}|M{3cm}|}
            \hline
            \textsc{Loi} & \textsc{Paramètre(s)} & $\mathbb{P}(X = k)$ & \textsc{Moments} & $\vfi_X(t)$ \\[0.2cm]
            \hline
            \hline
            Uniforme $\mathcal{U}(E)$ & $E = (x_k)_{1 \lleq k \lleq n}$ & $\mathbb{P}(X = x_k) = \dfrac{1}{n}$ & $\mathbb{E}(X) = (n+1)(2n+1)/6$ $\text{Var}(X)=(n^2-1)/12$ & \\[0.3cm]
            \hline 
            Bernoulli $\mathcal{B}(p)$ & $p \in\ ]0,1[$ & $\mathbb{P}(X=1)=p$ $\mathbb{P}(X=0)=1-p$ & $\mathbb{E}(X) = p$ $\text{Var}(X)=p(1-p)$ & $1-p+pe^{it}$ \\[0.3cm]
            \hline 
            Binomiale $\mathcal{B}(n,p)$ & $p \in\ ]0,1[$, $n \in \N^*$ & $\di\binom{k}{n}p^k(1-p)^{n-k}$, $0 \lleq k \lleq n$ & $\mathbb{E}(X) = np$ $\text{Var}(X)=np(1-p)$ & $\left(1-p+pe^{it}\right)^n$\\[0.3cm]
            \hline 
            Géométrique $\mathcal{G}(p)$ & $p \in\ ]0,1[$ & $p(1-p)^{k-1}$, $k \ggeq 1$ & $\mathbb{E}(X) = \dfrac{1}{p}$ $\text{Var}(X)=(1-p)/p^2$ & $\dfrac{pe^{it}}{1-(1-p)e^{it}}$\\[0.7cm]
            \hline 
            Poisson $\mathcal{P}(\lambda)$ & $\lambda > 0$ & $\dfrac{\lambda^k}{k!}e^{-\lambda}$, $k \ggeq 0$ & $\mathbb{E}(X) = \lambda$, $\text{Var}(X)=\lambda$ & $e^{\lambda(e^{it}-1)}$\\[0.1cm]
            \hline 
        \end{tabular}
    \end{adjustbox}
\end{table}

Here $M$ is defined as follow : \newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}. It allows me to have line changes when a text is too long inside a cell. It's kinda messy, but it works.

My problem : Line spacing inside my table is too small, making things hard to read. Here is an picture of what I get with the previous code :

Cells in yellow are problematic

Searching for some time didn't get me anywhere, as any promising answer had little to no effect to my table. Maybe the setspace package can be of some help, but nothing is working thus far and I can't find the documentation on CTAN.

I welcome every suggestion. Thanks for your time.

1
  • 1
    scaling tables with adjustbox or resizebox etc is evil, only use in a last resort (and even then avoid it if possible) it leads to inconsistent font sizes and rule widths, better to choose an appropriate font size such as \small or \footnotesize so that you can arrange a consistent typesetting. Commented Oct 26, 2021 at 18:20

1 Answer 1

1

I know it's not really an answer to your question, but I would not use adjustwidth that will squeeze the table with no control on the font size.

I removed the vertical rules that give no information and use simply c columns, with a trick for splitting some cells into two lines, generously spaced.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{amsmath,amssymb}
\usepackage{booktabs}
\usepackage{array}

\newcolumntype{M}[1]{w{c}{#1}}
\newcommand{\vfi}{\varphi}
\newcommand{\lleq}{\leqslant}
\newcommand{\ggeq}{\geqslant}
\newcommand{\N}{\mathbb{N}}
\DeclareMathOperator{\Var}{Var}

\newcommand{\splitcell}[1]{%
  \renewcommand{\arraystretch}{1.5}%
  \begin{tabular}{@{}c@{}}#1\end{tabular}%
}

\begin{document}

\begin{table}[htbp!]

\scriptsize
\setlength{\tabcolsep}{0pt}
\begin{tabular}{@{\extracolsep{\fill}}lcccc@{}}
\toprule
\multicolumn{1}{c}{\textsc{Loi}}
& \textsc{Paramètre(s)}
& $\mathbb{P}(X = k)$
& \textsc{Moments}
& $\vfi_X(t)$
\\
\midrule
Uniforme $\mathcal{U}(E)$
& $E = (x_k)_{1 \lleq k \lleq n}$
& $\mathbb{P}(X = x_k) = \dfrac{1}{n}$
& \splitcell{$\mathbb{E}(X) = (n+1)(2n+1)/6$ \\ $\Var(X)=(n^2-1)/12$}
&
\\
\midrule
Bernoulli $\mathcal{B}(p)$
& $p \in \mathopen]0,1\mathclose[$
& \splitcell{$\mathbb{P}(X=1)=p$ \\ $\mathbb{P}(X=0)=1-p$}
& \splitcell{$\mathbb{E}(X) = p$ \\ $\Var(X)=p(1-p)$}
& $1-p+pe^{it}$
\\
\midrule
Binomiale $\mathcal{B}(n,p)$
& \splitcell{$p \in \mathopen]0,1\mathclose[$, \\ $n \in \N^*$}
& \splitcell{$\binom{k}{n}p^k(1-p)^{n-k}$, \\ $0 \lleq k \lleq n$}
& \splitcell{$\mathbb{E}(X) = np$ \\ $\Var(X)=np(1-p)$}
& $(1-p+pe^{it})^n$
\\
\midrule
Géométrique $\mathcal{G}(p)$
& $p \in \mathopen]0,1\mathclose[$
& $p(1-p)^{k-1}$, $k \ggeq 1$
& \splitcell{$\mathbb{E}(X) = 1/p$ \\ $\Var(X)=(1-p)/p^2$}
& $\dfrac{pe^{it}}{1-(1-p)e^{it}}$
\\
\midrule
Poisson $\mathcal{P}(\lambda)$
& $\lambda > 0$
& $\dfrac{\lambda^k}{k!}e^{-\lambda}$, $k \ggeq 0$
& \splitcell{$\mathbb{E}(X) = \lambda$, \\ $\Var(X)=\lambda$}
& $e^{\lambda(e^{it}-1)}$
\\
\bottomrule
\end{tabular}

\end{table}

\end{document}

Depending on your textwidth you might be able to use \footnotesize instead of \scriptsize.

Note the changes, namely \Var instead of the wrong \text{Var} and the typesetting of French-style open intervals.

enter image description here

You must log in to answer this question.

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