Latex表格内容过长,最简单自动换行方法

在用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就可实现。

如果帮助到大家,希望能给我点个赞~

评论 23
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值