## 编译环境 操作系统 * [x ] Windows 7/8/10 * [ ] macOS * [ ] Linux `若需勾选,请把[ ]改成[x]` Tex发行版 * [x ] TexLive `年份` * [ ] MikTeX `版本号` * [ ] CTeX `若需勾选,请把[ ]改成[x]` ## 我的问题 三线表填色时颜色无法充满整个格子,与边框线之间存在空白。```markdown \begin{table}[h] \centering \caption{Variation of some parameters} \label{tab7} \begin{tabular}{ccccccc} \toprule[1pt] \cellcolor{Blue!20}$V$ & $A_1$ & $A_2$ & $T_2$ & $q_{m1}$ & $q_{m2}$ & $\Phi_q$ \\ \midrule[0.5pt] \cellcolor{Blue!20}-15.00\% & -5.06\% & -9.31\% & -12.67\% & -2.67\% & -14.14\% & -5.80\% \\ \cellcolor{Blue!20}-12.00\% &\cellcolor{Red!10} -4.04\% & -7.43\% & -10.09\% & -2.13\% & -11.31\% & -4.63\% \\ \cellcolor{Blue!20}-8.00\% & -2.68\% & -4.94\% & -6.68\% & -1.41\% & -7.54\% & -3.07\% \\ -8.00\% & -2.68\% & -4.94\% & -6.68\% & -1.41\% & -7.54\% & -3.07\% \\ -8.00\% & -2.68\% & -4.94\% & -6.68\% & -1.41\% & -7.54\% & -3.07\% \\ -8.00\% & -2.68\% & -4.94\% & -6.68\% & -1.41\% & -7.54\% & -3.07\% \\ -8.00\% & -2.68\% & -4.94\% & -6.68\% & -1.41\% & -7.54\% & -3.07\% \\ -8.00\% & -2.68\% & -4.94\% & -6.68\% & -1.41\% & -7.54\% & -3.07\% \\ -8.00\% & -2.68\% & -4.94\% & -6.68\% & -1.41\% & -7.54\% & -3.07\% \\ -8.00\% & -2.68\% & -4.94\% & -6.68\% & -1.41\% & -7.54\% & -3.07\% \\ -8.00\% & -2.68\% & -4.94\% & -6.68\% & -1.41\% & -7.54\% & -3.07\% \\ \bottomrule[1pt] \end{tabular} \end{table} ```

2 回答2

1
您好!不要用\toprule环境,全部用\hline环境: ```c \documentclass[fontset=none]{ctexart} \setCJKmainfont[BoldFont={FZHei-B01},ItalicFont={FZKai-Z03}]{FZShuSong-Z01} \setCJKsansfont{FZHei-B01} \usepackage[margin=2.5cm]{geometry} \usepackage{newtxtext} \usepackage{graphicx} \usepackage{booktabs,colortbl} \usepackage{xcolor} \begin{document} \begin{table}[htpb] \centering \caption{Variation of some parameters} \label{tab7} \begin{tabular}{c|cccccc} \hline \cellcolor{blue!20}$V$ & \cellcolor{blue!20}$A_1$ & \cellcolor{blue!20}$A_2$ & \cellcolor{blue!20}$T_2$ & \cellcolor{blue!20}$q_{m1}$ & \cellcolor{blue!20}$q_{m2}$ & \cellcolor{blue!20}$\Phi_q$ \\ \hline \cellcolor{blue!20}-15.00\% & -5.06\% & -9.31\% & -12.67\% & -2.67\% & -14.14\% & -5.80\% \\ \cellcolor{blue!20}-12.00\% &\cellcolor{red!10} -4.04\% & -7.43\% & -10.09\% & -2.13\% & -11.31\% & -4.63\% \\ \hline \end{tabular} \end{table} \end{document} ``` 最后结果是: ![](https://wenda.latexstudio.net/data/attach/210205/UulUGoQu.jpg) 或者如果表头线和最后尾部线条你非要加粗的话可以查看(建议去下载比较完整):https://www.latexstudio.net/index/details/index/mid/154.html 代码: ```c \documentclass[fontset=none]{ctexart} \setCJKmainfont[BoldFont={FZHei-B01},ItalicFont={FZKai-Z03}]{FZShuSong-Z01} \setCJKsansfont{FZHei-B01} \usepackage[margin=2.5cm]{geometry} \usepackage{newtxtext} \usepackage{graphicx} \usepackage{booktabs,colortbl} \usepackage{xcolor} \colorlet{tableheadcolor}{gray!25} % Table header colour = 25% gray \newcommand{\headcol}{\rowcolor{tableheadcolor}} % \colorlet{tablerowcolor}{gray!10} % Table row separator colour = 10% gray \newcommand{\rowcol}{\rowcolor{tablerowcolor}} % % Command \topline consists of a (slightly modified) \toprule followed by a \heavyrule rule of colour tableheadcolor (hence, 2 separate rules) \newcommand{\topline}{\arrayrulecolor{black}\specialrule{0.1em}{\abovetopsep}{0pt}% \arrayrulecolor{tableheadcolor}\specialrule{\belowrulesep}{0pt}{0pt}% \arrayrulecolor{black}} % Command \midline consists of 3 rules (top colour tableheadcolor, middle colour black, bottom colour white) \newcommand{\bottomlinec}{\arrayrulecolor{tablerowcolor}\specialrule{\aboverulesep}{0pt}{0pt}% \arrayrulecolor{black}\specialrule{\heavyrulewidth}{0pt}{\belowbottomsep}}% \colorlet{blcolor}{gray!80} \newcommand{\rowmidlineHR}{\arrayrulecolor{tableheadcolor} \specialrule{\aboverulesep}{0pt}{0pt}% \arrayrulecolor{black}\specialrule{\lightrulewidth}{0pt}{0pt}% \arrayrulecolor{tablerowcolor}\specialrule{\belowrulesep}{0pt}{0pt}% \arrayrulecolor{black}} % Command \rowmidlinewc consists of 3 rules % (top colour tableheadcolor, middle colour black, bottom colour tablerowcolor) \newcommand{\rowmidlineG}{\arrayrulecolor{tablerowcolor}% \specialrule{\aboverulesep}{0pt}{0pt}% \arrayrulecolor{blcolor}\specialrule{\lightrulewidth}{0pt}{0pt}% \arrayrulecolor{tablerowcolor}\specialrule{\belowrulesep}{0pt}{0pt}% \arrayrulecolor{black}} \begin{document} \large \begin{table} [htpb] \centering \centering \caption{Size and shape distribution for a sampled rock riprap} \label{tab:size_shape} \begin{tabular} { p{0.2\textwidth} p{0.15\textwidth} p{0.10 \textwidth} p{0.10 \textwidth} p{0.15 \textwidth} } \topline \headcol & Small & Medium & Large & Shape fraction \\ \rowmidlineHR % Head Rule \rowcol Compact & 10\% & 44\% & 7\% & 61\% \\ \rowcol Flat & 4\% & 10\% & 4\% & 18\% \\ \rowcol Elongated & 5\% & 12\% & 4\% & 21\% \\ \rowmidlineG % Gray midline \rowcol Size fraction & 19\% & 66\% & 15\% & 100\% \\ \bottomlinec \end{tabular} \end{table} \end{document} ``` 最后的效果是: ![](https://wenda.latexstudio.net/data/attach/210205/wWYyWY2W.jpg)
0
那就不要填色了

你的回答

请登录后回答

你的回答将会帮助更多人,请务必认真回答问题。