\documentclass[12pt, a4paper, UTF8, scheme = plain, twoside]{ctexart}
%%
%%
\usepackage{amsmath}
\usepackage{booktabs,array}
\usepackage[top=0.5cm,left=0.5cm,right=0.5cm,bottom=1.68cm]{geometry}
\usepackage{graphicx}
%%
%%
\begin{document}
%%
%%
\begin{center}
\renewcommand*{\arraystretch}{1.2}
\Large
\begin{tabular}{| >{\centering}p{5.8cm} | >{\centering}p{1.8cm} |
>{\centering}p{1.0cm} |
>{\centering}p{1.0cm} |
>{\centering}p{1.0cm} |
>{\centering}p{1.0cm} |
c | % works with c|
}
\toprule
\textbf{PaperName} &
\textbf{Page} &
\textbf{A} &
\textbf{B} &
\textbf{C} &
\textbf{D} &
\textbf{E} \\
\midrule
\verb=9709_s21_ms_13= & 1 & 59 & 51 & 42 & 32 & 22 \\
\verb=9709_s21_ms_12= & 17 & 63 & 54 & 44 & 34 & 23 \\
\verb=9709_s21_ms_11= & 33 & 61 & 50 & 41 & 31 & 21 \\
\verb=9709_s20_ms_13= & 49 & & & & & \\
\verb=9709_s20_ms_12= & 67 & & & & & \\
\verb=9709_s20_ms_11= & 81 & & & & & \\
\verb=9709_s19_ms_13= & 97 & 62 & 54 & 44 & 34 & 24 \\
\verb=9709_s19_ms_12= & 111 & 65 & 54 & 43 & 31 & 19 \\
\verb=9709_s19_ms_11= & 127 & 65 & 57 & 47 & 37 & 28 \\
\verb=9709_s18_ms_13= & 146 & 62 & 55 & 45 & 35 & 25 \\
\verb=9709_s18_ms_12= & 164 & 62 & 52 & 42 & 32 & 21 \\
\verb=9709_s18_ms_11= & 182 & 62 & 54 & 44 & 34 & 24 \\
\verb=9709_s17_ms_13= & 199 & 49 & 41 & 32 & 23 & 13 \\
\verb=9709_s17_ms_12= & 214 & 51 & 42 & 31 & 21 & 10 \\
\verb=9709_s17_ms_11= & 232 & 55 & 46 & 37 & 28 & 18 \\
\bottomrule
\end{tabular}%
\end{center}
%%
\end{document}
For the last colum, if I used
>{\centering}p{1.0cm} |
>{\centering}p{1.0cm} |
>{\centering}p{1.0cm} |
>{\centering}p{1.0cm} |
>{\centering}p{1.0cm} | % works with c|
instead, it will give me an error……
\midrule ->\noalign
{\ifnum 0=`}\fi @aboverulesep =\aboverulesep \global @…
why? how can I fix this?
Best Answer
\centering
redefines\\
to be a centred newline, breaking thetabular
use ,you can use\centering\arraybackslash
to restore the array/tabular\\
Alternatively and possibly better since it looks like your table cells are not really multi-line paragraphs use the fixed width form of
c
sowc{1cm}
rather thanp{1cm}
for all the columns. (Requires anarray
package that's not too old)