![\@array 的使用与其定义不符](https://linux22.com/image/302510/%5C%40array%20%E7%9A%84%E4%BD%BF%E7%94%A8%E4%B8%8E%E5%85%B6%E5%AE%9A%E4%B9%89%E4%B8%8D%E7%AC%A6.png)
我在这里做错了什么。我收到一条消息说
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}