\headrow
无法正常工作并在 Overleaf 上出现错误:
The compiler is having trouble understanding a command you have used. Check that the command is spelled correctly. If the command is part of a package, make sure you have included the package in your preamble using \usepackage{...}.
甚至我也使用\usepackage{threeparttable}
如何解决?
\begin{table}[bt]
\centering
\caption{Toy Students Dataset}
\label{owakey}
\begin{threeparttable}
\begin{tabular}{lccc}
\headrow
t & FirstName & LastName & HasFriend \\
student\_1&&&\\
student\_2&&&---\\
student\_3& &&\\
\hiderowcolors
\hline % Please only put a hline at the end of the table
\end{tabular}
\end{threeparttable}
\end{table}
和\documentclass[12pt]{memoireuqam1.3ang}
答案1
该命令\headrow
在 Overleaf 开发的自定义类中定义,称为wiley-article.cls
(参见将代码从 Overleaf 复制/粘贴到 LaTeX?)。那里的定义是\newcommand{\headrow}{\rowcolor{black!20}}
,符合您对“替代行颜色”的描述。命令\rowcolor
本身由包提供colortbl
,可以使用加载\usepackage[table]{xcolor}
。加载xcolor
还允许使用颜色规范,如black!20
(20%黑色)。
梅威瑟:
\documentclass{memoir}
\usepackage{threeparttable}
\usepackage[table]{xcolor}
\newcommand{\headrow}{\rowcolor{black!20}}
\begin{document}
\begin{table}[bt]
\centering
\caption{Toy Students Dataset}
\label{owakey}
\begin{threeparttable}
\begin{tabular}{lccc}
\headrow
t & FirstName & LastName & HasFriend \\
student\_1&&&\\
student\_2&&&---\\
student\_3& &&\\
\hiderowcolors
\hline % Please only put a hline at the end of the table
\end{tabular}
\end{threeparttable}
\end{table}
\end{document}
结果: