\@array 的使用与其定义不符

\@array 的使用与其定义不符

我在这里做错了什么。我收到一条消息说

Use of \@array doesn't match its definition. `\@ifnextchar ... \reserved@d =#1\def  
\reserved@a { #2}\def \reserved@b {#3}\f... l.108 ...tabular}{|c|>{\centering}p{3cm}
|c|c|l|c|}.

以下是完整的代码

\documentclass{exam}
\usepackage{textcomp, booktabs}
\begin{document}
\section*{\large \textrecipe}

\begin{tabular}{|c|>{\centering}p{3cm}|c|c|l|c|}
\toprule 
Sr No & Drug & Dose  & frequency & Duration & Remark \midrule
1 &  &  & -~~ -~~ -  & x & before/with/after meals, at night \midrule
\hline 
2 &  &  & -~~ -~~ -  & x & before/with/after meals, at night \\
\hline 
3 &  &  & -~~ -~~ -  & x & before/with/after meals, at night \\ 
\hline 
4 &  &  & -~~ -~~ -  & x & before/with/after meals, at night \\ 
\hline 
5 &  &  & -~~ -~~ -  & x & before/with/after meals, at night  \\
\hline 
6 &  &  & -~~ -~~ -  & x & before/with/after meals, at night \\
\hline 
7 &  &  & -~~ -~~ -  & x & before/with/after meals, at night  \bottomrule 

\end{tabular}



\end{document}

答案1

解决了。​​只需添加数组包或修改代码即可

\section*{\large \textrecipe}
\begin{table}[htp]
\rowcolors{2}{gray!25}{white}
\begin{tabular}{c p{3cm}p{3cm}clc} 
\toprule 
 Sr No & Drug & Dose  & frequency & Duration & Remark \\ \midrule
1 &  &  & -~~ -~~ -  & x & before/with/after meals, at night \\

 2 &  &  & -~~ -~~ -  & x & before/with/after meals, at night \\

3 &  &  & -~~ -~~ -  & x & before/with/after meals, at night \\ 

 4 &  &  & -~~ -~~ -  & x & before/with/after meals, at night \\ 

5 &  &  & -~~ -~~ -  & x & before/with/after meals, at night  \\

6 &  &  & -~~ -~~ -  & x & before/with/after meals, at night \\

7 &  &  & -~~ -~~ -  & x & before/with/after meals, at night \\ \bottomrule 

\end{tabular}
\end{table}
\end{document}

相关内容