2

I want to increase the line spacing in the following array table, what should I do?

\documentclass{article}
\usepackage{amsmath, amssymb} 
\begin{document}
\[
 \begin{array}
 {|c|c|c|c|}
 \hline
 X & 1 & 2 & 3
 \\
 \hline
 \mathrm{p}(X=x_{i}) &
 \dfrac{1}{22} & \dfrac{9}{22} & \dfrac{6}{11}
 \\
 \hline
 \end{array}
 \]
 \end{document}
3
  • Do you want to increase the line spacing per se, or do you mainly want to get some visual separation between the cell contents and the horizontal rules? Please advise.
    – Mico
    Mar 24 at 14:37
  • Have you seen this answer to the query Inserting a small vertical space in a table?
    – Mico
    Mar 24 at 14:40
  • Do you really need the rules?
    – egreg
    Mar 24 at 23:32

3 Answers 3

3

A possible solution is to use the tabularray package:

\documentclass{article}

\usepackage{amsmath,amssymb,tabularray}

\begin{document}

\[
\begin{tblr}{cells=c,rowsep=3pt,hlines,vlines}
X & 1 & 2 & 3 \\
\operatorname{p}(X=x_{i}) & \dfrac{1}{22} & \dfrac{9}{22} & \dfrac{6}{11} \\
\end{tblr}
\]

\end{document}

enter image description here

2

With {NiceArray} of nicematrix, you have an option cell-space-limits to set a minimal space above and below each cell. Moreover, the key hvlines draws all the rules.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

\[
\begin{NiceArray}{cccc}[hvlines,cell-space-limits=3pt]
X & 1 & 2 & 3 \\
\mathrm{p}(X=x_{i}) & \dfrac{1}{22} & \dfrac{9}{22} & \dfrac{6}{11} \\
\end{NiceArray}
\]

\end{document}

Output of the above code

1
  • Thank you very much for your edit.
    – Sebastiano
    Apr 22 at 11:32
1

Using cellspace package with \setlength.

\documentclass{article}
\usepackage{amsmath, amssymb}
\usepackage{array} % for tabular environment
\usepackage{cellspace} % for adjusting cell spacing

% Set minimum vertical spacing above and below cells in the "S" columns
\setlength\cellspacetoplimit{3pt}
\setlength\cellspacebottomlimit{3pt}

\begin{document}

\[
\begin{array}{|Sc|Sc|Sc|Sc|}
\hline
$X$ & 1 & 2 & 3 \\
\hline
$\mathrm{p}(X=x_{i})$ & $\dfrac{1}{22}$ & $\dfrac{9}{22}$ & $\dfrac{6}{11}$ \\
\hline
\end{array}
\]

\end{document}

enter image description here

You must log in to answer this question.

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