如何确保 LaTex 表中的文本换行

问题描述

当我从第二列开始在 LaTex 中使用下面的表格代码时,表格列不会坚持此处给出的单元格宽度。随着列的扩展,表格超出了页面宽度。如何解决此问题。

\documentclass[smallextended]{svjour3}
\smartqed
\usepackage{graphicx}
\begin{document}
\begin{table}
\caption{Comparison of Block confirmation rate}
\label{tab:4} 
\begin{tabular}{p{1in} l p{2in} l p{2in} l p{2n} l p{2n}}
\hline\noalign{\smallskip}
No of Organizations participating in Blockchain network [Column 1] & Available Bandwidth in Mbps for each node [10Mbps*1/2n(n-1)] [Column 2] 
 & No of messages of size 560bytes from each node with available bandwidth [Column 3] & No of Blocks (NBCT) (Number of nodes * number of message from column 3)  [Column 4] & Blocks (OBCT) [Column 5] \\
\noalign{\smallskip}\hline
1 & 2 & 3 & 4 & 5 \\
\noalign{\smallskip}\hline
\end{tabular}
\end{table}
\end{document}

解决方法

几个问题:

  • 您的表格有 5 列,但您指定了 9 列,每隔一列左对齐,没有换行符。

  • 2n 不是列宽的有效单位,我怀疑您的意思是 2in

  • 您选择的文档类具有非常窄的文本宽度。即使解决了上述所有问题,也没有足够的可用空间来容纳 5 列,每列 2 列。即使只有 1 英寸,桌子仍然会粘在边缘。要么选择其他文档布局,要么重新考虑表格的布局。

  • 您可能需要查看 siunitx 之类的包以正确排版单位和值....


\documentclass[smallextended]{svjour3}
\smartqed
\usepackage{graphicx}
\begin{document}
\begin{table}
\caption{Comparison of Block confirmation rate}
\label{tab:4} 
\begin{tabular}{p{1in} p{1in} p{1in} p{1in} p{1in}}
\hline\noalign{\smallskip}
No of Organizations participating in Blockchain network [Column 1] 
& Available Bandwidth in Mbps for each node [10Mbps*1/2n(n-1)] [Column 2] 
& No of messages of size 560bytes from each node with available bandwidth [Column 3] 
& No of Blocks (NBCT) (Number of nodes * number of message from column 3)  [Column 4] 
& Blocks (OBCT) [Column 5] \\
\noalign{\smallskip}\hline
1 & 2 & 3 & 4 & 5 \\
\noalign{\smallskip}\hline
\end{tabular}
\end{table}
\end{document}