表格中左对齐、固定宽度的列无法正常工作

表格中左对齐、固定宽度的列无法正常工作

得益于此回答我可以在表格中创建左对齐的固定宽度列。但是,我想问一下是否有其他人遇到过最后一列无法正常工作的问题,例如:

\begin{table}
\caption{Device technical specifications summary.}
\begin{tabular}{|R{3cm}|R{2cm}|R{2cm}|R{2cm}|R{3cm}|}
\hline
~ & Samsung Galaxy Pocket Neo & Samsung S3 Mini & Vodafone Smart4 Mini & Google (Asus) Nexus 7 (2012) \\
\hline
CPU Speed [MHz] & 850 & 1000 & 1300  & 1200 \\
\hline
CPU Type & 1 Core & 2 Core Coretex-A9 & 2 Core Cortex-A7 & 4 Core Cortex-A9 \\
\hline
RAM [MB] & 512 & 1024 & 512 & 1024 \\ 
\hline
Release Year & 2013 & 2012 & 2014 & 2012 \\
\hline
\end{tabular}
\label{Device technical specifications summary}
\end{table}

一切正常 \begin{tabular}{|R{3cm}|R{2cm}|R{2cm}|R{2cm}|p{3cm}|}

但如果按照上面所述,我得到:

错误:./contents/Chap-6.tex:40:放错 \noalign。[\hline]

即从第一个 \hline 开始就给我带来问题。

有什么建议吗?

答案1

这对我来说很好:(从您提供的链接中逐字复制了列类型,我认为这就是您所做的)

\documentclass{article}
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}


\begin{document}

\begin{table}
\caption{Device technical specifications summary.\label{Device technical specifications summary}}
\begin{tabular}{|R{3cm}|R{2cm}|R{2cm}|R{2cm}|R{3cm}|}
\hline
~ & Samsung Galaxy Pocket Neo & Samsung S3 Mini & Vodafone Smart4 Mini & Google (Asus) Nexus 7 (2012) \\
\hline
CPU Speed [MHz] & 850 & 1000 & 1300  & 1200 \\
\hline
CPU Type & 1 Core & 2 Core Coretex-A9 & 2 Core Cortex-A7 & 4 Core Cortex-A9 \\
\hline
RAM [MB] & 512 & 1024 & 512 & 1024 \\ 
\hline
Release Year & 2013 & 2012 & 2014 & 2012 \\
\hline
\end{tabular}
\end{table}

\end{document}

相关内容