![我想增加以下数组表中的行距,该怎么办?](https://linux22.com/image/475020/%E6%88%91%E6%83%B3%E5%A2%9E%E5%8A%A0%E4%BB%A5%E4%B8%8B%E6%95%B0%E7%BB%84%E8%A1%A8%E4%B8%AD%E7%9A%84%E8%A1%8C%E8%B7%9D%EF%BC%8C%E8%AF%A5%E6%80%8E%E4%B9%88%E5%8A%9E%EF%BC%9F.png)
我想增加以下数组表中的行距,该怎么办?
\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}