为了创建表格,我使用了 makecell 包。我需要最后四列的宽度小于第一列的宽度:这是我的尝试
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsmath,amssymb,amsfonts,systeme}
\usepackage{makecell}
\setcellgapes{5pt}
\begin{document}
\begin{table}[h]
\centering
\makegapedcells
\begin{tabular}{| *{1}{>{\centering\arraybackslash}p{2.5cm} | *{4}{>{\centering\arraybackslash}p{1cm}} |}
\hline
Sostanza & $\theta$ & $\eta$ & $\nu$ & $\rho$ \\ \hline\hline
Acido benzoico & a & a & a & a \\ \hline
Saccarosio & b & b & b & b \\ \hline
Acido salicilico & c & c & c & c \\ \hline
\end{tabular}
\end{table}
\end{document}
错误信息如下:
!段落在 @@array 完成之前结束。
你可以帮帮我吗?
先感谢您
答案1
您的问题与包无关makecell
。您的列定义中缺少一个}
。但是,
\begin{tabular}{| *{1}{>{\centering\arraybackslash}p{2.5cm} | % here is mised }
*{4}{>{\centering\arraybackslash}p{1cm}|} }
写起来更简单
\begin{tabular}{| >{\centering\arraybackslash}p{2.5cm}|
*{4}{>{\centering\arraybackslash}p{1cm} |} }
完整的 MWE 是:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsmath,amssymb,systeme} % "amssymb" load "amsfonts"
\usepackage{makecell}
\setcellgapes{5pt}
\begin{document}
\begin{table}[h]
\centering
\makegapedcells
\begin{tabular}{| >{\centering\arraybackslash}p{2.5cm}|
*{4}{>{\centering\arraybackslash}p{1cm} |} }
\hline
Sostanza & $\theta$ & $\eta$ & $\nu$ & $\rho$ \\ \hline\hline
Acido benzoico & a & a & a & a \\ \hline
Saccarosio & b & b & b & b \\ \hline
Acido salicilico & c & c & c & c \\ \hline
\end{tabular}
\end{table}
\end{document}