表格 - 粗线和普通线(居中)

表格 - 粗线和普通线(居中)

请问我该如何解决这个图形问题?

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[czech]{babel} 
\usepackage{multicol}
\usepackage{enumitem}
\usepackage{tabularx}
\usepackage{caption} 
\usepackage{multirow}
\usepackage{array}
\newcolumntype{?}{!{\vrule width 1.5pt}}
\usepackage[table]{xcolor}
\usepackage{tabularx, makecell}
\usepackage{caption}
\usepackage{cellspace}
\usepackage{etoolbox}
\preto\tabular{\shorthandoff{-}}


\begin{document}


\begin{table}[h!]\footnotesize
    \caption{Zářič $^{137}$Cs - přirozené pozadí}
    \centering
        \begin{tabular}{?c|c|c|c|c|c?}
        \Xhline{4\arrayrulewidth}

\multicolumn{1}{?c?}{\cellcolor{gray!25}$PEAK$ [keV]} & \multicolumn{1}{c?}{\centering \cellcolor{gray!25}$E_{tab}$ [keV]} & \multicolumn{1}{c?}{\centering Zdroj \cellcolor{gray!25}} & \multicolumn{1}{c?}{\centering \cellcolor{gray!25}$FWHM$ [keV]} & \multicolumn{1}{m{1.2cm}?}{\centering $NET$ \cellcolor{gray!25}} & \multicolumn{1}{m{1.2cm}?}{$GROSS$ \cellcolor{gray!25}}\\         

\Xhline{4\arrayrulewidth}
&&&&&\\[-10pt]
609,35& 609,31& \multirow{4}{*}{$^{214}$Bi} & 1,38&   539&    4675\\ 
\cline{1-2} \cline{4-6}
&&&&&\\[-10pt]
1120,29&    1120,29&    &   1,95&   558&    1530\\  
\cline{1-2} \cline{4-6}
&&&&&\\[-10pt]
1764,57&    1764,49&    &   2,08&   451&    574\\
\cline{1-2} \cline{4-6}
&&&&&\\[-10pt]
2204,36&    2204,21&    &   1,86&   141&    188\\
\hline
&&&&&\\[-10pt]
1460,81&    1460,75&    $^{40}$K&   1,73&   422&    738\\
\hline
&&&&&\\[-10pt]
74,71&  \multirow{2}{*}{rtg}&    \multirow{2}{*}{$^{214}$Pb}& 1,15&   2321&   34035\\
\cline{1-1} \cline{4-6}
&&&&&\\[-10pt]
84,54&  &   &   1,22&   891&    16412\\

        \Xhline{4\arrayrulewidth}
        \end{tabular}

    \label{Cs}
\end{table}
\end{document}

在此处输入图片描述

编辑

我尝试按照 Bernard 的脚本制作另一个表格,但 TeXMaker 没有翻译它,所以我看不出哪里出了错误。您知道问题出在哪里吗?谢谢

\begin{table}[h!]\footnotesize
    \caption{Zářič $^{137}$Cs}
    \centering
        \begin{tabular}{V{4}c|c|c|c|cV{4}}
        \Xhline{4\arrayrulewidth}        
       \rowcolor{gray!25}      
             \multicolumn{1}{V{4}cV{4.8}}|}{Pozorovaný objekt} & \multicolumn{1}{cV{3cm}|}{Určená hodnota $E$ [keV]} & \multicolumn{1}{cV{3.5cm}|}{Tabelovaná hodnota energie $E$ [keV]} & \multicolumn{1}{cV{1.5cm}|}{$\mathit{FWHM}$ [keV]} &\multicolumn{1}{V{1.5}m{1.2cm}V{4}}{\textit{NET}}\\

            \Xhline{4\arrayrulewidth}

&&&&\\[-10pt]
Energie $\gamma $-záření (FEP)& \centering  $661,68 \pm 0,02$& \centering   $661,66$& \centering    $1,5$&$70096$\\
\hline
Poloha comptonovy hrany& \centering $478 \pm 4$&\centering  477,34 (shoduje se s~teoretickou)&  &   \\
\hline
Hraniční energie dvojného comptonova rozptylu&\centering    $565 \pm 12$&\centering 554,58& &       \\
\hline
&&&&\\[-10pt]
Poloha píků zpětného rozptylu&\centering    $182 \pm 4$&\centering  184,32& &       \\

        \Xhline{4\arrayrulewidth}
        \end{tabular}

    \label{Cs}
\end{table}

答案1

我建议使用 包boldline(因此无需定义新的列类型):表格序言中指定的垂直线V{x}产生宽度为 x 倍的线\arrayrulewidth。我简化了使用 命令为列标题着色的代码\rowcolor,并删除了\centering类型的列中不必要的指令c。最后,我删除了每个双重包加载。

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[czech]{babel}
\usepackage{amsmath}
\usepackage{multicol}
\usepackage{enumitem}
\usepackage{multirow}
\usepackage{array}
\usepackage[table]{xcolor}
\usepackage{tabularx, makecell, boldline}
\usepackage{caption}
\usepackage{cellspace}
\usepackage{etoolbox}
\preto\tabular{\shorthandoff{-}}

\begin{document}

\begin{table}[h!]\footnotesize
\caption{Zářič $^{137}$Cs - přirozené pozadí}
\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}}{\textit{PEAK} [keV]} & \multicolumn{1}{V{1.5}cV{2.5}}{\centering $E_{\text{tab}}$ [keV]} & \multicolumn{1}{V{1.5}cV{2.5}}{\centering Zdroj} & \multicolumn{1}{V{1.5}cV{2.5}}{\textit{FWHM} [keV]} & \multicolumn{1}{V{1.5}m{1.2cm}V{2.5}}{\centering \textit{NET} } & \multicolumn{1}{V{1.5}m{1.2cm}V{4}}{\textit{GROSS}}\\

    \Xhline{4\arrayrulewidth}
    &&&&&\\[-10pt]
    609,35& 609,31& \multirow{4}{*}{$^{214}$Bi} & 1,38& 539& 4675\\
    \cline{1-2} \cline{4-6}
    &&&&&\\[-10pt]
    1120,29& 1120,29& & 1,95& 558& 1530\\
    \cline{1-2} \cline{4-6}
    &&&&&\\[-10pt]
    1764,57& 1764,49& & 2,08& 451& 574\\
    \cline{1-2} \cline{4-6}
    &&&&&\\[-10pt]
    2204,36& 2204,21& & 1,86& 141& 188\\
    \hline
    &&&&&\\[-10pt]
    1460,81& 1460,75& $^{40}$K& 1,73& 422& 738\\
    \hline
    &&&&&\\[-10pt]
    74,71& \multirow{2}{*}{rtg}& \multirow{2}{*}{$^{214}$Pb}& 1,15& 2321& 34035\\
    \cline{1-1} \cline{4-6}
    &&&&&\\[-10pt]
    84,54& & & 1,22& 891& 16412\\
    \Xhline{4\arrayrulewidth}
    \end{tabular}
\label{Cs}
\end{table}

\end{document} 

在此处输入图片描述

答案2

  • 指示图形问题无法解决。
  • 随意使用粗线可能会使表格设计看起来不美观。最好不要使用粗垂直线

无关

  • 每个包只需加载一次即可
  • 相反,\cellcolor在行中的每个单元格中使用更简单的方法 ˙\rowcolor`
  • 你的单元格的垂直间距很奇怪。为什么不利用已加载cellspace
  • 为什么不使用mchem包来写化学元素?

\documentclass[12pt,a4paper]{article}
\usepackage[table]{xcolor}
\usepackage{array, cellspace, makecell, multirow, tabularx}
\newcolumntype{?}{!{\vrule width 1.5pt}}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}
\newcommand\mc[1]{\multicolumn{1}{Sc?}{#1}}
\usepackage{caption}
\usepackage{etoolbox}
%\preto\tabular{\shorthandoff{-}}

\begin{document}
    \begin{table}[ht!]
    \footnotesize
    \caption{Zářič $^{137}$Cs - přirozené pozadí}
    \label{Cs}
    \centering
        \begin{tabular}{?Sc? *{4}{Sc|}c?}
        \Xhline{4\arrayrulewidth}
        \rowcolor{gray!25}
\multicolumn{1}{?c?}{$PEAK$ [keV]}
    & \mc{$E_{tab}$ [keV]}
        & \mc{Zdroj}
            & \mc{$FWHM$ [keV]}
                & \mc{$NET$}
                    & \mc{$GROSS$}\\
        \Xhline{4\arrayrulewidth}
%    &&&&&\\[-10pt]
609,35  & 609,31& \multirow{5.2}{*}{$^{214}$Bi} & 1,38&   539&    4675\\
        \cline{1-2} \cline{4-6}
%&&&&&\\[-10pt]
1120,29&    1120,29&    &   1,95&   558&    1530\\
    \cline{1-2} \cline{4-6}
%&&&&&\\[-10pt]
1764,57&    1764,49&    &   2,08&   451&    574\\
        \cline{1-2} \cline{4-6}
%&&&&&\\[-10pt]
2204,36&    2204,21&    &   1,86&   141&    188\\
        \hline
%&&&&&\\[-10pt]
1460,81&    1460,75&    $^{40}$K&   1,73&   422&    738\\
        \hline
%&&&&&\\[-10pt]
74,71 &  \multirow{2}{*}{rtg} & \multirow{2.4}{*}{$^{214}$Pb}& 1,15&   2321&   34035\\
        \cline{1-1} \cline{4-6}
%&&&&&\\[-10pt]
84,54&  &   &   1,22&   891&    16412\\
        \Xhline{4\arrayrulewidth}
    \end{tabular}
\end{table}
\end{document}

在此处输入图片描述

附录:

我会重新设计你的表格以:

在此处输入图片描述

\documentclass[12pt,a4paper]{article}
\usepackage{booktabs, makecell, multirow}
\renewcommand\theadgape{}                       % <--- new
\usepackage[version=4]{mhchem}                  % <--- new
\usepackage[group-minimum-digits=4] {siunitx}   % <--- new
\usepackage[skip=1ex]{caption}

\begin{document}
    \begin{table}[ht!]
    \caption{Zářič \ce{^{137}Cs} - přirozené pozadí}    % <--- changed
    \label{Cs}
    \centering
\begin{tabular}{S[table-format=4.2] % <--- changed
                S[table-format=4.2] % <--- changed
                c
                S[table-format=1.2] % <--- changed
                S[table-format=4.0] % <--- changed
                S[table-format=5.0] % <--- changed
                }
    \toprule    % <--- changed
{\thead{\textit{PEAK}\\ {[keV]}}}   % <--- changed
            & {\thead{$E_{\text{tab}}$\\ {[keV]}}}  % <--- changed
                      & {\textit{Zdroj}}    % <--- changed
                            & {\thead{\textit{FWHM}\\ {[keV]}}} % <--- changed
                                    & {\textit{NET}}    % <--- changed
                                            & {\textit{GROSS}}\\    % <--- changed
        \midrule    % <--- changed
    609,35  &  609,31 & \multirow{4}{*}{\ce{^{214}Bi}}  % <--- changed
                            & 1,38  & 539   & 4675  \\
    1120,29 & 1120,29 &     & 1,95  & 558   & 1530  \\
    1764,57 & 1764,49 &     & 2,08  & 451   &  574  \\
    2204,36 & 2204,21 &     & 1,86  & 141   &  188  \\
        \addlinespace   % <--- new
    1460,81&    1460,75&    \ce{^{40}K}                 % <--- changed
                            & 1,73  & 422   &  738  \\
        \addlinespace   % <--- new
    74,71 &  {\multirow{2}{*}{rtg}}
                      & \multirow{2}{*}{\ce{^{214}Pb}}  % <--- changed
                            & 1,15  & 2321  & 34035 \\
    84,54 &           &     & 1.22  &  891  & 16412 \\
       \bottomrule  % <--- changed
\end{tabular}
    \end{table}
\end{document}

答案3

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[czech]{babel} 
\usepackage{multicol}
\usepackage{enumitem}
\usepackage{tabularx}
\usepackage{caption} 
\usepackage{multirow}
\usepackage{array}
\newcolumntype{?}{!{\vrule width 1.5pt}}
\usepackage[table]{xcolor}
\usepackage{tabularx, makecell}
\usepackage{caption}
\usepackage{cellspace}
\usepackage{etoolbox}
\preto\tabular{\shorthandoff{-}}


\begin{document}


\begin{table}[h!]\footnotesize
    \caption{Zářič $^{137}$Cs - přirozené pozadí}
    \centering
\doublerulesepcolor{black}
        \begin{tabular}{?c||c|c|c|c|c?}
        \Xhline{4\arrayrulewidth}

\multicolumn{1}{?c|}{\cellcolor{gray!25}$PEAK$ [keV]} & \multicolumn{1}{c|}{\centering \cellcolor{gray!25}$E_{tab}$ [keV]} & \multicolumn{1}{c|}{\centering Zdroj \cellcolor{gray!25}} & \multicolumn{1}{c|}{\centering \cellcolor{gray!25}$FWHM$ [keV]} & \multicolumn{1}{m{1.2cm}|}{\centering $NET$ \cellcolor{gray!25}} & \multicolumn{1}{m{1.2cm}?}{$GROSS$ \cellcolor{gray!25}}\\         

\Xhline{4\arrayrulewidth}
&&&&&\\[-10pt]
609,35& 609,31& \multirow{4}{*}{$^{214}$Bi} & 1,38&   539&    4675\\ 
\cline{1-2} \cline{4-6}
&&&&&\\[-10pt]
1120,29&    1120,29&    &   1,95&   558&    1530\\  
\cline{1-2} \cline{4-6}
&&&&&\\[-10pt]
1764,57&    1764,49&    &   2,08&   451&    574\\
\cline{1-2} \cline{4-6}
&&&&&\\[-10pt]
2204,36&    2204,21&    &   1,86&   141&    188\\
\hline
&&&&&\\[-10pt]
1460,81&    1460,75&    $^{40}$K&   1,73&   422&    738\\
\hline
&&&&&\\[-10pt]
74,71&  \multirow{2}{*}{rtg}&    \multirow{2}{*}{$^{214}$Pb}& 1,15&   2321&   34035\\
\cline{1-1} \cline{4-6}
&&&&&\\[-10pt]
84,54&  &   &   1,22&   891&    16412\\

        \Xhline{4\arrayrulewidth}
        \end{tabular}

    \label{Cs}
\end{table}
\end{document}

相关内容