\documentclass[a4paper,12pt]{article}
\usepackage[nottoc]{tocbibind}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{booktabs,siunitx}
\usepackage{color, colortbl}
\usepackage[table,svgnames]{xcolor}
%\usepackage{xcolor, colortbl}
%\usepackage{enumitem}
\usepackage{flafter}
%\usepackage{geometry}
\usepackage{float}
\usepackage{bigstrut}
\usepackage{makecell}
\usepackage{siunitx}
\usepackage{geometry}
\geometry{
a4paper,
total={170mm,257mm},
left=20mm,
top=20mm,
left=20mm,
right=20mm
}
\usepackage{tgtermes}
%\usepackage{pslatex}
\usepackage{amsmath,amssymb,amsthm,textcomp}
\usepackage{enumerate}
\usepackage{multicol}
\usepackage{tikz}
\usepackage{ragged2e}
\pagenumbering{arabic}
\usepackage{enumerate,mdwlist}
\sisetup{separate-uncertainty=true}
\definecolor{LightCyan}{rgb}{0.69,1.21,1.21}
\renewcommand{\refname}{Bibliography}
\linespread{1.3}
%\renewcommand{\contentsname{Table of Contents}}
\renewcommand\theadalign{bc}
\renewcommand\theadfont{\sffamily}
\renewcommand\theadgape{\Gape[4pt]}
\renewcommand\cellgape{\Gape[4pt]}
\begin{document}
\begin{table}[H]
\centering
\caption{Add caption}
\begin{tabular}{r r r r r r }
\hline
\rowcolor{LightCyan}
\thead{Current \textit{I}/ \si{\milli\ampere} \\ $\Delta I$ $\approx$ 0 \si{\milli\ampere}} & \thead{Voltage \textit{$V_{1}$}/ \si{\volt} \\ $\Delta$ $V_{1}$ = $\pm$ 0.01 \si{\volt}} & \thead{Voltage \textit{$V_{2}$}/ \si{\volt} \\ $\Delta$ $V_{2}$ = $\pm$ 0.0001 \si{\volt}} & \thead{Voltage $\frac{V_{1}}{V_{2}}$/ \si{\volt} \\ } & \thead{Fractional uncertainty\\$\frac{\Delta V_{1}}{V_{1}}$+$\frac{\Delta V_{2}}{V_{2}}$} & V1(V) \bigstrut\\
\hline
1 & 0.50 & 0.5837 & 0.8566044 & 0.0202 & 0.7500 \bigstrut\\
\hline
2 & 1.00 & 1.1875 & 0.8421053 & 0.0101 & 0.7500 \bigstrut\\
\hline
3 & 1.50 & 1.7928 & 0.8366801 & 0.0067 & 0.7500 \bigstrut\\
\hline
4 & 2.00 & 2.4034 & 0.8321544 & 0.0050 & 0.7500 \bigstrut\\
\hline
5 & 2.50 & 3.0182 & 0.8283083 & 0.0040 & 0.7500 \bigstrut\\
\hline
6 & 3.00 & 3.6359 & 0.8251052 & 0.0034 & 0.7500 \bigstrut\\
\hline
7 & 3.50 & 4.2556 & 0.8224457 & 0.0029 & 0.7500 \bigstrut\\
\hline
8 & 4.00 & 4.8728 & 0.8208833 & 0.0025 & 0.7500 \bigstrut\\
\hline
9 & 4.50 & 5.4929 & 0.8192394 & 0.0022 & 0.7500 \bigstrut\\
\hline
10 & 5.00 & 6.1217 & 0.8167666 & 0.0020 & 0.7500 \bigstrut\\
\hline
11 & 5.50 & 6.7480 & 0.8150563 & 0.0018 & 0.7500 \bigstrut\\
\hline
12 & 6.00 & 7.3694 & 0.8141775 & 0.0017 & 0.7500 \bigstrut\\
\hline
\end{tabular}%
\end{table}%
\end{document}
答案1
米科(再次) 超过我 48 秒......
\documentclass[a4paper,12pt]{article}
\usepackage[nottoc]{tocbibind}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{booktabs,siunitx}
\sisetup{separate-uncertainty=true}
\usepackage{color, colortbl}
\usepackage[table,svgnames]{xcolor}
\definecolor{LightCyan}{rgb}{0.69,1.21,1.21}
%\usepackage{xcolor, colortbl}
%\usepackage{enumitem}
\usepackage{flafter}
%\usepackage{geometry}
\usepackage{float}
\usepackage{bigstrut}
\usepackage{makecell}
\renewcommand\theadalign{tc}
\renewcommand\theadfont{\sffamily}
\renewcommand\theadgape{}
\setcellgapes{5pt}
\usepackage{siunitx}
\usepackage{geometry}
\geometry{
a4paper,
total={170mm,257mm},
left=20mm,
top=20mm,
left=20mm,
right=20mm
}
\usepackage{tgtermes}
%\usepackage{pslatex}
\usepackage{amsmath,amssymb,amsthm,textcomp}
%\usepackage{enumerate}
\usepackage{multicol}
\usepackage{tikz}
\usepackage{ragged2e}
\pagenumbering{arabic}
\usepackage{enumerate,mdwlist}
\renewcommand{\refname}{Bibliography}
\linespread{1.3}
%\renewcommand{\contentsname{Table of Contents}}
\begin{document}
\begin{table}[htb]
\centering
\caption{Add caption}
\setlength\tabcolsep{0pt}
\makegapedcells
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
S[table-format=2]
S[table-format=1.2]
S[table-format=1.4]
S[table-format=1.6]
*{2}{S[table-format=1.4]}
}
\toprule
{\thead{$I$/\si{\milli\ampere}\\ $\Delta I\approx 0$ \si{\milli\ampere}}}
& {\thead{$V_{1}$/\si{\volt}\\ $\Delta V_{1} = \SI{\pm 0.01}{\volt}$}}
& {\thead{$V_{2}$/\si{\volt}\\ $\Delta V_{2} = \SI{\pm e-4}{\volt}$}}
& {\thead{$\frac{V_{1}}{V_{2}}$/\si{\volt}}}
& {\thead{Fractional\\[-1ex] uncertainty\\
$\frac{\Delta V_{1}}{V_{1}}+\frac{\Delta V_{2}}{V_{2}}$}}
& {$V_1(V)$} \\
\midrule
1 & 0.50 & 0.5837 & 0.8566044 & 0.0202 & 0.7500 \\
2 & 1.00 & 1.1875 & 0.8421053 & 0.0101 & 0.7500 \\
3 & 1.50 & 1.7928 & 0.8366801 & 0.0067 & 0.7500 \\
4 & 2.00 & 2.4034 & 0.8321544 & 0.0050 & 0.7500 \\
5 & 2.50 & 3.0182 & 0.8283083 & 0.0040 & 0.7500 \\
6 & 3.00 & 3.6359 & 0.8251052 & 0.0034 & 0.7500 \\
7 & 3.50 & 4.2556 & 0.8224457 & 0.0029 & 0.7500 \\
8 & 4.00 & 4.8728 & 0.8208833 & 0.0025 & 0.7500 \\
9 & 4.50 & 5.4929 & 0.8192394 & 0.0022 & 0.7500 \\
10 & 5.00 & 6.1217 & 0.8167666 & 0.0020 & 0.7500 \\
11 & 5.50 & 6.7480 & 0.8150563 & 0.0018 & 0.7500 \\
12 & 6.00 & 7.3694 & 0.8141775 & 0.0017 & 0.7500 \\
\bottomrule
\end{tabular*}%
\end{table}%
\end{document}
在您的序言中,您加载了两次软件包。我在上面的评论中对它们进行了注释。我还纠正了makecell
其他设置,它们与上面的设置大致相同米科回答。
答案2
首先,您需要缩小一些标题单元格的宽度 - 理想情况下,通过在第 4 列和第 5 列插入几个换行符。
我还将简化和精简表格的整体外观,主要是通过删除所有\hline
指令并在其位置使用、、\toprule
(\midrule
2\addlinespace
个实例)和\bottomrule
。这也将让您摆脱所有\bigstrut
指令。
用 7 [!] 位有效数字显示电压比似乎有些过头了。我建议您利用软件包中的一些功能siunitx
将数字四舍五入到 3 位。在最后一列显示 4 位数字似乎毫无意义,因为 2 位数字就足够了。
另外,我必须表达一种观点,即在标题材料中添加颜色对于其可读性或整个表格的可读性没有任何作用。老实说,除非我想营造一种华而不实的外观,否则我不会使用颜色。最后,我保留了您在标题单元格中以无衬线字体呈现文本模式单词的设置,但我必须承认,我认为它并没有增加太多(如果有的话......)。
\documentclass[12pt]{article}
%% (simplified the preamble as much as possible)
\usepackage[utf8]{inputenc}
\usepackage{booktabs,siunitx,float}
\usepackage{geometry}
\geometry{total={170mm,257mm},margin=20mm}
\usepackage{tgtermes}
\usepackage{setspace}
\setstretch{1.3}
\usepackage{makecell}
\renewcommand\theadalign{tc}
\renewcommand\theadfont{\sffamily}
\renewcommand\theadgape{\Gape[2pt]}
\renewcommand\cellgape{\Gape[2pt]}
\begin{document}
\begin{table}[H]
\centering
\sisetup{detect-mode,round-mode=places}
\caption{Add caption}
\begin{tabular}{@{}ccc
S[table-format=1.3,
round-precision=3]
c
S[table-format=1.2,
round-precision=2]@{}}
\toprule
\thead{Current $I$ (\si{\milli\ampere}) \\
$\Delta I \approx \SI{0}{\milli\ampere}$}
& \thead{Voltage $V_{1}$ (\si{\volt}) \\
$\Delta V_{1} = \pm \SI{0.01}{\volt}$}
& \thead{Voltage $V_{2}$ (\si{\volt}) \\
$\Delta V_{2} = \pm \SI{0.0001}{\volt}$}
& {\thead{Voltage\\ratio \\
$V_{1}/V_{2}$}}
& \thead{Fractional\\uncertainty\\
$\frac{\Delta V_{1}}{V_{1}}+\frac{\Delta V_{2}}{V_{2}}$}
& {\textsf{V1} (\si{V})} \\
\midrule
1 & 0.50 & 0.5837 & 0.8566044 & 0.0202 & 0.7500 \\
2 & 1.00 & 1.1875 & 0.8421053 & 0.0101 & 0.7500 \\
3 & 1.50 & 1.7928 & 0.8366801 & 0.0067 & 0.7500 \\
4 & 2.00 & 2.4034 & 0.8321544 & 0.0050 & 0.7500 \\
\addlinespace
5 & 2.50 & 3.0182 & 0.8283083 & 0.0040 & 0.7500 \\
6 & 3.00 & 3.6359 & 0.8251052 & 0.0034 & 0.7500 \\
7 & 3.50 & 4.2556 & 0.8224457 & 0.0029 & 0.7500 \\
8 & 4.00 & 4.8728 & 0.8208833 & 0.0025 & 0.7500 \\
\addlinespace
9 & 4.50 & 5.4929 & 0.8192394 & 0.0022 & 0.7500 \\
10 & 5.00 & 6.1217 & 0.8167666 & 0.0020 & 0.7500 \\
11 & 5.50 & 6.7480 & 0.8150563 & 0.0018 & 0.7500 \\
12 & 6.00 & 7.3694 & 0.8141775 & 0.0017 & 0.7500 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案3
一种解决方案,改进和简化代码,系统地使用siunitx
(makecell
特别是具有可变厚度的规则),并\bigstrut
用cellspace
定义最小在以字母 为前缀的列中,单元格顶部和底部的垂直间距S
,或者C
如果您加载 ,就像这里的情况一样siunitx
。请注意, 中的填充命令makecell
似乎与表格颜色命令存在问题。另外,我加载了caption
以在标题和表格之间留出合理的间距。
\documentclass[a4paper,12pt]{article}
\usepackage[nottoc]{tocbibind}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{booktabs,siunitx}
\usepackage[table,svgnames]{xcolor}
%\usepackage{enumitem}
\usepackage{flafter}
\usepackage{caption, float}
\usepackage{bigstrut}
\usepackage{makecell}
\usepackage{siunitx}
\usepackage{geometry}
\geometry{
a4paper,
total={170mm,257mm},
hmargin=20mm,
top=20mm,
showframe
}
\usepackage{amsmath, amssymb, amsthm, textcomp}%
\usepackage{tgtermes}
\usepackage[EULERGREEK]{sansmath}
\usepackage{enumerate}
\usepackage{multicol}
\usepackage{tikz}
\usepackage{ragged2e}
\pagenumbering{arabic}
\usepackage{enumerate,mdwlist}
\sisetup{separate-uncertainty=true}
\definecolor{LightCyan}{rgb}{0.69,1.21,1.21}
\renewcommand{\refname}{Bibliography}
\linespread{1.3}
%\renewcommand{\contentsname{Table of Contents}}
\renewcommand\theadalign{bc}
\renewcommand\theadfont{\sffamily\sansmath}
\usepackage{cellspace}
\setlength{\cellspacetoplimit}{6pt}
\setlength{\cellspacebottomlimit}{6pt}
%\renewcommand\theadgape{\Gape[4pt]}
% \renewcommand\cellgape{\Gape[4pt]}
\begin{document}
\begin{table}[H]
\centering\sisetup{detect-all}
\caption{Add caption}
\begin{tabular}{Cr r r r r r }
\Xhline{0.8pt}
\rowcolor{LightCyan}
\thead{Current $I/ \si{\mA}$ \\ $\Delta I\approx \SI{0}{\mA}$} & \thead{Voltage $V_{1}/\mkern1.5mu \si{\V}$ \\ $\Delta V_{1} = \pm \SI{0.01}{\V}$} & \thead{Voltage $V_{2}/\mkern1.5mu \si{\V}$ \\ $\Delta V_{2} = \pm \SI{0.0001}{\V}$} & \thead{Voltage $\frac{V_{1}}{V_{2}}/ \mkern1.5mu\si{\V}$} & \thead{Fractional\\[-1ex] uncertainty\\[-0.5ex] $\frac{\Delta V_{1}}{V_{1}} + \frac{\Delta V_{2}}{V_{2}}$} & V1(V) \\
\Xhline{0.8pt}
1 & 0.50 & 0.5837 & 0.8566044 & 0.0202 & 0.7500 \\
\hline
2 & 1.00 & 1.1875 & 0.8421053 & 0.0101 & 0.7500 \\
\hline
3 & 1.50 & 1.7928 & 0.8366801 & 0.0067 & 0.7500 \\
\hline
4 & 2.00 & 2.4034 & 0.8321544 & 0.0050 & 0.7500 \\
\hline
5 & 2.50 & 3.0182 & 0.8283083 & 0.0040 & 0.7500 \\
\hline
6 & 3.00 & 3.6359 & 0.8251052 & 0.0034 & 0.7500 \\
\hline
7 & 3.50 & 4.2556 & 0.8224457 & 0.0029 & 0.7500 \\
\hline
8 & 4.00 & 4.8728 & 0.8208833 & 0.0025 & 0.7500 \\
\hline
9 & 4.50 & 5.4929 & 0.8192394 & 0.0022 & 0.7500 \\
\hline
10 & 5.00 & 6.1217 & 0.8167666 & 0.0020 & 0.7500 \\
\hline
11 & 5.50 & 6.7480 & 0.8150563 & 0.0018 & 0.7500 \\
\hline
12 & 6.00 & 7.3694 & 0.8141775 & 0.0017 & 0.7500 \\
\Xhline{0.8pt}
\end{tabular}%
\end{table}%
\end{document}