我使用了 Excel2Latex
% Table generated by Excel2LaTeX from sheet 'Sheet1'
\begin{table}[htbp]
\centering
\caption{Add caption}
\begin{tabular}{|r|r|r|r|r|}
\cmidrule{1-1} \rowcolor[rgb]{1,1,0} & \multicolumn{1}{r}{\cellcolor[rgb]{1,1,1}} & \multicolumn{1}{r}{\cellcolor[rgb]{1,1,1}} & \multicolumn{1}{r}{\cellcolor[rgb]{1,1,1}} & \multicolumn{1}{r}{\cellcolor[rgb]{1,1,1}} \\
\cmidrule{1-2} & & \multicolumn{1}{r}{} & \multicolumn{1}{r}{} & \multicolumn{1}{r}{} \\
\cmidrule{1-3} & & & \multicolumn{1}{r}{} & \multicolumn{1}{r}{} \\
\cmidrule{1-4} & & & & \multicolumn{1}{r}{} \\
\midrule
\rowcolor[rgb]{.514,.235,.047} & \cellcolor[rgb]{1,1,1} & \cellcolor[rgb]{1,1,1} & \cellcolor[rgb]{1,1,1} & \cellcolor[rgb]{1,1,1} \\
\bottomrule
\end{tabular}%
\label{tab:addlabel}%
\end{table}%
答案1
答案2
借助于,hhline
而不是booktabs
:
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{hhline}
\newcommand{\nocell}{\multicolumn{1}{r}{}}
\begin{document}
\begin{table}[htbp]
\centering
\caption{Add caption}
\begin{tabular}{|r|r|r|r|r|}
\hhline{|-|~~~~}
\cellcolor[rgb]{1,1,0} & \nocell & \nocell & \nocell & \nocell \\
\hhline{|-|-|~~~}
& & \nocell & \nocell & \nocell \\
\hhline{|-|-|-|~}
& & & \nocell & \nocell \\
\hhline{|-|-|-|-|}
& & & & \nocell \\
\hline
\cellcolor[rgb]{.514,.235,.047} & & & & \\
\hline
\end{tabular}%
\label{tab:addlabel}%
\end{table}%
\end{document}
答案3
一个小的变化 @leandriis 的回答:
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{hhline}% part of shipunov bundle
\usepackage{cellspace}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}
\usepackage{xparse}
\NewExpandableDocumentCommand\mcc{O{1}m}
{\multicolumn{#1}{c}{#2}}
\begin{document}
\begin{table}[htbp]
\centering
\caption{Add caption}
\begin{tabular}{|*{5}{Sr|}}
\hhline{-~~~~}
\cellcolor[rgb]{1,1,0}{} & \mcc[4]{} \\
\hhline{--~~~}
& & \mcc[3]{} \\
\hhline{---~~}
& & & \mcc[2]{} \\
\hhline{----~}
& & & & \mcc{} \\
\hhline{*5{-}}
\cellcolor[rgb]{.514,.235,.047}
& & & & \\
\hhline{*5{-}}
\end{tabular}%
\label{tab:addlabel}%
\end{table}
\end{document}