我尝试了带有对齐小数点逗号的表格,但这不起作用。谢谢
原始代码:
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[czech]{babel}
\usepackage{tabularx, makecell, boldline}
\usepackage{caption}
\usepackage{cellspace}
\usepackage{etoolbox}
\preto\tabular{\shorthandoff{-}}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{array, cellspace, makecell, multirow, tabularx}
\usepackage[table]{xcolor}
\begin{document}
\begin{table}[h!]
\footnotesize
\caption{\small Naměřené amplitudy metodou ($\pi $,$\pi/2$) pro jednotlivé koncentrace}
\centering
\begin{tabular}{V{4}c|c|c|c|c|cV{4}}
\Xhline{4\arrayrulewidth}
\rowcolor{gray!25}
\multicolumn{1}{V{4}cV{2.5}}{$T$ (MJD)} & \multicolumn{1}{V{1.5}cV{2.5}}{\centering $\alpha $} & \multicolumn{1}{V{1.5}cV{2.5}}{\centering $\delta $} & \multicolumn{1}{V{1.5}cV{2.5}}{$B$} & \multicolumn{1}{V{1.5}m{1.2cm}V{2.5}}{\centering $V$} & \multicolumn{1}{V{1.5}m{1.2cm}V{4}}{$B-V$}\\
\Xhline{4\arrayrulewidth}
&&&&&\\[-10pt]
8585,154194& 3h44m03,5s& 24$^\circ$14'37"& 12,193& 12,021& 0,172\\
8585,164329& 3h47m29,1s& 24$^\circ$06'21"& 2,780& 2,870& -0,090\\
\Xhline{4\arrayrulewidth}
\end{tabular}
\end{table}
\end{document}
我试过:
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[czech]{babel}
\usepackage{tabularx, makecell, boldline}
\usepackage{caption}
\usepackage{cellspace}
\usepackage{etoolbox}
\preto\tabular{\shorthandoff{-}}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{array, cellspace, makecell, multirow, tabularx}
\usepackage[table]{xcolor}
\begin{document}
\begin{table}[h!]
\footnotesize
\caption{\small Naměřené amplitudy metodou ($\pi $,$\pi/2$) pro jednotlivé koncentrace}
\centering
\begin{tabular}{
@{}
S[table-format=4,6]|
S|
S|
S[table-format=2,3]|
S[table-format=2,3]|
S[table-format=1,3]
@{}
}
\Xhline{4\arrayrulewidth}
\rowcolor{gray!25}
\multicolumn{1}{2.5}{$T$ (MJD)} & \multicolumn{1}{2.5}{\centering $\alpha $} & \multicolumn{1}{2.5}{\centering $\delta $} & \multicolumn{1}{2.5}{$B$} & \multicolumn{1}{1.2cm}{\centering $V$} & \multicolumn{1}{1.2cm}{$B-V$}\\
\Xhline{4\arrayrulewidth}
&&&&&\\[-10pt]
8585,154194& 3h44m03,5s& 24$^\circ$14'37"& 12,193& 12,021& 0,172\\
8585,164329& 3h47m29,1s& 24$^\circ$06'21"& 2,780& 2,870& -0,090\\
\Xhline{4\arrayrulewidth}
\end{tabular}
\label{tabt1}
\end{table}
\end{document}
答案1
如果您想要改进,这里有一个。
- 不需要复杂的列类型
- 摆脱不必要的包
- 用于
siunitx
对齐逗号 - 删除所有垂直线,使用
\toprule
,\midrule
,\bottomrule
(通过booktabs
)表示表格
\documentclass{article}
\usepackage[locale=FR]{siunitx}
\usepackage{booktabs}
\usepackage{geometry}
\begin{document}
\begin{table}
\centering
\begin{tabular}{S[table-format=4.6]ccS[table-format=2.3]S[table-format=2.3]S}
\toprule
{$T$ (MJD)} & $\alpha$ & $\delta$ & {$B$} & {$V$} & {$B-V$}\\
\midrule
8585,154194 & 3h44m03,5s & 24$^\circ$14'37" & 12,193 & 12,021 & 0,172\\
8585,164329 & 3h47m29,1s & 24$^\circ$06'21" & 2,780 & 2,870 & -0,090\\
\bottomrule
\end{tabular}
\caption{Caption}
\label{tab:my_label}
\end{table}
\end{document}
答案2
因此我基本上结合了二 现存的回答了这个问题,然后为了科学的一致性,取消了 OP 所有的小时-分钟和度-分-秒,耶。
\documentclass{article}
\usepackage[locale=FR]{siunitx}
%% https://tex.stackexchange.com/a/38957/142180
\ExplSyntaxOn
\NewDocumentCommand \hms { o > { \SplitArgument { 2 } { ; } } m }
{
\group_begin:
\IfNoValueF {#1}
{ \keys_set:nn { siunitx } {#1} }
\siunitx_hms_output:nnn #2
\group_end:
}
\cs_new_protected:Npn \siunitx_hms_output:nnn #1#2#3
{
\IfNoValueF {#1}
{
\tl_if_blank:nF {#1}
{
\SI {#1} { \hour }
\IfNoValueF {#2} { ~ }
}
}
\IfNoValueF {#2}
{
\tl_if_blank:nF {#2}
{
\SI {#2} { \minute }
\IfNoValueF {#3} { ~ }
}
}
\IfNoValueF {#3}
{ \tl_if_blank:nF {#3} { \SI {#3} { \second } } }
}
\ExplSyntaxOff
%% https://tex.stackexchange.com/a/484535/142180
\usepackage{booktabs}
\usepackage{geometry}
\begin{document}
\begin{table}
\centering
\begin{tabular}{S[table-format=4.6]ccS[table-format=2.3]S[table-format=2.3]S}
\toprule
{$T$ (MJD)} & $\alpha$ & $\delta$ & {$B$} & {$V$} & {$B-V$}\\
\midrule
8585,154194 & \hms{3;44;03,5} & \ang{24}14'37" & 12,193 & 12,021 & 0,172\\
8585,164329 & \hms{3;47;29,1} & \ang{24}06'21" & 2,780 & 2,870 & -0,090\\
\bottomrule
\end{tabular}
\caption{Caption}
\label{tab:my_label}
\end{table}
\begin{table}
\centering
\begin{tabular}{S[table-format=4.6]S[table-format=5.1]S[table-format=2.5]S[table-format=2.3]S[table-format=2.3]S}
\toprule
{$T$ (MJD)} & {$\alpha$, sec} & {$\delta$} & {$B$} & {$V$} & {$B-V$}\\
\midrule
8585,154194 & 13443.5 & \ang{24.24361} & 12,193 & 12,021 & 0,172\\
8585,164329 & 13649.1 & \ang{24.10583} & 2,780 & 2,870 & -0,090\\
\bottomrule
\end{tabular}
\caption{Seconds and decimal degrees}
\label{tab:my_label2}
\end{table}
\end{document}