对行进行着色后显示表格的水平线和垂直线

对行进行着色后显示表格的水平线和垂直线

如何在为行着色后重新显示下表中的每一行?

 \documentclass[english,a4paper,12pt]{report}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage[latin9]{inputenc}
\usepackage{graphicx}
\usepackage{xcolor,colortbl}
\usepackage[showframe=false]{geometry}
\usepackage{changepage}
\usepackage{hhline}

\usepackage[font=normalsize,labelfont=bf,justification=centering]{caption}
\begin{document}

\begin{table}[htb]
\begin{adjustwidth}{-1cm}{}
\resizebox{0.6\textwidth}{!}{
\begin{minipage}{\linewidth}
\def\arraystretch{1.5}%

\begin{tabular}{ | c | c | c | c | c |  c |  c |  c | c |  c |  c |  }
\cline{2-11}
\multicolumn{1}{c|}{} & \textbf{Telestrada} & \textbf{Telestrada} & \textbf{Telestrada} & \textbf{Telestrada} &
\textbf{Telestrada} & \textbf{Telestrada} & \textbf{Telestrada} &
\textbf{Telestrada} & \textbf{Telestrada} & \textbf{Telestrada} \\

\hline
  \textbf{LOC} & 5 & 5 & 6 & 5 & - & 5 & 6 & 5 & 6 & 5  \\
\hline
\rowcolor{gray!40}  \textbf{VS} & 8 & 5 & 9 & 8 & 9 & 8 & 9 & 8 & 9 & 8 \\
\hline

\end{tabular}
\end{minipage} 
}
\end{adjustwidth}
%% put caption outside here
\caption{\label{fig:text}text experiment experiment experiment experiment experiment experiment experiment}
\end{table}
\end{document}

enter image description here

答案1

一种方法是增加线条的宽度

\setlength\arrayrulewidth{1pt}

代码:

 \documentclass[english,a4paper,12pt]{report}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage[latin9]{inputenc}
\usepackage{graphicx}
\usepackage{xcolor,colortbl}
\usepackage[showframe=false]{geometry}
\usepackage{changepage}
\usepackage{hhline}

\usepackage[font=normalsize,labelfont=bf,justification=centering]{caption}
\begin{document}

\begin{table}[htb]
\setlength\arrayrulewidth{1pt}        %% put it inside table environment so that change is local
\begin{adjustwidth}{-1cm}{}
\resizebox{0.6\textwidth}{!}{
\begin{minipage}{\linewidth}
\def\arraystretch{1.5}%

\begin{tabular}{ | c | c | c | c | c |  c |  c |  c | c |  c |  c |  }
\cline{2-11}
\multicolumn{1}{c|}{} & \textbf{Telestrada} & \textbf{Telestrada} & \textbf{Telestrada} & \textbf{Telestrada} &
\textbf{Telestrada} & \textbf{Telestrada} & \textbf{Telestrada} &
\textbf{Telestrada} & \textbf{Telestrada} & \textbf{Telestrada} \\

\hline
  \textbf{LOC} & 5 & 5 & 6 & 5 & - & 5 & 6 & 5 & 6 & 5  \\
\hline
\rowcolor{gray!40}  \textbf{VS} & 8 & 5 & 9 & 8 & 9 & 8 & 9 & 8 & 9 & 8 \\
\hline

\end{tabular}
\end{minipage}
}
\end{adjustwidth}
%% put caption outside here
\caption{\label{fig:text}text experiment experiment experiment experiment experiment experiment experiment}
\end{table}
\end{document}

enter image description here

如果您删除垂直线和一些水平线(您只需要三条,两条在顶部,一条在底部),您的表格将变得更易读、更美观。我们使用booktabs包来实现这一点(其文档解释了一些有关编写表格的良好做法)

 \documentclass[english,a4paper,12pt]{report}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage[latin9]{inputenc}
\usepackage{graphicx}
\usepackage{xcolor,colortbl}
\usepackage[showframe=false]{geometry}
\usepackage{changepage}
\usepackage{hhline}
\usepackage{booktabs}

\usepackage[font=normalsize,labelfont=bf,justification=centering]{caption}
\begin{document}

\begin{table}[htb]
\begin{adjustwidth}{-1cm}{}
\resizebox{0.6\textwidth}{!}{
\begin{minipage}{\linewidth}
\def\arraystretch{1.5}%

\begin{tabular}{ *{11}{c}}
\\\toprule
                    & \textbf{Telestrada} & \textbf{Telestrada} & \textbf{Telestrada} & \textbf{Telestrada} &
\textbf{Telestrada} & \textbf{Telestrada} & \textbf{Telestrada} &
\textbf{Telestrada} & \textbf{Telestrada} & \textbf{Telestrada} \\

\midrule
  \textbf{LOC} & 5 & 5 & 6 & 5 & - & 5 & 6 & 5 & 6 & 5  \\
\rowcolor{gray!40}  \textbf{VS} & 8 & 5 & 9 & 8 & 9 & 8 & 9 & 8 & 9 & 8 \\
\bottomrule

\end{tabular}
\end{minipage}
}
\end{adjustwidth}
%% put caption outside here
\caption{\label{fig:text}text experiment experiment experiment experiment experiment experiment experiment}
\end{table}
\end{document}

enter image description here

相关内容