\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}
在你的序言中你加載了一些包兩次..我在上面的mwe中評論了它們。我也為makecell
其他人正確的設定或多或少與在相同米科回答。
答案2
首先也是最重要的,您需要縮小一些標題單元格的寬度——理想情況下,可以在第 4 列和第 5 列中插入幾個換行符。
我還將簡化和簡化表格的整個外觀,主要是透過刪除所有\hline
指令並在其位置使用 、\toprule
、\midrule
(\addlinespace
2 個實例)和\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}