为什么第四列不居中?如何修复这个问题并保持样式不变?
\documentclass[12pt,oneside,ngerman,reqno,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsthm} % ams stuff should be before font loading
\usepackage{lmodern}
\usepackage[T1]{fontenc} % should be after font loading
\usepackage{fixltx2e,babel}
\usepackage[numbers]{natbib} % bibtex package
%\usepackage{typearea} % custom type area
% \areaset[0mm]{135mm}{210mm} % typearea configuration
% \topmargin5mm % typearea configuration
\usepackage{graphicx}
\usepackage{url}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{subfig}
\usepackage{pgfplots}
\usepackage{floatrow}
\usepackage{hhline, array, makecell}
\setcellgapes{4pt}
\makegapedcells
%\usepackage[showframe, margin = 25mm]{geometry}
\usepackage{siunitx}
\newcolumntype{I}{S[table-format=4.0]}
\begin{document}
\begin{tabular}{@{}I|I|I|I|S[table-format = 2.2]@{}}
{Züge\,[\#]} & {Planungsintervall\,[min]} & {Zeit\,[s]} &{ Lücke\,[\%]} & {Verbesserung\,[MW]} \\
\hhline{ >{\arrayrulewidth = 2pt}:=:=:=:=:=:}
10 & 28 & 25 & 0.00 & 2.05\\
20 & 36 & 12 & 0.00 & 2.79 \\
50 & 68 & 333 & 0.00 & 1.92 \\
100 & 122 & 1800 & 1.92 & 2.09\\
200 & 127 & 1800 & 1.08 & 3.94 \\
500 & 149 & 1800 & 21.37 & 0.00 \\
1000 & 346 & 509 & 0.00 & 3.00\\
2000 & 460 & 1514 & 0.00 & 3.06\\
\hhline{ >{\arrayrulewidth = 2pt}:=:=:=:=:=:}
\O & & 974 & 3.04 & 2.36 \\ \hline
\Xhline{0.8pt}
\end{tabular}
\end{document}
答案1
其中几列table-format
所含数据不正确,导致它们看起来不居中。
更规范地使用booktabs
和的解决方案siunitx
。我稍微调整了值,\tabcolsep
以便表格适合文本宽度。
\documentclass[12pt,oneside,ngerman,reqno,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsthm} % ams stuff should be before font loading
\usepackage{lmodern,babel}
\usepackage{booktabs}
\usepackage{array}
\setlength\tabcolsep{4pt} % slightly narrowed (default 6pt) to fit to text width
\usepackage{siunitx}
\newcolumntype{I}{S[table-format=4.0]}
\begin{document}
\begin{tabular}{IS[table-format=3.0]IS[table-format=2.2]S[table-format = 1.2]}
\toprule
{Züge/\si{\#}} & {Planungsintervall/\si{\minute}} & {Zeit/\si{\second}} &{ Lücke/\si{\percent}} & {Verbesserung/\si{\mega\watt}} \\
\midrule
10 & 28 & 25 & 0.00 & 2.05 \\
20 & 36 & 12 & 0.00 & 2.79 \\
50 & 68 & 333 & 0.00 & 1.92 \\
100 & 122 & 1800 & 1.92 & 2.09 \\
200 & 127 & 1800 & 1.08 & 3.94 \\
500 & 149 & 1800 & 21.37 & 0.00 \\
1000 & 346 & 509 & 0.00 & 3.00 \\
2000 & 460 & 1514 & 0.00 & 3.06 \\
\addlinespace
\O & & 974 & 3.04 & 2.36 \\
\bottomrule
\end{tabular}
\end{document}