在用Texstudio编写表格,遇到表格无法换行的问题,查了一大堆方法都不好用,最后参考icode9上的一篇博文才找到最简便的方法,分享给大家。
错误情况
可以看到,第二列内容太长,导致第三列的内容都被挤没了
以下是我的代码,我曾经尝试\begin{tabularx}{\textwidth}{lXXX} 以及/tabincell{c}{haha// heihei//zeze} 的方法都改不动,相信大家应该遇到类似问题。
\begin{tabular}{ccc}\toprule
Biodiversity quality grade & Feature description \centering & Adjustment coefficient \\ \hline
High & The ecosystem is in excellent The ecosystem is in excellent The ecosystem is in excellent The ecosystem is in excellent & 2 \\
High & The ecosystem is in excellent The ecosystem is in excellent The ecosystem is in excellent The ecosystem is in excellent & 1 \\
High & The ecosystem is in excellent The ecosystem is in excellent The ecosystem is in excellent The ecosystem is in excellent & 0 \\
High & The ecosystem is in excellent The ecosystem is in excellent The ecosystem is in excellent The ecosystem is in excellent & 1 \\
High & The ecosystem is in excellent The ecosystem is in excellent The ecosystem is in excellent The ecosystem is in excellent & 2 \\
\bottomrule
\label{t2}
\end{tabular}
调整情况
以上是我的最终效果,可以看到表格都显示出来了,而我只是对\begin{tabular}{ccc}\toprule 进行了调整:
\begin{tabular}{cp{8cm}c}\toprule
Biodiversity quality grade & Feature description \centering
其中,原本{ccc}对应3列,我对其中一个c(这里是第二列)固定了长度,改写为p{8cm},这样写以后,表内内容会自动换行。同时,使用p会导致对应列内容左对齐,如果需要居中,在文本后加入\centering就可实现。
如果帮助到大家,希望能给我点个赞~