请教一下这里面的内容怎么设置成等宽?

发布于 2021-05-04 20:53:14

请教一下这里面的内容怎么设置成等宽,现在每一列的宽度都不一样

3a9498836fcbecee12acf3f642cd7914.png

查看更多

关注者
0
被浏览
1.3k
4 个回答
阿巴阿巴666
阿巴阿巴666 2021-05-04
这家伙很懒,什么也没写!
\begin{tabular}{ccccccc}
\hline
$n$&$1$&$2$&$3$&$4$&5&6\\
\hline
$Na^{\scriptscriptstyle{+}}$&$3$&$4$&$5$&$6$&6&7\\   
$K^{\scriptscriptstyle{+}}$&$2$&$4$&$5$&$7$&7.2&8\\
$Ca^{\scriptscriptstyle{2+}}$&$9$&$10$&$10.5$&$11.2$&11.5&11.9\\
\hline
\end{tabular}
啸行
啸行 2021-05-04
这家伙很懒,什么也没写!
\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage[version=4]{mhchem}
\usepackage{array}
\begin{document}
\begin{tabularx}{1\linewidth}{*{7}{>{\centering\arraybackslash}X}}
    \toprule
    \(n\) & 1 & 2 & 3 & 4 & 5 & 6\\
    \midrule
    \ce{Na^+} & 3 & 4 & 5 & 6 & 6 & 7\\
    \ce{K^+} & 2 & 4 & 5 & 7 & 7.2 & 8\\
    \ce{Ca^2+} & 9 & 10 & 10.5 & 11.2 & 11.5 & 11.9\\
    \bottomrule
\end{tabularx}
\end{document}

image.png

行者
行者 2021-05-04
这家伙很懒,什么也没写!
\documentclass{standalone}
\usepackage{nicematrix}
\begin{document}
\begin{NiceTabular}[columns-width = 1cm]{ccccccc}
\hline
$n$&$1$&$2$&$3$&$4$&5&6\\
\hline
$Na^{\scriptscriptstyle{+}}$&$3$&$4$&$5$&$6$&6&7\\
$K^{\scriptscriptstyle{+}}$&$2$&$4$&$5$&$7$&7.2&8\\
$Ca^{\scriptscriptstyle{2+}}$&$9$&$10$&$10.5$&$11.2$&11.5&11.9\\
\hline
\end{NiceTabular}
\end{document}
LaTeXStudio
LaTeXStudio 2021-05-04
这家伙很懒,什么也没写!

用 tabularx 即可,参考代码,如果用 Y 参数就是居中对齐,如果是 X 参数就是左对齐,自己选择吧:

\documentclass{ctexart}
\usepackage{amsmath}
\usepackage{array,tabularx}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\begin{document}
\begin{tabularx}{10cm}{YYYYYYY}
\hline
$n$&$ 1$&$ 2$&$ 3$&$4$&5&6\\
\hline
$Na^{\scriptscriptstyle{+} }$&$3$&$4$&$ 5$&$6$&6&7\\
$K^{\scriptscriptstyle{+}}$&$2$&$4$&$5$&$7$&7. 2&8\\
$Ca^{\scriptscriptstyle{2+}}$&$9$&$10$&$10.5$&$11.2$&11.5&11.9\\
\hline
\end{tabularx}
\end{document}

效果:
image.png

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览