我想增加以下数组表中的行距,该怎么办?
\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}
答案1
答案2
使用,您可以选择设置每个单元格上方和下方的最小空间。此外,键{NiceArray}
会绘制所有规则。nicematrix
cell-space-limits
hvlines
\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}
答案3
使用cellspace
包与\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}