表格边框定义奇怪

表格边框定义奇怪

`

大家好。我得到了这些奇怪的边框。你能解释一下我要怎么做才能得到一张漂亮的桌子吗?谢谢!

\documentclass[a4paper,12pt]{report}
\usepackage{graphicx}
\usepackage[table,xcdraw]{xcolor}
\usepackage{textcomp}
\begin{document}
\begin{table}
\centering
\resizebox{\textwidth}{!}{%
\begin{tabular}{|c|c|c|c|c|c|}
\hline
\rowcolor[HTML]{C0C0C0} 
{\color[HTML]{000000} Material} & {\color[HTML]{000000} Quenching} & {\color[HTML]{000000} \begin{tabular}[c]{@{}c@{}}Tempering\\ temp. {[}°C{]}\end{tabular}} & {\color[HTML]{000000} \begin{tabular}[c]{@{}c@{}}Surface\\ hardness \\ {[}HRC{]}\end{tabular}} & {\color[HTML]{000000} \begin{tabular}[c]{@{}c@{}}Core \\ hardness\\ {[}HRC{]}\end{tabular}} & {\color[HTML]{000000} \begin{tabular}[c]{@{}c@{}}Density\\ {[}g/cc{]}\end{tabular}} \\ \hline
\cellcolor[HTML]{C6E3F9}BS S82 & oil & 170 & 61.8 & 42.7 & 7.86 \\ \hline
\cellcolor[HTML]{C6E3F9}FNDW & gas & 300 & 60.8 & 44.5 & 7.8 \\ \hline
\cellcolor[HTML]{C6E3F9}Pyrowear 675 & oil & 316 & 62 & 39-41 & 7.76 \\ \hline
\cellcolor[HTML]{C6E3F9}XD15NW & HF & 650 (TBC) & 58-60 & 59.2 & 7.7 \\ \hline
\cellcolor[HTML]{C6E3F9}CX13VDW & gas or oil & 250 & 63.9 & 39.2 & 7.8 \\ \hline
\cellcolor[HTML]{C6E3F9}GKHW & oil & 625 & 72.5 & 95 HRB & 7.8 \\ \hline
\rowcolor[HTML]{C0C0C0} 
Surface treatment & Process & \begin{tabular}[c]{@{}c@{}}Process \\ temp. {[}°C{]}\end{tabular} & \begin{tabular}[c]{@{}c@{}}Corrosion\\ resistance {[}hours SST{]}\end{tabular} & Hardness & \begin{tabular}[c]{@{}c@{}}Wear \\ resistance\end{tabular} \\ \hline
\cellcolor[HTML]{C6E3F9}\begin{tabular}[c]{@{}c@{}}Manganese\\ phosphating\end{tabular} & spraying & 150 & 100 & na & - - \\ \hline
\cellcolor[HTML]{C6E3F9}Ni-P + PTFE & chemical & 140 - 300 & 500 - 1,000 & 550 HV & + \\ \hline
\cellcolor[HTML]{C6E3F9}CrN + DLC & PVD-CVD & \textgreater 200 & ++ & 1,500 - 6,000 HV & ++ \\ \hline
\cellcolor[HTML]{C6E3F9}CrN + WC/C & PVD-CVD & 180 - 250 & ++ & 2,000 - 2,500 HV & - \\ \hline
\cellcolor[HTML]{C6E3F9}Micronite & PVD + other & 400 (TBC) & +++ & 3,500 - 4,000 HK & +++ \\ \hline
\end{tabular}%
}
\caption{Materials and surface treatments investigated by Sonaca}
\label{table:sonaca_trials}
\end{table}
\end{document}

答案1

线条sumatra非常明显:

在此处输入图片描述

为了在表中写入多行单元格的内容,我定义了新命令:

\newcommand\mrc[1]{\begin{tabular}{@{} c @{}} #1 \end{tabular}}

为了编写单元,siunitx添加了包。表中还删除了所有cellcolor(多余的):

\documentclass[a4paper,12pt]{report}
\usepackage{graphicx}
\usepackage[table,xcdraw]{xcolor}
\usepackage{textcomp}
\usepackage{array}
\newcommand\mrc[1]{\begin{tabular}{@{} c @{}} #1 \end{tabular}}
\usepackage{siunitx}

\begin{document}
\begin{table}
\centering
%\setlength\arrayrulewidth{0.8pt} % use when better visibility of lines are needed
\setlength\tabcolsep{3pt}
\begin{tabular}{|>{\columncolor[HTML]{C6E3F9}}c|c|c|c|c|c|}
\hline
\rowcolor[HTML]{C0C0C0}
Material & Quenching    & \mrc{Tempering\\ temp. {[\si{\celsius}]}}
                            & \mrc{Surface\\ hardness \\ {[HRC]}}
                                & \mrc{Core\\ hardness\\ {[HRC]}}
                                    & \mrc{Density\\ {[g/cc]}} \\
    \hline
BS S82          & oil           & 170       & 61.8  & 42.7      & 7.86  \\ \hline
FNDW            & gas           & 300       & 60.8  & 44.5      & 7.8   \\ \hline
Pyrowear 675    & oil           & 316       & 62    & 39-41     & 7.76  \\ \hline
XD15NW          & HF            & 650 (TBC) & 58-60 & 59.2      & 7.7   \\ \hline
CX13VDW         & gas or oil    & 250       & 63.9  & 39.2      & 7.8   \\ \hline
GKHW            & oil           & 625       & 72.5  & 95 HRB    & 7.8   \\ \hline
\rowcolor[HTML]{C0C0C0}
\mrc{Surface\\ 
     treatment} & Process & \mrc{Process \\ temp. {[\si{\celsius}]}}
                                & \mrc{Corrosion\\ resistance\\
                                            {[hours SST]}}
                                    & Hardness
                                        & \mrc{Wear\\ resistance}          \\ \hline
\mrc{Manganese\\ phosphating}
                & spraying      & 150       & 100   & na                & --    \\  \hline
Ni-P + PTFE     & chemical      & 140 - 300 & 500 - 1,000
                                                    & 550 HV            & +     \\ \hline
CrN + DLC       & PVD-CVD       & $>200$    & ++    & 1,500 - 6,000 HV  & ++    \\ \hline
CrN + WC/C      & PVD-CVD       & 180 - 250 & ++    & 2,000 - 2,500 HV  & -     \\ \hline
Micronite       & PVD + other   & 400 (TBC) & +++   & 3,500 - 4,000 HK  & +++   \\ \hline
\end{tabular}%

\caption{Materials and surface treatments investigated by Sonaca}
\label{table:sonaca_trials}
\end{table}
\end{document}

答案2

这虽然不是实际问题的解决方案,但可能对“如何做才能有一张漂亮的桌子”有所帮助:

在此处输入图片描述

\documentclass[a4paper,12pt]{report}

\usepackage{booktabs}
\usepackage{makecell}
\usepackage{siunitx}


\begin{document}
\begin{table}
\caption{Materials and surface treatments investigated by Sonaca}
\label{table:sonaca_trials}
\centering
\small
\setlength\tabcolsep{0pt}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lccccc}
\toprule
\thead{Material} 
      & \thead{Quenching}    
            & \thead{Tempering\\ temp. {[\si{\celsius}]}}
                  & \thead{Surface\\ hardness \\ {[HRC]}}
                        & \thead{Core\\ hardness\\ {[HRC]}}
                              & \thead{Density\\ {[g/cc]}} \\
\midrule
BS S82          & oil           & 170       & 61.8  & 42.7      & 7.86  \\ 
FNDW            & gas           & 300       & 60.8  & 44.5      & 7.8   \\ 
Pyrowear 675    & oil           & 316       & 62    & 39-41     & 7.76  \\ 
XD15NW          & HF            & 650 (TBC) & 58-60 & 59.2      & 7.7   \\ 
CX13VDW         & gas or oil    & 250       & 63.9  & 39.2      & 7.8   \\ 
GKHW            & oil           & 625       & 72.5  & 95 HRB    & 7.8   \\ 
\bottomrule
\end{tabular*}

\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lccccc}
\thead{Surface\\ treatment} 
      & Process 
           & \thead{Process \\ temp. {[\si{\celsius}]}}
                 & \thead{Corrosion\\ resistance\\ {[hours SST]}}
                       & \thead{Hardness}
                             & \thead{Wear\\ resistance}          \\ 
\midrule
\makecell[l]{Manganese\\ phosphating}
                & spraying      & 150       & 100   & na                & --    \\  
Ni-P + PTFE     & chemical      & 140 - 300 & 500 - 1,000
                                                    & 550 HV            & +     \\ 
CrN + DLC       & PVD-CVD       & $>200$    & ++    & 1,500 - 6,000 HV  & ++    \\ 
CrN + WC/C      & PVD-CVD       & 180 - 250 & ++    & 2,000 - 2,500 HV  & -     \\ 
Micronite       & PVD + other   & 400 (TBC) & +++   & 3,500 - 4,000 HK  & +++   \\ \bottomrule
\end{tabular*}%
\end{table}
\end{document}

相关内容