解决Overleaf中合并列单元格长文本溢出表格的问题
解决tabularx合并列长文本溢出问题
你的问题出在合并列时用了c格式——c是居中但不自动换行的固定宽度列,长文本直接超出表格边界。结合你用的tabularx环境,只需要把合并列的格式换成带居中的X列即可自动换行。
修改后的完整代码
{\footnotesize \begin{tabularx}{\textwidth}[h!]{| X | X |} \caption{Description of the selected algorithms\label{TABLEA}}\\ \hline \multicolumn{2}{| >{\centering\arraybackslash}X |}{Begin of Table}\\ \hline Algorithm & General Operation \\ \hline \endfirsthead \hline \multicolumn{2}{| >{\centering\arraybackslash}X |}{Continuation of Table \ref{TABLEA}}\\ \hline Algorithm & General Operation \\ \hline \endhead \hline \endfoot \hline \multicolumn{2}{| >{\centering\arraybackslash}X |}{End of Table}\\ \hline\hline \endlastfoot \multicolumn{2}{| >{\centering\arraybackslash}X |}{\textbf{Agglomerative methods}} \\ \multicolumn{2}{| >{\centering\arraybackslash}X |}{The notion of distance in this family makes it possible to identify cliques through relational proximities (in the network) that favor the exchange of resources..........} \\ \hline \textbf{Hierarchical algorithm} with 4 different settings: Euclidean distance / Complete linkage; Euclidean distance / Ward; Manhattan distance / Complete linkage; Manhattan distance / Ward. & The basic idea is to construct the hierarchical relationship among data in order to cluster. Each data point stands for an individual cluster in the beginning, and then, the most neighboring two clusters are merged into a new one until there is only one cluster left. The concept of "neighborhood" depends on the distance between nodes which is computed by squaring the Euclidean or Manhattan distances and grouping them into a symmetric matrix. The clustering method (here, complete linkage and Ward's algorithm) identifies the closest nodes to agglomerate them. We obtain a hierarchical dendogram which is cut to the desired number of clusters. \\ \end{tabularx} }
关键改动说明
把所有
\multicolumn{2}{| c |}{...}替换成\multicolumn{2}{| >{\centering\arraybackslash}X |}{...}:X是tabularx的自适应宽度列,会根据表格总宽度自动调整并换行;>{\centering}让单元格内文本居中;\arraybackslash修复居中后换行命令\\的失效问题。
如果你不需要居中,直接用
\multicolumn{2}{| X |}{...}即可,文本会左对齐并自动换行。
内容的提问来源于stack exchange,提问作者user_s_moon
相关产品推荐
相关产品推荐

