单元格框线在 Latex 表中显示不正确

单元格框线在 Latex 表中显示不正确

我有以下结果,但在有结果的单元格中,单元格框线显示不正确,如屏幕截图所示。有人能帮忙解决这个问题吗?谢谢

桌子

\begin{table}[htbp]
\centering
\begin{tabular}{|{1cm}|{2.5cm}|{2.5cm}|{2.5cm}|} 
\hline
Question & Yes & No & Maybe  \\ 
\hline
As a Coach, would you use this type \\ of system instead of the traditional 
method?        
&   11   &  2     &    2     \\ 
\hline 
Do you think that this system will \\ save you time to identify a player's 
position?         & 9     &  2    &  4  \\
\hline
Does the system has any errors/bugs \\ that interfered during the testing?     
&   3     &  12   &  0 \\
\hline
Do you think the system achieved the \\ necessary results for your work?    
& 10  &  4   &   1 \\
\hline
Is the System user-friendly to use?        &
14  &  0   &  1  \\
\hline
\end{tabular}
\label{table:3}
\end{table}

结果

结果截图

答案1

您的代码包含无效的列规范。{1cm}您可能打算使用而不是p{1cm}。但是,如果我添加缺少的字母以使代码可编译,我将无法获得您在问题中显示的输出,因为第一列非常窄。将第一列的列说明符更改为p{7cm}或其他内容,并将最后三列更改为ctype columns 会得到接近屏幕截图的结果。

缺少垂直线是因为您的表格的第二行缺少三个&符号。如果添加它们,垂直线将完整。但是,如果您使用p类型列,则无需手动换行。请参阅我的 MWE 中的第一个表格。

如果您仍然坚持在表格单元格内手动换行,请使用\newline\\要在第一列水平居中文本,请使用>{\Centering}p{7cm}。如果您还希望垂直居中文本,请用 替换pm(请参阅我的 MWE 中的第二张表格)。

tabularx就我个人而言,我建议使用包对类型列进行不同的布局X,该包会自动计算相应列的宽度,以便整个表格的宽度与指定的宽度一样宽(在我的示例中为文本宽度)。此外,我会避免使用垂直线,并用包中的规则替换水平线booktabs。(参见我的 MWE 中的第三个表格):

在此处输入图片描述

\documentclass{article}

\usepackage{array}    % Needed for the second example.
\usepackage{ragged2e} % Needed for the second example.

\usepackage{tabularx} % Needed for the third example.
\usepackage{booktabs} % Needed for the third example.

\begin{document}
\begin{table}[htbp]
\centering
\begin{tabular}{|p{7cm}|c|c|c|} 
\hline
Question & Yes & No & Maybe  \\ 
\hline
As a Coach, would you use this type  of system instead of the traditional 
method?        
&   11   &  2     &    2     \\ 
\hline 
Do you think that this system will  save you time to identify a player's 
position?         & 9     &  2    &  4  \\
\hline
Does the system has any errors/bugs  that interfered during the testing?     
&   3     &  12   &  0 \\
\hline
Do you think the system achieved the  necessary results for your work?    
& 10  &  4   &   1 \\
\hline
Is the System user-friendly to use?        &
14  &  0   &  1  \\
\hline
\end{tabular}
\label{table:3}
\end{table}

\begin{table}[htbp]
\centering
\begin{tabular}{|>{\Centering}m{7cm}|c|c|c|} 
\hline
Question & Yes & No & Maybe  \\ 
\hline
As a Coach, would you use this type \newline of system instead of the traditional 
method?        
&   11   &  2     &    2     \\ 
\hline 
Do you think that this system will \newline save you time to identify a player's 
position?         & 9     &  2    &  4  \\
\hline
Does the system has any errors/bugs  that interfered during the testing?     
&   3     &  12   &  0 \\
\hline
Do you think the system achieved the  necessary results for your work?    
& 10  &  4   &   1 \\
\hline
Is the System user-friendly to use?        &
14  &  0   &  1  \\
\hline
\end{tabular}
\label{table:3}
\end{table}

\begin{table}[htbp]
\centering
\begin{tabularx}{\textwidth}{Xccc} 
\toprule
Question & Yes & No & Maybe  \\ 
\midrule
As a Coach, would you use this type  of system instead of the traditional 
method?        
&   11   &  2     &    2     \\  
Do you think that this system will  save you time to identify a player's 
position?         & 9     &  2    &  4  \\
Does the system has any errors/bugs  that interfered during the testing?     
&   3     &  12   &  0 \\
Do you think the system achieved the  necessary results for your work?    
& 10  &  4   &   1 \\
Is the System user-friendly to use?        &
14  &  0   &  1  \\
\bottomrule
\end{tabularx}
\label{table:3}
\end{table}
\end{document}

相关内容